Improve make's diagnostic of mistmatched .if-.endif. This patch is
slightly different from the patch in the PR. The problem is, that make handles .if clauses inside false .if clauses simply by counting them - it doesn't put them onto the conditional stack, nor even parses them so we need an extra line number stack for these ifs. PR: bin/61257 Submitted by: Mikhail Teterin <mi@aldan.algebra.com>
This commit is contained in:
parent
da5b50a882
commit
ee1888d896
@ -133,8 +133,10 @@ static Token condPushBack=None; /* Single push-back token used in
|
||||
#define MAXIF 30 /* greatest depth of #if'ing */
|
||||
|
||||
static Boolean condStack[MAXIF]; /* Stack of conditionals's values */
|
||||
static int condLineno[MAXIF]; /* Line numbers of the opening .if */
|
||||
static int condTop = MAXIF; /* Top-most conditional */
|
||||
static int skipIfLevel=0; /* Depth of skipped conditionals */
|
||||
static int skipIfLineno[MAXIF]; /* Line numbers of skipped .ifs */
|
||||
static Boolean skipLine = FALSE; /* Whether the parse module is skipping
|
||||
* lines */
|
||||
|
||||
@ -1047,8 +1049,10 @@ Cond_Eval (char *line)
|
||||
Boolean isElse;
|
||||
Boolean value = FALSE;
|
||||
int level; /* Level at which to report errors. */
|
||||
int lineno;
|
||||
|
||||
level = PARSE_FATAL;
|
||||
lineno = curFile.lineno;
|
||||
|
||||
for (line++; *line == ' ' || *line == '\t'; line++) {
|
||||
continue;
|
||||
@ -1109,6 +1113,7 @@ Cond_Eval (char *line)
|
||||
return (COND_INVALID);
|
||||
} else if (skipIfLevel == 0) {
|
||||
value = !condStack[condTop];
|
||||
lineno = condLineno[condTop];
|
||||
} else {
|
||||
return (COND_SKIP);
|
||||
}
|
||||
@ -1130,6 +1135,7 @@ Cond_Eval (char *line)
|
||||
* undefined, for which there's an enclosing ifdef that
|
||||
* we're skipping...
|
||||
*/
|
||||
skipIfLineno[skipIfLevel - 1] = lineno;
|
||||
return(COND_SKIP);
|
||||
}
|
||||
} else if (skipLine) {
|
||||
@ -1137,6 +1143,7 @@ Cond_Eval (char *line)
|
||||
* Don't even try to evaluate a conditional that's not an else if
|
||||
* we're skipping things...
|
||||
*/
|
||||
skipIfLineno[skipIfLevel] = lineno;
|
||||
skipIfLevel += 1;
|
||||
return(COND_SKIP);
|
||||
}
|
||||
@ -1202,6 +1209,7 @@ Cond_Eval (char *line)
|
||||
return (COND_INVALID);
|
||||
} else {
|
||||
condStack[condTop] = value;
|
||||
condLineno[condTop] = lineno;
|
||||
skipLine = !value;
|
||||
return (value ? COND_PARSE : COND_SKIP);
|
||||
}
|
||||
@ -1223,9 +1231,20 @@ Cond_Eval (char *line)
|
||||
void
|
||||
Cond_End(void)
|
||||
{
|
||||
int level;
|
||||
|
||||
if (condTop != MAXIF) {
|
||||
Parse_Error(PARSE_FATAL, "%d open conditional%s", MAXIF-condTop,
|
||||
MAXIF-condTop == 1 ? "" : "s");
|
||||
Parse_Error(PARSE_FATAL, "%d open conditional%s:",
|
||||
MAXIF - condTop + skipIfLevel,
|
||||
MAXIF - condTop + skipIfLevel== 1 ? "" : "s");
|
||||
|
||||
for (level = skipIfLevel; level > 0; level--)
|
||||
Parse_Error(PARSE_FATAL, "\t%*sat line %d (skipped)",
|
||||
MAXIF - condTop + level + 1, "", skipIfLineno[level - 1]);
|
||||
for (level = condTop; level < MAXIF; level++)
|
||||
Parse_Error(PARSE_FATAL, "\t%*sat line %d "
|
||||
"(evaluated to %s)", MAXIF - level + skipIfLevel, "",
|
||||
condLineno[level], condStack[level] ? "true" : "false");
|
||||
}
|
||||
condTop = MAXIF;
|
||||
}
|
||||
|
@ -141,6 +141,21 @@ typedef struct GNode {
|
||||
* but the Suff module) */
|
||||
} GNode;
|
||||
|
||||
|
||||
/*
|
||||
* Definitions for handling #include specifications
|
||||
*/
|
||||
typedef struct {
|
||||
char *str;
|
||||
char *ptr;
|
||||
} PTR;
|
||||
typedef struct IFile {
|
||||
char *fname; /* name of previous file */
|
||||
int lineno; /* saved line number */
|
||||
FILE *F; /* the open stream */
|
||||
PTR *p; /* the char pointer */
|
||||
} IFile;
|
||||
|
||||
/*
|
||||
* The OP_ constants are used when parsing a dependency line as a way of
|
||||
* communicating to other parts of the program the way in which a target
|
||||
@ -273,6 +288,7 @@ extern Lst create; /* The list of target names specified on the
|
||||
* make(...) statements */
|
||||
extern Lst dirSearchPath; /* The list of directories to search when
|
||||
* looking for targets */
|
||||
extern IFile curFile; /* current makefile */
|
||||
extern Lst parseIncPath; /* The list of directories to search when
|
||||
* looking for includes */
|
||||
|
||||
|
@ -105,27 +105,13 @@ static Lst targets; /* targets we're working on */
|
||||
static Lst targCmds; /* command lines for targets */
|
||||
static Boolean inLine; /* true if currently in a dependency
|
||||
* line or its commands */
|
||||
typedef struct {
|
||||
char *str;
|
||||
char *ptr;
|
||||
} PTR;
|
||||
|
||||
static int fatals = 0;
|
||||
|
||||
static GNode *mainNode; /* The main target to create. This is the
|
||||
* first target on the first dependency
|
||||
* line in the first makefile */
|
||||
/*
|
||||
* Definitions for handling #include specifications
|
||||
*/
|
||||
typedef struct IFile {
|
||||
char *fname; /* name of previous file */
|
||||
int lineno; /* saved line number */
|
||||
FILE * F; /* the open stream */
|
||||
PTR * p; /* the char pointer */
|
||||
} IFile;
|
||||
|
||||
static IFile curFile;
|
||||
IFile curFile; /* current makefile */
|
||||
|
||||
static Lst includes; /* stack of IFiles generated by
|
||||
* #includes */
|
||||
|
Loading…
Reference in New Issue
Block a user