* app.c: Fix comment typos.
[deliverable/binutils-gdb.git] / gas / app.c
index 0494aec23b6816fdc6280862fcd64e765cdd18ea..ba587d4651bb4601828652d5e5eebdb7485e569a 100644 (file)
--- a/gas/app.c
+++ b/gas/app.c
@@ -1,5 +1,6 @@
 /* This is the Assembler Pre-Processor
-   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+   Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 #endif
 #endif
 
+#ifdef TC_M68K
 /* Whether we are scrubbing in m68k MRI mode.  This is different from
    flag_m68k_mri, because the two flags will be affected by the .mri
    pseudo-op at different times.  */
 static int scrub_m68k_mri;
+#else
+#define scrub_m68k_mri 0
+#endif
 
 /* The pseudo-op which switches in and out of MRI mode.  See the
    comment in do_scrub_chars.  */
 static const char mri_pseudo[] = ".mri 0";
 
 #if defined TC_ARM && defined OBJ_ELF
-/* The pseudo-op for which we need to special-case `@' characters. 
+/* The pseudo-op for which we need to special-case `@' characters.
    See the comment in do_scrub_chars.  */
 static const char   symver_pseudo[] = ".symver";
 static const char * symver_state;
@@ -68,11 +73,16 @@ static const char symbol_chars[] =
 #define LEX_IS_DOUBLEDASH_1ST          12
 #endif
 #ifdef TC_M32R
+#define DOUBLEBAR_PARALLEL
+#endif
+#ifdef DOUBLEBAR_PARALLEL
 #define LEX_IS_DOUBLEBAR_1ST           13
 #endif
+#define LEX_IS_PARALLEL_SEPARATOR      14
 #define IS_SYMBOL_COMPONENT(c)         (lex[c] == LEX_IS_SYMBOL_COMPONENT)
 #define IS_WHITESPACE(c)               (lex[c] == LEX_IS_WHITESPACE)
 #define IS_LINE_SEPARATOR(c)           (lex[c] == LEX_IS_LINE_SEPARATOR)
+#define IS_PARALLEL_SEPARATOR(c)       (lex[c] == LEX_IS_PARALLEL_SEPARATOR)
 #define IS_COMMENT(c)                  (lex[c] == LEX_IS_COMMENT_START)
 #define IS_LINE_COMMENT(c)             (lex[c] == LEX_IS_LINE_COMMENT_START)
 #define        IS_NEWLINE(c)                   (lex[c] == LEX_IS_NEWLINE)
@@ -81,29 +91,31 @@ static int process_escape PARAMS ((int));
 
 /* FIXME-soon: The entire lexer/parser thingy should be
    built statically at compile time rather than dynamically
-   each and every time the assembler is run.  xoxorich. */
+   each and every time the assembler is run.  xoxorich.  */
 
-void 
+void
 do_scrub_begin (m68k_mri)
-     int m68k_mri;
+     int m68k_mri ATTRIBUTE_UNUSED;
 {
   const char *p;
   int c;
 
-  scrub_m68k_mri = m68k_mri;
-
   lex[' '] = LEX_IS_WHITESPACE;
   lex['\t'] = LEX_IS_WHITESPACE;
   lex['\r'] = LEX_IS_WHITESPACE;
   lex['\n'] = LEX_IS_NEWLINE;
-  lex[';'] = LEX_IS_LINE_SEPARATOR;
   lex[':'] = LEX_IS_COLON;
 
+#ifdef TC_M68K
+  scrub_m68k_mri = m68k_mri;
+
   if (! m68k_mri)
+#endif
     {
       lex['"'] = LEX_IS_STRINGQUOTE;
 
-#ifndef TC_HPPA
+#if ! defined (TC_HPPA) && ! defined (TC_I370)
+      /* I370 uses single-quotes to delimit integer, float constants */
       lex['\''] = LEX_IS_ONECHAR_QUOTE;
 #endif
 
@@ -154,6 +166,15 @@ do_scrub_begin (m68k_mri)
       lex[(unsigned char) *p] = LEX_IS_LINE_SEPARATOR;
     }                          /* declare line separators */
 
+#ifdef tc_parallel_separator_chars
+  /* This macro permits the processor to specify all characters which
+     separate parallel insns on the same line.  */
+  for (p = tc_parallel_separator_chars; *p; p++)
+    {
+      lex[(unsigned char) *p] = LEX_IS_PARALLEL_SEPARATOR;
+    }                          /* declare parallel separators */
+#endif
+
   /* Only allow slash-star comments if slash is not in use.
      FIXME: This isn't right.  We should always permit them.  */
   if (lex['/'] == 0)
@@ -161,6 +182,7 @@ do_scrub_begin (m68k_mri)
       lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST;
     }
 
