diff options
-rw-r--r-- | miscutils/make.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 24e286aa9..fcd1e3fbe 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -1636,22 +1636,39 @@ run_command(const char *cmd) | |||
1636 | } | 1636 | } |
1637 | pclose(fd); | 1637 | pclose(fd); |
1638 | 1638 | ||
1639 | if (val) { | 1639 | if (val == NULL) |
1640 | #if ENABLE_PLATFORM_MINGW32 | 1640 | return NULL; |
1641 | len = remove_cr(val, len + 1) - 1; | 1641 | |
1642 | // Strip leading whitespace in POSIX 202X mode | ||
1643 | if (posix) { | ||
1644 | s = val; | ||
1645 | while (isspace(*s)) { | ||
1646 | ++s; | ||
1647 | --len; | ||
1648 | } | ||
1649 | |||
1642 | if (len == 0) { | 1650 | if (len == 0) { |
1643 | free(val); | 1651 | free(val); |
1644 | return NULL; | 1652 | return NULL; |
1645 | } | 1653 | } |
1654 | memmove(val, s, len + 1); | ||
1655 | } | ||
1656 | |||
1657 | #if ENABLE_PLATFORM_MINGW32 | ||
1658 | len = remove_cr(val, len + 1) - 1; | ||
1659 | if (len == 0) { | ||
1660 | free(val); | ||
1661 | return NULL; | ||
1662 | } | ||
1646 | #endif | 1663 | #endif |
1647 | // Remove one newline from the end (BSD compatibility) | 1664 | |
1648 | if (val[len - 1] == '\n') | 1665 | // Remove one newline from the end (BSD compatibility) |
1649 | val[len - 1] = '\0'; | 1666 | if (val[len - 1] == '\n') |
1650 | // Other newlines are changed to spaces | 1667 | val[len - 1] = '\0'; |
1651 | for (s = val; *s; ++s) { | 1668 | // Other newlines are changed to spaces |
1652 | if (*s == '\n') | 1669 | for (s = val; *s; ++s) { |
1653 | *s = ' '; | 1670 | if (*s == '\n') |
1654 | } | 1671 | *s = ' '; |
1655 | } | 1672 | } |
1656 | return val; | 1673 | return val; |
1657 | } | 1674 | } |