tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: make :ts documentation
David Holland <dholland-tech%netbsd.org@localhost> wrote:
> > So the patch below is probably better - assume octal explicitly hex.
>
> hex should be \xff like in C, not \0xff...
Good point. This seems the neatest way to do that....
With added unit test
Index: var.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/var.c,v
retrieving revision 1.205
diff -u -p -r1.205 var.c
--- var.c 20 Feb 2016 01:19:03 -0000 1.205
+++ var.c 4 Mar 2016 18:15:41 -0000
@@ -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,17 @@ ApplyModifiers(char *nstr, const char *t
parsestate.varSpace = '\t';
cp = tstr + 4;
break;
+ case 'x':
+ base = 16;
+ xp++;
+ 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: unit-tests/modts.mk
===================================================================
RCS file: /cvsroot/src/usr.bin/make/unit-tests/modts.mk,v
retrieving revision 1.1
diff -u -p -r1.1 modts.mk
--- unit-tests/modts.mk 21 Aug 2014 13:44:51 -0000 1.1
+++ unit-tests/modts.mk 4 Mar 2016 18:15:41 -0000
@@ -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?'
Index: unit-tests/modts.exp
===================================================================
RCS file: /cvsroot/src/usr.bin/make/unit-tests/modts.exp,v
retrieving revision 1.1
diff -u -p -r1.1 modts.exp
--- unit-tests/modts.exp 21 Aug 2014 13:44:51 -0000 1.1
+++ unit-tests/modts.exp 4 Mar 2016 18:15:41 -0000
@@ -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?
Home |
Main Index |
Thread Index |
Old Index