Module Name:    src
Committed By:   rillig
Date:           Tue Jun 14 19:43:02 UTC 2022

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

Log Message:
make: reduce indentation in ParseVarnameShort

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.1023 -r1.1024 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.1023 src/usr.bin/make/var.c:1.1024
--- src/usr.bin/make/var.c:1.1023	Tue Jun 14 19:37:11 2022
+++ src/usr.bin/make/var.c	Tue Jun 14 19:43:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1023 2022/06/14 19:37:11 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1024 2022/06/14 19:43:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1023 2022/06/14 19:37:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1024 2022/06/14 19:43:02 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -4172,6 +4172,7 @@ ParseVarnameShort(char varname, const ch
 {
 	char name[2];
 	Var *v;
+	const char *val;
 
 	if (!IsShortVarnameValid(varname, *pp)) {
 		(*pp)++;
@@ -4183,41 +4184,40 @@ ParseVarnameShort(char varname, const ch
 	name[0] = varname;
 	name[1] = '\0';
 	v = VarFind(name, scope, true);
-	if (v == NULL) {
-		const char *val;
-		*pp += 2;
+	if (v != NULL) {
+		/* XXX: *pp should be incremented in this case as well. */
+		*out_true_var = v;
+		return true;
+	}
 
-		val = UndefinedShortVarValue(varname, scope);
-		if (val == NULL)
-			val = emode == VARE_UNDEFERR
-			    ? var_Error : varUndefined;
+	*pp += 2;
 
-		if (opts.strict && val == var_Error) {
-			Parse_Error(PARSE_FATAL,
-			    "Variable \"%s\" is undefined", name);
-			*out_false_res = VPR_ERR;
-			*out_false_val = val;
-			return false;
-		}
+	val = UndefinedShortVarValue(varname, scope);
+	if (val == NULL)
+		val = emode == VARE_UNDEFERR ? var_Error : varUndefined;
 
-		/*
-		 * XXX: This looks completely wrong.
-		 *
-		 * If undefined expressions are not allowed, this should
-		 * rather be VPR_ERR instead of VPR_UNDEF, together with an
-		 * error message.
-		 *
-		 * If undefined expressions are allowed, this should rather
-		 * be VPR_UNDEF instead of VPR_OK.
-		 */
-		*out_false_res = emode == VARE_UNDEFERR
-		    ? VPR_UNDEF : VPR_OK;
+	if (opts.strict && val == var_Error) {
+		Parse_Error(PARSE_FATAL,
+		    "Variable \"%s\" is undefined", name);
+		*out_false_res = VPR_ERR;
 		*out_false_val = val;
 		return false;
 	}
 
-	*out_true_var = v;
-	return true;
+	/*
+	 * XXX: This looks completely wrong.
+	 *
+	 * If undefined expressions are not allowed, this should
+	 * rather be VPR_ERR instead of VPR_UNDEF, together with an
+	 * error message.
+	 *
+	 * If undefined expressions are allowed, this should rather
+	 * be VPR_UNDEF instead of VPR_OK.
+	 */
+	*out_false_res = emode == VARE_UNDEFERR
+	    ? VPR_UNDEF : VPR_OK;
+	*out_false_val = val;
+	return false;
 }
 
 /* Find variables like @F or <D. */

Reply via email to