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): fix error handling on parse errors in ...



details:   https://anonhg.NetBSD.org/src/rev/aca7df1a8b0c
branches:  trunk
changeset: 941988:aca7df1a8b0c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 02 21:34:40 2020 +0000

description:
make(1): fix error handling on parse errors in variable expressions

This change doesn't change any of the unit tests since the error
handling code is not yet complete, see the many "handle errors" in the
code.  Nevertheless, the "out_FALSE_res = VPR_PARSE_MSG" was wrong since
the error message was only printed in lint mode, not in default mode.

diffstat:

 usr.bin/make/var.c |  18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diffs (72 lines):

diff -r 9b6de4063deb -r aca7df1a8b0c usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Nov 02 21:24:23 2020 +0000
+++ b/usr.bin/make/var.c        Mon Nov 02 21:34:40 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.651 2020/11/02 21:24:23 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.652 2020/11/02 21:34:40 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.651 2020/11/02 21:24:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.652 2020/11/02 21:34:40 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3544,7 +3544,7 @@
     return Buf_Destroy(&buf, FALSE);
 }
 
-static Boolean
+static VarParseResult
 ValidShortVarname(char varname, const char *start)
 {
     switch (varname) {
@@ -3555,11 +3555,11 @@
     case '$':
        break;                  /* and continue below */
     default:
-       return TRUE;
+       return VPR_OK;
     }
 
     if (!DEBUG(LINT))
-       return FALSE;
+       return VPR_PARSE_SILENT;
 
     if (varname == '$')
        Parse_Error(PARSE_FATAL,
@@ -3570,7 +3570,7 @@
        Parse_Error(PARSE_FATAL,
                    "Invalid variable name '%c', at \"%s\"", varname, start);
 
-    return FALSE;
+    return VPR_PARSE_MSG;
 }
 
 /* Parse a single-character variable name such as $V or $@.
@@ -3587,6 +3587,7 @@
 ) {
     char name[2];
     Var *v;
+    VarParseResult vpr;
 
     /*
      * If it's not bounded by braces of some sort, life is much simpler.
@@ -3594,10 +3595,11 @@
      * value if it exists.
      */
 
-    if (!ValidShortVarname(startc, *pp)) {
+    vpr = ValidShortVarname(startc, *pp);
+    if (vpr != VPR_OK) {
        (*pp)++;
        *out_FALSE_val = var_Error;
-       *out_FALSE_res = VPR_PARSE_MSG;
+       *out_FALSE_res = vpr;
        return FALSE;
     }
 



Home | Main Index | Thread Index | Old Index