2010-08-04 Tristan Gingold <gingold@adacore.com>
[deliverable/binutils-gdb.git] / gas / listing.c
index 3af70d7be49728a8f744440fca0866a7caeca3fa..bc6af712a0e798baa350fdf0988da36d6f1c6fa4 100644 (file)
@@ -1,6 +1,6 @@
 /* listing.c - maintain assembly listings
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2005, 2006, 2007, 2008
+   2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -130,6 +130,18 @@ typedef struct file_info_struct
   int                       at_end;
 } file_info_type;
 
+enum edict_enum
+{
+  EDICT_NONE,
+  EDICT_SBTTL,
+  EDICT_TITLE,
+  EDICT_NOLIST,
+  EDICT_LIST,
+  EDICT_NOLIST_NEXT,
+  EDICT_EJECT
+};
+
+
 /* This structure remembers which line from which file goes into which
    frag.  */
 struct list_info_struct
@@ -160,16 +172,7 @@ struct list_info_struct
   /* Pointer to any error message associated with this line.  */
   char *message;
 
-  enum
-    {
-      EDICT_NONE,
-      EDICT_SBTTL,
-      EDICT_TITLE,
-      EDICT_NOLIST,
-      EDICT_LIST,
-      EDICT_NOLIST_NEXT,
-      EDICT_EJECT
-    } edict;
+  enum edict_enum edict;
   char *edict_arg;
 
   /* Nonzero if this line is to be omitted because it contains
@@ -260,7 +263,7 @@ file_info (const char *file_name)
     }
 
   /* Make new entry.  */
-  p = xmalloc (sizeof (file_info_type));
+  p = (file_info_type *) xmalloc (sizeof (file_info_type));
   p->next = file_info_head;
   file_info_head = p;
   p->filename = xstrdup (file_name);
@@ -285,7 +288,7 @@ listing_newline (char *ps)
   unsigned int line;
   static unsigned int last_line = 0xffff;
   static char *last_file = NULL;
-  list_info_type *new = NULL;
+  list_info_type *new_i = NULL;
 
   if (listing == 0)
     return;
@@ -318,7 +321,7 @@ listing_newline (char *ps)
          && !(last_file && file && strcmp (file, last_file)))
        return;
 
