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: merge duplicate enum constants for CondEv...



details:   https://anonhg.NetBSD.org/src/rev/ead8f0dee616
branches:  trunk
changeset: 1029272:ead8f0dee616
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 29 05:01:35 2021 +0000

description:
make: merge duplicate enum constants for CondEvalResult and CondResult

No binary change.

diffstat:

 usr.bin/make/cond.c  |  52 ++++++++++++++++++++++++++--------------------------
 usr.bin/make/make.h  |  11 ++++-------
 usr.bin/make/parse.c |  12 ++++++------
 3 files changed, 36 insertions(+), 39 deletions(-)

diffs (247 lines):

diff -r 22df258dea9f -r ead8f0dee616 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Wed Dec 29 04:50:56 2021 +0000
+++ b/usr.bin/make/cond.c       Wed Dec 29 05:01:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.310 2021/12/29 04:50:56 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.311 2021/12/29 05:01:35 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.310 2021/12/29 04:50:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.311 2021/12/29 05:01:35 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -990,10 +990,10 @@
 
        res = CondParser_Or(par, true);
        if (res == CR_ERROR)
-               return COND_INVALID;
+               return CR_ERROR;
 
        if (CondParser_Token(par, false) != TOK_EOF)
-               return COND_INVALID;
+               return CR_ERROR;
 
        return res;
 }
@@ -1004,8 +1004,8 @@
  * function(arg), comparisons and parenthetical groupings thereof.
  *
  * Results:
- *     COND_PARSE      if the condition was valid grammatically
- *     COND_INVALID    if not a valid conditional.
+ *     CR_TRUE         if the condition was valid grammatically
+ *     CR_ERROR        if not a valid conditional.
  *
  *     *out_value      is set to the boolean value of the condition
  */
@@ -1029,7 +1029,7 @@
 
        rval = CondParser_Eval(&par);
 
-       if (rval == COND_INVALID && eprint && !par.printedError)
+       if (rval == CR_ERROR && eprint && !par.printedError)
                Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", cond);
 
        return rval;
@@ -1111,12 +1111,12 @@
  * parenthetical groupings thereof.
  *
  * Results:
- *     COND_PARSE      to continue parsing the lines that follow the
+ *     CR_TRUE         to continue parsing the lines that follow the
  *                     conditional (when <cond> evaluates to true)
- *     COND_SKIP       to skip the lines after the conditional
+ *     CR_FALSE        to skip the lines after the conditional
  *                     (when <cond> evaluates to false, or when a previous
  *                     branch has already been taken)
- *     COND_INVALID    if the conditional was not valid, either because of
+ *     CR_ERROR        if the conditional was not valid, either because of
  *                     a syntax error or because some variable was undefined
  *                     or because the condition could not be evaluated
  */
@@ -1170,13 +1170,13 @@
 
                if (cond_depth == cond_min_depth) {
                        Parse_Error(PARSE_FATAL, "if-less endif");
-                       return COND_PARSE;
+                       return CR_TRUE;
                }
 
                /* Return state for previous conditional */
                cond_depth--;
                return cond_states[cond_depth] & IFS_ACTIVE
-                   ? COND_PARSE : COND_SKIP;
+                   ? CR_TRUE : CR_FALSE;
        }
 
        /* Parse the name of the directive, such as 'if', 'elif', 'endif'. */
@@ -1187,7 +1187,7 @@
                         * transformation rule like '.err.txt',
                         * therefore no error message here.
                         */
-                       return COND_INVALID;
+                       return CR_ERROR;
                }
 
                /* Quite likely this is 'else' or 'elif' */
@@ -1201,7 +1201,7 @@
 
                        if (cond_depth == cond_min_depth) {
                                Parse_Error(PARSE_FATAL, "if-less else");
-                               return COND_PARSE;
+                               return CR_TRUE;
                        }
 
                        state = cond_states[cond_depth];
@@ -1215,7 +1215,7 @@
                        }
                        cond_states[cond_depth] = state;
 
-                       return state & IFS_ACTIVE ? COND_PARSE : COND_SKIP;
+                       return state & IFS_ACTIVE ? CR_TRUE : CR_FALSE;
                }
                /* Assume for now it is an elif */
                isElif = true;
@@ -1227,27 +1227,27 @@
                 * Unknown directive.  It might still be a transformation rule
                 * like '.elisp.scm', therefore no error message here.
                 */
