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): test funny character in .for variable ...



details:   https://anonhg.NetBSD.org/src/rev/413aff264775
branches:  trunk
changeset: 956280:413aff264775
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 25 15:49:03 2020 +0000

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

diffstat:

 usr.bin/make/for.c                        |   6 ++++--
 usr.bin/make/unit-tests/directive-for.exp |   2 ++
 usr.bin/make/unit-tests/directive-for.mk  |  10 +++++++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diffs (62 lines):

diff -r c97c42f78324 -r 413aff264775 usr.bin/make/for.c
--- a/usr.bin/make/for.c        Sun Oct 25 15:41:31 2020 +0000
+++ b/usr.bin/make/for.c        Sun Oct 25 15:49:03 2020 +0000
@@ -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 @@
            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;
diff -r c97c42f78324 -r 413aff264775 usr.bin/make/unit-tests/directive-for.exp
--- a/usr.bin/make/unit-tests/directive-for.exp Sun Oct 25 15:41:31 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-for.exp Sun Oct 25 15:49:03 2020 +0000
@@ -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 140: outer value value
+make: "directive-for.mk" line 140: outer "quoted" \"quoted\"
 exit status 0
diff -r c97c42f78324 -r 413aff264775 usr.bin/make/unit-tests/directive-for.mk
--- a/usr.bin/make/unit-tests/directive-for.mk  Sun Oct 25 15:41:31 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-for.mk  Sun Oct 25 15:49:03 2020 +0000
@@ -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 @@
 .  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:
        @:;



Home | Main Index | Thread Index | Old Index