Module Name:    src
Committed By:   rillig
Date:           Sun Dec 27 13:12:34 UTC 2020

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make(1): move error handling code out of UndefinedShortVarValue


To generate a diff of this commit:
cvs rdiff -u -r1.768 -r1.769 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.768 src/usr.bin/make/var.c:1.769
--- src/usr.bin/make/var.c:1.768	Sun Dec 27 11:03:00 2020
+++ src/usr.bin/make/var.c	Sun Dec 27 13:12:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.768 2020/12/27 11:03:00 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.769 2020/12/27 13:12:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.768 2020/12/27 11:03:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.769 2020/12/27 13:12:34 rillig Exp $");
 
 typedef enum VarFlags {
 	VAR_NONE	= 0,
@@ -3673,7 +3673,7 @@ VarnameIsDynamic(const char *name, size_
 }
 
 static const char *
-UndefinedShortVarValue(char varname, const GNode *ctxt, VarEvalFlags eflags)
+UndefinedShortVarValue(char varname, const GNode *ctxt)
 {
 	if (ctxt == VAR_CMDLINE || ctxt == VAR_GLOBAL) {
 		/*
@@ -3696,7 +3696,7 @@ UndefinedShortVarValue(char varname, con
 			return "$(.ARCHIVE)";
 		}
 	}
-	return eflags & VARE_UNDEFERR ? var_Error : varUndefined;
+	return NULL;
 }
 
 /* Parse a variable name, until the end character or a colon, whichever
@@ -3803,7 +3803,12 @@ ParseVarnameShort(char startc, const cha
 	if (v == NULL) {
 		*pp += 2;
 
-		*out_FALSE_val = UndefinedShortVarValue(startc, ctxt, eflags);
+		*out_FALSE_val = UndefinedShortVarValue(startc, ctxt);
+		if (*out_FALSE_val == NULL) {
+			*out_FALSE_val =
+			    eflags & VARE_UNDEFERR ? var_Error : varUndefined;
+		}
+
 		if (opts.strict && *out_FALSE_val == var_Error) {
 			Parse_Error(PARSE_FATAL,
 			    "Variable \"%s\" is undefined", name);

Reply via email to