aboutsummaryrefslogtreecommitdiff
path: root/gas/read.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2024-08-02 09:43:58 +0200
committerJan Beulich <jbeulich@suse.com>2024-08-02 09:43:58 +0200
commit3615e5db8d07da71110143ee37f604235dd088a6 (patch)
tree9a1444dd570a58a17f39030bca2d2e72fe2c5780 /gas/read.c
parentb6e1210536c585be025218687a5c6911ceb1e1e8 (diff)
downloadbinutils-3615e5db8d07da71110143ee37f604235dd088a6.zip
binutils-3615e5db8d07da71110143ee37f604235dd088a6.tar.gz
binutils-3615e5db8d07da71110143ee37f604235dd088a6.tar.bz2
gas: correctly deal with line comments when not preprocessing
Internal naming of functions / data as well as commentary mixes lines and statements. It is presumably this confusion which has led to the wrong use of ignore_rest_of_line() when dealing with line comments in read_a_source_file(). We shall not (silently) produce different output depending on whether -f is passed (for suitable input). Introduce two new helper macros, intended to be used in favor of open- coded accesses to is_end_of_line[]. To emphasize the difference, convert ignore_rest_of_line() right away, including adjustments to its comments. Since most targets have # in line_comment_chars[], add a target- independent test for that, plus an x86-only one also checking for non-# to work as intended.
Diffstat (limited to 'gas/read.c')
-rw-r--r--gas/read.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gas/read.c b/gas/read.c
index 9a26a9a..adb4759 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -1324,8 +1324,11 @@ read_a_source_file (const char *name)
s = input_line_pointer;
if (!startswith (s, "APP\n"))
{
- /* We ignore it. */
- ignore_rest_of_line ();
+ /* 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 ();
@@ -3974,7 +3977,7 @@ demand_empty_rest_of_line (void)
/* Return pointing just after end-of-line. */
}
-/* Silently advance to the end of line. Use this after already having
+/* Silently advance to the end of a statement. Use this after already having
issued an error about something bad. Like demand_empty_rest_of_line,
this function may leave input_line_pointer one after buffer_limit;
Don't call it from within expression parsing code in an attempt to
@@ -3984,9 +3987,9 @@ void
ignore_rest_of_line (void)
{
while (input_line_pointer <= buffer_limit)
- if (is_end_of_line[(unsigned char) *input_line_pointer++])
+ if (is_end_of_stmt (*input_line_pointer++))
break;
- /* Return pointing just after end-of-line. */
+ /* Return pointing just after end-of-statement. */
}
/* Sets frag for given symbol to zero_address_frag, except when the