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: inline ParseEmptyArg into CondParser_Func...
details: https://anonhg.NetBSD.org/src/rev/17931c99e571
branches: trunk
changeset: 1027559:17931c99e571
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Dec 11 10:41:31 2021 +0000
description:
make: inline ParseEmptyArg into CondParser_FuncCallEmpty
No functional change.
diffstat:
usr.bin/make/cond.c | 48 +++++++++++++----------------
usr.bin/make/unit-tests/cond-func-empty.mk | 12 +++---
usr.bin/make/var.c | 10 +++---
3 files changed, 32 insertions(+), 38 deletions(-)
diffs (152 lines):
diff -r ccde253c1f21 -r 17931c99e571 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Sat Dec 11 10:28:59 2021 +0000
+++ b/usr.bin/make/cond.c Sat Dec 11 10:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.294 2021/12/11 10:28:59 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.295 2021/12/11 10:41:31 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.294 2021/12/11 10:28:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.295 2021/12/11 10:41:31 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -563,7 +563,10 @@
/* For .if ${...}, check for non-empty string. This is different from
* the evaluation function from that .if variant, which would test
* whether a variable of the given name were defined. */
- /* XXX: Whitespace should count as empty, just as in ParseEmptyArg. */
+ /*
+ * XXX: Whitespace should count as empty, just as in
+ * CondParser_FuncCallEmpty.
+ */
if (par->plain)
return value[0] != '\0';
@@ -715,17 +718,26 @@
* The argument to empty() is a variable name, optionally followed by
* variable modifiers.
*/
-static Token
-ParseEmptyArg(const char **pp, bool doEval)
+static bool
+CondParser_FuncCallEmpty(CondParser *par, bool doEval, Token *out_token)
{
+ const char *cp = par->p;
+ Token tok;
FStr val;
- Token tok;
+
+ if (!is_token(cp, "empty", 5))
+ return false;
+ cp += 5;
- (*pp)--; /* Make (*pp)[1] point to the '('. */
- (void)Var_Parse(pp, SCOPE_CMDLINE,
+ cpp_skip_whitespace(&cp);
+ if (*cp != '(')
+ return false;
+
+ cp--; /* Make cp[1] point to the '('. */
+ (void)Var_Parse(&cp, SCOPE_CMDLINE,
doEval ? VARE_WANTRES : VARE_PARSE_ONLY, &val);
/* TODO: handle errors */
- /* If successful, *pp points beyond the closing ')' now. */
+ /* If successful, cp points beyond the closing ')' now. */
if (val.str == var_Error)
tok = TOK_ERROR;
@@ -735,24 +747,6 @@
}
FStr_Done(&val);
- return tok;
-}
-
-static bool
-CondParser_FuncCallEmpty(CondParser *par, bool doEval, Token *out_token)
-{
- Token tok;
- const char *cp = par->p;
-
- if (!is_token(cp, "empty", 5))
- return false;
- cp += 5;
-
- cpp_skip_whitespace(&cp);
- if (*cp != '(')
- return false;
-
- tok = ParseEmptyArg(&cp, doEval);
if (tok == TOK_FALSE && !doEval)
tok = TOK_TRUE;
*out_token = tok;
diff -r ccde253c1f21 -r 17931c99e571 usr.bin/make/unit-tests/cond-func-empty.mk
--- a/usr.bin/make/unit-tests/cond-func-empty.mk Sat Dec 11 10:28:59 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-func-empty.mk Sat Dec 11 10:41:31 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func-empty.mk,v 1.15 2021/12/11 09:53:53 rillig Exp $
+# $NetBSD: cond-func-empty.mk,v 1.16 2021/12/11 10:41:31 rillig Exp $
#
# Tests for the empty() function in .if conditions, which tests a variable
# expression for emptiness.
@@ -89,9 +89,9 @@
# Now the variable named " " gets a non-empty value, which demonstrates that
# neither leading nor trailing spaces are trimmed in the argument of the
# function. If the spaces were trimmed, the variable name would be "" and
-# that variable is indeed undefined. Since ParseEmptyArg calls Var_Parse
-# without VARE_UNDEFERR, the value of the undefined variable is returned as an
-# empty string.
+# that variable is indeed undefined. Since CondParser_FuncCallEmpty calls
+# Var_Parse without VARE_UNDEFERR, the value of the undefined variable is
+# returned as an empty string.
${:U }= space
.if empty( )
. error
@@ -126,8 +126,8 @@
#
# If everything goes well, the argument expands to "WORD", and that variable
# is defined at the beginning of this file. The surrounding 'W' and 'D'
-# ensure that ParseEmptyArg keeps track of the parsing position, both before
-# and after the call to Var_Parse.
+# ensure that CondParser_FuncCallEmpty keeps track of the parsing position,
+# both before and after the call to Var_Parse.
.if empty(W${:UOR}D)
. error
.endif
diff -r ccde253c1f21 -r 17931c99e571 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sat Dec 11 10:28:59 2021 +0000
+++ b/usr.bin/make/var.c Sat Dec 11 10:41:31 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.970 2021/12/09 20:27:01 rillig Exp $ */
+/* $NetBSD: var.c,v 1.971 2021/12/11 10:41:31 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.970 2021/12/09 20:27:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.971 2021/12/11 10:41:31 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -4517,9 +4517,9 @@
*
* Input:
* *pp The string to parse.
- * When parsing a condition in ParseEmptyArg, it may also
- * point to the "y" of "empty(VARNAME:Modifiers)", which
- * is syntactically the same.
+ * In CondParser_FuncCallEmpty, it may also point to the
+ * "y" of "empty(VARNAME:Modifiers)", which is
+ * syntactically the same.
* scope The scope for finding variables
* emode Controls the exact details of parsing and evaluation
*
Home |
Main Index |
Thread Index |
Old Index