Module Name: src
Committed By: rillig
Date: Fri Jul 31 13:43:44 UTC 2020
Modified Files:
src/usr.bin/make: var.c
Log Message:
make(1): reduce scope of local variables in ApplyModifier_Subst
To generate a diff of this commit:
cvs rdiff -u -r1.361 -r1.362 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.361 src/usr.bin/make/var.c:1.362
--- src/usr.bin/make/var.c:1.361 Fri Jul 31 13:39:15 2020
+++ src/usr.bin/make/var.c Fri Jul 31 13:43:44 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.361 2020/07/31 13:39:15 rillig Exp $ */
+/* $NetBSD: var.c,v 1.362 2020/07/31 13:43:44 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.361 2020/07/31 13:39:15 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.362 2020/07/31 13:43:44 rillig 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.361 2020/07/31 13:39:15 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.362 2020/07/31 13:43:44 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -2392,8 +2392,6 @@ ApplyModifier_Match(const char *mod, App
static ApplyModifierResult
ApplyModifier_Subst(const char * const mod, ApplyModifiersState *st)
{
- ModifyWord_SubstArgs args;
- Boolean oneBigWord = st->oneBigWord;
char delim = mod[1];
if (delim == '\0') {
Error("Missing delimiter for :S modifier");
@@ -2403,11 +2401,13 @@ ApplyModifier_Subst(const char * const m
st->next = mod + 2;
+ ModifyWord_SubstArgs args;
+ args.pflags = 0;
+
/*
* If pattern begins with '^', it is anchored to the
* start of the word -- skip over it and flag pattern.
*/
- args.pflags = 0;
if (*st->next == '^') {
args.pflags |= VARP_ANCHOR_START;
st->next++;
@@ -2429,11 +2429,7 @@ ApplyModifier_Subst(const char * const m
}
args.rhs = rhs;
- /*
- * Check for global substitution. If 'g' after the final
- * delimiter, substitution is global and is marked that
- * way.
- */
+ Boolean oneBigWord = st->oneBigWord;
for (;; st->next++) {
switch (*st->next) {
case 'g':