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: reduce indentation in ParseVarnameShort



details:   https://anonhg.NetBSD.org/src/rev/afbdecb1c7e7
branches:  trunk
changeset: 366786:afbdecb1c7e7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jun 14 19:43:02 2022 +0000

description:
make: reduce indentation in ParseVarnameShort

No functional change.

diffstat:

 usr.bin/make/var.c |  66 +++++++++++++++++++++++++++---------------------------
 1 files changed, 33 insertions(+), 33 deletions(-)

diffs (98 lines):

diff -r a7f31ff34c71 -r afbdecb1c7e7 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Tue Jun 14 19:37:11 2022 +0000
+++ b/usr.bin/make/var.c        Tue Jun 14 19:43:02 2022 +0000
@@ -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 @@
 {
        char name[2];
        Var *v;
+       const char *val;
 
        if (!IsShortVarnameValid(varname, *pp)) {
                (*pp)++;
@@ -4183,41 +4184,40 @@
        name[0] = varname;
        name[1] = '\0';
        v = VarFind(name, scope, true);
-       if (v == NULL) {
-               const char *val;
-               *pp += 2;
-
-               val = UndefinedShortVarValue(varname, scope);
-               if (val == NULL)
-                       val = emode == VARE_UNDEFERR
-                           ? var_Error : varUndefined;
-
-               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;
-               }
-
-               /*
-                * 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 (v != NULL) {
+               /* XXX: *pp should be incremented in this case as well. */
+               *out_true_var = v;
+               return true;
+       }
+
+       *pp += 2;
+
+       val = UndefinedShortVarValue(varname, scope);
+       if (val == NULL)
+               val = emode == VARE_UNDEFERR ? var_Error : varUndefined;
+
+       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. */



Home | Main Index | Thread Index | Old Index