]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* listing.c (struct file_info_struct): Rename end_pending field to
authorIan Lance Taylor <ian@airs.com>
Thu, 6 Jul 1995 18:00:09 +0000 (18:00 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 6 Jul 1995 18:00:09 +0000 (18:00 +0000)
at_end.
(file_info): Initialize at_end, not end_pending.
(buffer_line): If at_end set, just return immediately.  Don't
worry about end_pending cases.  Set at_end when EOF is read.
(print_source): Check at_end, not end_pending.
(listing_listing): Likewise.
PR 6636.

gas/ChangeLog
gas/listing.c

index a8659fe621f80f60b2e3d5829d3e76d92ce0f12b..91742991d6a39c5b0fe5daa614c4fdbecceaa9a6 100644 (file)
@@ -1,5 +1,13 @@
 Thu Jul  6 12:54:27 1995  Ian Lance Taylor  <ian@cygnus.com>
 
+       * listing.c (struct file_info_struct): Rename end_pending field to
+       at_end.
+       (file_info): Initialize at_end, not end_pending.
+       (buffer_line): If at_end set, just return immediately.  Don't
+       worry about end_pending cases.  Set at_end when EOF is read.
+       (print_source): Check at_end, not end_pending.
+       (listing_listing): Likewise.
+
        * config/tc-alpha.h (alpha_do_align): Don't declare.
        (md_do_align): Don't define.
        (tc_frob_label): Define.
index aa9d99bbd73f12e840913e11f08157943cf5d222..799223a732c11e2bfe54a21ecf91057178f94923 100644 (file)
@@ -128,7 +128,7 @@ typedef struct file_info_struct
   int linenum;
   FILE *file;
   struct file_info_struct *next;
-  int end_pending;
+  int at_end;
 }
 
 file_info_type;
@@ -273,7 +273,7 @@ file_info (file_name)
   p->filename = xmalloc ((unsigned long) strlen (file_name) + 1);
   strcpy (p->filename, file_name);
   p->linenum = 0;
-  p->end_pending = 0;
+  p->at_end = 0;
 
   p->file = fopen (p->filename, "r");
   if (p->file)
@@ -303,7 +303,7 @@ listing_newline (ps)
   list_info_type *new;
 
   as_where (&file, &line);
-  if (line != last_line || last_file && file && strcmp(file, last_file))
+  if (line != last_line || (last_file && file && strcmp(file, last_file)))
     {
       last_line = line;
       last_file = file;
@@ -379,7 +379,7 @@ buffer_line (file, line, size)
   char *p = line;
 
   /* If we couldn't open the file, return an empty line */
-  if (file->file == (FILE *) NULL)
+  if (file->file == (FILE *) NULL || file->at_end)
     {
       return "";
     }
@@ -387,20 +387,8 @@ buffer_line (file, line, size)
   if (file->linenum == 0)
     rewind (file->file);
 
-  if (file->end_pending == 10)
-    {
-      *p++ = '\n';
-#if 1
-      fseek (file->file, 0, 0);
-      file->linenum = 0;
-#else
-      file->linenum = 9999999;
-#endif
-      file->end_pending = 0;
-    }
   c = fgetc (file->file);
 
-
   size -= 1;                   /* leave room for null */
 
   while (c != EOF && c != '\n')
@@ -414,7 +402,7 @@ buffer_line (file, line, size)
     }
   if (c == EOF)
     {
-      file->end_pending++;
+      file->at_end = 1;
       *p++ = '.';
       *p++ = '.';
       *p++ = '.';
@@ -687,7 +675,8 @@ list_symbol_table ()
                sprintf (buf, "%08lx", (unsigned long) val);
              else if (sizeof (val) <= sizeof (unsigned long))
                {
-                 sprintf (fmt, "%%0%dlx", sizeof (val) * 2);
+                 sprintf (fmt, "%%0%lulx",
+                          (unsigned long) (sizeof (val) * 2));
                  sprintf (buf, fmt, (unsigned long) val);
                }
 #if defined (BFD64)
@@ -773,7 +762,7 @@ print_source (current_file, list, buffer, width)
   if (current_file->file)
     {
       while (current_file->linenum < list->hll_line
-            && current_file->end_pending == 0)
+            && !current_file->at_end)
        {
          char *p = buffer_line (current_file, buffer, width);
          printf ("%4d:%-13s **** %s\n", current_file->linenum, current_file->filename, p);
@@ -900,7 +889,7 @@ listing_listing (name)
 
          while (list->file->file
                 && list->file->linenum < list->line
-                && !list->file->end_pending)
+                && !list->file->at_end)
            {
              p = buffer_line (list->file, buffer, width);
 
@@ -919,7 +908,7 @@ listing_listing (name)
        {
          while (list->file->file
                 && list->file->linenum < list->line
-                && !list->file->end_pending)
+                && !list->file->at_end)
            p = buffer_line (list->file, buffer, width);
        }