diff options
author | Jan Beulich <jbeulich@suse.com> | 2024-08-05 16:28:43 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2024-08-05 16:28:43 +0200 |
commit | 1068b74548858fe9c8ed17f0bba8b136111fbec9 (patch) | |
tree | 53ec9fdf0918ce5b4995b727516e1ec65b55987d /gas/read.c | |
parent | b464e193d116bd752375b92cc65c676cbd6f00fa (diff) | |
download | gdb-1068b74548858fe9c8ed17f0bba8b136111fbec9.zip gdb-1068b74548858fe9c8ed17f0bba8b136111fbec9.tar.gz gdb-1068b74548858fe9c8ed17f0bba8b136111fbec9.tar.bz2 |
gas: recognize #APP at start-of-physical-line only
It's not valid to recognize it after mere line separators (often
semicolon) or after labels, let alone after tc_unrecognized_line()
perhaps having parsed off parts of a line. It shouldn't even be
preceded by whitespace, aiui.
However, keep ignoring line comments as before, for backwards
compatibility.
Diffstat (limited to 'gas/read.c')
-rw-r--r-- | gas/read.c | 106 |
1 files changed, 60 insertions, 46 deletions
@@ -900,7 +900,7 @@ read_a_source_file (const char *name) #endif while (input_line_pointer < buffer_limit) { - bool was_new_line; + char was_new_line; /* We have more of this buffer to parse. */ /* We now have input_line_pointer->1st char of next line. @@ -953,6 +953,59 @@ read_a_source_file (const char *name) listing_newline (NULL); } #endif + + next_char = *input_line_pointer; + if (was_new_line == 1 && next_char + && strchr (line_comment_chars, next_char)) + { + /* Its a comment. Check for APP followed by NO_APP. */ + sb sbuf; + char *ends; + size_t len; + + s = input_line_pointer + 1; + if (!startswith (s, "APP\n")) + { + /* We ignore it. Note: Not ignore_rest_of_line ()! */ + while (s <= buffer_limit) + if (is_end_of_line (*s++)) + break; + input_line_pointer = s; + continue; + } + bump_line_counters (); + s += 4; + + ends = strstr (s, "#NO_APP\n"); + len = ends ? ends - s : buffer_limit - s; + + sb_build (&sbuf, len + 100); + sb_add_buffer (&sbuf, s, len); + if (!ends) + { + /* The end of the #APP wasn't in this buffer. We + keep reading in buffers until we find the #NO_APP + that goes with this #APP There is one. The specs + guarantee it... */ + do + { + buffer_limit = input_scrub_next_buffer (&buffer); + if (!buffer_limit) + break; + ends = strstr (buffer, "#NO_APP\n"); + len = ends ? ends - buffer : buffer_limit - buffer; + sb_add_buffer (&sbuf, buffer, len); + } + while (!ends); + } + + input_line_pointer = ends ? ends + 8 : NULL; + input_scrub_include_sb (&sbuf, input_line_pointer, expanding_none); + sb_kill (&sbuf); + buffer_limit = input_scrub_next_buffer (&input_line_pointer); + continue; + } + if (was_new_line) { line_label = NULL; @@ -1316,51 +1369,12 @@ read_a_source_file (const char *name) } if (next_char && strchr (line_comment_chars, next_char)) - { /* Its a comment. Better say APP or NO_APP. */ - sb sbuf; - char *ends; - size_t len; - - s = input_line_pointer; - if (!startswith (s, "APP\n")) - { - /* We ignore it. Note: Not ignore_rest_of_line ()! */ - while (s <= buffer_limit) - if (is_end_of_line (*s++)) - break; - input_line_pointer = s; - continue; - } - bump_line_counters (); - s += 4; - - ends = strstr (s, "#NO_APP\n"); - len = ends ? ends - s : buffer_limit - s; - - sb_build (&sbuf, len + 100); - sb_add_buffer (&sbuf, s, len); - if (!ends) - { - /* The end of the #APP wasn't in this buffer. We - keep reading in buffers until we find the #NO_APP - that goes with this #APP There is one. The specs - guarantee it... */ - do - { - buffer_limit = input_scrub_next_buffer (&buffer); - if (!buffer_limit) - break; - ends = strstr (buffer, "#NO_APP\n"); - len = ends ? ends - buffer : buffer_limit - buffer; - sb_add_buffer (&sbuf, buffer, len); - } - while (!ends); - } - - input_line_pointer = ends ? ends + 8 : NULL; - input_scrub_include_sb (&sbuf, input_line_pointer, expanding_none); - sb_kill (&sbuf); - buffer_limit = input_scrub_next_buffer (&input_line_pointer); + { + /* Its a comment, ignore it. Note: Not ignore_rest_of_line ()! */ + while (s <= buffer_limit) + if (is_end_of_line (*s++)) + break; + input_line_pointer = s; continue; } |