Module Name:    src
Committed By:   rillig
Date:           Sun Nov  1 13:55:31 UTC 2020

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: modword.exp modword.mk varmod-range.exp
            varmod-range.mk

Log Message:
make(1): add tests for the variable modifiers :[words] and :range


To generate a diff of this commit:
cvs rdiff -u -r1.633 -r1.634 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/modword.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/modword.mk \
    src/usr.bin/make/unit-tests/varmod-range.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-range.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/var.c
diff -u src/usr.bin/make/var.c:1.633 src/usr.bin/make/var.c:1.634
--- src/usr.bin/make/var.c:1.633	Sun Nov  1 12:34:45 2020
+++ src/usr.bin/make/var.c	Sun Nov  1 13:55:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.633 2020/11/01 12:34:45 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.634 2020/11/01 13:55:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.633 2020/11/01 12:34:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.634 2020/11/01 13:55:31 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2648,7 +2648,7 @@ ApplyModifier_To(const char **pp, ApplyM
     return AMR_BAD;
 }
 
-/* :[#], :[1], etc. */
+/* :[#], :[1], :[-1..1], etc. */
 static ApplyModifierResult
 ApplyModifier_Words(const char **pp, ApplyModifiersState *st)
 {

Index: src/usr.bin/make/unit-tests/modword.exp
diff -u src/usr.bin/make/unit-tests/modword.exp:1.1 src/usr.bin/make/unit-tests/modword.exp:1.2
--- src/usr.bin/make/unit-tests/modword.exp:1.1	Thu Aug 21 13:44:51 2014
+++ src/usr.bin/make/unit-tests/modword.exp	Sun Nov  1 13:55:31 2020
@@ -66,6 +66,7 @@ LIST:[@]:[2]="two"
 LIST:[*]:C/ /,/:[2]=""
 LIST:[*]:C/ /,/:[*]:[2]=""
 LIST:[*]:C/ /,/:[@]:[2]="three"
+LONGLIST:[012..0x12]="10 11 12 13 14 15 16 17 18"
 make: Bad modifier `:[1.]' for LIST
 LIST:[1.]="" is an error
 make: Bad modifier `:[1..]' for LIST
@@ -99,6 +100,7 @@ LIST:[${EMPTY}]="" is an error
 LIST:[${LONGLIST:[21]:S/2//}]="one"
 LIST:[${LIST:[#]}]="six"
 LIST:[${LIST:[${HASH}]}]="six"
+LIST:[  -1..   +3]="six five four three"
 LIST:S/ /,/="one two three four five six"
 LIST:S/ /,/W="one,two three four five six"
 LIST:S/ /,/gW="one,two,three,four,five,six"

Index: src/usr.bin/make/unit-tests/modword.mk
diff -u src/usr.bin/make/unit-tests/modword.mk:1.3 src/usr.bin/make/unit-tests/modword.mk:1.4
--- src/usr.bin/make/unit-tests/modword.mk:1.3	Sat Oct 24 08:50:17 2020
+++ src/usr.bin/make/unit-tests/modword.mk	Sun Nov  1 13:55:31 2020
@@ -1,4 +1,4 @@
-# $NetBSD: modword.mk,v 1.3 2020/10/24 08:50:17 rillig Exp $
+# $NetBSD: modword.mk,v 1.4 2020/11/01 13:55:31 rillig Exp $
 #
 # Test behaviour of new :[] modifier
 
@@ -22,7 +22,8 @@ mod-squarebrackets: mod-squarebrackets-0
 	mod-squarebrackets-hash \
 	mod-squarebrackets-n \
 	mod-squarebrackets-start-end \
-	mod-squarebrackets-nested
+	mod-squarebrackets-nested \
+	mod-squarebrackets-space
 
 mod-squarebrackets-0-star-at:
 	@echo 'LIST:[]="${LIST:[]}" is an error'
@@ -92,6 +93,7 @@ mod-squarebrackets-n:
 	@echo 'LIST:[*]:C/ /,/:[2]="${LIST:[*]:C/ /,/:[2]}"'
 	@echo 'LIST:[*]:C/ /,/:[*]:[2]="${LIST:[*]:C/ /,/:[*]:[2]}"'
 	@echo 'LIST:[*]:C/ /,/:[@]:[2]="${LIST:[*]:C/ /,/:[@]:[2]}"'
+	@echo 'LONGLIST:[012..0x12]="${LONGLIST:[012..0x12]}"'
 
 mod-squarebrackets-start-end:
 	@echo 'LIST:[1.]="${LIST:[1.]}" is an error'
@@ -124,6 +126,12 @@ mod-squarebrackets-nested:
 	@echo 'LIST:[$${LIST:[#]}]="${LIST:[${LIST:[#]}]}"'
 	@echo 'LIST:[$${LIST:[$${HASH}]}]="${LIST:[${LIST:[${HASH}]}]}"'
 
+mod-squarebrackets-space:
+	# As of 2020-11-01, it is possible to have spaces before the numbers
+	# but not after them.  This is an unintended side-effect of using
+	# strtol for parsing the numbers.
+	@echo 'LIST:[  -1..   +3]="${LIST:[  -1..   +3]}"'
+
 mod-C-W:
 	@echo 'LIST:C/ /,/="${LIST:C/ /,/}"'
 	@echo 'LIST:C/ /,/W="${LIST:C/ /,/W}"'
Index: src/usr.bin/make/unit-tests/varmod-range.exp
diff -u src/usr.bin/make/unit-tests/varmod-range.exp:1.3 src/usr.bin/make/unit-tests/varmod-range.exp:1.4
--- src/usr.bin/make/unit-tests/varmod-range.exp:1.3	Sun Nov  1 13:10:22 2020
+++ src/usr.bin/make/unit-tests/varmod-range.exp	Sun Nov  1 13:55:31 2020
@@ -1,13 +1,13 @@
 make: Unknown modifier 'x'
-make: "varmod-range.mk" line 46: Malformed conditional ("${:U:range=x}Rest" != "Rest")
+make: "varmod-range.mk" line 49: Malformed conditional ("${:U:range=x}Rest" != "Rest")
 make: Unknown modifier 'x'
-make: "varmod-range.mk" line 55: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
+make: "varmod-range.mk" line 58: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
 make: Unknown modifier 'r'
-make: "varmod-range.mk" line 71: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
+make: "varmod-range.mk" line 74: Malformed conditional ("${a b c:L:rang}Rest" != "Rest")
 make: Unknown modifier 'r'
-make: "varmod-range.mk" line 78: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
+make: "varmod-range.mk" line 81: Malformed conditional ("${a b c:L:rango}Rest" != "Rest")
 make: Unknown modifier 'r'
-make: "varmod-range.mk" line 85: Malformed conditional ("${a b c:L:ranger}Rest" != "Rest")
+make: "varmod-range.mk" line 88: Malformed conditional ("${a b c:L:ranger}Rest" != "Rest")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-range.mk
diff -u src/usr.bin/make/unit-tests/varmod-range.mk:1.5 src/usr.bin/make/unit-tests/varmod-range.mk:1.6
--- src/usr.bin/make/unit-tests/varmod-range.mk:1.5	Sun Nov  1 13:10:22 2020
+++ src/usr.bin/make/unit-tests/varmod-range.mk	Sun Nov  1 13:55:31 2020
@@ -1,7 +1,10 @@
-# $NetBSD: varmod-range.mk,v 1.5 2020/11/01 13:10:22 rillig Exp $
+# $NetBSD: varmod-range.mk,v 1.6 2020/11/01 13:55:31 rillig Exp $
 #
 # Tests for the :range variable modifier, which generates sequences
 # of integers from the given range.
+#
+# See also:
+#	modword.mk
 
 # The :range modifier generates a sequence of integers, one number per
 # word of the variable expression's value.

Reply via email to