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): remove unnecessary snprintf from Var_E...
details: https://anonhg.NetBSD.org/src/rev/d8a6f37be939
branches: trunk
changeset: 1012489:d8a6f37be939
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 01 06:35:00 2020 +0000
description:
make(1): remove unnecessary snprintf from Var_ExportVars
String literals can be concatenated at compile time.
Furthermore, MAKE_EXPORTED can now contain percent characters without
invoking undefined behavior. Not that anyone would ever want to do this.
diffstat:
usr.bin/make/var.c | 30 ++++++++++++------------------
1 files changed, 12 insertions(+), 18 deletions(-)
diffs (70 lines):
diff -r d024c7bfa10d -r d8a6f37be939 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sat Aug 01 06:34:59 2020 +0000
+++ b/usr.bin/make/var.c Sat Aug 01 06:35:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.368 2020/07/31 14:59:53 rillig Exp $ */
+/* $NetBSD: var.c,v 1.369 2020/08/01 06:35:00 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.368 2020/07/31 14:59:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.369 2020/08/01 06:35:00 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.368 2020/07/31 14:59:53 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.369 2020/08/01 06:35:00 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -582,7 +582,6 @@
{
char tmp[BUFSIZ];
char *val;
- int n;
/*
* Several make's support this sort of mechanism for tracking
@@ -601,26 +600,21 @@
Hash_ForEach(&VAR_GLOBAL->context, Var_ExportVars_callback, NULL);
return;
}
- /*
- * We have a number of exported vars,
- */
- n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":O:u}");
- if (n < (int)sizeof(tmp)) {
+
+ val = Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL, VARE_WANTRES);
+ if (*val) {
char **av;
char *as;
int ac;
int i;
- val = Var_Subst(tmp, VAR_GLOBAL, VARE_WANTRES);
- if (*val) {
- av = brk_string(val, &ac, FALSE, &as);
- for (i = 0; i < ac; i++)
- Var_Export1(av[i], 0);
- free(as);
- free(av);
- }
- free(val);
+ av = brk_string(val, &ac, FALSE, &as);
+ for (i = 0; i < ac; i++)
+ Var_Export1(av[i], 0);
+ free(as);
+ free(av);
}
+ free(val);
}
/*
Home |
Main Index |
Thread Index |
Old Index