/* 1 if a corresponding ELSE has been */
/* encountered. */
+int nestlevel = -1;
+int svnestlevel[30] = {-1};
+int nestcount;
+
PRIVATE char *
GetIdentifier()
{
}
else {
WorkingDir = getwdir(result);
- nestlevel = -1;
+ svnestlevel[++nestcount] = nestlevel;
FileName = result;
LineNumber = 1;
}
PRIVATE
do_elif()
{
- if (nestlevel < 0 || (ifstack[nestlevel])) {
+ if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) {
error("#elif without corresponding #if");
PushBack();
skipline();
{
PushBack();
skipline();
- if (nestlevel < 0 || (ifstack[nestlevel]))
+ if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel]))
error("#else without corresponding #if");
else { /* mark this level as else-d */
++(ifstack[nestlevel]);
{
PushBack();
skipline();
- if (nestlevel-- < 0)
+ if (nestlevel-- <= svnestlevel[nestcount])
error("#endif without corresponding #if");
}
unsigned int fil_lino;
char *fil_name;
char *fil_wdir;
- int fil_nestlevel;
};
#define LineNumber finfo.fil_lino
#define FileName finfo.fil_name
#define WorkingDir finfo.fil_wdir
-#define nestlevel finfo.fil_nestlevel
extern struct file_info finfo; /* input.c */
AtEoIF()
{
+ extern int nestlevel;
+ extern int nestcount;
+ extern int svnestlevel[];
- if (nestlevel != -1) warning("missing #endif");
+ if (nestlevel > svnestlevel[nestcount]) warning("missing #endif");
else if (NoUnstack) warning("unexpected EOF");
+ nestlevel = svnestlevel[nestcount--];
return 0;
}
fatal("%s: no source file %s\n", prog_name,
source ? source : "stdin");
if (source) WorkingDir = getwdir(dummy);
- nestlevel = -1;
preprocess(source);
}