* read.c (old_buffer, old_input, old_limit): Remove variables.
authorHans-Peter Nilsson <hp@axis.com>
Tue, 13 May 2003 01:51:40 +0000 (01:51 +0000)
committerHans-Peter Nilsson <hp@axis.com>
Tue, 13 May 2003 01:51:40 +0000 (01:51 +0000)
  (read_a_source_file): Delete label contin.
<handling #APP/#NO_APP>: Use an "sb" to push #APP expansion into
input as with macros, instead of in separate old_* variables.
Zero-terminate string being scrubbed.

gas/ChangeLog
gas/read.c

index 93718c0341acc143dfd0de53850622a4077a600e..3a2383fa54d581e00dc7393a0e6a2543a0288c43 100644 (file)
@@ -1,3 +1,11 @@
+2003-05-13  Hans-Peter Nilsson  <hp@axis.com>
+
+       * read.c (old_buffer, old_input, old_limit): Remove variables.
+       (read_a_source_file): Delete label contin.
+       <handling #APP/#NO_APP>: Use an "sb" to push #APP expansion into
+       input as with macros, instead of in separate old_* variables.
+       Zero-terminate string being scrubbed.
+
 2003-05-12  Nick Clifton  <nickc@redhat.com>
 
        * config/tc-xstormy16.c (skipping_fptr): New local variable.
index 3c4c244280a95edd2a3758d7d63b268cc329c2e7..07f8238d073d4aed688c671cb5f5815c3551142a 100644 (file)
@@ -168,10 +168,6 @@ static char *buffer_limit; /*->1 + last char in buffer.  */
    internals manual.  */
 int target_big_endian = TARGET_BYTES_BIG_ENDIAN;
 
-static char *old_buffer;       /* JF a hack.  */
-static char *old_input;
-static char *old_limit;
-
 /* Variables for handling include file directory table.  */
 
 /* Table of pointers to directories to search for .include's.  */
@@ -533,9 +529,7 @@ read_a_source_file (name)
   while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
     {                          /* We have another line to parse.  */
       know (buffer_limit[-1] == '\n'); /* Must have a sentinel.  */
-    contin:                    /* JF this goto is my fault I admit it.
-                                  Someone brave please re-write the whole
-                                  input section here?  Pleeze???  */
+
       while (input_line_pointer < buffer_limit)
        {
          /* We have more of this buffer to parse.  */
@@ -953,6 +947,7 @@ read_a_source_file (name)
 
          if (c && strchr (line_comment_chars, c))
            {                   /* Its a comment.  Better say APP or NO_APP.  */
+             sb sbuf;
              char *ends;
              char *new_buf;
              char *new_tmp;
@@ -965,6 +960,7 @@ read_a_source_file (name)
                continue;       /* We ignore it */
              s += 4;
 
+             sb_new (&sbuf);
              ends = strstr (s, "#NO_APP\n");
 
              if (!ends)
@@ -1026,7 +1022,7 @@ read_a_source_file (name)
 
                  if (size < space)
                    {
-                     new_tmp += size;
+                     new_tmp[size] = 0;
                      break;
                    }
 
@@ -1037,13 +1033,19 @@ read_a_source_file (name)
 
              if (tmp_buf)
                free (tmp_buf);
-             old_buffer = buffer;
-             old_input = input_line_pointer;
-             old_limit = buffer_limit;
-             buffer = new_buf;
-             input_line_pointer = new_buf;
-             buffer_limit = new_tmp;
 
+             /* We've "scrubbed" input to the preferred format.  In the
+                process we may have consumed the whole of the remaining
+                file (and included files).  We handle this formatted
+                input similar to that of macro expansion, letting
+                actual macro expansion (possibly nested) and other
+                input expansion work.  Beware that in messages, line
+                numbers and possibly file names will be incorrect.  */
+             sb_add_string (&sbuf, new_buf);
+             input_scrub_include_sb (&sbuf, input_line_pointer, 0);
+             sb_kill (&sbuf);
+             buffer_limit = input_scrub_next_buffer (&input_line_pointer);
+             free (new_buf);
              continue;
            }
 
@@ -1061,20 +1063,6 @@ read_a_source_file (name)
 #ifdef md_after_pass_hook
       md_after_pass_hook ();
 #endif
-
-      if (old_buffer)
-       {
-         free (buffer);
-         bump_line_counters ();
-         if (old_input != 0)
-           {
-             buffer = old_buffer;
-             input_line_pointer = old_input;
-             buffer_limit = old_limit;
-             old_buffer = 0;
-             goto contin;
-           }
-       }
     }
 
  quit: