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: rename ParseFuncArg to ParseWord, update ...
details: https://anonhg.NetBSD.org/src/rev/d788fa0fc314
branches: trunk
changeset: 1027571:d788fa0fc314
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Dec 12 08:55:28 2021 +0000
description:
make: rename ParseFuncArg to ParseWord, update comments
No functional change.
diffstat:
usr.bin/make/cond.c | 18 ++++++++++--------
usr.bin/make/unit-tests/cond-func-defined.mk | 4 ++--
usr.bin/make/unit-tests/cond-token-plain.mk | 4 ++--
3 files changed, 14 insertions(+), 12 deletions(-)
diffs (99 lines):
diff -r 119c77572c38 -r d788fa0fc314 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Sun Dec 12 08:49:57 2021 +0000
+++ b/usr.bin/make/cond.c Sun Dec 12 08:55:28 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.300 2021/12/12 08:42:29 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.301 2021/12/12 08:55:28 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.300 2021/12/12 08:42:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.301 2021/12/12 08:55:28 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -205,7 +205,9 @@
}
/*
- * Parse the argument of a built-in function.
+ * Parse a single word, taking into account balanced parentheses as well as
+ * embedded expressions. Used for the argument of a built-in function as
+ * well as for bare words, which are then passed to the default function.
*
* Arguments:
* *pp initially points at the '(',
@@ -214,12 +216,12 @@
* *out_arg receives the argument as string.
*
* func says whether the argument belongs to an actual function, or
- * whether the parsed argument is passed to the default function.
+ * NULL when parsing a bare word.
*
- * Return the length of the argument, or 0 on error.
+ * Return the length of the argument, or an ambiguous 0 on error.
*/
static size_t
-ParseFuncArg(CondParser *par, const char **pp, bool doEval, const char *func,
+ParseWord(CondParser *par, const char **pp, bool doEval, const char *func,
char **out_arg)
{
const char *p = *pp;
@@ -771,7 +773,7 @@
if (*cp != '(')
return false;
- arglen = ParseFuncArg(par, &cp, doEval, fn->fn_name, &arg);
+ arglen = ParseWord(par, &cp, doEval, fn->fn_name, &arg);
*out_token = ToToken(arglen != 0 && (!doEval || fn->fn_eval(arg)));
free(arg);
@@ -808,7 +810,7 @@
* XXX: Is it possible to have a variable expression evaluated twice
* at this point?
*/
- (void)ParseFuncArg(par, &cp, doEval, NULL, &arg);
+ (void)ParseWord(par, &cp, doEval, NULL, &arg);
cp1 = cp;
cpp_skip_whitespace(&cp1);
if (*cp1 == '=' || *cp1 == '!' || *cp1 == '<' || *cp1 == '>')
diff -r 119c77572c38 -r d788fa0fc314 usr.bin/make/unit-tests/cond-func-defined.mk
--- a/usr.bin/make/unit-tests/cond-func-defined.mk Sun Dec 12 08:49:57 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-func-defined.mk Sun Dec 12 08:55:28 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func-defined.mk,v 1.7 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: cond-func-defined.mk,v 1.8 2021/12/12 08:55:28 rillig Exp $
#
# Tests for the defined() function in .if conditions.
@@ -29,7 +29,7 @@
. error
.endif
-# Parse error: missing closing parenthesis; see ParseFuncArg.
+# Parse error: missing closing parenthesis; see ParseWord.
.if defined(DEF
. error
.else
diff -r 119c77572c38 -r d788fa0fc314 usr.bin/make/unit-tests/cond-token-plain.mk
--- a/usr.bin/make/unit-tests/cond-token-plain.mk Sun Dec 12 08:49:57 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-token-plain.mk Sun Dec 12 08:55:28 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-plain.mk,v 1.12 2021/09/21 22:38:25 rillig Exp $
+# $NetBSD: cond-token-plain.mk,v 1.13 2021/12/12 08:55:28 rillig Exp $
#
# Tests for plain tokens (that is, string literals without quotes)
# in .if conditions.
@@ -152,7 +152,7 @@
.endif
# The '\\' is not a line continuation. Neither is it an unquoted string
-# literal. Instead, it is parsed as a function argument (ParseFuncArg),
+# literal. Instead, it is parsed as a bare word (ParseWord),
# and in that context, the backslash is just an ordinary character. The
# function argument thus stays '\\' (2 backslashes). This string is passed
# to FuncDefined, and since there is no variable named '\\', the condition
Home |
Main Index |
Thread Index |
Old Index