Avoid confusing error message for trivial profiled testcase.
[external/binutils.git] / gas / app.c
index d33089a..275ad68 100644 (file)
--- a/gas/app.c
+++ b/gas/app.c
@@ -345,6 +345,8 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
   char *fromend;
   int fromlen;
   register int ch, ch2 = 0;
+  /* Character that started the string we're working on.  */
+  static char quotechar;
 
   /*State 0: beginning of normal line
          1: After first whitespace on line (flush more white)
@@ -374,6 +376,10 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
         15: After seeing a `(' at state 1, looking for a `)' as
             predicate.
 #endif
+#ifdef TC_Z80
+        16: After seeing an 'a' or an 'A' at the start of a symbol
+        17: After seeing an 'f' or an 'F' in state 16
+#endif
          */
 
   /* I added states 9 and 10 because the MIPS ECOFF assembler uses
@@ -536,11 +542,8 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
            for (s = from; s < fromend; s++)
              {
                ch = *s;
-               /* This condition must be changed if the type of any
-                  other character can be LEX_IS_STRINGQUOTE.  */
                if (ch == '\\'
-                   || ch == '"'
-                   || ch == '\''
+                   || ch == quotechar
                    || ch == '\n')
                  break;
              }
@@ -558,12 +561,12 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
          ch = GET ();
          if (ch == EOF)
            {
-             as_warn (_("end of file in string; inserted '\"'"));
+             as_warn (_("end of file in string; '%c' inserted"), quotechar);
              state = old_state;
              UNGET ('\n');
-             PUT ('"');
+             PUT (quotechar);
            }
-         else if (lex[ch] == LEX_IS_STRINGQUOTE)
+         else if (ch == quotechar)
            {
              state = old_state;
              PUT (ch);
@@ -603,8 +606,8 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
              continue;
 
            case EOF:
-             as_warn (_("end of file in string; '\"' inserted"));
-             PUT ('"');
+             as_warn (_("end of file in string; '%c' inserted"), quotechar);
+             PUT (quotechar);
              continue;
 
            case '"':
@@ -638,10 +641,9 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
 
        case 7:
          ch = GET ();
+         quotechar = ch;
          state = 5;
          old_state = 8;
-         if (ch == EOF)
-           goto fromeof;
          PUT (ch);
          continue;
 
@@ -667,6 +669,32 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
          PUT ('|');
          continue;
 #endif
+#ifdef TC_Z80
+       case 16:
+         /* We have seen an 'a' at the start of a symbol, look for an 'f'.  */
+         ch = GET ();
+         if (ch == 'f' || ch == 'F') 
+           {
+             state = 17;
+             PUT (ch);
+           }
+         else
+           {
+             state = 9;
+             break;
+           }
+       case 17:
+         /* We have seen "af" at the start of a symbol,
+            a ' here is a part of that symbol.  */
+         ch = GET ();
+         state = 9;
+         if (ch == '\'')
+           /* Change to avoid warning about unclosed string.  */
+           PUT ('`');
+         else
+           UNGET (ch);
+         break;
+#endif
        }
 
       /* OK, we are somewhere in states 0 through 4 or 9 through 11.  */
@@ -975,6 +1003,7 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
          break;
 
        case LEX_IS_STRINGQUOTE:
+         quotechar = ch;
          if (state == 10)
            {
              /* Preserve the whitespace in foo "bar".  */
@@ -1243,6 +1272,30 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
              break;
            }
 
+#ifdef TC_Z80
+         /* "af'" is a symbol containing '\''.  */
+         if (state == 3 && (ch == 'a' || ch == 'A')) 
+           {
+             state = 16;
+             PUT (ch);
+             ch = GET ();
+             if (ch == 'f' || ch == 'F') 
+               {
+                 state = 17;
+                 PUT (ch);
+                 break;
+               }
+             else
+               {
+                 state = 9;
+                 if (!IS_SYMBOL_COMPONENT (ch)) 
+                   {
+                     UNGET (ch);
+                     break;
+                   }
+               }
+           }
+#endif
          if (state == 3)
            state = 9;
 
@@ -1282,26 +1335,9 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
              if (len > 0)
                {
                  PUT (ch);
-                 if (len > 8)
-                   {
-                     memcpy (to, from, len);
-                     to += len;
-                     from += len;
-                   }
-                 else
-                   {
-                     switch (len)
-                       {
-                       case 8: *to++ = *from++;
-                       case 7: *to++ = *from++;
-                       case 6: *to++ = *from++;
-                       case 5: *to++ = *from++;
-                       case 4: *to++ = *from++;
-                       case 3: *to++ = *from++;
-                       case 2: *to++ = *from++;
-                       case 1: *to++ = *from++;
-                       }
-                   }
+                 memcpy (to, from, len);
+                 to += len;
+                 from += len;
                  if (to >= toend)
                    goto tofull;
                  ch = GET ();