Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests tests/make: test escape sequences in...



details:   https://anonhg.NetBSD.org/src/rev/c107c2a8b250
branches:  trunk
changeset: 1026566:c107c2a8b250
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 29 00:17:10 2021 +0000

description:
tests/make: test escape sequences in string literals for .MAKEFLAGS

These escape sequences differ from those in string literals in
conditions.  In "assignments" to .MAKEFLAGS, \n is a newline, while in a
line like '.if ${VAR} == "\n"', it is simply the letter 'n'.

diffstat:

 usr.bin/make/unit-tests/deptgt-makeflags.mk |  29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diffs (50 lines):

diff -r b137080be991 -r c107c2a8b250 usr.bin/make/unit-tests/deptgt-makeflags.mk
--- a/usr.bin/make/unit-tests/deptgt-makeflags.mk       Sun Nov 28 23:12:51 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt-makeflags.mk       Mon Nov 29 00:17:10 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-makeflags.mk,v 1.6 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: deptgt-makeflags.mk,v 1.7 2021/11/29 00:17:10 rillig Exp $
 #
 # Tests for the special target .MAKEFLAGS in dependency declarations,
 # which adds command line options later, at parse time.
@@ -65,7 +65,7 @@
 .endif
 
 # Next try at defining another newline variable.  Since whitespace around the
-# variable value is trimmed, two empty variable expressions surround the
+# variable value is trimmed, two empty variable expressions ${:U} surround the
 # literal newline now.  This prevents the newline from being skipped during
 # parsing.  The ':=' assignment operator expands the empty variable
 # expressions, leaving only the newline as the variable value.
@@ -81,6 +81,31 @@
 .endif
 #.MAKEFLAGS: -d0
 
+# Now do the same for the other escape sequences; see Substring_Words.
+.MAKEFLAGS: CHAR_BS:="$${:U}\b$${:U}"
+.MAKEFLAGS: CHAR_FF:="$${:U}\f$${:U}"
+.MAKEFLAGS: CHAR_NL:="$${:U}\n$${:U}"
+.MAKEFLAGS: CHAR_CR:="$${:U}\r$${:U}"
+.MAKEFLAGS: CHAR_TAB:="$${:U}\t$${:U}"
+
+# Note: backspace is not whitespace, it is a control character.
+.if ${CHAR_BS:C,^[[:cntrl:]]$,found,W} != "found"
+.  error
+.endif
+.if ${CHAR_FF:C,^[[:space:]]$,found,W} != "found"
+.  error
+.endif
+.if ${CHAR_NL:C,^[[:space:]]$,found,W} != "found"
+.  error
+.endif
+.if ${CHAR_CR:C,^[[:space:]]$,found,W} != "found"
+.  error
+.endif
+.if ${CHAR_TAB:C,^[[:space:]]$,found,W} != "found"
+.  error
+.endif
+
+
 # Unbalanced quotes produce an error message.  If they occur anywhere in the
 # command line, the whole command line is skipped.
 .MAKEFLAGS: VAR=previous



Home | Main Index | Thread Index | Old Index