Module Name:    src
Committed By:   rillig
Date:           Sun Dec 12 08:55:29 UTC 2021

Modified Files:
        src/usr.bin/make: cond.c
        src/usr.bin/make/unit-tests: cond-func-defined.mk cond-token-plain.mk

Log Message:
make: rename ParseFuncArg to ParseWord, update comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/usr.bin/make/cond.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-func-defined.mk
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-token-plain.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.300 src/usr.bin/make/cond.c:1.301
--- src/usr.bin/make/cond.c:1.300	Sun Dec 12 08:42:29 2021
+++ src/usr.bin/make/cond.c	Sun Dec 12 08:55:28 2021
@@ -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 @@ CondParser_SkipWhitespace(CondParser *pa
 }
 
 /*
- * 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 @@ CondParser_SkipWhitespace(CondParser *pa
  *	*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 @@ CondParser_FuncCall(CondParser *par, boo
 	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 @@ CondParser_ComparisonOrLeaf(CondParser *
 	 * 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 == '>')

Index: src/usr.bin/make/unit-tests/cond-func-defined.mk
diff -u src/usr.bin/make/unit-tests/cond-func-defined.mk:1.7 src/usr.bin/make/unit-tests/cond-func-defined.mk:1.8
--- src/usr.bin/make/unit-tests/cond-func-defined.mk:1.7	Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cond-func-defined.mk	Sun Dec 12 08:55:28 2021
@@ -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 @@ ${:UA B}=	variable name with spaces
 .  error
 .endif
 
-# Parse error: missing closing parenthesis; see ParseFuncArg.
+# Parse error: missing closing parenthesis; see ParseWord.
 .if defined(DEF
 .  error
 .else

Index: src/usr.bin/make/unit-tests/cond-token-plain.mk
diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.12 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.13
--- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.12	Tue Sep 21 22:38:25 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.mk	Sun Dec 12 08:55:28 2021
@@ -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 @@ VAR=	defined
 .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

Reply via email to