1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-01 08:29:37 +00:00

Fixed minor and rather obscure problem: When including files, the line after

the .include statement went into the listing file, before the contents of
the include file. The problem was caused by the several levels of lookahead
in the scanner, and the only way to avoid it was to remove the calls to
NextTok () in relevant places - and add compensation for it in others.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3609 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2005-08-31 21:29:11 +00:00
parent c732d3e360
commit 2a19f6b700
2 changed files with 27 additions and 17 deletions

View File

@ -1106,15 +1106,11 @@ Done:
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);
}
}
@ -1222,9 +1218,6 @@ static void DoMacPack (void)
return;
}
/* Skip the package name */
NextTok ();
/* Insert the package */
MacPackInsert (Package);
}

View File

@ -364,8 +364,12 @@ void NewInputFile (const char* Name)
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;
}
}
@ -409,8 +413,11 @@ void NewInputData (char* Data, int Malloced)
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;
}
@ -457,8 +464,8 @@ static void NextChar (void)
C = *IData->Pos++;
if (C == '\0') {
/* End of input data, will set to last file char */
DoneInputData ();
/* End of input data */
C = EOF;
}
} else {
@ -1198,11 +1205,21 @@ CharAgain:
/* 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;
}