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 In either a variable assignmentor a ...



details:   https://anonhg.NetBSD.org/src/rev/0ccd3aa2266b
branches:  trunk
changeset: 331796:0ccd3aa2266b
user:      apb <apb%NetBSD.org@localhost>
date:      Sun Aug 24 16:47:12 2014 +0000

description:
In either a variable assignmentor a command, backslash-backslash-newline
does not escape the newline.  This is compatible with gmake.

diffstat:

 usr.bin/make/unit-tests/escape.exp |  12 +++---------
 usr.bin/make/unit-tests/escape.mk  |  32 +++++++++++++++++---------------
 2 files changed, 20 insertions(+), 24 deletions(-)

diffs (79 lines):

diff -r 743bd4c75799 -r 0ccd3aa2266b usr.bin/make/unit-tests/escape.exp
--- a/usr.bin/make/unit-tests/escape.exp        Sun Aug 24 16:42:46 2014 +0000
+++ b/usr.bin/make/unit-tests/escape.exp        Sun Aug 24 16:47:12 2014 +0000
@@ -57,15 +57,9 @@
 :first line\
        only one tab should be elided, second tab remains
 cmd-2bsnl
-:first line\\
-#second line without space\\
-third line:
-:first line\\
-     second line spaces should be retained:
-:first line\\
-second line tab should be elided:
-:first line\\
-       only one tab should be elided, second tab remains
+take one\
+take two\
+take three\
 cmd-3bsnl
 :first line\\\
 #second line without space\\\
diff -r 743bd4c75799 -r 0ccd3aa2266b usr.bin/make/unit-tests/escape.mk
--- a/usr.bin/make/unit-tests/escape.mk Sun Aug 24 16:42:46 2014 +0000
+++ b/usr.bin/make/unit-tests/escape.mk Sun Aug 24 16:47:12 2014 +0000
@@ -1,4 +1,4 @@
-# $Id: escape.mk,v 1.7 2014/08/24 16:08:14 apb Exp $
+# $Id: escape.mk,v 1.8 2014/08/24 16:47:12 apb Exp $
 #
 # Test backslash escaping.
 
@@ -32,10 +32,12 @@
 # in a variable assignment stores "#" as part of the value.
 # The "\" is not taken literally, and the "#" does not begin a comment.
 #
-# Also, our practice is that an even number of backslashes before a newline
-# in a variable assignment simply stores the backslashes as part of the
-# value, and treats the newline as though it was not escaped.  This
-# is compatible with GNU make.
+# Also, our practice is that an even number of backslashes before a
+# newline in a variable assignment simply stores the backslashes as part
+# of the value, and treats the newline as though it was not escaped.
+# Similarly, ann even number of backslashes before a newline in a
+# command simply uses the backslashes as part of the command test, but
+# does not escape the newline.  This is compatible with GNU make.
 
 all: .PHONY
 # We will add dependencies like "all: yet-another-test" later.
@@ -202,20 +204,20 @@
        @echo :'first line\
                only one tab should be elided, second tab remains'
 
-# Double-backslash-newline in a command is retained.
+# Double-backslash-newline in a command.
+# Both backslashes are retained, but the newline is not escaped.
+# XXX: This may differ from POSIX, but matches gmake.
+#
+# When make passes two backslashes to the shell, the shell will pass one
+# backslash to the echo commant.
 #
 all: cmd-2bsnl
 cmd-2bsnl: .PHONY
        @echo ${.TARGET}
-       @echo :'first line\\
-#second line without space\\
-third line':
-       @echo :'first line\\
-     second line spaces should be retained':
-       @echo :'first line\\
-       second line tab should be elided':
-       @echo :'first line\\
-               only one tab should be elided, second tab remains'
+       @echo take one\\
+# this should be a comment
+       @echo take two\\
+       @echo take three\\
 
 # Triple-backslash-newline in a command is retained.
 #



Home | Main Index | Thread Index | Old Index