]> git.sur5r.net Git - cc65/commitdiff
Fixed problems that occured on input files with missing LF at end of file.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 19 Jan 2003 12:04:33 +0000 (12:04 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 19 Jan 2003 12:04:33 +0000 (12:04 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1903 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/condasm.c
src/ca65/ea.c
src/ca65/expr.c
src/ca65/macro.c
src/ca65/nexttok.c
src/ca65/pseudo.c
src/ca65/scanner.h

index a270a39a739e3360210cfa6dbb44f0cb1b218881..ebe58f0f19f565ef3ffec1bc09032737dac18d15 100644 (file)
@@ -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);
index f715ec6d792287f6849af79e7121647ec93134a6..9bd5d3010ce00b1a38768c458efa1d72a9dcc94d 100644 (file)
@@ -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;
 
index 634836bde21287b7110cf32556cfec6367fbb1d0..0c638c6422fb04a27e3a50f1893d9ed8f43a6343 100644 (file)
@@ -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;
        }
 
index 976e19306d54b2b96c47a5723238baa42845c6a6..3d12a96d5e322a85128e587e68e248ce0030bad3 100644 (file)
@@ -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;
index c1a5bb5d344edcea9ca4e7a28cee27416f0884d7..9c3b709b2e2f99a44c0a68cd5349082fe0807400 100644 (file)
@@ -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 ();
     }
 }
index 1c73143086879cc80841921a263b4f1ec21d129b..d2c380a38cecca0ebc506864d512c19250e681f3 100644 (file)
@@ -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 {
index c10d69e3bfcbf8887de6f7f5ae178e66d8c2edcd..24ae7e4479bfada5c121974e0a1e684fcb455ae3 100644 (file)
@@ -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