From 7545aa2dd2eb85a852f978dc0d93b3deb6f52536 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 14 Feb 2023 08:34:03 +0100 Subject: gas: improve interaction between read_a_source_file() and s_linefile() read_a_source_file() would bump line numbers only when seeing a newline, whereas is_end_of_line[] indicates further end-of-line characters, in particular the nul character. s_linefile() attempts to compensate for the bump, but was too aggressive with this so far: It should only adjust when a newline ends the line. To facilitate such a check, the check for nothing else on the line needs to move ahead, which luckily is easily possible: The relevant two conditions match, and the function can simply return from the body of that earlier instance of the conditional. The more strict treatment in s_linefile() then requires an adjustment to buffer_and_nest()'s invocation of the function: The line terminator now needs to be a newline, not nul. --- gas/read.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'gas/read.c') diff --git a/gas/read.c b/gas/read.c index 9f6a700..f1099cb 100644 --- a/gas/read.c +++ b/gas/read.c @@ -2049,18 +2049,22 @@ s_linefile (int ignore ATTRIBUTE_UNUSED) if (file || flags) { - linenum--; + demand_empty_rest_of_line (); + + /* read_a_source_file() will bump the line number only if the line + is terminated by '\n'. */ + if (input_line_pointer[-1] == '\n') + linenum--; + new_logical_line_flags (file, linenum, flags); #ifdef LISTING if (listing) listing_source_line (linenum); #endif + return; } } - if (file || flags) - demand_empty_rest_of_line (); - else - ignore_rest_of_line (); + ignore_rest_of_line (); } /* Handle the .end pseudo-op. Actually, the real work is done in -- cgit v1.1