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): help the compiler to find common subex...
details: https://anonhg.NetBSD.org/src/rev/84f9e8cc3afd
branches: trunk
changeset: 936403:84f9e8cc3afd
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 26 15:37:44 2020 +0000
description:
make(1): help the compiler to find common subexpressions
diffstat:
usr.bin/make/var.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diffs (53 lines):
diff -r 7afec721bbd0 -r 84f9e8cc3afd usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Jul 26 15:26:27 2020 +0000
+++ b/usr.bin/make/var.c Sun Jul 26 15:37:44 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.314 2020/07/26 15:26:27 rillig Exp $ */
+/* $NetBSD: var.c,v 1.315 2020/07/26 15:37:44 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.314 2020/07/26 15:26:27 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.315 2020/07/26 15:37: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.314 2020/07/26 15:26:27 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.315 2020/07/26 15:37:44 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1325,6 +1325,7 @@
if (args->pflags & VARP_ANCHOR_END) {
if (wordLen < args->lhsLen)
goto nosub;
+
const char *start = word + (wordLen - args->lhsLen);
if (memcmp(start, args->lhs, args->lhsLen) != 0)
goto nosub;
@@ -1336,13 +1337,13 @@
}
/* unanchored */
- const char *cp;
- while ((cp = Str_FindSubstring(word, args->lhs)) != NULL) {
- SepBuf_AddBytesBetween(buf, word, cp);
+ const char *match;
+ while ((match = Str_FindSubstring(word, args->lhs)) != NULL) {
+ SepBuf_AddBytesBetween(buf, word, match);
SepBuf_AddBytes(buf, args->rhs, args->rhsLen);
args->pflags |= VARP_SUB_MATCHED;
- wordLen -= (cp - word) + args->lhsLen;
- word = cp + args->lhsLen;
+ wordLen -= (match - word) + args->lhsLen;
+ word += (match - word) + args->lhsLen;
if (wordLen == 0 || !(args->pflags & VARP_SUB_GLOBAL))
break;
}
Home |
Main Index |
Thread Index |
Old Index