daily update
[deliverable/binutils-gdb.git] / gas / listing.c
index 7fdb67d7722093fea803374ef08e7d3083fab80d..7510d858959772411036af4a60e9a5f5a237f936 100644 (file)
@@ -1,5 +1,6 @@
 /* listing.c - mainting assembly listings
-   Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001, 2002
    Free Software Foundation, Inc.
 
 This file is part of GAS, the GNU Assembler.
@@ -90,10 +91,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
                         on a line
 */
 
-#include <ctype.h>
-
 #include "as.h"
-#include <obstack.h>
+#include "obstack.h"
+#include "safe-ctype.h"
 #include "input-file.h"
 #include "subsegs.h"
 
@@ -226,12 +226,12 @@ listing_message (name, message)
      const char *name;
      const char *message;
 {
-  unsigned int l = strlen (name) + strlen (message) + 1;
-  char *n = (char *) xmalloc (l);
-  strcpy (n, name);
-  strcat (n, message);
   if (listing_tail != (list_info_type *) NULL)
     {
+      unsigned int l = strlen (name) + strlen (message) + 1;
+      char *n = (char *) xmalloc (l);
+      strcpy (n, name);
+      strcat (n, message);
       listing_tail->message = n;
     }
 }
@@ -269,8 +269,7 @@ file_info (file_name)
   p = (file_info_type *) xmalloc (sizeof (file_info_type));
   p->next = file_info_head;
   file_info_head = p;
-  p->filename = xmalloc ((unsigned long) strlen (file_name) + 1);
-  strcpy (p->filename, file_name);
+  p->filename = xstrdup (file_name);
   p->pos = 0;
   p->linenum = 0;
   p->at_end = 0;
@@ -369,7 +368,7 @@ listing_newline (ps)
                  unsigned char c = *src++;
 
                  /* Omit control characters in the listing.  */
-                 if (isascii (c) && ! iscntrl (c))
+                 if (!ISCNTRL (c))
                    *dest++ = c;
                }
 
@@ -484,7 +483,7 @@ buffer_line (file, line, size)
        }
 
       last_open_file_info = file;
-      last_open_file = fopen (file->filename, "r");
+      last_open_file = fopen (file->filename, FOPEN_RT);
       if (last_open_file == NULL)
        {
          file->at_end = 1;
@@ -513,9 +512,12 @@ buffer_line (file, line, size)
   if (c == EOF)
     {
       file->at_end = 1;
-      *p++ = '.';
-      *p++ = '.';
-      *p++ = '.';
+      if (count + 2 < size)
+       {
+         *p++ = '.';
+         *p++ = '.';
+         *p++ = '.';
+       }
     }
   file->linenum++;
   *p++ = 0;
@@ -613,35 +615,36 @@ calc_hex (list)
          data_buffer_size += 2;
          octet_in_frag++;
        }
-      {
-       unsigned int var_rep_max = octet_in_frag;
-       unsigned int var_rep_idx = octet_in_frag;
-
-       /* Print as many bytes from the variable part as is sensible.  */
-       while (((offsetT) octet_in_frag
-               < (frag_ptr->fr_fix + frag_ptr->fr_var * frag_ptr->fr_offset))
-              && data_buffer_size < MAX_BYTES - 3)
-         {
-           if (address == ~(unsigned int) 0)
-             {
-               address = frag_ptr->fr_address / OCTETS_PER_BYTE;
-             }
-           sprintf (data_buffer + data_buffer_size,
-                    "%02X",
-                    (frag_ptr->fr_literal[var_rep_idx]) & 0xff);
+      if (frag_ptr->fr_type == rs_fill)
+       {
+         unsigned int var_rep_max = octet_in_frag;
+         unsigned int var_rep_idx = octet_in_frag;
+
+         /* Print as many bytes from the variable part as is sensible.  */
+         while (((offsetT) octet_in_frag
+                 < (frag_ptr->fr_fix + frag_ptr->fr_var * frag_ptr->fr_offset))
+                && data_buffer_size < MAX_BYTES - 3)
+           {
+             if (address == ~(unsigned int) 0)
+               {
+                 address = frag_ptr->fr_address / OCTETS_PER_BYTE;
+               }
+             sprintf (data_buffer + data_buffer_size,
+                      "%02X",
+                      (frag_ptr->fr_literal[var_rep_idx]) & 0xff);
 #if 0
-           data_buffer[data_buffer_size++] = '*';
-           data_buffer[data_buffer_size++] = '*';
+             data_buffer[data_buffer_size++] = '*';
+             data_buffer[data_buffer_size++] = '*';
 #endif
-           data_buffer_size += 2;
+             data_buffer_size += 2;
 
-           var_rep_idx++;
-           octet_in_frag++;
+             var_rep_idx++;
+             octet_in_frag++;
 
-           if ((offsetT) var_rep_idx >= frag_ptr->fr_fix + frag_ptr->fr_var)
-             var_rep_idx = var_rep_max;
-         }
-      }
+             if ((offsetT) var_rep_idx >= frag_ptr->fr_fix + frag_ptr->fr_var)
+               var_rep_idx = var_rep_max;
+           }
+       }
 
       frag_ptr = frag_ptr->fr_next;
     }
@@ -906,7 +909,7 @@ debugging_pseudo (list, line)
   was_debug = in_debug;
   in_debug = 0;
 
-  while (isspace ((unsigned char) *line))
+  while (ISSPACE (*line))
     line++;
 
   if (*line != '.')
@@ -1006,6 +1009,8 @@ listing_listing (name)
          show_listing--;
          break;
        case EDICT_NOLIST_NEXT:
+         if (show_listing == 0)
+           list_line--;
          break;
        case EDICT_EJECT:
          break;
@@ -1028,7 +1033,8 @@ listing_listing (name)
            p = buffer_line (list->file, buffer, width);
        }
 
-      if (list->edict == EDICT_LIST)
+      if (list->edict == EDICT_LIST
+         || (list->edict == EDICT_NOLIST_NEXT && show_listing == 0))
        {
          /* Enable listing for the single line that caused the enable.  */
          list_line++;
@@ -1056,7 +1062,7 @@ listing_listing (name)
              if (!((listing & LISTING_NODEBUG)
                    && debugging_pseudo (list, list->line_contents)))
                {
-                 print_lines (list,
+                 print_lines (list,
                               list->file->linenum == 0 ? list->line : list->file->linenum,
                               list->line_contents, calc_hex (list));
                }
@@ -1089,7 +1095,7 @@ listing_listing (name)
            }
        }
 
-      if (list->edict == EDICT_NOLIST_NEXT)
+      if (list->edict == EDICT_NOLIST_NEXT && show_listing == 1)
        --show_listing;
 
       list = list->next;
@@ -1116,7 +1122,7 @@ listing_print (name)
     }
   else
     {
-      list_file = fopen (name, "w");
+      list_file = fopen (name, FOPEN_WT);
       if (list_file != NULL)
        using_stdout = 0;
       else
@@ -1290,7 +1296,7 @@ listing_title (depth)
        }
       else if (*input_line_pointer == '\n')
        {
-         as_bad (_("New line in title"));
+         as_bad (_("new line in title"));
          demand_empty_rest_of_line ();
          return;
        }
This page took 0.027719 seconds and 4 git commands to generate.