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: clean up structure of For_Eval



details:   https://anonhg.NetBSD.org/src/rev/20b3a7285c01
branches:  trunk
changeset: 359500:20b3a7285c01
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jan 07 23:13:50 2022 +0000

description:
make: clean up structure of For_Eval

Put related decisions on the same indentation level, remove unnecessary
negation, keep the code for the '.for' directive together.

No functional change.

diffstat:

 usr.bin/make/for.c |  39 +++++++++++++++++----------------------
 1 files changed, 17 insertions(+), 22 deletions(-)

diffs (69 lines):

diff -r 58823bc378eb -r 20b3a7285c01 usr.bin/make/for.c
--- a/usr.bin/make/for.c        Fri Jan 07 22:59:32 2022 +0000
+++ b/usr.bin/make/for.c        Fri Jan 07 23:13:50 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: for.c,v 1.157 2022/01/07 20:15:10 rillig Exp $ */
+/*     $NetBSD: for.c,v 1.158 2022/01/07 23:13:50 rillig Exp $ */
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*     "@(#)for.c      8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: for.c,v 1.157 2022/01/07 20:15:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.158 2022/01/07 23:13:50 rillig Exp $");
 
 
 typedef struct ForLoop {
@@ -191,35 +191,30 @@
 int
 For_Eval(const char *line)
 {
+       const char *p;
        ForLoop *f;
-       const char *p;
 
        p = line + 1;           /* skip the '.' */
        cpp_skip_whitespace(&p);
 
-       if (!IsFor(p)) {
-               if (IsEndfor(p)) {
-                       Parse_Error(PARSE_FATAL, "for-less endfor");
+       if (IsFor(p)) {
+               p += 3;
+
+               f = ForLoop_New();
+               if (!ForLoop_ParseVarnames(f, &p)) {
+                       ForLoop_Free(f);
                        return -1;
                }
-               return 0;
-       }
-       p += 3;
+               if (!ForLoop_ParseItems(f, p))
+                       f->items.len = 0;       /* don't iterate */
 
-       f = ForLoop_New();
-
-       if (!ForLoop_ParseVarnames(f, &p)) {
-               ForLoop_Free(f);
+               accumFor = f;
+               return 1;
+       } else if (IsEndfor(p)) {
+               Parse_Error(PARSE_FATAL, "for-less endfor");
                return -1;
-       }
-
-       if (!ForLoop_ParseItems(f, p)) {
-               /* Continue parsing the .for loop, but don't iterate. */
-               f->items.len = 0;
-       }
-
-       accumFor = f;
-       return 1;
+       } else
+               return 0;
 }
 
 /*



Home | Main Index | Thread Index | Old Index