From b6cb833560b6c0a39b6899ee7fe3c0dc2508077e Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 21 May 2006 11:23:22 +0000 Subject: [PATCH] Don't check for open .IF clauses when reaching the end of pushed input data. This will allow to write macros that contain open .IFs. git-svn-id: svn://svn.cc65.org/cc65/trunk@3740 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/scanner.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index 7504ae2ea..247503918 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1211,27 +1211,31 @@ CharAgain: return; case EOF: - /* Check if we have any open .IFs in this file */ - CheckOpenIfs (); - /* Check if we have any open token lists in this file */ - CheckInputStack (); - - /* 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. - */ + CheckInputStack (); if (IData) { /* Input came from internal data */ DoneInputData (); goto Again; } else if (ICount > 1) { + /* We're at the end of an include file. Check if we have any + * open .IFs, or any open token lists in this file. This + * enforcement is artificial, using conditionals that start + * in one file and end in another are uncommon, and don't + * allowing these things will help finding errors. + */ + CheckOpenIfs (); + + /* Close the include file 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). + */ DoneInputFile (); goto Again; } else { + /* In case of the main file, do not close it, but return EOF. */ Tok = TOK_EOF; } return;