aboutsummaryrefslogtreecommitdiff
path: root/gas/macro.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2009-10-15 10:58:34 +0000
committerAlan Modra <amodra@gmail.com>2009-10-15 10:58:34 +0000
commitf19df8f73a7bbfeb12d1540791ed51aa86b0bdf9 (patch)
treeac25f2e334b6e60122305754da1c4d0e3bdc93ab /gas/macro.c
parentc44c601a50df172a963c97120ae40c25630552a5 (diff)
downloadgdb-f19df8f73a7bbfeb12d1540791ed51aa86b0bdf9.zip
gdb-f19df8f73a7bbfeb12d1540791ed51aa86b0bdf9.tar.gz
gdb-f19df8f73a7bbfeb12d1540791ed51aa86b0bdf9.tar.bz2
PR gas/1491
gas/ * macro.c: Delete unnecessary function declarations. (buffer_and_nest): Support multiple labels per line for LABELS_WITHOUT_COLONS targets if the labels do have colons. (free_macro): Move so that we don't need forward declaration. * read.c (read_a_source_file): Take a copy of macro expansion line before we trim labels. * listing.c (listing_newline): Adjust stdin line save for input_line_pointer still at start of line. gas/testsuite/ * gas/macros/dot.s: Don't start macro invocations is first column. * gas/macros/dot.l: Update. * gas/macros/macros.exp: Run dot test on more targets.
Diffstat (limited to 'gas/macro.c')
-rw-r--r--gas/macro.c65
1 files changed, 28 insertions, 37 deletions
diff --git a/gas/macro.c b/gas/macro.c
index dd7f9a2..f77be59 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -30,21 +30,6 @@
/* The routines in this file handle macro definition and expansion.
They are called by gas. */
-/* Internal functions. */
-
-static int get_token (int, sb *, sb *);
-static int getstring (int, sb *, sb *);
-static int get_any_string (int, sb *, sb *);
-static formal_entry *new_formal (void);
-static void del_formal (formal_entry *);
-static int do_formals (macro_entry *, int, sb *);
-static int get_apost_token (int, sb *, sb *, int);
-static int sub_actual (int, sb *, sb *, struct hash_control *, int, sb *, int);
-static const char *macro_expand_body
- (sb *, sb *, formal_entry *, struct hash_control *, const macro_entry *);
-static const char *macro_expand (int, sb *, macro_entry *, sb *);
-static void free_macro(macro_entry *);
-
#define ISWHITE(x) ((x) == ' ' || (x) == '\t')
#define ISSEP(x) \
@@ -146,6 +131,7 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
{
/* Try to find the first pseudo op on the line. */
int i = line_start;
+ bfd_boolean had_colon = FALSE;
/* With normal syntax we can suck what we want till we get
to the dot. With the alternate, labels have to start in
@@ -169,19 +155,24 @@ buffer_and_nest (const char *from, const char *to, sb *ptr,
i++;
if (i < ptr->len && is_name_ender (ptr->ptr[i]))
i++;
- if (LABELS_WITHOUT_COLONS)
- break;
/* Skip whitespace. */
while (i < ptr->len && ISWHITE (ptr->ptr[i]))
i++;
/* Check for the colon. */
if (i >= ptr->len || ptr->ptr[i] != ':')
{
+ /* LABELS_WITHOUT_COLONS doesn't mean we cannot have a
+ colon after a label. If we do have a colon on the
+ first label then handle more than one label on the
+ line, assuming that each label has a colon. */
+ if (LABELS_WITHOUT_COLONS && !had_colon)
+ break;
i = line_start;
break;
}
i++;
line_start = i;
+ had_colon = TRUE;
}
/* Skip trailing whitespace. */
@@ -606,6 +597,26 @@ do_formals (macro_entry *macro, int idx, sb *in)
return idx;
}
+/* Free the memory allocated to a macro. */
+
+static void
+free_macro (macro_entry *macro)
+{
+ formal_entry *formal;
+
+ for (formal = macro->formals; formal; )
+ {
+ formal_entry *f;
+
+ f = formal;
+ formal = formal->next;
+ del_formal (f);
+ }
+ hash_die (macro->formal_hash);
+ sb_kill (&macro->sub);
+ free (macro);
+}
+
/* Define a new macro. Returns NULL on success, otherwise returns an
error message. If NAMEP is not NULL, *NAMEP is set to the name of
the macro which was defined. */
@@ -1235,26 +1246,6 @@ check_macro (const char *line, sb *expand,
return 1;
}
-/* Free the memory allocated to a macro. */
-
-static void
-free_macro(macro_entry *macro)
-{
- formal_entry *formal;
-
- for (formal = macro->formals; formal; )
- {
- formal_entry *f;
-
- f = formal;
- formal = formal->next;
- del_formal (f);
- }
- hash_die (macro->formal_hash);
- sb_kill (&macro->sub);
- free (macro);
-}
-
/* Delete a macro. */
void