From: Jan Beulich Date: Fri, 12 Dec 2025 07:04:41 +0000 (+0100) Subject: gas/macro: drop ISSEP() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=618ca60a400346ec36cbf7d3c232ac455a45c1fd;p=thirdparty%2Fbinutils-gdb.git gas/macro: drop ISSEP() I've been irritated by it more than once: It very obviously doesn't cover all separators, hence resulting in inconsistent behavior. Nor do both use sites look to really want the same set of separators. In macro_expand() we really can pull the get_token() call ahead. If we don't find the expected '=' we can simply continue parsing from the original position. The use in get_any_string() is dead code afaict, inherited from gasp. The sole leftover thereof is handled in the scrubber (see H_TICK_HEX, LEX_IS_H, and alike there). With that dropped, ISBASE() also can be. --- diff --git a/gas/macro.c b/gas/macro.c index b272800388a..4bb66004f1b 100644 --- a/gas/macro.c +++ b/gas/macro.c @@ -29,17 +29,6 @@ /* The routines in this file handle macro definition and expansion. They are called by gas. */ -#define ISSEP(x) \ - (is_whitespace (x) || (x) == ',' || (x) == '"' || (x) == ';' \ - || (x) == ')' || (x) == '(' \ - || ((flag_macro_alternate || flag_mri) && ((x) == '<' || (x) == '>'))) - -#define ISBASE(x) \ - ((x) == 'b' || (x) == 'B' \ - || (x) == 'q' || (x) == 'Q' \ - || (x) == 'h' || (x) == 'H' \ - || (x) == 'd' || (x) == 'D') - /* The macro hash table. */ htab_t macro_hash; @@ -347,7 +336,6 @@ getstring (size_t idx, sb *in, sb *acc) /* Fetch string from the input stream, rules: - 'Bxyx -> return 'Bxyza % -> return string of decimal value of "string" -> return string (string) -> return (string-including-whitespaces) @@ -361,12 +349,7 @@ get_any_string (size_t idx, sb *in, sb *out) if (idx < in->len) { - if (in->len > idx + 2 && in->ptr[idx + 1] == '\'' && ISBASE (in->ptr[idx])) - { - while (idx < in->len && !ISSEP (in->ptr[idx])) - sb_add_char (out, in->ptr[idx++]); - } - else if (in->ptr[idx] == '%' && flag_macro_alternate) + if (in->ptr[idx] == '%' && flag_macro_alternate) { /* Turn the following expression into a string. */ expressionS ex; @@ -1069,31 +1052,18 @@ macro_expand (size_t idx, sb *in, macro_entry *m, sb *out) idx = sb_skip_white (idx, in); while (idx < in->len) { + /* Look and see if it's a positional or keyword arg. */ size_t scan; - /* Look and see if it's a positional or keyword arg. */ - scan = idx; - while (scan < in->len - && !ISSEP (in->ptr[scan]) - && !(flag_mri && in->ptr[scan] == '\'') - && (!flag_macro_alternate && in->ptr[scan] != '=')) - scan++; - if (scan < in->len && !flag_macro_alternate && in->ptr[scan] == '=') + sb_reset (&t); + scan = !flag_macro_alternate ? get_token (idx, in, &t) : idx; + + if (scan > idx && scan < in->len && in->ptr[scan] == '=') { is_keyword = 1; /* It's OK to go from positional to keyword. */ - /* This is a keyword arg, fetch the formal name and - then the actual stuff. */ - sb_reset (&t); - idx = get_token (idx, in, &t); - if (idx >= in->len || in->ptr[idx] != '=') - { - err = _("confusion in formal parameters"); - break; - } - /* Lookup the formal in the macro's list. */ ptr = str_hash_find (m->formal_hash, sb_terminate (&t)); if (!ptr) @@ -1102,7 +1072,8 @@ macro_expand (size_t idx, sb *in, macro_entry *m, sb *out) t.ptr, m->name); sb_reset (&t); - idx = get_any_string (idx + 1, in, &t); + /* Skip what would be the actual stuff. */ + idx = get_any_string (scan + 1, in, &t); } else { @@ -1114,7 +1085,8 @@ macro_expand (size_t idx, sb *in, macro_entry *m, sb *out) m->name); sb_reset (&ptr->actual); } - idx = get_any_string (idx + 1, in, &ptr->actual); + /* Fetch the actual stuff. */ + idx = get_any_string (scan + 1, in, &ptr->actual); if (ptr->actual.len > 0) ++narg; }