From: cuz Date: Sun, 19 Jan 2003 12:04:33 +0000 (+0000) Subject: Fixed problems that occured on input files with missing LF at end of file. X-Git-Tag: V2.12.0~1782 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b6c4ff2e01f984abed705ac0cb46bc1772053d1e;p=cc65 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 --- diff --git a/src/ca65/condasm.c b/src/ca65/condasm.c index a270a39a7..ebe58f0f1 100644 --- a/src/ca65/condasm.c +++ b/src/ca65/condasm.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000-2002 Ullrich von Bassewitz */ +/* (C) 2000-2003 Ullrich von Bassewitz */ /* Wacholderweg 14 */ /* D-70597 Stuttgart */ /* EMail: uz@musoftware.de */ @@ -279,7 +279,7 @@ void DoConditionals (void) D = AllocIf (".IFBLANK", 1); NextTok (); if (IfCond) { - if (Tok == TOK_SEP) { + if (TokIsSep (Tok)) { SetIfCond (D, 1); } else { SetIfCond (D, 0); @@ -318,7 +318,7 @@ void DoConditionals (void) D = AllocIf (".IFNBLANK", 1); NextTok (); if (IfCond) { - if (Tok == TOK_SEP) { + if (TokIsSep (Tok)) { SetIfCond (D, 0); } else { SetIfCond (D, 1); diff --git a/src/ca65/ea.c b/src/ca65/ea.c index f715ec6d7..9bd5d3010 100644 --- a/src/ca65/ea.c +++ b/src/ca65/ea.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-2003 Ullrich von Bassewitz */ /* Wacholderweg 14 */ /* D-70597 Stuttgart */ /* EMail: uz@musoftware.de */ @@ -56,7 +56,7 @@ void GetEA (unsigned long* AddrMode, ExprNode** Expr, ExprNode** Bank) *Bank = *Expr = 0; - if (Tok == TOK_SEP) { + if (TokIsSep (Tok)) { *AddrMode = AM_IMPLICIT; @@ -185,7 +185,7 @@ void GetEA (unsigned long* AddrMode, ExprNode** Expr, ExprNode** Bank) } - } else { + } else { *AddrMode = AM_ABS | AM_DIR; diff --git a/src/ca65/expr.c b/src/ca65/expr.c index 634836bde..0c638c642 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2002 Ullrich von Bassewitz */ +/* (C) 1998-2003 Ullrich von Bassewitz */ /* Wacholderweg 14 */ /* D-70597 Stuttgart */ /* EMail: uz@musoftware.de */ @@ -160,7 +160,7 @@ static int FuncBlank (void) } else { /* Skip any tokens */ int Braces = 0; - while (Tok != TOK_SEP && Tok != TOK_EOF) { + while (!TokIsSep (Tok)) { if (Tok == TOK_LPAREN) { ++Braces; } else if (Tok == TOK_RPAREN) { @@ -284,7 +284,7 @@ static int DoMatch (enum TC EqualityLevel) while (Tok != TOK_COMMA) { /* 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); return 0; } @@ -315,7 +315,7 @@ static int DoMatch (enum TC EqualityLevel) while (Tok != TOK_RPAREN) { /* 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); return 0; } @@ -468,7 +468,7 @@ static int FuncTCount (void) * will check for the closing paren, we don't need to print an error * here, just bail out. */ - if (Tok == TOK_SEP || Tok == TOK_EOF) { + if (TokIsSep (Tok)) { break; } diff --git a/src/ca65/macro.c b/src/ca65/macro.c index 976e19306..3d12a96d5 100644 --- a/src/ca65/macro.c +++ b/src/ca65/macro.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-2003 Ullrich von Bassewitz */ /* Wacholderweg 14 */ /* D-70597 Stuttgart */ /* EMail: uz@musoftware.de */ @@ -382,7 +382,7 @@ void MacDef (unsigned Style) } } else { /* Accept a newline or end of file for new style macros */ - if (Tok == TOK_SEP || Tok == TOK_EOF) { + if (TokIsSep (Tok)) { break; } } @@ -548,7 +548,7 @@ static int MacExpand (void* Data) * generated by a user. */ unsigned PrefixLen = (I->Id[0] == LocalStart); - sprintf (SVal, "%.*sLOCAL-MACRO-SYMBOL-%04X", PrefixLen, + sprintf (SVal, "%.*sLOCAL-MACRO-SYMBOL-%04X", PrefixLen, I->Id, Mac->LocalStart + Index); break; } @@ -604,7 +604,7 @@ static void StartExpClassic (Macro* M) E = NewMacExp (M); /* Read the actual parameters */ - while (Tok != TOK_SEP && Tok != TOK_EOF) { + while (!TokIsSep (Tok)) { TokNode* Last; @@ -617,7 +617,7 @@ static void StartExpClassic (Macro* M) /* Read tokens for one parameter, accept empty params */ Last = 0; - while (Tok != TOK_COMMA && Tok != TOK_SEP) { + while (!TokIsSep (Tok)) { TokNode* T; @@ -679,7 +679,7 @@ static void StartExpDefine (Macro* M) TokNode* Last; /* 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); SkipUntilSep (); return; @@ -696,16 +696,16 @@ static void StartExpDefine (Macro* M) /* Insert it into the list */ if (Last == 0) { - E->Params [E->ParamCount] = T; + E->Params [E->ParamCount] = T; } else { - Last->Next = T; + Last->Next = T; } Last = T; /* And skip it... */ NextTok (); - } while (Tok != TOK_COMMA && Tok != TOK_SEP && Tok != TOK_EOF); + } while (Tok != TOK_COMMA && !TokIsSep (Tok)); /* One parameter more */ ++E->ParamCount; diff --git a/src/ca65/nexttok.c b/src/ca65/nexttok.c index c1a5bb5d3..9c3b709b2 100644 --- a/src/ca65/nexttok.c +++ b/src/ca65/nexttok.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2000-2003 Ullrich von Bassewitz */ +/* Wacholderweg 14 */ +/* D-70597 Stuttgart */ +/* EMail: uz@musoftware.de */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -79,7 +79,7 @@ static TokList* CollectTokens (unsigned Start, unsigned Count) while (Parens != 0 || Tok != TOK_RPAREN) { /* Check for end of line or end of input */ - if (Tok == TOK_SEP || Tok == TOK_EOF) { + if (TokIsSep (Tok)) { Error (ERR_UNEXPECTED_EOL); return List; } @@ -459,7 +459,7 @@ void ConsumeComma (void) void SkipUntilSep (void) /* Skip tokens until we reach a line separator or end of file */ { - while (Tok != TOK_SEP && Tok != TOK_EOF) { + while (!TokIsSep (Tok)) { NextTok (); } } diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index 1c7314308..d2c380a38 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2002 Ullrich von Bassewitz */ +/* (C) 1998-2003 Ullrich von Bassewitz */ /* Wacholderweg 14 */ /* D-70597 Stuttgart */ /* EMail: uz@musoftware.de */ @@ -128,7 +128,7 @@ static void SetBoolOption (unsigned char* Flag) case 1: *Flag = 1; NextTok (); break; default: ErrorSkip (ERR_ONOFF_EXPECTED); break; } - } else if (Tok == TOK_SEP || Tok == TOK_EOF) { + } else if (TokIsSep (Tok)) { /* Without anything assume switch on */ *Flag = 1; } else { diff --git a/src/ca65/scanner.h b/src/ca65/scanner.h index c10d69e3b..24ae7e447 100644 --- a/src/ca65/scanner.h +++ b/src/ca65/scanner.h @@ -40,6 +40,7 @@ /* common */ #include "filepos.h" +#include "inline.h" @@ -82,7 +83,7 @@ enum Token { TOK_PLUS, /* + */ TOK_MINUS, /* - */ - TOK_MUL, /* * */ + TOK_MUL, /* * */ TOK_STAR = TOK_MUL, /* Alias */ TOK_DIV, /* / */ TOK_MOD, /* ! */ @@ -258,6 +259,16 @@ int TokHasSVal (enum Token Tok); int TokHasIVal (enum Token Tok); /* 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); /* 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