Module Name: src
Committed By: rillig
Date: Sun Feb 14 12:16:13 UTC 2021
Modified Files:
src/usr.bin/make: var.c
Log Message:
make: document purpose of stepping back in the parser
In ApplyModifier_Assign there was no need to compute the delimiter from
st->startc since that has already be done at that point.
To generate a diff of this commit:
cvs rdiff -u -r1.808 -r1.809 src/usr.bin/make/var.c
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.808 src/usr.bin/make/var.c:1.809
--- src/usr.bin/make/var.c:1.808 Sat Feb 6 21:40:14 2021
+++ src/usr.bin/make/var.c Sun Feb 14 12:16:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.808 2021/02/06 21:40:14 rillig Exp $ */
+/* $NetBSD: var.c,v 1.809 2021/02/14 12:16:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.808 2021/02/06 21:40:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.809 2021/02/14 12:16:13 rillig Exp $");
typedef enum VarFlags {
VAR_NONE = 0,
@@ -3220,7 +3220,8 @@ ApplyModifier_IfElse(const char **pp, Ap
if (res != VPR_OK)
return AMR_CLEANUP;
- (*pp)--;
+ (*pp)--; /* Go back to the st->endc. */
+
if (cond_rc == COND_INVALID) {
Error("Bad conditional expression `%s' in %s?%s:%s",
st->var->name.str, st->var->name.str, then_expr, else_expr);
@@ -3264,7 +3265,6 @@ static ApplyModifierResult
ApplyModifier_Assign(const char **pp, ApplyModifiersState *st)
{
GNode *scope;
- char delim;
char *val;
VarParseResult res;
@@ -3303,12 +3303,11 @@ ok:
break;
}
- delim = st->startc == '(' ? ')' : '}';
- res = ParseModifierPart(pp, delim, st->eflags, st, &val);
+ res = ParseModifierPart(pp, st->endc, st->eflags, st, &val);
if (res != VPR_OK)
return AMR_CLEANUP;
- (*pp)--;
+ (*pp)--; /* Go back to the st->endc. */
/* XXX: Expanding the variable name at this point sounds wrong. */
if (st->eflags & VARE_WANTRES) {
@@ -3436,7 +3435,8 @@ ApplyModifier_SysV(const char **pp, cons
if (res != VPR_OK)
return AMR_CLEANUP;
- (*pp)--;
+ (*pp)--; /* Go back to the st->endc. */
+
if (lhs[0] == '\0' && val[0] == '\0') {
st->newVal = FStr_InitRefer(val); /* special case */
} else {