Fixed problems that occured on input files with missing LF at end of file.

git-svn-id: svn://svn.cc65.org/cc65/trunk@1903 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-01-19 12:04:33 +00:00
parent 22b4faabb2
commit b6c4ff2e01
7 changed files with 40 additions and 29 deletions

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2000-2002 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -279,7 +279,7 @@ void DoConditionals (void)
D = AllocIf (".IFBLANK", 1); D = AllocIf (".IFBLANK", 1);
NextTok (); NextTok ();
if (IfCond) { if (IfCond) {
if (Tok == TOK_SEP) { if (TokIsSep (Tok)) {
SetIfCond (D, 1); SetIfCond (D, 1);
} else { } else {
SetIfCond (D, 0); SetIfCond (D, 0);
@@ -318,7 +318,7 @@ void DoConditionals (void)
D = AllocIf (".IFNBLANK", 1); D = AllocIf (".IFNBLANK", 1);
NextTok (); NextTok ();
if (IfCond) { if (IfCond) {
if (Tok == TOK_SEP) { if (TokIsSep (Tok)) {
SetIfCond (D, 0); SetIfCond (D, 0);
} else { } else {
SetIfCond (D, 1); SetIfCond (D, 1);

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2000 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -56,7 +56,7 @@ void GetEA (unsigned long* AddrMode, ExprNode** Expr, ExprNode** Bank)
*Bank = *Expr = 0; *Bank = *Expr = 0;
if (Tok == TOK_SEP) { if (TokIsSep (Tok)) {
*AddrMode = AM_IMPLICIT; *AddrMode = AM_IMPLICIT;

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2002 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -160,7 +160,7 @@ static int FuncBlank (void)
} else { } else {
/* Skip any tokens */ /* Skip any tokens */
int Braces = 0; int Braces = 0;
while (Tok != TOK_SEP && Tok != TOK_EOF) { while (!TokIsSep (Tok)) {
if (Tok == TOK_LPAREN) { if (Tok == TOK_LPAREN) {
++Braces; ++Braces;
} else if (Tok == TOK_RPAREN) { } else if (Tok == TOK_RPAREN) {
@@ -284,7 +284,7 @@ static int DoMatch (enum TC EqualityLevel)
while (Tok != TOK_COMMA) { while (Tok != TOK_COMMA) {
/* We may not end-of-line of end-of-file here */ /* We may not end-of-line of end-of-file here */
if (Tok == TOK_SEP || Tok == TOK_EOF) { if (TokIsSep (Tok)) {
Error (ERR_UNEXPECTED_EOL); Error (ERR_UNEXPECTED_EOL);
return 0; return 0;
} }
@@ -315,7 +315,7 @@ static int DoMatch (enum TC EqualityLevel)
while (Tok != TOK_RPAREN) { while (Tok != TOK_RPAREN) {
/* We may not end-of-line of end-of-file here */ /* We may not end-of-line of end-of-file here */
if (Tok == TOK_SEP || Tok == TOK_EOF) { if (TokIsSep (Tok)) {
Error (ERR_UNEXPECTED_EOL); Error (ERR_UNEXPECTED_EOL);
return 0; return 0;
} }
@@ -468,7 +468,7 @@ static int FuncTCount (void)
* will check for the closing paren, we don't need to print an error * will check for the closing paren, we don't need to print an error
* here, just bail out. * here, just bail out.
*/ */
if (Tok == TOK_SEP || Tok == TOK_EOF) { if (TokIsSep (Tok)) {
break; break;
} }

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2000 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -382,7 +382,7 @@ void MacDef (unsigned Style)
} }
} else { } else {
/* Accept a newline or end of file for new style macros */ /* Accept a newline or end of file for new style macros */
if (Tok == TOK_SEP || Tok == TOK_EOF) { if (TokIsSep (Tok)) {
break; break;
} }
} }
@@ -604,7 +604,7 @@ static void StartExpClassic (Macro* M)
E = NewMacExp (M); E = NewMacExp (M);
/* Read the actual parameters */ /* Read the actual parameters */
while (Tok != TOK_SEP && Tok != TOK_EOF) { while (!TokIsSep (Tok)) {
TokNode* Last; TokNode* Last;
@@ -617,7 +617,7 @@ static void StartExpClassic (Macro* M)
/* Read tokens for one parameter, accept empty params */ /* Read tokens for one parameter, accept empty params */
Last = 0; Last = 0;
while (Tok != TOK_COMMA && Tok != TOK_SEP) { while (!TokIsSep (Tok)) {
TokNode* T; TokNode* T;
@@ -679,7 +679,7 @@ static void StartExpDefine (Macro* M)
TokNode* Last; TokNode* Last;
/* Check if there is really a parameter */ /* Check if there is really a parameter */
if (Tok == TOK_SEP || Tok == TOK_EOF || Tok == TOK_COMMA) { if (TokIsSep (Tok) || Tok == TOK_COMMA) {
Error (ERR_MACRO_PARAM_EXPECTED); Error (ERR_MACRO_PARAM_EXPECTED);
SkipUntilSep (); SkipUntilSep ();
return; return;
@@ -705,7 +705,7 @@ static void StartExpDefine (Macro* M)
/* And skip it... */ /* And skip it... */
NextTok (); NextTok ();
} while (Tok != TOK_COMMA && Tok != TOK_SEP && Tok != TOK_EOF); } while (Tok != TOK_COMMA && !TokIsSep (Tok));
/* One parameter more */ /* One parameter more */
++E->ParamCount; ++E->ParamCount;

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2000 Ullrich von Bassewitz */ /* (C) 2000-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -79,7 +79,7 @@ static TokList* CollectTokens (unsigned Start, unsigned Count)
while (Parens != 0 || Tok != TOK_RPAREN) { while (Parens != 0 || Tok != TOK_RPAREN) {
/* Check for end of line or end of input */ /* Check for end of line or end of input */
if (Tok == TOK_SEP || Tok == TOK_EOF) { if (TokIsSep (Tok)) {
Error (ERR_UNEXPECTED_EOL); Error (ERR_UNEXPECTED_EOL);
return List; return List;
} }
@@ -459,7 +459,7 @@ void ConsumeComma (void)
void SkipUntilSep (void) void SkipUntilSep (void)
/* Skip tokens until we reach a line separator or end of file */ /* Skip tokens until we reach a line separator or end of file */
{ {
while (Tok != TOK_SEP && Tok != TOK_EOF) { while (!TokIsSep (Tok)) {
NextTok (); NextTok ();
} }
} }

View File

@@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2002 Ullrich von Bassewitz */ /* (C) 1998-2003 Ullrich von Bassewitz */
/* Wacholderweg 14 */ /* Wacholderweg 14 */
/* D-70597 Stuttgart */ /* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */ /* EMail: uz@musoftware.de */
@@ -128,7 +128,7 @@ static void SetBoolOption (unsigned char* Flag)
case 1: *Flag = 1; NextTok (); break; case 1: *Flag = 1; NextTok (); break;
default: ErrorSkip (ERR_ONOFF_EXPECTED); break; default: ErrorSkip (ERR_ONOFF_EXPECTED); break;
} }
} else if (Tok == TOK_SEP || Tok == TOK_EOF) { } else if (TokIsSep (Tok)) {
/* Without anything assume switch on */ /* Without anything assume switch on */
*Flag = 1; *Flag = 1;
} else { } else {

View File

@@ -40,6 +40,7 @@
/* common */ /* common */
#include "filepos.h" #include "filepos.h"
#include "inline.h"
@@ -258,6 +259,16 @@ int TokHasSVal (enum Token Tok);
int TokHasIVal (enum Token Tok); int TokHasIVal (enum Token Tok);
/* Return true if the given token has an attached IVal */ /* Return true if the given token has an attached IVal */
#if defined(HAVE_INLINE)
INLINE int TokIsSep (enum Token T)
/* Return true if this is a separator token */
{
return (T == TOK_SEP || T == TOK_EOF);
}
#else
# define TokIsSep(T) (T == TOK_SEP || T == TOK_EOF)
#endif
int GetSubKey (const char** Keys, unsigned Count); int GetSubKey (const char** Keys, unsigned Count);
/* Search for a subkey in a table of keywords. The current token must be an /* Search for a subkey in a table of keywords. The current token must be an
* identifier and all keys must be in upper case. The identifier will be * identifier and all keys must be in upper case. The identifier will be