Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): in lint mode, reject modifiers without...
details: https://anonhg.NetBSD.org/src/rev/0ef299338c1f
branches: trunk
changeset: 944541:0ef299338c1f
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Oct 03 12:30:17 2020 +0000
description:
make(1): in lint mode, reject modifiers without delimiter
The expression ${VAR:LPL} must now be written as ${VAR:L:P:L}. The
manual page has never documented that some modifiers don't need to be
delimited by ':' and others need to. That would have been unnecessarily
confusing anyway.
diffstat:
usr.bin/make/unit-tests/opt-debug-lint.exp | 3 +++
usr.bin/make/var.c | 21 +++++++++++++++++----
2 files changed, 20 insertions(+), 4 deletions(-)
diffs (73 lines):
diff -r 92086351b920 -r 0ef299338c1f usr.bin/make/unit-tests/opt-debug-lint.exp
--- a/usr.bin/make/unit-tests/opt-debug-lint.exp Sat Oct 03 12:26:11 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-lint.exp Sat Oct 03 12:30:17 2020 +0000
@@ -1,5 +1,8 @@
make: "opt-debug-lint.mk" line 19: Variable "X" is undefined
make: "opt-debug-lint.mk" line 41: Variable "UNDEF" is undefined
+make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "L"
+make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "P"
+make: "opt-debug-lint.mk" line 67: Missing delimiter ':' after indirect modifier "${:UL}"
make: Unknown modifier '$'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
diff -r 92086351b920 -r 0ef299338c1f usr.bin/make/var.c
--- a/usr.bin/make/var.c Sat Oct 03 12:26:11 2020 +0000
+++ b/usr.bin/make/var.c Sat Oct 03 12:30:17 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.559 2020/10/03 10:42:08 rillig Exp $ */
+/* $NetBSD: var.c,v 1.560 2020/10/03 12:30:17 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.559 2020/10/03 10:42:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.560 2020/10/03 12:30:17 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3169,13 +3169,21 @@
/* TODO: handle errors */
/*
- * If we have not parsed up to st.endc or ':',
- * we are not interested.
+ * If we have not parsed up to st.endc or ':', we are not
+ * interested. This means the expression ${VAR:${M_1}${M_2}}
+ * is not accepted, but ${VAR:${M_1}:${M_2}} is.
*/
if (rval[0] != '\0' &&
(c = *nested_p) != '\0' && c != ':' && c != st.endc) {
+ if (DEBUG(LINT))
+ Parse_Error(PARSE_FATAL,
+ "Missing delimiter ':' after indirect modifier \"%.*s\"",
+ (int)(nested_p - p), p);
+
free(freeIt);
/* XXX: apply_mods doesn't sound like "not interested". */
+ /* XXX: Why is the indirect modifier parsed again by
+ * apply_mods? If any, p should be advanced to nested_p. */
goto apply_mods;
}
@@ -3196,6 +3204,7 @@
}
}
free(freeIt);
+
if (*p == ':')
p++;
else if (*p == '\0' && endc != '\0') {
@@ -3252,6 +3261,10 @@
st.endc, st.v->name, st.val, *mod);
} else if (*p == ':') {
p++;
+ } else if (DEBUG(LINT) && *p != '\0' && *p != endc) {
+ Parse_Error(PARSE_FATAL,
+ "Missing delimiter ':' after modifier \"%.*s\"",
+ (int)(p - mod), mod);
}
}
out:
Home |
Main Index |
Thread Index |
Old Index