summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-01-15 22:36:15 +0000
committermarcel <marcel@FreeBSD.org>2003-01-15 22:36:15 +0000
commitc97b10a2a8457205d00f09632015c6d0d58732f1 (patch)
treeda610cb7f70beeca0a745d1e8a023daaa1510c52 /usr.bin
parentb6f4bee98646c52363a423a8f7de656535689e12 (diff)
downloadFreeBSD-src-c97b10a2a8457205d00f09632015c6d0d58732f1.zip
FreeBSD-src-c97b10a2a8457205d00f09632015c6d0d58732f1.tar.gz
Change the handling of non-anchored global substitutions of the empty
string from a silent implicit non-global substitution to a non-silent explicit fatal error. Archored substitutions are those containing '^' or '$'. The problem with changing the substitution to prevent an infinite number of matches is that it doesn't provide the necessary feedback to the user that there's a bug in the/a makefile. Reporting the bug without making the condition fatal makes the feedback mostly useless due to the way that make fails to prefix the error with program name, makefile file name and line number information. Note that global substitutions of the empty string anchored with '^' (start of string) or '$' (end of string) do not cause an infinite number of matches and are therefore not reported and hence are non- fatal. Suggested by: bde Tested with: buildworld
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/var.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 32da4e8..3221bdd 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1350,15 +1350,16 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
}
/*
- * Replacing the empty string for something else when
- * done globally causes an infinite loop. The only
- * meaningful substitution of the empty string would
- * be those anchored by '^' or '$'. Thus, we can
- * safely turn the substitution into a non-global one
- * if the LHS is the empty string.
+ * Global substitution of the empty string causes an
+ * infinite number of matches, unless anchored by '^'
+ * (start of string) or '$' (end of string). Catch the
+ * infinite substitution here.
+ * Note that flags can only contain the 3 bits we're
+ * interested in so we don't have to mask unrelated
+ * bits. We can test for equality.
*/
- if (pattern.leftLen == 0)
- pattern.flags &= ~VAR_SUB_GLOBAL;
+ if (!pattern.leftLen && pattern.flags == VAR_SUB_GLOBAL)
+ Fatal("Global substitution of the empty string");
termc = *cp;
newStr = VarModify(str, VarSubstitute,
OpenPOWER on IntegriCloud