From f97b2b0875027d51fe272a6e94049d387f8b680d Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 13 Nov 2022 15:13:55 +0000 Subject: make: use correct test for valid macro name The test for valid macro names in POSIX mode was incorrect: it shouldn't have allowed '-'. --- miscutils/make.c | 2 +- testsuite/make.tests | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/miscutils/make.c b/miscutils/make.c index 42fac7f77..7b54bfe95 100644 --- a/miscutils/make.c +++ b/miscutils/make.c @@ -520,7 +520,7 @@ is_valid_macro(const char *name) for (s = name; *s; ++s) { // In POSIX mode only a limited set of characters are guaranteed // to be allowed in macro names. - if (posix && !isfname(*s)) + if (posix && !ispname(*s)) return FALSE; // As an extension allow anything that can get through the // input parser, apart from the following. diff --git a/testsuite/make.tests b/testsuite/make.tests index 70c1231b9..8a0f1a7d2 100755 --- a/testsuite/make.tests +++ b/testsuite/make.tests @@ -339,6 +339,19 @@ target: b} ' +# POSIX 202X permits additional characters in macro and target names +testing "make allow - and / in target names, - in macro names" \ + "make -f -" \ + "/hello\nhel-lo\nmac-ro\n" "" ' +target: ./hello hel-lo + @echo $(mac-ro) +./hello: + @echo /hello +hel-lo: + @echo hel-lo +mac-ro = mac-ro +' + testing "make double-colon rule" \ "make -f -" "target1\ntarget2\n" "" ' target:: -- cgit v1.2.3-55-g6feb