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: condense code in Parse_IsVar



details:   https://anonhg.NetBSD.org/src/rev/c0703d104cab
branches:  trunk
changeset: 359670:c0703d104cab
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 16 09:41:28 2022 +0000

description:
make: condense code in Parse_IsVar

No functional change.

diffstat:

 usr.bin/make/parse.c |  22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diffs (60 lines):

diff -r 9c1a27a85bf5 -r c0703d104cab usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sun Jan 16 09:38:04 2022 +0000
+++ b/usr.bin/make/parse.c      Sun Jan 16 09:41:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.651 2022/01/15 19:13:08 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.652 2022/01/16 09:41:28 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.651 2022/01/15 19:13:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.652 2022/01/16 09:41:28 rillig Exp $");
 
 /*
  * A file being read.
@@ -1497,10 +1497,7 @@
 static bool
 Parse_IsVar(const char *p, VarAssign *out_var)
 {
-       const char *nameStart;
-       const char *nameEnd;
-       const char *eq;
-       const char *firstSpace = NULL;
+       const char *nameStart, *nameEnd, *firstSpace, *eq;
        int level = 0;
 
        cpp_skip_hspace(&p);    /* Skip to variable name */
@@ -1508,14 +1505,12 @@
        /*
         * During parsing, the '+' of the '+=' operator is initially parsed
         * as part of the variable name.  It is later corrected, as is the
-        * ':sh' modifier. Of these two (nameEnd and op), the earlier one
+        * ':sh' modifier. Of these two (nameEnd and eq), the earlier one
         * determines the actual end of the variable name.
         */
+
        nameStart = p;
-#ifdef CLEANUP
-       nameEnd = NULL;
-       eq = NULL;
-#endif
+       firstSpace = NULL;
 
        /*
         * Scan for one of the assignment operators outside a variable
@@ -1535,9 +1530,8 @@
                if (level != 0)
                        continue;
 
-               if (ch == ' ' || ch == '\t')
-                       if (firstSpace == NULL)
-                               firstSpace = p - 1;
+               if ((ch == ' ' || ch == '\t') && firstSpace == NULL)
+                       firstSpace = p - 1;
                while (ch == ' ' || ch == '\t')
                        ch = *p++;
 



Home | Main Index | Thread Index | Old Index