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): use better variable names in Var_Exists
details: https://anonhg.NetBSD.org/src/rev/ccc7aee1f66e
branches: trunk
changeset: 936642:ccc7aee1f66e
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 01 07:29:04 2020 +0000
description:
make(1): use better variable names in Var_Exists
Calling strchr just to initialize a variable to NULL is not as
straight-forward as possible.
The unspecific variable name cp made it unnecessarily difficult to
understand its purpose.
diffstat:
usr.bin/make/var.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diffs (46 lines):
diff -r bf8cf9ed2cb0 -r ccc7aee1f66e usr.bin/make/var.c
--- a/usr.bin/make/var.c Sat Aug 01 07:14:05 2020 +0000
+++ b/usr.bin/make/var.c Sat Aug 01 07:29:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.372 2020/08/01 07:14:04 rillig Exp $ */
+/* $NetBSD: var.c,v 1.373 2020/08/01 07:29:04 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.372 2020/08/01 07:14:04 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.373 2020/08/01 07:29:04 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.372 2020/08/01 07:14:04 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.373 2020/08/01 07:29:04 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -990,13 +990,12 @@
Boolean
Var_Exists(const char *name, GNode *ctxt)
{
- Var *v;
- char *cp;
-
- if ((cp = strchr(name, '$')) != NULL)
- cp = Var_Subst(name, ctxt, VARE_WANTRES);
- v = VarFind(cp ? cp : name, ctxt, FIND_CMD | FIND_GLOBAL | FIND_ENV);
- free(cp);
+ char *name_freeIt = NULL;
+ if (strchr(name, '$') != NULL)
+ name = name_freeIt = Var_Subst(name, ctxt, VARE_WANTRES);
+
+ Var *v = VarFind(name, ctxt, FIND_CMD | FIND_GLOBAL | FIND_ENV);
+ free(name_freeIt);
if (v == NULL)
return FALSE;
Home |
Main Index |
Thread Index |
Old Index