]> git.sur5r.net Git - cc65/blobdiff - src/ca65/scanner.c
Fixed gcc compiler warning (#867)
[cc65] / src / ca65 / scanner.c
index 4fde5ac5e69e3cbd7f7e1e122cf39e1a1fa4c499..361a817c1383dc0b0aee9c5fa8fcb78f3e66501a 100644 (file)
@@ -216,6 +216,7 @@ struct DotKeyword {
     { ".IFNDEF",        TOK_IFNDEF              },
     { ".IFNREF",        TOK_IFNREF              },
     { ".IFP02",         TOK_IFP02               },
+    { ".IFP4510",       TOK_IFP4510             },
     { ".IFP816",        TOK_IFP816              },
     { ".IFPC02",        TOK_IFPC02              },
     { ".IFPSC02",       TOK_IFPSC02             },
@@ -251,6 +252,7 @@ struct DotKeyword {
     { ".ORG",           TOK_ORG                 },
     { ".OUT",           TOK_OUT                 },
     { ".P02",           TOK_P02                 },
+    { ".P4510",         TOK_P4510               },
     { ".P816",          TOK_P816                },
     { ".PAGELEN",       TOK_PAGELENGTH          },
     { ".PAGELENGTH",    TOK_PAGELENGTH          },
@@ -408,7 +410,7 @@ static void IFNextChar (CharSource* S)
 
         /* If we come here, we have a new input line. To avoid problems
         ** with strange line terminators, remove all whitespace from the
-        ** end of the line, the add a single newline.
+        ** end of the line, then add a single newline.
         */
         Len = SB_GetLen (&S->V.File.Line);
         while (Len > 0 && IsSpace (SB_AtUnchecked (&S->V.File.Line, Len-1))) {
@@ -499,7 +501,7 @@ int NewInputFile (const char* Name)
         /* Main file */
         F = fopen (Name, "r");
         if (F == 0) {
-            Fatal ("Cannot open input file `%s': %s", Name, strerror (errno));
+            Fatal ("Cannot open input file '%s': %s", Name, strerror (errno));
         }
     } else {
         /* We are on include level. Search for the file in the include
@@ -508,7 +510,7 @@ int NewInputFile (const char* Name)
         PathName = SearchFile (IncSearchPath, Name);
         if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
             /* Not found or cannot open, print an error and bail out */
-            Error ("Cannot open include file `%s': %s", Name, strerror (errno));
+            Error ("Cannot open include file '%s': %s", Name, strerror (errno));
             goto ExitPoint;
         }
 
@@ -525,7 +527,7 @@ int NewInputFile (const char* Name)
     ** here.
     */
     if (FileStat (Name, &Buf) != 0) {
-        Fatal ("Cannot stat input file `%s': %s", Name, strerror (errno));
+        Fatal ("Cannot stat input file '%s': %s", Name, strerror (errno));
     }
 
     /* Add the file to the input file table and remember the index */
@@ -792,6 +794,43 @@ static void ReadStringConst (int StringTerm)
             break;
         }
 
+        if (C == '\\' && StringEscapes) {
+            NextChar ();
+
+            switch (C) {
+                case EOF:
+                    Error ("Unterminated escape sequence in string constant");
+                    break;
+                case '\\':
+                case '\'':
+                case '"':
+                    break;
+                case 't':
+                    C = '\x09';
+                    break;
+                case 'r':
+                    C = '\x0D';
+                    break;
+                case 'n':
+                    C = '\x0A';
+                    break;
+                case 'x':
+                    NextChar ();
+                    if (IsXDigit (C)) {
+                        char high_nibble = DigitVal (C) << 4;
+                        NextChar ();
+                        if (IsXDigit (C)) {
+                            C = high_nibble | DigitVal (C);
+                            break;
+                        }
+                    }
+                    /* FALLTHROUGH */
+                default:
+                    Error ("Unsupported escape sequence in string constant");
+                    break;
+            }
+        }
+
         /* Append the char to the string */
         SB_AppendChar (&CurTok.SVal, C);
 
@@ -1052,7 +1091,7 @@ Again:
                 /* Not found */
                 if (!LeadingDotInIdents) {
                     /* Invalid pseudo instruction */
-                    Error ("`%m%p' is not a recognized control command", &CurTok.SVal);
+                    Error ("'%m%p' is not a recognized control command", &CurTok.SVal);
                     goto Again;
                 }
 
@@ -1170,7 +1209,7 @@ Again:
                     CurTok.Tok = TOK_S;
                     return;
                 }
-                /* fall through */
+                /* FALL THROUGH */
             default:
                 if (CPU == CPU_SWEET16 &&
                    (CurTok.IVal = Sweet16Reg (&CurTok.SVal)) >= 0) {
@@ -1475,7 +1514,7 @@ CharAgain:
 
 
 
-int GetSubKey (const char** Keys, unsigned Count)
+int GetSubKey (const char* const* 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
 ** uppercased in the process. The function returns the index of the keyword,