Module Name:    src
Committed By:   sjg
Date:           Mon Mar  7 20:20:35 UTC 2016

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

Log Message:
For :ts numeric escapes \x* is hex, anything else is octal.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/modts.exp \
    src/usr.bin/make/unit-tests/modts.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.205 src/usr.bin/make/var.c:1.206
--- src/usr.bin/make/var.c:1.205	Sat Feb 20 01:19:03 2016
+++ src/usr.bin/make/var.c	Mon Mar  7 20:20:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.206 2016/03/07 20:20:35 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.206 2016/03/07 20:20:35 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.206 2016/03/07 20:20:35 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3006,6 +3006,9 @@ ApplyModifiers(char *nstr, const char *t
 			    parsestate.varSpace = 0; /* no separator */
 			    cp = tstr + 2;
 			} else if (tstr[2] == '\\') {
+			    const char *xp = &tstr[3];
+			    int base = 8; /* assume octal */
+
 			    switch (tstr[3]) {
 			    case 'n':
 				parsestate.varSpace = '\n';
@@ -3015,12 +3018,20 @@ ApplyModifiers(char *nstr, const char *t
 				parsestate.varSpace = '\t';
 				cp = tstr + 4;
 				break;
+			    case 'x':
+				base = 16;
+				xp++;
+				goto get_numeric;
+			    case '0':
+				base = 0;
+				goto get_numeric;
 			    default:
 				if (isdigit((unsigned char)tstr[3])) {
 				    char *ep;
 
+				get_numeric:
 				    parsestate.varSpace =
-					strtoul(&tstr[3], &ep, 0);
+					strtoul(xp, &ep, base);
 				    if (*ep != ':' && *ep != endc)
 					goto bad_modifier;
 				    cp = ep;

Index: src/usr.bin/make/unit-tests/modts.exp
diff -u src/usr.bin/make/unit-tests/modts.exp:1.1 src/usr.bin/make/unit-tests/modts.exp:1.2
--- src/usr.bin/make/unit-tests/modts.exp:1.1	Thu Aug 21 13:44:51 2014
+++ src/usr.bin/make/unit-tests/modts.exp	Mon Mar  7 20:20:35 2016
@@ -23,10 +23,16 @@ THREE
 FOUR
 FIVE
 SIX"
+LIST:ts/xa:tu="ONE
+TWO
+THREE
+FOUR
+FIVE
+SIX"
 make: Bad modifier `:tx' for LIST
 LIST:tx="}"
-make: Bad modifier `:ts\x' for LIST
-LIST:ts/x:tu="\x:tu}"
+make: Bad modifier `:ts\X' for LIST
+LIST:ts/x:tu="\X:tu}"
 FU_mod-ts="a/b/cool"
 FU_mod-ts:ts:T="cool" == cool?
 B.${AAA:ts}="Baaa" == Baaa?
Index: src/usr.bin/make/unit-tests/modts.mk
diff -u src/usr.bin/make/unit-tests/modts.mk:1.1 src/usr.bin/make/unit-tests/modts.mk:1.2
--- src/usr.bin/make/unit-tests/modts.mk:1.1	Thu Aug 21 13:44:51 2014
+++ src/usr.bin/make/unit-tests/modts.mk	Mon Mar  7 20:20:35 2016
@@ -36,8 +36,9 @@ mod-ts:
 	@${PRINT} 'LIST:ts/n="${LIST:ts\n}"'
 	@${PRINT} 'LIST:ts/t="${LIST:ts\t}"'
 	@${PRINT} 'LIST:ts/012:tu="${LIST:ts\012:tu}"'
+	@${PRINT} 'LIST:ts/xa:tu="${LIST:ts\xa:tu}"'
 	@${PRINT} 'LIST:tx="${LIST:tx}"'
-	@${PRINT} 'LIST:ts/x:tu="${LIST:ts\x:tu}"'
+	@${PRINT} 'LIST:ts/x:tu="${LIST:ts\X:tu}"'
 	@${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
 	@${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
 	@${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'

Reply via email to