Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make For :ts numeric escapes \x* is hex, anything el...



details:   https://anonhg.NetBSD.org/src/rev/7dc3d22a66a8
branches:  trunk
changeset: 343973:7dc3d22a66a8
user:      sjg <sjg%NetBSD.org@localhost>
date:      Mon Mar 07 20:20:35 2016 +0000

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

diffstat:

 usr.bin/make/unit-tests/modts.exp |  10 ++++++++--
 usr.bin/make/unit-tests/modts.mk  |   3 ++-
 usr.bin/make/var.c                |  19 +++++++++++++++----
 3 files changed, 25 insertions(+), 7 deletions(-)

diffs (94 lines):

diff -r 5e51b06cec68 -r 7dc3d22a66a8 usr.bin/make/unit-tests/modts.exp
--- a/usr.bin/make/unit-tests/modts.exp Mon Mar 07 15:58:05 2016 +0000
+++ b/usr.bin/make/unit-tests/modts.exp Mon Mar 07 20:20:35 2016 +0000
@@ -23,10 +23,16 @@
 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?
diff -r 5e51b06cec68 -r 7dc3d22a66a8 usr.bin/make/unit-tests/modts.mk
--- a/usr.bin/make/unit-tests/modts.mk  Mon Mar 07 15:58:05 2016 +0000
+++ b/usr.bin/make/unit-tests/modts.mk  Mon Mar 07 20:20:35 2016 +0000
@@ -36,8 +36,9 @@
        @${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?'
diff -r 5e51b06cec68 -r 7dc3d22a66a8 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Mar 07 15:58:05 2016 +0000
+++ b/usr.bin/make/var.c        Mon Mar 07 20:20:35 2016 +0000
@@ -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 @@
                            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 @@
                                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;



Home | Main Index | Thread Index | Old Index