Module Name:    src
Committed By:   rillig
Date:           Sun Oct 25 15:49:03 UTC 2020

Modified Files:
        src/usr.bin/make: for.c
        src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk

Log Message:
make(1): test funny character in .for variable names


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/for.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-for.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.103 src/usr.bin/make/for.c:1.104
--- src/usr.bin/make/for.c:1.103	Sun Oct 25 15:41:31 2020
+++ src/usr.bin/make/for.c	Sun Oct 25 15:49:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.103 2020/10/25 15:41:31 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.104 2020/10/25 15:49:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -60,7 +60,7 @@
 #include    "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.103 2020/10/25 15:41:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.104 2020/10/25 15:49:03 rillig Exp $");
 
 typedef enum ForEscapes {
     FOR_SUB_ESCAPE_CHAR = 0x0001,
@@ -205,8 +205,10 @@ For_Eval(const char *line)
 	    return -1;
 	}
 
+	/* XXX: This allows arbitrary variable names; see directive-for.mk. */
 	for (len = 1; ptr[len] && !ch_isspace(ptr[len]); len++)
 	    continue;
+
 	if (len == 2 && ptr[0] == 'i' && ptr[1] == 'n') {
 	    ptr += 2;
 	    break;

Index: src/usr.bin/make/unit-tests/directive-for.exp
diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.5 src/usr.bin/make/unit-tests/directive-for.exp:1.6
--- src/usr.bin/make/unit-tests/directive-for.exp:1.5	Sun Oct 25 14:55:23 2020
+++ src/usr.bin/make/unit-tests/directive-for.exp	Sun Oct 25 15:49:03 2020
@@ -14,4 +14,6 @@ make: "directive-for.mk" line 132: {{}} 
 make: "directive-for.mk" line 132: )( )( )(
 make: "directive-for.mk" line 132: ][ ][ ][
 make: "directive-for.mk" line 132: }{ }{ }{
+make: "directive-for.mk" line 140: outer value value
+make: "directive-for.mk" line 140: outer "quoted" \"quoted\"
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-for.mk
diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.7 src/usr.bin/make/unit-tests/directive-for.mk:1.8
--- src/usr.bin/make/unit-tests/directive-for.mk:1.7	Sun Oct 25 14:55:23 2020
+++ src/usr.bin/make/unit-tests/directive-for.mk	Sun Oct 25 15:49:03 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for.mk,v 1.7 2020/10/25 14:55:23 rillig Exp $
+# $NetBSD: directive-for.mk,v 1.8 2020/10/25 15:49:03 rillig Exp $
 #
 # Tests for the .for directive.
 
@@ -132,5 +132,13 @@ EXPANSION${plus}=	value
 .  info $v ${v} $(v)
 .endfor
 
+# As of 2020-10-25, the variable names may contain arbitrary characters,
+# except for whitespace.  This allows for creative side effects. Hopefully
+# nobody is misusing this "feature".
+var=	outer
+.for var:Q in value "quoted"
+.  info ${var} ${var:Q} ${var:Q:Q}
+.endfor
+
 all:
 	@:;

Reply via email to