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(1): clean up VarParseErrors, for proper er...



details:   https://anonhg.NetBSD.org/src/rev/9f4b6ad93f30
branches:  trunk
changeset: 944147:9f4b6ad93f30
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Sep 21 05:28:26 2020 +0000

description:
make(1): clean up VarParseErrors, for proper error handling

Having a pure bitset was wrong.

Instead, there are several alternatives (parse error, eval error, undef
error), and each of them can either have an error message printed (good)
or not (bad).  In addition, there are VPE_OK for successful expression
evaluation and VPE_UNKNOWN (only used during migration to the correct
error handling scheme).

diffstat:

 usr.bin/make/nonints.h |  50 ++++++++++++++++++++++++--------------------------
 usr.bin/make/var.c     |   8 ++++----
 2 files changed, 28 insertions(+), 30 deletions(-)

diffs (116 lines):

diff -r 84ef24f91efd -r 9f4b6ad93f30 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Mon Sep 21 04:20:35 2020 +0000
+++ b/usr.bin/make/nonints.h    Mon Sep 21 05:28:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.122 2020/09/13 20:38:47 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.123 2020/09/21 05:28:26 rillig Exp $     */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -218,47 +218,45 @@
     /* Both parsing and evaluation succeeded. */
     VPE_OK             = 0x0000,
 
-    /* Parsing failed.
-     * An error message has already been printed. */
-    VPE_PARSE_MSG      = 0x0001,
+    /* See if a message has already been printed for this error. */
+    VPE_ANY_MSG                = 0x0001,
 
     /* Parsing failed.
      * No error message has been printed yet.
-     *
-     * This should never happen since it is impossible to say where
-     * the parsing error occurred. */
+     * Deprecated, migrate to VPE_PARSE_MSG instead. */
     VPE_PARSE_SILENT   = 0x0002,
 
-    /* Parsing succeeded.
-     * During evaluation, VARE_UNDEFERR was set and there was an undefined
-     * variable.
+    /* Parsing failed.
      * An error message has already been printed. */
-    VPE_UNDEF_MSG      = 0x0010,
+    VPE_PARSE_MSG      = VPE_PARSE_SILENT | VPE_ANY_MSG,
 
     /* Parsing succeeded.
      * During evaluation, VARE_UNDEFERR was set and there was an undefined
      * variable.
      * No error message has been printed yet.
-     *
-     * This should never happen since it is impossible to say which of
-     * the variables was undefined. */
-    VPE_UNDEF_SILENT   = 0x0020,
+     * Deprecated, migrate to VPE_UNDEF_MSG instead. */
+    VPE_UNDEF_SILENT   = 0x0004,
+
+    /* Parsing succeeded.
+     * During evaluation, VARE_UNDEFERR was set and there was an undefined
+     * variable.
+     * An error message has already been printed. */
+    VPE_UNDEF_MSG      = VPE_UNDEF_SILENT | VPE_ANY_MSG,
+
+    /* Parsing succeeded.
+     * Evaluation failed.
+     * No error message has been printed yet.
+     * Deprecated, migrate to VPE_EVAL_MSG instead. */
+    VPE_EVAL_SILENT    = 0x0006,
 
     /* Parsing succeeded.
      * Evaluation failed.
      * An error message has already been printed. */
-    VPE_EVAL_MSG       = 0x0100,
+    VPE_EVAL_MSG       = VPE_EVAL_SILENT | VPE_ANY_MSG,
 
-    /* Parsing succeeded.
-     * Evaluation failed.
-     * No error message has been printed yet.
-     *
-     * This should never happen since it is impossible to say where
-     * exactly the evaluation error occurred. */
-    VPE_EVAL_SILENT    = 0x0200,
-
-    /* See if a message has already been printed for this error. */
-    VPE_ANY_MSG                = VPE_PARSE_MSG | VPE_UNDEF_MSG | VPE_EVAL_MSG
+    /* The exact error handling status is not known yet.
+     * Deprecated, migrate to VPE_OK or any VPE_*_MSG instead. */
+    VPE_UNKNOWN                = 0x0008
 } VarParseErrors;
 
 void Var_Delete(const char *, GNode *);
diff -r 84ef24f91efd -r 9f4b6ad93f30 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Sep 21 04:20:35 2020 +0000
+++ b/usr.bin/make/var.c        Mon Sep 21 05:28:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.522 2020/09/14 21:55:53 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.523 2020/09/21 05:28:26 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include    "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.522 2020/09/14 21:55:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.523 2020/09/21 05:28:26 rillig Exp $");
 
 #define VAR_DEBUG_IF(cond, fmt, ...)   \
     if (!(DEBUG(VAR) && (cond)))       \
@@ -3368,7 +3368,7 @@
     case '}':
     case ':':
     case '$':
-       break;
+       break;                  /* and continue below */
     default:
         return TRUE;
     }
@@ -3683,7 +3683,7 @@
        free(v);
     }
     *out_val = nstr;
-    return VPE_OK;             /* TODO: may also be errors */
+    return VPE_UNKNOWN;
 }
 
 /* Substitute for all variables in the given string in the given context.



Home | Main Index | Thread Index | Old Index