diff options
author | Jan Beulich <jbeulich@suse.com> | 2024-07-26 08:00:42 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2024-07-26 08:00:42 +0200 |
commit | e0b9535c824deb24e209acddcb7662124aeb413f (patch) | |
tree | 5a02d18ed2ba0d4f8d7fee385829cffb2f59d48a /gas/app.c | |
parent | c97f0d71ea9cc5c3bf63aacef34b5ebc95dd3b9a (diff) | |
download | fsf-binutils-gdb-e0b9535c824deb24e209acddcb7662124aeb413f.zip fsf-binutils-gdb-e0b9535c824deb24e209acddcb7662124aeb413f.tar.gz fsf-binutils-gdb-e0b9535c824deb24e209acddcb7662124aeb413f.tar.bz2 |
gas: drop scrubber state -2
Instead re-use code handling LEX_IS_TWOCHAR_COMMENT_1ST, thus ensuring
that we wouldn't get bogus state transitions: For example, when we're in
states 0 or 1, a comment should be no different from whitespace
encountered in those states. Plus for e.g. x86 this results in such
comments now truly being converted to a blank, as mandated by
documentation. Both aspects apparently were a result of blindly (and
wrongly) moving to state 3 _before_ consuming the "ungot" blank.
Also amend a related comment elsewhere.
In the new testcase the .irp is to make visible in the listing all the
whitespace that the scrubber inserts / leaves in place.
Diffstat (limited to 'gas/app.c')
-rw-r--r-- | gas/app.c | 54 |
1 files changed, 6 insertions, 48 deletions
@@ -217,7 +217,8 @@ do_scrub_begin (int m68k_mri ATTRIBUTE_UNUSED) lex[(unsigned char) *p] = LEX_IS_PARALLEL_SEPARATOR; #endif - /* Only allow slash-star comments if slash is not in use. + /* Only allow slash-star comments if slash is not in use. Certain + other cases are dealt with in LEX_IS_LINE_COMMENT_START handling. FIXME: This isn't right. We should always permit them. */ if (lex['/'] == 0) lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST; @@ -476,7 +477,6 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen, 10: After seeing whitespace in state 9 (keep white before symchar) 11: After seeing a symbol character in state 0 (eg a label definition) -1: output string in out_string and go to the state in old_state - -2: flush text until a '*' '/' is seen, then go to state old_state 12: no longer used #ifdef DOUBLEBAR_PARALLEL 13: After seeing a vertical bar, looking for a second @@ -579,43 +579,6 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen, PUT (ch); continue; - case -2: - for (;;) - { - do - { - ch = GET (); - - if (ch == EOF) - { - as_warn (_("end of file in comment")); - goto fromeof; - } - - if (ch == '\n') - PUT ('\n'); - } - while (ch != '*'); - - while ((ch = GET ()) == '*') - ; - - if (ch == EOF) - { - as_warn (_("end of file in comment")); - goto fromeof; - } - - if (ch == '/') - break; - - UNGET (ch); - } - - state = old_state; - UNGET (' '); - continue; - case 4: ch = GET (); if (ch == EOF) @@ -1076,6 +1039,7 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen, ch2 = GET (); if (ch2 == '*') { + twochar_comment: for (;;) { do @@ -1290,15 +1254,9 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen, { ch2 = GET (); if (ch2 == '*') - { - old_state = 3; - state = -2; - break; - } - else if (ch2 != EOF) - { - UNGET (ch2); - } + goto twochar_comment; + if (ch2 != EOF) + UNGET (ch2); } if (state == 0 || state == 1) /* Only comment at start of line. */ |