-      new = (list_info_type *) xmalloc (sizeof (list_info_type));
+      new_i = (list_info_type *) xmalloc (sizeof (list_info_type));
 
       /* Detect if we are reading from stdin by examining the file
         name returned by as_where().
@@ -339,24 +342,26 @@ listing_newline (char *ps)
          int seen_quote = 0;
          int seen_slash = 0;
 
-         for (copy = input_line_pointer - 1;
+         for (copy = input_line_pointer;
               *copy && (seen_quote
                         || is_end_of_line [(unsigned char) *copy] != 1);
               copy++)
            {
-             if (*copy == '\\')
-               seen_slash = ! seen_slash;
-             else if (*copy == '"' && seen_slash)
-               seen_quote = ! seen_quote;
+             if (seen_slash)
+               seen_slash = 0;
+             else if (*copy == '\\')
+               seen_slash = 1;
+             else if (*copy == '"')
+               seen_quote = !seen_quote;
            }
 
-         len = (copy - input_line_pointer) + 2;
+         len = copy - input_line_pointer + 1;
 
-         copy = xmalloc (len);
+         copy = (char *) xmalloc (len);
 
          if (copy != NULL)
            {
-             char *src = input_line_pointer - 1;
+             char *src = input_line_pointer;
              char *dest = copy;
 
              while (--len)
@@ -371,15 +376,15 @@ listing_newline (char *ps)
              *dest = 0;
            }
 
-         new->line_contents = copy;
+         new_i->line_contents = copy;
        }
       else
-       new->line_contents = NULL;
+       new_i->line_contents = NULL;
     }
   else
     {
-      new = xmalloc (sizeof (list_info_type));
-      new->line_contents = ps;
+      new_i = (list_info_type *) xmalloc (sizeof (list_info_type));
+      new_i->line_contents = ps;
     }
 
   last_line = line;
@@ -388,21 +393,21 @@ listing_newline (char *ps)
   new_frag ();
 
   if (listing_tail)
-    listing_tail->next = new;
+    listing_tail->next = new_i;
   else
-    head = new;
+    head = new_i;
 
-  listing_tail = new;
+  listing_tail = new_i;
 
-  new->frag = frag_now;
-  new->line = line;
-  new->file = file_info (file);
-  new->next = (list_info_type *) NULL;
-  new->message = (char *) NULL;
-  new->edict = EDICT_NONE;
-  new->hll_file = (file_info_type *) NULL;
-  new->hll_line = 0;
-  new->debugging = 0;
+  new_i->frag = frag_now;
+  new_i->line = line;
+  new_i->file = file_info (file);
+  new_i->next = (list_info_type *) NULL;
+  new_i->message = (char *) NULL;
+  new_i->edict = EDICT_NONE;
+  new_i->hll_file = (file_info_type *) NULL;
+  new_i->hll_line = 0;
+  new_i->debugging = 0;
 
   new_frag ();
 
@@ -416,7 +421,7 @@ listing_newline (char *ps)
       segname = segment_name (now_seg);
       if (strncmp (segname, ".debug", sizeof ".debug" - 1) == 0
          || strncmp (segname, ".line", sizeof ".line" - 1) == 0)
-       new->debugging = 1;
+       new_i->debugging = 1;
     }
 #endif
 }
@@ -983,7 +988,7 @@ print_source (file_info_type *  current_file,
 #define NUM_CACHE_LINES  3
   static cached_line cached_lines[NUM_CACHE_LINES];
   static int next_free_line = 0;
-  cached_line * cache;
+  cached_line * cache = NULL;
 
   if (current_file->linenum > list->hll_line
       && list->hll_line > 0)
@@ -1040,11 +1045,11 @@ print_source (file_info_type *  current_file,
       while (current_file->linenum < list->hll_line
             && !current_file->at_end)
        {
-         cached_line * cache = cached_lines + next_free_line;
          char *p;
 
+         cache = cached_lines + next_free_line;
          cache->file = current_file;
-         cache->line = current_file->linenum;
+         cache->line = current_file->linenum + 1;
          cache->buffer[0] = 0;
          p = buffer_line (current_file, cache->buffer, width);
 
@@ -1070,17 +1075,22 @@ print_source (file_info_type *  current_file,
 static int
 debugging_pseudo (list_info_type *list, const char *line)
 {
+#ifdef OBJ_ELF
   static int in_debug;
   int was_debug;
+#endif
 
   if (list->debugging)
     {
+#ifdef OBJ_ELF
       in_debug = 1;
+#endif
       return 1;
     }
-
+#ifdef OBJ_ELF
   was_debug = in_debug;
   in_debug = 0;
+#endif
 
   while (ISSPACE (*line))
     line++;
@@ -1141,14 +1151,13 @@ listing_listing (char *name ATTRIBUTE_UNUSED)
 {
   list_info_type *list = head;
   file_info_type *current_hll_file = (file_info_type *) NULL;
-  char *message;
   char *buffer;
   char *p;
   int show_listing = 1;
   unsigned int width;
 
-  buffer = xmalloc (listing_rhs_width);
-  data_buffer = xmalloc (MAX_BYTES);
+  buffer = (char *) xmalloc (listing_rhs_width);
+  data_buffer = (char *) xmalloc (MAX_BYTES);
   eject = 1;
   list = head->next;
 
@@ -1206,8 +1215,6 @@ listing_listing (char *name ATTRIBUTE_UNUSED)
        {
          /* Scan down the list and print all the stuff which can be done
             with this line (or lines).  */
-         message = 0;
-
          if (list->hll_file)
            current_hll_file = list->hll_file;
 
@@ -1406,14 +1413,6 @@ listing_eject (int ignore ATTRIBUTE_UNUSED)
     listing_tail->edict = EDICT_EJECT;
 }
 
-void
-listing_flags (int ignore ATTRIBUTE_UNUSED)
-{
-  while ((*input_line_pointer++) && (*input_line_pointer != '\n'))
-    input_line_pointer++;
-
-}
-
 /* Turn listing on or off.  An argument of 0 means to turn off
    listing.  An argument of 1 means to turn on listing.  An argument
    of 2 means to turn off listing, but as of the next line; that is,
@@ -1509,7 +1508,7 @@ listing_title (int depth)
          if (listing)
            {
              length = input_line_pointer - start;
-             ttl = xmalloc (length + 1);
+             ttl = (char *) xmalloc (length + 1);
              memcpy (ttl, start, length);
              ttl[length] = 0;
              listing_tail->edict = depth ? EDICT_SBTTL : EDICT_TITLE;
@@ -1555,12 +1554,6 @@ listing_source_file (const char *file)
 
 /* Dummy functions for when compiled without listing enabled.  */
 
-void
-listing_flags (int ignore)
-{
-  s_ignore (0);
-}
-
 void
 listing_list (int on)
 {
This page took 0.029707 seconds and 4 git commands to generate.