Use VAR_INTERNAL when calling ApplyModifiers for VAR_{CMD,GLOBAL} only.
This commit is contained in:
parent
5f2f8cfca3
commit
5a008e2e63
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: var.c,v 1.210 2017/01/30 02:46:20 sjg Exp $ */
|
||||
/* $NetBSD: var.c,v 1.211 2017/01/31 07:00:59 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.210 2017/01/30 02:46:20 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.211 2017/01/31 07:00:59 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.210 2017/01/30 02:46:20 sjg Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.211 2017/01/31 07:00:59 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -3729,6 +3729,7 @@ char *
|
||||
Var_Parse(const char *str, GNode *ctxt, int flags,
|
||||
int *lengthPtr, void **freePtr)
|
||||
{
|
||||
GNode *mctxt;
|
||||
const char *tstr; /* Pointer into str */
|
||||
Var *v; /* Variable in invocation */
|
||||
Boolean haveModifier;/* TRUE if have modifiers for the variable */
|
||||
@ -3746,6 +3747,12 @@ Var_Parse(const char *str, GNode *ctxt, int flags,
|
||||
const char *extramodifiers; /* extra modifiers to apply first */
|
||||
char name[2];
|
||||
|
||||
/*
|
||||
* We can safely (and only need to?) use VAR_INTERNAL for modifiers
|
||||
* (so correct $_ is found) if ctxt is any of VAR_CMD, VAR_GLOBAL
|
||||
* or VAR_INTERNAL, otherwise leave it alone.
|
||||
*/
|
||||
mctxt = (ctxt == VAR_GLOBAL || ctxt == VAR_CMD) ? VAR_INTERNAL : ctxt;
|
||||
*freePtr = NULL;
|
||||
extramodifiers = NULL;
|
||||
dynamic = FALSE;
|
||||
@ -3992,7 +3999,7 @@ Var_Parse(const char *str, GNode *ctxt, int flags,
|
||||
extraFree = NULL;
|
||||
if (extramodifiers != NULL) {
|
||||
nstr = ApplyModifiers(nstr, extramodifiers, '(', ')',
|
||||
v, ctxt, flags, &used, &extraFree);
|
||||
v, mctxt, flags, &used, &extraFree);
|
||||
}
|
||||
|
||||
if (haveModifier) {
|
||||
@ -4000,7 +4007,7 @@ Var_Parse(const char *str, GNode *ctxt, int flags,
|
||||
tstr++;
|
||||
|
||||
nstr = ApplyModifiers(nstr, tstr, startc, endc,
|
||||
v, ctxt, flags, &used, freePtr);
|
||||
v, mctxt, flags, &used, freePtr);
|
||||
tstr += used;
|
||||
free(extraFree);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user