Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): in ModifyWord_Match, use different var...
details: https://anonhg.NetBSD.org/src/rev/6caebdd9d902
branches: trunk
changeset: 936497:6caebdd9d902
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Jul 27 22:59:49 2020 +0000
description:
make(1): in ModifyWord_Match, use different variables
Using the same registers or memory locations for different variables is
the job of the register allocator, not the programmer. For humans, that
practice is rather confusing.
diffstat:
usr.bin/make/var.c | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diffs (78 lines):
diff -r 8f5e73c07b7a -r 6caebdd9d902 usr.bin/make/var.c
--- a/usr.bin/make/var.c Mon Jul 27 22:50:01 2020 +0000
+++ b/usr.bin/make/var.c Mon Jul 27 22:59:49 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.345 2020/07/27 22:50:01 rillig Exp $ */
+/* $NetBSD: var.c,v 1.346 2020/07/27 22:59:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.345 2020/07/27 22:50:01 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.346 2020/07/27 22:59:49 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.345 2020/07/27 22:50:01 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.346 2020/07/27 22:59:49 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -2349,22 +2349,21 @@
st->termc = *st->cp;
const char *endpat = st->cp;
- char *pattern = NULL;
+ char *pattern;
if (copy) {
/* Compress the \:'s out of the pattern. */
pattern = bmake_malloc(st->cp - (mod + 1) + 1);
- char *cp2;
- for (cp2 = pattern, st->cp = mod + 1;
- st->cp < endpat;
- st->cp++, cp2++) {
- if ((*st->cp == '\\') && (st->cp+1 < endpat) &&
+ char *dst = pattern;
+ const char *src = mod + 1;
+ for (; src < endpat; src++, dst++) {
+ if (src[0] == '\\' && src + 1 < endpat &&
/* XXX: st->startc is missing here; see above */
- (st->cp[1] == ':' || st->cp[1] == st->endc))
- st->cp++;
- *cp2 = *st->cp;
+ (src[1] == ':' || src[1] == st->endc))
+ src++;
+ *dst = *src;
}
- *cp2 = '\0';
- endpat = cp2;
+ *dst = '\0';
+ endpat = dst;
} else {
/*
* Either Var_Subst or ModifyWords will need a
@@ -2372,15 +2371,18 @@
*/
pattern = bmake_strndup(mod + 1, endpat - (mod + 1));
}
+
if (needSubst) {
/* pattern contains embedded '$', so use Var_Subst to expand it. */
char *old_pattern = pattern;
pattern = Var_Subst(NULL, pattern, st->ctxt, st->eflags);
free(old_pattern);
}
+
if (DEBUG(VAR))
fprintf(debug_file, "Pattern[%s] for [%s] is [%s]\n",
st->v->name, st->nstr, pattern);
+
ModifyWordsCallback callback = mod[0] == 'M'
? ModifyWord_Match : ModifyWord_NoMatch;
st->newStr = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->nstr,
Home |
Main Index |
Thread Index |
Old Index