Module Name: src
Committed By: rillig
Date: Fri Jan 7 23:13:50 UTC 2022
Modified Files:
src/usr.bin/make: for.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/usr.bin/make/for.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/for.c
diff -u src/usr.bin/make/for.c:1.157 src/usr.bin/make/for.c:1.158
--- src/usr.bin/make/for.c:1.157 Fri Jan 7 20:15:10 2022
+++ src/usr.bin/make/for.c Fri Jan 7 23:13:50 2022
@@ -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 @@ IsEndfor(const char *p)
int
For_Eval(const char *line)
{
- ForLoop *f;
const char *p;
+ ForLoop *f;
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;
-
- f = ForLoop_New();
+ if (!ForLoop_ParseItems(f, p))
+ f->items.len = 0; /* don't iterate */
- 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;
}
/*