ApplyModifiers: if we parse a variable in the modifier list,
do not consider it a nested modifier set, unless it is followed by endc, a ':' or end of string.
This commit is contained in:
parent
272b9fa3d1
commit
43c87c739c
|
@ -1,13 +1,26 @@
|
|||
# $Id: sysv,v 1.1 2011/03/06 00:02:14 sjg Exp $
|
||||
# $Id: sysv,v 1.2 2011/06/03 21:10:42 sjg Exp $
|
||||
|
||||
FOO ?=
|
||||
FOOBAR = $(FOO:=bar)
|
||||
|
||||
_this := ${.PARSEDIR}/${.PARSEFILE}
|
||||
|
||||
B = /b
|
||||
S = /
|
||||
FUN = ${B}${S}fun
|
||||
SUN = the Sun
|
||||
|
||||
# we expect nothing when FOO is empty
|
||||
all:
|
||||
all: foo fun
|
||||
|
||||
foo:
|
||||
@echo FOOBAR = $(FOOBAR)
|
||||
.if empty(FOO)
|
||||
@FOO="foo fu" ${.MAKE} -f ${_this}
|
||||
@FOO="foo fu" ${.MAKE} -f ${_this} foo
|
||||
.endif
|
||||
|
||||
fun:
|
||||
@echo ${FUN:T}
|
||||
@echo ${FUN:${B}${S}fun=fun}
|
||||
@echo ${FUN:${B}${S}%=%}
|
||||
@echo ${In:L:%=% ${SUN}}
|
||||
|
|
|
@ -317,6 +317,10 @@ Now we expect an error...
|
|||
V.i386 ?= OK
|
||||
FOOBAR =
|
||||
FOOBAR = foobar fubar
|
||||
fun
|
||||
fun
|
||||
fun
|
||||
In the Sun
|
||||
The answer is unknown
|
||||
The answer is unknown
|
||||
The answer is empty
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: var.c,v 1.166 2011/05/21 07:30:42 tsutsui Exp $ */
|
||||
/* $NetBSD: var.c,v 1.167 2011/06/03 21:10:42 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -69,14 +69,14 @@
|
|||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.166 2011/05/21 07:30:42 tsutsui Exp $";
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.167 2011/06/03 21:10:42 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.166 2011/05/21 07:30:42 tsutsui Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.167 2011/06/03 21:10:42 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -2498,14 +2498,28 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||
|
||||
if (*tstr == '$') {
|
||||
/*
|
||||
* We have some complex modifiers in a variable.
|
||||
* We may have some complex modifiers in a variable.
|
||||
*/
|
||||
void *freeIt;
|
||||
char *rval;
|
||||
int rlen;
|
||||
int c;
|
||||
|
||||
rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
|
||||
|
||||
/*
|
||||
* If we have not parsed up to endc or ':',
|
||||
* we are not interested.
|
||||
*/
|
||||
if (rval != NULL && *rval &&
|
||||
(c = tstr[rlen]) != '\0' &&
|
||||
c != ':' &&
|
||||
c != endc) {
|
||||
if (freeIt)
|
||||
free(freeIt);
|
||||
goto apply_mods;
|
||||
}
|
||||
|
||||
if (DEBUG(VAR)) {
|
||||
fprintf(debug_file, "Got '%s' from '%.*s'%.*s\n",
|
||||
rval, rlen, tstr, rlen, tstr + rlen);
|
||||
|
@ -2537,6 +2551,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
|||
}
|
||||
continue;
|
||||
}
|
||||
apply_mods:
|
||||
if (DEBUG(VAR)) {
|
||||
fprintf(debug_file, "Applying :%c to \"%s\"\n", *tstr, nstr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue