make: eliminate file-scope variable forLevel
No functional change.
This commit is contained in:
parent
d8d5dfa77e
commit
9053a08fe0
|
@ -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 @@ typedef struct ForLoop {
|
|||
|
||||
|
||||
static ForLoop *accumFor; /* Loop being accumulated */
|
||||
static int forLevel = 0; /* Nesting level */
|
||||
|
||||
|
||||
static ForLoop *
|
||||
|
@ -224,7 +223,6 @@ For_Eval(const char *line)
|
|||
}
|
||||
|
||||
accumFor = f;
|
||||
forLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -233,7 +231,7 @@ For_Eval(const char *line)
|
|||
* 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 @@ For_Accum(const char *line)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ void SearchPath_Free(SearchPath *);
|
|||
/* 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 *);
|
||||
|
||||
|
|
|
@ -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 @@ ParseForLoop(const char *line)
|
|||
{
|
||||
int rval;
|
||||
int firstLineno;
|
||||
int forLevel;
|
||||
|
||||
rval = For_Eval(line);
|
||||
if (rval == 0)
|
||||
|
@ -2570,6 +2571,7 @@ ParseForLoop(const char *line)
|
|||
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 @@ ParseForLoop(const char *line)
|
|||
"Unexpected end of file in .for loop");
|
||||
break;
|
||||
}
|
||||
} while (For_Accum(line));
|
||||
} while (For_Accum(line, &forLevel));
|
||||
|
||||
For_Run(firstLineno);
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue