aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-09-10 07:54:16 +0100
committerRon Yorston <rmy@pobox.com>2024-09-10 07:54:16 +0100
commitb4d811aa232df8c7416a14f38a2396b028c35ac9 (patch)
tree7a5991fdb2e14f6de5f30ba6ec934a52e37b1afb
parent074ebfca2153bf4a1fc6bdf4f3430d989de503c8 (diff)
downloadbusybox-w32-b4d811aa232df8c7416a14f38a2396b028c35ac9.tar.gz
busybox-w32-b4d811aa232df8c7416a14f38a2396b028c35ac9.tar.bz2
busybox-w32-b4d811aa232df8c7416a14f38a2396b028c35ac9.zip
make: reinstate conditional skipping of command lines
Commit e90345c10 (make: allow empty commands) rearranged readline() in a way that broke the use of conditionals within the definition of a rule. Add a test case to detect this. Adjust readline() so that conditionals are processed before returning command lines or checking for empty lines and comments. Remove the test for a leading tab in skip_lines(). This allows conditionals in the definition of a rule to be indented with a leading tab.
-rw-r--r--miscutils/make.c22
-rwxr-xr-xtestsuite/make.tests2
2 files changed, 13 insertions, 11 deletions
diff --git a/miscutils/make.c b/miscutils/make.c
index 871c434f8..b2edfdbb4 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -1605,9 +1605,6 @@ skip_line(const char *str1)
1605 int ret = cstate[clevel] & SKIP_LINE; 1605 int ret = cstate[clevel] & SKIP_LINE;
1606 int key; 1606 int key;
1607 1607
1608 if (*str1 == '\t')
1609 return ret;
1610
1611 copy = xstrdup(str1); 1608 copy = xstrdup(str1);
1612 q = process_line(copy); 1609 q = process_line(copy);
1613 if ((token = gettok(&q)) != NULL) { 1610 if ((token = gettok(&q)) != NULL) {
@@ -1754,16 +1751,19 @@ readline(FILE *fd, int want_command)
1754 } 1751 }
1755 dispno = lineno; 1752 dispno = lineno;
1756 1753
1757 if (want_command && *str == '\t') 1754 // Check for lines that are conditionally skipped.
1758 return str; 1755 if (posix || !skip_line(str)) {
1756 if (want_command && *str == '\t')
1757 return str;
1759 1758
1760 // Check for comment lines and lines that are conditionally skipped. 1759 // Check for comment lines
1761 p = str; 1760 p = str;
1762 while (isblank(*p)) 1761 while (isblank(*p))
1763 p++; 1762 p++;
1764 1763
1765 if (*p != '\n' && *str != '#' && (posix || !skip_line(str))) 1764 if (*p != '\n' && *str != '#')
1766 return str; 1765 return str;
1766 }
1767 1767
1768 pos = 0; 1768 pos = 0;
1769 } 1769 }
diff --git a/testsuite/make.tests b/testsuite/make.tests
index c92c69340..a12e50b8b 100755
--- a/testsuite/make.tests
+++ b/testsuite/make.tests
@@ -652,6 +652,8 @@ B = b
652target: 652target:
653ifeq ($(A),a) 653ifeq ($(A),a)
654 @echo A OK 654 @echo A OK
655else
656 @echo A not OK
655endif 657endif
656ifneq "a" "$B" 658ifneq "a" "$B"
657 @echo B OK 659 @echo B OK