diff options
Diffstat (limited to 'gas/macro.c')
-rw-r--r-- | gas/macro.c | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/gas/macro.c b/gas/macro.c index 20309d4..b272800 100644 --- a/gas/macro.c +++ b/gas/macro.c @@ -112,11 +112,13 @@ buffer_and_nest (const char *from, const char *to, sb *ptr, unsigned int line; char *linefile; - as_where_top (&line); - if (!flag_m68k_mri) - linefile = xasprintf ("\t.linefile %u .", line + 1); + const char *prefix = flag_m68k_mri ? "" : "."; + const char *file = as_where_top (&line); + + if (file) + linefile = xasprintf ("\t%slinefile %u \"%s\"", prefix, line + 1, file); else - linefile = xasprintf ("\tlinefile %u .", line + 1); + linefile = xasprintf ("\t%slinefile %u .", prefix, line + 1); sb_add_string (ptr, linefile); xfree (linefile); } @@ -290,24 +292,25 @@ getstring (size_t idx, sb *in, sb *acc) { int nest = 0; idx++; - while (idx < in->len - && (in->ptr[idx] != '>' || nest)) + while (idx < in->len) { - if (in->ptr[idx] == '!') - { - idx++; - sb_add_char (acc, in->ptr[idx++]); - } - else + if (in->ptr[idx] == '!' && idx + 1 < in->len) + idx++; + else if (in->ptr[idx] == '>') { - if (in->ptr[idx] == '>') - nest--; - if (in->ptr[idx] == '<') - nest++; - sb_add_char (acc, in->ptr[idx++]); + if (nest == 0) + { + idx++; + break; + } + nest--; } + else if (in->ptr[idx] == '<') + nest++; + + sb_add_char (acc, in->ptr[idx]); + idx++; } - idx++; } else if (in->ptr[idx] == '"' || in->ptr[idx] == '\'') { @@ -315,7 +318,6 @@ getstring (size_t idx, sb *in, sb *acc) int escaped = 0; idx++; - while (idx < in->len) { if (in->ptr[idx - 1] == '\\') @@ -323,32 +325,19 @@ getstring (size_t idx, sb *in, sb *acc) else escaped = 0; - if (flag_macro_alternate && in->ptr[idx] == '!') + if (flag_macro_alternate + && in->ptr[idx] == '!' && idx + 1 < in->len) { - idx ++; - - sb_add_char (acc, in->ptr[idx]); - - idx ++; - } - else if (escaped && in->ptr[idx] == tchar) - { - sb_add_char (acc, tchar); - idx ++; + idx++; } - else + else if (!escaped && in->ptr[idx] == tchar) { - if (in->ptr[idx] == tchar) - { - idx ++; - - if (idx >= in->len || in->ptr[idx] != tchar) - break; - } - - sb_add_char (acc, in->ptr[idx]); - idx ++; + idx++; + if (idx >= in->len || in->ptr[idx] != tchar) + break; } + sb_add_char (acc, in->ptr[idx]); + idx++; } } } |