-               return COND_INVALID;    /* Not an ifxxx or elifxxx line */
+               return CR_ERROR;        /* Not an ifxxx or elifxxx line */
        }
 
        if (!DetermineKindOfConditional(&p, &plain, &evalBare, &negate))
-               return COND_INVALID;
+               return CR_ERROR;
 
        if (isElif) {
                if (cond_depth == cond_min_depth) {
                        Parse_Error(PARSE_FATAL, "if-less elif");
-                       return COND_PARSE;
+                       return CR_TRUE;
                }
                state = cond_states[cond_depth];
                if (state & IFS_SEEN_ELSE) {
                        Parse_Error(PARSE_WARNING, "extra elif");
                        cond_states[cond_depth] =
                            IFS_WAS_ACTIVE | IFS_SEEN_ELSE;
-                       return COND_SKIP;
+                       return CR_FALSE;
                }
                if (state != IFS_INITIAL) {
                        cond_states[cond_depth] = IFS_WAS_ACTIVE;
-                       return COND_SKIP;
+                       return CR_FALSE;
                }
        } else {
                /* Normal .if */
@@ -1269,28 +1269,28 @@
                         * treat as always false.
                         */
                        cond_states[cond_depth] = IFS_WAS_ACTIVE;
-                       return COND_SKIP;
+                       return CR_FALSE;
                }
        }
 
        /* And evaluate the conditional expression */
        res = CondEvalExpression(p, plain, evalBare, negate, true, false);
-       if (res == COND_INVALID) {
+       if (res == CR_ERROR) {
                /*
                 * Syntax error in conditional, error message already output.
                 */
                /* Skip everything to matching .endif */
                /* XXX: An extra '.else' is not detected in this case. */
                cond_states[cond_depth] = IFS_WAS_ACTIVE;
-               return COND_SKIP;
+               return CR_FALSE;
        }
 
-       if (res == COND_SKIP) {
+       if (res == CR_FALSE) {
                cond_states[cond_depth] = IFS_INITIAL;
-               return COND_SKIP;
+               return CR_FALSE;
        }
        cond_states[cond_depth] = IFS_ACTIVE;
-       return COND_PARSE;
+       return CR_TRUE;
 }
 
 void
diff -r 22df258dea9f -r ead8f0dee616 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Wed Dec 29 04:50:56 2021 +0000
+++ b/usr.bin/make/make.h       Wed Dec 29 05:01:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.282 2021/12/29 04:41:38 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.283 2021/12/29 05:01:35 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -519,12 +519,9 @@
  * Values returned by Cond_EvalLine and Cond_EvalCondition.
  */
 typedef enum CondEvalResult {
-       COND_PARSE,             /* Parse the next lines */
-       COND_SKIP,              /* Skip the next lines */
-       COND_INVALID,           /* Not a conditional statement */
-       CR_TRUE = COND_PARSE,
-       CR_FALSE = COND_SKIP,
-       CR_ERROR = COND_INVALID
+       CR_TRUE,                /* Parse the next lines */
+       CR_FALSE,               /* Skip the next lines */
+       CR_ERROR                /* Unknown directive or parse error */
 } CondEvalResult, CondResult;
 
 /* Names of the variables that are "local" to a specific target. */
diff -r 22df258dea9f -r ead8f0dee616 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Wed Dec 29 04:50:56 2021 +0000
+++ b/usr.bin/make/parse.c      Wed Dec 29 05:01:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.603 2021/12/28 19:43:42 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.604 2021/12/29 05:01:35 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.603 2021/12/28 19:43:42 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.604 2021/12/29 05:01:35 rillig Exp $");
 
 /* types and constants */
 
@@ -2727,7 +2727,7 @@
        char *line;
 
        while ((line = ReadLowLevelLine(LK_DOT)) != NULL) {
-               if (Cond_EvalLine(line) == COND_PARSE)
+               if (Cond_EvalLine(line) == CR_TRUE)
                        break;
                /*
                 * TODO: Check for typos in .elif directives
@@ -2805,13 +2805,13 @@
                 * about it and act accordingly
                 */
                switch (Cond_EvalLine(line)) {
-               case COND_SKIP:
+               case CR_FALSE:  /* May also mean a syntax error. */
                        if (!SkipIrrelevantBranches())
                                return NULL;
                        continue;
-               case COND_PARSE:
+               case CR_TRUE:
                        continue;
-               case COND_INVALID:      /* Not a conditional line */
+               case CR_ERROR:  /* Not a conditional line */
                        if (ParseForLoop(line))
                                continue;
                        break;



Home | Main Index | Thread Index | Old Index