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: use proper return type for ParseEmptyArg
details: https://anonhg.NetBSD.org/src/rev/764c994d08c6
branches: trunk
changeset: 1027556:764c994d08c6
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Dec 11 10:14:32 2021 +0000
description:
make: use proper return type for ParseEmptyArg
Now that ParseEmptyArg is no longer bound to have the same prototype as
ParseFuncArg, it can use a more appropriate return type instead of
encoding everything in a size_t.
Since ParseEmptyArg never returned 0, that code path was unused. It was
only used for all other functions.
No functional change.
diffstat:
usr.bin/make/cond.c | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diffs (83 lines):
diff -r 7db4d3736c75 -r 764c994d08c6 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Sat Dec 11 10:07:31 2021 +0000
+++ b/usr.bin/make/cond.c Sat Dec 11 10:14:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.291 2021/12/11 10:07:31 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.292 2021/12/11 10:14:32 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.291 2021/12/11 10:07:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.292 2021/12/11 10:14:32 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -715,11 +715,11 @@
* The argument to empty() is a variable name, optionally followed by
* variable modifiers.
*/
-static size_t
+static Token
ParseEmptyArg(const char **pp, bool doEval)
{
FStr val;
- size_t magic_res;
+ Token tok;
(*pp)--; /* Make (*pp)[1] point to the '('. */
(void)Var_Parse(pp, SCOPE_CMDLINE,
@@ -729,7 +729,7 @@
if (val.str == var_Error) {
FStr_Done(&val);
- return (size_t)-1;
+ return TOK_ERROR;
}
/*
@@ -738,19 +738,15 @@
*/
cpp_skip_whitespace(&val.str);
- /*
- * For consistency with the other functions we can't generate the
- * true/false here.
- */
- magic_res = val.str[0] != '\0' ? 2 : 1;
+ tok = val.str[0] != '\0' ? TOK_FALSE : TOK_TRUE;
FStr_Done(&val);
- return magic_res;
+ return tok;
}
static bool
CondParser_FuncCallEmpty(CondParser *par, bool doEval, Token *out_token)
{
- size_t arglen;
+ Token tok;
const char *cp = par->p;
if (!is_token(cp, "empty", 5))
@@ -761,14 +757,14 @@
if (*cp != '(')
return false;
- arglen = ParseEmptyArg(&cp, doEval);
- if (arglen == 0 || arglen == (size_t)-1) {
+ tok = ParseEmptyArg(&cp, doEval);
+ if (tok == TOK_ERROR) {
par->p = cp;
- *out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR;
+ *out_token = TOK_ERROR;
return true;
}
- *out_token = ToToken(!doEval || arglen == 1);
+ *out_token = ToToken(!doEval || tok == TOK_TRUE);
par->p = cp;
return true;
}
Home |
Main Index |
Thread Index |
Old Index