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): allocate capturing groups for :C modif...
details: https://anonhg.NetBSD.org/src/rev/64764b101385
branches: trunk
changeset: 974119:64764b101385
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jul 24 08:03:27 2020 +0000
description:
make(1): allocate capturing groups for :C modifier statically
Since there are at most 10 capturing groups, it's easier to allocate them
on the stack.
To avoid growing the code size on x86_64, the matches have been moved to
the end of the struct, to keep the other offsets small.
diffstat:
usr.bin/make/var.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diffs (50 lines):
diff -r a32c754a6078 -r 64764b101385 usr.bin/make/var.c
--- a/usr.bin/make/var.c Fri Jul 24 07:59:35 2020 +0000
+++ b/usr.bin/make/var.c Fri Jul 24 08:03:27 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.302 2020/07/24 07:59:35 rillig Exp $ */
+/* $NetBSD: var.c,v 1.303 2020/07/24 08:03:27 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.302 2020/07/24 07:59:35 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.303 2020/07/24 08:03:27 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.302 2020/07/24 07:59:35 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.303 2020/07/24 08:03:27 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1376,9 +1376,9 @@
typedef struct {
regex_t re;
int nsub;
- regmatch_t *matches;
char *replace;
VarPatternFlags pflags;
+ regmatch_t matches[10];
} ModifyWord_SubstRegexArgs;
/* Callback for ModifyWords to implement the :C/from/to/ modifier.
@@ -2530,12 +2530,10 @@
args.nsub = 1;
if (args.nsub > 10)
args.nsub = 10;
- args.matches = bmake_malloc(args.nsub * sizeof(regmatch_t));
st->newStr = ModifyWords(st->ctxt, st->sep, oneBigWord, st->nstr,
ModifyWord_SubstRegex, &args);
regfree(&args.re);
free(args.replace);
- free(args.matches);
return TRUE;
}
#endif
Home |
Main Index |
Thread Index |
Old Index