+#ifdef TC_M68K
   if (m68k_mri)
     {
       lex['\''] = LEX_IS_STRINGQUOTE;
@@ -170,11 +192,12 @@ do_scrub_begin (m68k_mri)
          then it can't be used in an expression.  */
       lex['!'] = LEX_IS_LINE_COMMENT_START;
     }
+#endif
 
 #ifdef TC_V850
   lex['-'] = LEX_IS_DOUBLEDASH_1ST;
 #endif
-#ifdef TC_M32R
+#ifdef DOUBLEBAR_PARALLEL
   lex['|'] = LEX_IS_DOUBLEBAR_1ST;
 #endif
 #ifdef TC_D30V
@@ -200,22 +223,23 @@ static char mri_last_ch;
    state at the time .include is interpreted is completely unrelated.
    That's why we have to save it all.  */
 
-struct app_save
-  {
-    int          state;
-    int          old_state;
-    char *       out_string;
-    char         out_buf[sizeof (out_buf)];
-    int          add_newlines;
-    char *       saved_input;
-    int          saved_input_len;
-    int          scrub_m68k_mri;
-    const char * mri_state;
-    char         mri_last_ch;
+struct app_save {
+  int          state;
+  int          old_state;
+  char *       out_string;
+  char         out_buf[sizeof (out_buf)];
+  int          add_newlines;
+  char *       saved_input;
+  int          saved_input_len;
+#ifdef TC_M68K
+  int          scrub_m68k_mri;
+#endif
+  const char * mri_state;
+  char         mri_last_ch;
 #if defined TC_ARM && defined OBJ_ELF
-    const char * symver_state;
+  const char * symver_state;
 #endif
-  };
+};
 
 char *
 app_push ()
@@ -236,14 +260,16 @@ app_push ()
       memcpy (saved->saved_input, saved_input, saved_input_len);
       saved->saved_input_len = saved_input_len;
     }
+#ifdef TC_M68K
   saved->scrub_m68k_mri = scrub_m68k_mri;
+#endif
   saved->mri_state = mri_state;
   saved->mri_last_ch = mri_last_ch;
 #if defined TC_ARM && defined OBJ_ELF
   saved->symver_state = symver_state;
 #endif
 
-  /* do_scrub_begin() is not useful, just wastes time. */
+  /* do_scrub_begin() is not useful, just wastes time.  */
 
   state = 0;
   saved_input = NULL;
@@ -251,13 +277,13 @@ app_push ()
   return (char *) saved;
 }
 
-void 
+void
 app_pop (arg)
      char *arg;
 {
   register struct app_save *saved = (struct app_save *) arg;
 
-  /* There is no do_scrub_end (). */
+  /* There is no do_scrub_end ().  */
   state = saved->state;
   old_state = saved->old_state;
   out_string = saved->out_string;
@@ -273,7 +299,9 @@ app_pop (arg)
       saved_input_len = saved->saved_input_len;
       free (saved->saved_input);
     }
+#ifdef TC_M68K
   scrub_m68k_mri = saved->scrub_m68k_mri;
+#endif
   mri_state = saved->mri_state;
   mri_last_ch = saved->mri_last_ch;
 #if defined TC_ARM && defined OBJ_ELF
@@ -285,7 +313,7 @@ app_pop (arg)
 
 /* @@ This assumes that \n &c are the same on host and target.  This is not
    necessarily true.  */
-static int 
+static int
 process_escape (ch)
      int ch;
 {
@@ -351,7 +379,7 @@ do_scrub_chars (get, tostart, tolen)
 #ifdef TC_V850
          12: After seeing a dash, looking for a second dash as a start of comment.
 #endif
-#ifdef TC_M32R
+#ifdef DOUBLEBAR_PARALLEL
         13: After seeing a vertical bar, looking for a second vertical bar as a parallel expression seperator.
 #endif
          */
@@ -359,7 +387,7 @@ do_scrub_chars (get, tostart, tolen)
   /* I added states 9 and 10 because the MIPS ECOFF assembler uses
      constructs like ``.loc 1 20''.  This was turning into ``.loc
      120''.  States 9 and 10 ensure that a space is never dropped in
-     between characters which could appear in a identifier.  Ian
+     between characters which could appear in an identifier.  Ian
      Taylor, ian@cygnus.com.
 
      I added state 11 so that something like "Lfoo add %r25,%r26,%r27" works
@@ -538,7 +566,7 @@ do_scrub_chars (get, tostart, tolen)
          ch = GET ();
          if (ch == EOF)
            {
-             as_warn (_("end of file in string: inserted '\"'"));
+             as_warn (_("end of file in string; inserted '\"'"));
              state = old_state;
              UNGET ('\n');
              PUT ('"');
@@ -604,7 +632,7 @@ do_scrub_chars (get, tostart, tolen)
              break;
 #if defined(IGNORE_NONSTANDARD_ESCAPES) | defined(ONLY_STANDARD_ESCAPES)
            default:
-             as_warn (_("Unknown escape '\\%c' in string: Ignored"), ch);
+             as_warn (_("unknown escape '\\%c' in string; ignored"), ch);
              break;
 #else  /* ONLY_STANDARD_ESCAPES */
            default:
@@ -613,7 +641,7 @@ do_scrub_chars (get, tostart, tolen)
 #endif /* ONLY_STANDARD_ESCAPES */
 
            case EOF:
-             as_warn (_("End of file in string: '\"' inserted"));
+             as_warn (_("end of file in string; '\"' inserted"));
              PUT ('"');
              continue;
            }
