summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-01-08 22:42:27 +0000
committerrillig <rillig@NetBSD.org>2022-01-08 22:42:27 +0000
commitea523013178f0628ebc53ee275c405b452765dfe (patch)
treedb3bfda8f02b51c7981c50529fb7ef9dbcba7989 /usr.bin/make/parse.c
parent8945ce32d487ece029d959596ec144b7b6d26a9b (diff)
make: reduce confusing code in ParseForLoop
The previous version of the code gave the wrong impression that For_Eval would modify CurFile. That happens only later, in For_Run. No functional change.
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r--usr.bin/make/parse.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index f9297a06c78..648e76f6bc3 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.641 2022/01/08 22:24:20 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.642 2022/01/08 22:42:27 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.641 2022/01/08 22:24:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.642 2022/01/08 22:42:27 rillig Exp $");
/*
* A file being read.
@@ -336,9 +336,6 @@ PrintStackTrace(void)
const IncludedFile *entries;
size_t i, n;
- if (!DEBUG(PARSE))
- return;
-
entries = GetInclude(0);
n = includes.len;
if (n == 0)
@@ -463,7 +460,8 @@ ParseVErrorInternal(FILE *f, const char *fname, size_t lineno,
parseErrors++;
}
- PrintStackTrace();
+ if (DEBUG(PARSE))
+ PrintStackTrace();
}
static void
@@ -2508,16 +2506,17 @@ ParseForLoop(const char *line)
int bodyReadLines;
int forLevel;
- forHeadLineno = CurFile()->lineno;
rval = For_Eval(line);
if (rval == 0)
return false; /* Not a .for line */
if (rval < 0)
return true; /* Syntax error - error printed, ignore line */
+ forHeadLineno = CurFile()->lineno;
+ bodyReadLines = CurFile()->readLines;
+
/* Accumulate the loop body until the matching '.endfor'. */
forLevel = 1;
- bodyReadLines = CurFile()->readLines;
do {
line = ReadLowLevelLine(LK_FOR_BODY);
if (line == NULL) {