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: remove redundant type VarParseResult
details: https://anonhg.NetBSD.org/src/rev/6f796d21ee49
branches: trunk
changeset: 373531:6f796d21ee49
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Feb 14 21:56:47 2023 +0000
description:
make: remove redundant type VarParseResult
No functional change.
diffstat:
usr.bin/make/make.h | 26 +-------
usr.bin/make/unit-tests/parse-var.exp | 2 +-
usr.bin/make/unit-tests/parse-var.mk | 5 +-
usr.bin/make/unit-tests/varparse-errors.exp | 8 +-
usr.bin/make/unit-tests/varparse-errors.mk | 3 +-
usr.bin/make/var.c | 98 +++++++++-------------------
6 files changed, 42 insertions(+), 100 deletions(-)
diffs (truncated from 425 to 300 lines):
diff -r 9249cab0d004 -r 6f796d21ee49 usr.bin/make/make.h
--- a/usr.bin/make/make.h Tue Feb 14 21:38:31 2023 +0000
+++ b/usr.bin/make/make.h Tue Feb 14 21:56:47 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.313 2023/02/14 21:38:31 rillig Exp $ */
+/* $NetBSD: make.h,v 1.314 2023/02/14 21:56:47 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -973,30 +973,6 @@
VAR_SET_READONLY = 1 << 1
} VarSetFlags;
-/* The state of error handling returned by Var_Parse. */
-typedef enum VarParseResult {
-
- /* Both parsing and evaluation succeeded. */
- VPR_OK,
-
- /* Parsing or evaluating failed, with an error message. */
- VPR_ERR,
-
- /*
- * Parsing succeeded, undefined expressions are allowed and the
- * expression was still undefined after applying all modifiers.
- * No error message is printed in this case.
- *
- * Some callers handle this case differently, so return this
- * information to them, for now.
- *
- * TODO: Instead of having this special return value, rather ensure
- * that VARE_EVAL_KEEP_UNDEF is processed properly.
- */
- VPR_UNDEF
-
-} VarParseResult;
-
typedef enum VarExportMode {
/* .export-env */
VEM_ENV,
diff -r 9249cab0d004 -r 6f796d21ee49 usr.bin/make/unit-tests/parse-var.exp
--- a/usr.bin/make/unit-tests/parse-var.exp Tue Feb 14 21:38:31 2023 +0000
+++ b/usr.bin/make/unit-tests/parse-var.exp Tue Feb 14 21:56:47 2023 +0000
@@ -1,5 +1,5 @@
make: Unfinished modifier for "BRACE_GROUP" (',' missing)
-make: "parse-var.mk" line 130: Malformed conditional (0 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},<lbraces>,})
+make: "parse-var.mk" line 129: Malformed conditional (0 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},<lbraces>,})
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff -r 9249cab0d004 -r 6f796d21ee49 usr.bin/make/unit-tests/parse-var.mk
--- a/usr.bin/make/unit-tests/parse-var.mk Tue Feb 14 21:38:31 2023 +0000
+++ b/usr.bin/make/unit-tests/parse-var.mk Tue Feb 14 21:56:47 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: parse-var.mk,v 1.6 2022/09/25 21:26:23 rillig Exp $
+# $NetBSD: parse-var.mk,v 1.7 2023/02/14 21:56:48 rillig Exp $
#
# Tests for parsing variable expressions.
#
@@ -68,8 +68,7 @@
#
# Effects:
# How much does the parsing position advance (pp)?
-# What's the value of the expression (out_val)?
-# What's the status after parsing the expression (VarParseResult)?
+# What's the value of the expression (return value)?
# What error messages are printed (Parse_Error)?
# What no-effect error messages are printed (Error)?
# What error messages should be printed but aren't?
diff -r 9249cab0d004 -r 6f796d21ee49 usr.bin/make/unit-tests/varparse-errors.exp
--- a/usr.bin/make/unit-tests/varparse-errors.exp Tue Feb 14 21:38:31 2023 +0000
+++ b/usr.bin/make/unit-tests/varparse-errors.exp Tue Feb 14 21:56:47 2023 +0000
@@ -1,10 +1,10 @@
-make: "varparse-errors.mk" line 38: Unknown modifier "Z"
-make: "varparse-errors.mk" line 46: Unknown modifier "Z"
+make: "varparse-errors.mk" line 37: Unknown modifier "Z"
+make: "varparse-errors.mk" line 45: Unknown modifier "Z"
make: Bad modifier ":OX" for variable ""
-make: "varparse-errors.mk" line 68: Undefined variable "${:U:OX"
+make: "varparse-errors.mk" line 67: Undefined variable "${:U:OX"
make: Bad modifier ":OX" for variable ""
make: Bad modifier ":OX" for variable ""
-make: "varparse-errors.mk" line 68: Undefined variable "${:U:OX"
+make: "varparse-errors.mk" line 67: Undefined variable "${:U:OX"
make: Bad modifier ":OX" for variable ""
make: Unclosed variable expression, expecting '}' for modifier "Q" of variable "" with value ""
make: Unclosed variable expression, expecting '}' for modifier "sh" of variable "" with value ""
diff -r 9249cab0d004 -r 6f796d21ee49 usr.bin/make/unit-tests/varparse-errors.mk
--- a/usr.bin/make/unit-tests/varparse-errors.mk Tue Feb 14 21:38:31 2023 +0000
+++ b/usr.bin/make/unit-tests/varparse-errors.mk Tue Feb 14 21:56:47 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varparse-errors.mk,v 1.7 2022/08/24 22:09:41 rillig Exp $
+# $NetBSD: varparse-errors.mk,v 1.8 2023/02/14 21:56:48 rillig Exp $
# Tests for parsing and evaluating all kinds of variable expressions.
#
@@ -6,7 +6,6 @@
# Var_Subst, collecting typical and not so typical use cases.
#
# See also:
-# VarParseResult
# Var_Parse
# Var_Subst
diff -r 9249cab0d004 -r 6f796d21ee49 usr.bin/make/var.c
--- a/usr.bin/make/var.c Tue Feb 14 21:38:31 2023 +0000
+++ b/usr.bin/make/var.c Tue Feb 14 21:56:47 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1043 2023/02/14 21:38:31 rillig Exp $ */
+/* $NetBSD: var.c,v 1.1044 2023/02/14 21:56:47 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1043 2023/02/14 21:38:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1044 2023/02/14 21:56:47 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -2195,7 +2195,7 @@
}
/* See ParseModifierPart for the documentation. */
-static VarParseResult
+static bool
ParseModifierPartSubst(
const char **pp,
char delim,
@@ -2246,7 +2246,7 @@
Error("Unfinished modifier for \"%s\" ('%c' missing)",
ch->expr->name, delim);
LazyBuf_Done(part);
- return VPR_ERR;
+ return false;
}
*pp = p + 1;
@@ -2257,7 +2257,7 @@
(int)Substring_Length(sub), sub.start);
}
- return VPR_OK;
+ return true;
}
/*
@@ -2266,11 +2266,11 @@
* including the next unescaped delimiter. The delimiter, as well as the
* backslash or the dollar, can be escaped with a backslash.
*
- * Return VPR_OK if parsing succeeded, together with the parsed (and possibly
+ * Return true if parsing succeeded, together with the parsed (and possibly
* expanded) part. In that case, pp points right after the delimiter. The
* delimiter is not included in the part though.
*/
-static VarParseResult
+static bool
ParseModifierPart(
/* The parsing position, updated upon return */
const char **pp,
@@ -2420,15 +2420,13 @@
Expr *expr = ch->expr;
struct ModifyWord_LoopArgs args;
char prev_sep;
- VarParseResult res;
LazyBuf tvarBuf, strBuf;
FStr tvar, str;
args.scope = expr->scope;
(*pp)++; /* Skip the first '@' */
- res = ParseModifierPart(pp, '@', VARE_PARSE_ONLY, ch, &tvarBuf);
- if (res != VPR_OK)
+ if (!ParseModifierPart(pp, '@', VARE_PARSE_ONLY, ch, &tvarBuf))
return AMR_CLEANUP;
tvar = LazyBuf_DoneGet(&tvarBuf);
args.var = tvar.str;
@@ -2440,8 +2438,7 @@
return AMR_CLEANUP;
}
- res = ParseModifierPart(pp, '@', VARE_PARSE_ONLY, ch, &strBuf);
- if (res != VPR_OK)
+ if (!ParseModifierPart(pp, '@', VARE_PARSE_ONLY, ch, &strBuf))
return AMR_CLEANUP;
str = LazyBuf_DoneGet(&strBuf);
args.body = str.str;
@@ -2649,13 +2646,11 @@
ApplyModifier_ShellCommand(const char **pp, ModChain *ch)
{
Expr *expr = ch->expr;
- VarParseResult res;
LazyBuf cmdBuf;
FStr cmd;
(*pp)++;
- res = ParseModifierPart(pp, '!', expr->emode, ch, &cmdBuf);
- if (res != VPR_OK)
+ if (!ParseModifierPart(pp, '!', expr->emode, ch, &cmdBuf))
return AMR_CLEANUP;
cmd = LazyBuf_DoneGet(&cmdBuf);
@@ -2858,7 +2853,6 @@
{
struct ModifyWord_SubstArgs args;
bool oneBigWord;
- VarParseResult res;
LazyBuf lhsBuf, rhsBuf;
char delim = (*pp)[1];
@@ -2878,15 +2872,13 @@
(*pp)++;
}
- res = ParseModifierPartSubst(pp, delim, ch->expr->emode, ch, &lhsBuf,
- &args.pflags, NULL);
- if (res != VPR_OK)
+ if (!ParseModifierPartSubst(pp, delim, ch->expr->emode, ch, &lhsBuf,
+ &args.pflags, NULL))
return AMR_CLEANUP;
args.lhs = LazyBuf_Get(&lhsBuf);
- res = ParseModifierPartSubst(pp, delim, ch->expr->emode, ch, &rhsBuf,
- NULL, &args);
- if (res != VPR_OK) {
+ if (!ParseModifierPartSubst(pp, delim, ch->expr->emode, ch, &rhsBuf,
+ NULL, &args)) {
LazyBuf_Done(&lhsBuf);
return AMR_CLEANUP;
}
@@ -2911,7 +2903,6 @@
struct ModifyWord_SubstRegexArgs args;
bool oneBigWord;
int error;
- VarParseResult res;
LazyBuf reBuf, replaceBuf;
FStr re;
@@ -2924,13 +2915,11 @@
*pp += 2;
- res = ParseModifierPart(pp, delim, ch->expr->emode, ch, &reBuf);
- if (res != VPR_OK)
+ if (!ParseModifierPart(pp, delim, ch->expr->emode, ch, &reBuf))
return AMR_CLEANUP;
re = LazyBuf_DoneGet(&reBuf);
- res = ParseModifierPart(pp, delim, ch->expr->emode, ch, &replaceBuf);
- if (res != VPR_OK) {
+ if (!ParseModifierPart(pp, delim, ch->expr->emode, ch, &replaceBuf)) {
FStr_Done(&re);
return AMR_CLEANUP;
}
@@ -3163,14 +3152,12 @@
Expr *expr = ch->expr;
const char *estr;
int first, last;
- VarParseResult res;
const char *p;
LazyBuf estrBuf;
FStr festr;
(*pp)++; /* skip the '[' */
- res = ParseModifierPart(pp, ']', expr->emode, ch, &estrBuf);
- if (res != VPR_OK)
+ if (!ParseModifierPart(pp, ']', expr->emode, ch, &estrBuf))
return AMR_CLEANUP;
festr = LazyBuf_DoneGet(&estrBuf);
estr = festr.str;
@@ -3395,7 +3382,6 @@
ApplyModifier_IfElse(const char **pp, ModChain *ch)
{
Expr *expr = ch->expr;
- VarParseResult res;
LazyBuf thenBuf;
LazyBuf elseBuf;
@@ -3412,12 +3398,10 @@
}
(*pp)++; /* skip past the '?' */
- res = ParseModifierPart(pp, ':', then_emode, ch, &thenBuf);
- if (res != VPR_OK)
+ if (!ParseModifierPart(pp, ':', then_emode, ch, &thenBuf))
return AMR_CLEANUP;
- res = ParseModifierPart(pp, ch->endc, else_emode, ch, &elseBuf);
- if (res != VPR_OK) {
+ if (!ParseModifierPart(pp, ch->endc, else_emode, ch, &elseBuf)) {
LazyBuf_Done(&thenBuf);
return AMR_CLEANUP;
}
@@ -3478,7 +3462,6 @@
Expr *expr = ch->expr;
GNode *scope;
FStr val;
Home |
Main Index |
Thread Index |
Old Index