@@ -761,9 +789,26 @@ do_scrub_chars (get, tostart, tolen)
              break;
            }
 
+#ifdef KEEP_WHITE_AROUND_COLON
+         if (lex[ch] == LEX_IS_COLON)
+           {
+             /* Only keep this white if there's no white *after* the
+                 colon.  */
+             ch2 = GET ();
+             UNGET (ch2);
+             if (!IS_WHITESPACE (ch2))
+               {
+                 state = 9;
+                 UNGET (ch);
+                 PUT (' ');
+                 break;
+               }
+           }
+#endif
          if (IS_COMMENT (ch)
              || ch == '/'
-             || IS_LINE_SEPARATOR (ch))
+             || IS_LINE_SEPARATOR (ch)
+             || IS_PARALLEL_SEPARATOR (ch))
            {
              if (scrub_m68k_mri)
                {
@@ -831,11 +876,7 @@ do_scrub_chars (get, tostart, tolen)
              state = 10;       /* Sp after symbol char */
              goto recycle;
            case 11:
-             if (flag_m68k_mri
-#ifdef LABELS_WITHOUT_COLONS
-                 || 1
-#endif
-                 )
+             if (LABELS_WITHOUT_COLONS || flag_m68k_mri)
                state = 1;
              else
                {
@@ -884,6 +925,21 @@ do_scrub_chars (get, tostart, tolen)
              ch = ' ';
              goto recycle;
            }
+#ifdef DOUBLESLASH_LINE_COMMENTS
+         else if (ch2 == '/')
+           {
+             do
+               {
+                 ch = GET ();
+               }
+             while (ch != EOF && !IS_NEWLINE (ch));
+             if (ch == EOF)
+               as_warn ("end of file in comment; newline inserted");
+             state = 0;
+             PUT ('\n');
+             break;
+           }
+#endif
          else
            {
              if (ch2 != EOF)
@@ -948,7 +1004,7 @@ do_scrub_chars (get, tostart, tolen)
          if ((ch = GET ()) != '\'')
            {
 #ifdef REQUIRE_CHAR_CLOSE_QUOTE
-             as_warn (_("Missing close quote: (assumed)"));
+             as_warn (_("missing close quote; (assumed)"));
 #else
              if (ch != EOF)
                UNGET (ch);
@@ -970,10 +1026,14 @@ do_scrub_chars (get, tostart, tolen)
 #endif
 
        case LEX_IS_COLON:
+#ifdef KEEP_WHITE_AROUND_COLON
+         state = 9;
+#else
          if (state == 9 || state == 10)
            state = 3;
          else if (state != 3)
            state = 1;
+#endif
          PUT (ch);
          break;
 
@@ -984,22 +1044,27 @@ do_scrub_chars (get, tostart, tolen)
              --add_newlines;
              UNGET (ch);
            }
-         /* fall thru into... */
+         /* Fall through.  */
 
        case LEX_IS_LINE_SEPARATOR:
          state = 0;
          PUT (ch);
          break;
 
+       case LEX_IS_PARALLEL_SEPARATOR:
+         state = 1;
+         PUT (ch);
+         break;
+
 #ifdef TC_V850
        case LEX_IS_DOUBLEDASH_1ST:
-         ch2 = GET();
+         ch2 = GET ();
          if (ch2 != '-')
            {
              UNGET (ch2);
              goto de_fault;
            }
-         /* read and skip to end of line */
+         /* Read and skip to end of line.  */
          do
            {
              ch = GET ();
@@ -1012,10 +1077,10 @@ do_scrub_chars (get, tostart, tolen)
          state = 0;
          PUT ('\n');
          break;
-#endif     
-#ifdef TC_M32R
+#endif
+#ifdef DOUBLEBAR_PARALLEL
        case LEX_IS_DOUBLEBAR_1ST:
-         ch2 = GET();
+         ch2 = GET ();
          if (ch2 != '|')
            {
              UNGET (ch2);
@@ -1027,7 +1092,7 @@ do_scrub_chars (get, tostart, tolen)
          PUT ('|');
          PUT ('|');
          break;
-#endif     
+#endif
        case LEX_IS_LINE_COMMENT_START:
          /* FIXME-someday: The two character comment stuff was badly
             thought out.  On i386, we want '/' as line comment start
@@ -1071,12 +1136,12 @@ do_scrub_chars (get, tostart, tolen)
                  while (ch != EOF && !IS_NEWLINE (ch))
                    ch = GET ();
                  if (ch == EOF)
-                   as_warn (_("EOF in Comment: Newline inserted"));
+                   as_warn (_("end of file in comment; newline inserted"));
                  state = 0;
                  PUT ('\n');
                  break;
                }
-             /* Loks like `# 123 "filename"' from cpp.  */
+             /* Looks like `# 123 "filename"' from cpp.  */
              UNGET (ch);
              old_state = 4;
              state = -1;
@@ -1093,12 +1158,14 @@ do_scrub_chars (get, tostart, tolen)
             Trap is the only short insn that has a first operand that is
             neither register nor label.
             We must prevent exef0f ||trap #1 to degenerate to exef0f ||trap#1 .
-            We can't make '#' LEX_IS_SYMBOL_COMPONENT because it is already
-            LEX_IS_LINE_COMMENT_START.  However, it is the only character in
-            line_comment_chars for d10v, hence we can recognize it as such.  */
+            We can't make '#' LEX_IS_SYMBOL_COMPONENT because it is
+            already LEX_IS_LINE_COMMENT_START.  However, it is the
+            only character in line_comment_chars for d10v, hence we
+            can recognize it as such.  */
          /* An alternative approach would be to reset the state to 1 when
             we see '||', '<'- or '->', but that seems to be overkill.  */
-         if (state == 10) PUT (' ');
+         if (state == 10)
+           PUT (' ');
 #endif
          /* We have a line comment character which is not at the
             start of a line.  If this is also a normal comment
@@ -1118,11 +1185,15 @@ do_scrub_chars (get, tostart, tolen)
 #if defined TC_ARM && defined OBJ_ELF
          /* On the ARM, `@' is the comment character.
             Unfortunately this is also a special character in ELF .symver
-            directives (and .type, though we deal with those another way).  So
-            we check if this line is such a directive, and treat the character
-            as default if so.  This is a hack.  */
+            directives (and .type, though we deal with those another way).
+            So we check if this line is such a directive, and treat
+            the character as default if so.  This is a hack.  */
          if ((symver_state != NULL) && (*symver_state == 0))
            goto de_fault;
+#endif
+#ifdef WARN_COMMENTS
+         if (!found_comment)
+           as_where (&found_comment_file, &found_comment);
 #endif
          do
            {
@@ -1166,7 +1237,7 @@ do_scrub_chars (get, tostart, tolen)
                {
                  int type;
 
-                 ch2 = * (unsigned char *) s;
+                 ch2 = *(unsigned char *) s;
                  type = lex[ch2];
                  if (type != 0
                      && type != LEX_IS_SYMBOL_COMPONENT)
@@ -1203,7 +1274,7 @@ do_scrub_chars (get, tostart, tolen)
                        case 2: *to++ = *from++;
                        case 1: *to++ = *from++;
                        }
-                   } 
+                   }
                  ch = GET ();
                }
            }
@@ -1227,6 +1298,23 @@ do_scrub_chars (get, tostart, tolen)
            }
          else if (state == 10)
            {
+             if (ch == '\\')
+               {
+                 /* Special handling for backslash: a backslash may
+                    be the beginning of a formal parameter (of a
+                    macro) following another symbol character, with
+                    whitespace in between.  If that is the case, we
+                    output a space before the parameter.  Strictly
+                    speaking, correct handling depends upon what the
+                    macro parameter expands into; if the parameter
+                    expands into something which does not start with
+                    an operand character, then we don't want to keep
+                    the space.  We don't have enough information to
+                    make the right choice, so here we are making the
+                    choice which is more likely to be correct.  */
+                 PUT (' ');
+               }
+
              state = 3;
            }
          PUT (ch);
This page took 0.030069 seconds and 4 git commands to generate.