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: eliminate file-scope variable forLevel
details: https://anonhg.NetBSD.org/src/rev/f294d5518a89
branches: trunk
changeset: 359489:f294d5518a89
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jan 07 20:09:58 2022 +0000
description:
make: eliminate file-scope variable forLevel
No functional change.
diffstat:
usr.bin/make/for.c | 16 +++++++---------
usr.bin/make/nonints.h | 4 ++--
usr.bin/make/parse.c | 8 +++++---
3 files changed, 14 insertions(+), 14 deletions(-)
diffs (121 lines):
diff -r 4606a0e30feb -r f294d5518a89 usr.bin/make/for.c
--- a/usr.bin/make/for.c Fri Jan 07 20:04:49 2022 +0000
+++ b/usr.bin/make/for.c Fri Jan 07 20:09:58 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.155 2022/01/07 20:04:49 rillig Exp $ */
+/* $NetBSD: for.c,v 1.156 2022/01/07 20:09:58 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.155 2022/01/07 20:04:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.156 2022/01/07 20:09:58 rillig Exp $");
typedef struct ForLoop {
@@ -70,7 +70,6 @@
static ForLoop *accumFor; /* Loop being accumulated */
-static int forLevel = 0; /* Nesting level */
static ForLoop *
@@ -224,7 +223,6 @@
}
accumFor = f;
- forLevel = 1;
return 1;
}
@@ -233,7 +231,7 @@
* Returns false when the matching .endfor is reached.
*/
bool
-For_Accum(const char *line)
+For_Accum(const char *line, int *forLevel)
{
const char *p = line;
@@ -242,12 +240,12 @@
cpp_skip_whitespace(&p);
if (IsEndfor(p)) {
- DEBUG1(FOR, "For: end for %d\n", forLevel);
- if (--forLevel <= 0)
+ DEBUG1(FOR, "For: end for %d\n", *forLevel);
+ if (--*forLevel <= 0)
return false;
} else if (IsFor(p)) {
- forLevel++;
- DEBUG1(FOR, "For: new loop %d\n", forLevel);
+ (*forLevel)++;
+ DEBUG1(FOR, "For: new loop %d\n", *forLevel);
}
}
diff -r 4606a0e30feb -r f294d5518a89 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Fri Jan 07 20:04:49 2022 +0000
+++ b/usr.bin/make/nonints.h Fri Jan 07 20:09:58 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.230 2022/01/07 19:24:27 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.231 2022/01/07 20:09:58 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
/* for.c */
struct ForLoop;
int For_Eval(const char *) MAKE_ATTR_USE;
-bool For_Accum(const char *) MAKE_ATTR_USE;
+bool For_Accum(const char *, int *) MAKE_ATTR_USE;
void For_Run(int);
bool For_NextIteration(struct ForLoop *, Buffer *);
diff -r 4606a0e30feb -r f294d5518a89 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Fri Jan 07 20:04:49 2022 +0000
+++ b/usr.bin/make/parse.c Fri Jan 07 20:09:58 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.628 2022/01/07 14:03:55 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.629 2022/01/07 20:09:58 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.628 2022/01/07 14:03:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.629 2022/01/07 20:09:58 rillig Exp $");
/*
* A file being read.
@@ -2559,6 +2559,7 @@
{
int rval;
int firstLineno;
+ int forLevel;
rval = For_Eval(line);
if (rval == 0)
@@ -2570,6 +2571,7 @@
firstLineno = CurFile()->readLines;
/* Accumulate the loop body until the matching '.endfor'. */
+ forLevel = 1;
do {
line = ReadLowLevelLine(LK_FOR_BODY);
if (line == NULL) {
@@ -2577,7 +2579,7 @@
"Unexpected end of file in .for loop");
break;
}
- } while (For_Accum(line));
+ } while (For_Accum(line, &forLevel));
For_Run(firstLineno);
return true;
Home |
Main Index |
Thread Index |
Old Index