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 and invert CondParser.lhsStrict to...



details:   https://anonhg.NetBSD.org/src/rev/68e0afafbf10
branches:  trunk
changeset: 1023683:68e0afafbf10
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Sep 21 22:48:04 2021 +0000

description:
make: rename and invert CondParser.lhsStrict to leftUnquotedOK

The new name is easier to grasp than the rather abstract word 'strict'.

No functional change.

diffstat:

 usr.bin/make/cond.c |  26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diffs (113 lines):

diff -r 38b162367834 -r 68e0afafbf10 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Tue Sep 21 22:38:25 2021 +0000
+++ b/usr.bin/make/cond.c       Tue Sep 21 22:48:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.276 2021/09/21 22:38:25 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.277 2021/09/21 22:48:04 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.276 2021/09/21 22:38:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.277 2021/09/21 22:48:04 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -155,7 +155,7 @@
        bool negateEvalBare;
 
        /*
-        * Whether the left-hand side of a comparison may NOT be an unquoted
+        * Whether the left-hand side of a comparison may be an unquoted
         * string.  This is allowed for expressions of the form
         * ${condition:?:}, see ApplyModifier_IfElse.  Such a condition is
         * expanded before it is evaluated, due to ease of implementation.
@@ -166,7 +166,7 @@
         * In all other contexts, the left-hand side must either be a
         * variable expression, a quoted string or a number.
         */
-       bool lhsStrict;
+       bool leftUnquotedOK;
 
        const char *p;          /* The remaining condition to parse */
        Token curr;             /* Single push-back token used in parsing */
@@ -479,7 +479,7 @@
  *     Sets out_quoted if the leaf was a quoted string literal.
  */
 static void
-CondParser_Leaf(CondParser *par, bool doEval, bool strictLHS,
+CondParser_Leaf(CondParser *par, bool doEval, bool unquotedOK,
                  FStr *out_str, bool *out_quoted)
 {
        Buffer buf;
@@ -527,11 +527,11 @@
                                goto cleanup;
                        continue;
                default:
-                       if (strictLHS && !quoted && *start != '$' &&
+                       if (!unquotedOK && !quoted && *start != '$' &&
                            !ch_isdigit(*start)) {
                                /*
                                 * The left-hand side must be quoted,
-                                * a variable reference or a number.
+                                * a variable expression or a number.
                                 */
                                str = FStr_InitRefer(NULL);
                                goto cleanup;
@@ -684,7 +684,7 @@
        ComparisonOp op;
        bool lhsQuoted, rhsQuoted;
 
-       CondParser_Leaf(par, doEval, par->lhsStrict, &lhs, &lhsQuoted);
+       CondParser_Leaf(par, doEval, par->leftUnquotedOK, &lhs, &lhsQuoted);
        if (lhs.str == NULL)
                goto done_lhs;
 
@@ -705,7 +705,7 @@
                goto done_lhs;
        }
 
-       CondParser_Leaf(par, doEval, false, &rhs, &rhsQuoted);
+       CondParser_Leaf(par, doEval, true, &rhs, &rhsQuoted);
        if (rhs.str == NULL)
                goto done_rhs;
 
@@ -1060,7 +1060,7 @@
 static CondEvalResult
 CondEvalExpression(const char *cond, bool *out_value, bool plain,
                   bool (*evalBare)(size_t, const char *), bool negate,
-                  bool eprint, bool strictLHS)
+                  bool eprint, bool leftUnquotedOK)
 {
        CondParser par;
        CondEvalResult rval;
@@ -1070,7 +1070,7 @@
        par.plain = plain;
        par.evalBare = evalBare;
        par.negateEvalBare = negate;
-       par.lhsStrict = strictLHS;
+       par.leftUnquotedOK = leftUnquotedOK;
        par.p = cond;
        par.curr = TOK_NONE;
        par.printedError = false;
@@ -1091,7 +1091,7 @@
 Cond_EvalCondition(const char *cond, bool *out_value)
 {
        return CondEvalExpression(cond, out_value, true,
-           FuncDefined, false, false, false);
+           FuncDefined, false, false, true);
 }
 
 static bool
@@ -1322,7 +1322,7 @@
 
        /* And evaluate the conditional expression */
        if (CondEvalExpression(p, &value, plain, evalBare, negate,
-           true, true) == COND_INVALID) {
+           true, false) == COND_INVALID) {
                /* Syntax error in conditional, error message already output. */
                /* Skip everything to matching .endif */
                /* XXX: An extra '.else' is not detected in this case. */



Home | Main Index | Thread Index | Old Index