Module Name:    src
Committed By:   rillig
Date:           Sat Jan  8 22:42:28 UTC 2022

Modified Files:
        src/usr.bin/make: parse.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.641 -r1.642 src/usr.bin/make/parse.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/parse.c
diff -u src/usr.bin/make/parse.c:1.641 src/usr.bin/make/parse.c:1.642
--- src/usr.bin/make/parse.c:1.641	Sat Jan  8 22:24:20 2022
+++ src/usr.bin/make/parse.c	Sat Jan  8 22:42:27 2022
@@ -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 
 		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) {

Reply via email to