static void DoInclude (void)
/* Include another file */
{
- char Name [MAX_STR_LEN+1];
-
/* Name must follow */
if (Tok != TOK_STRCON) {
ErrorSkip ("String constant expected");
} else {
- strcpy (Name, SVal);
- NextTok ();
- NewInputFile (Name);
+ NewInputFile (SVal);
}
}
return;
}
- /* Skip the package name */
- NextTok ();
-
/* Insert the package */
MacPackInsert (Package);
}
IFile = I;
++ICount;
- /* Prime the pump */
- NextChar ();
+ /* Setup the next token and character so it will be skipped on the
+ * next call to NextRawTok().
+ */
+ C = ' ';
+ Tok = TOK_SEP;
+
}
}
I->Next = IData;
IData = I;
- /* Prime the pump */
- NextChar ();
+ /* Setup the next token and character so it will be skipped on the
+ * next call to NextRawTok().
+ */
+ C = ' ';
+ Tok = TOK_SEP;
}
C = *IData->Pos++;
if (C == '\0') {
- /* End of input data, will set to last file char */
- DoneInputData ();
+ /* End of input data */
+ C = EOF;
}
} else {
/* Check if we have any open token lists in this file */
CheckInputStack ();
- /* If this was an include file, then close it and handle like a
- * separator. Do not close the main file, but return EOF.
+ /* If this was an include file, then close it and read the next
+ * token. When an include file is opened, the last token of the
+ * old file is not skipped, to prevent the lookahead to read
+ * the next line of the old input file. So we do effectively
+ * skip the last token in the old file (the file name of the
+ * include statement).
+ * In case of the main file, do not close it, but return EOF.
*/
- if (ICount > 1) {
+ if (IData) {
+ /* Input came from internal data */
+ DoneInputData ();
+ goto Again;
+ } else if (ICount > 1) {
DoneInputFile ();
+ goto Again;
} else {
Tok = TOK_EOF;
}