Module Name: src Committed By: christos Date: Sun Jan 29 23:39:12 UTC 2023
Modified Files: src/external/gpl3/binutils/dist/gas: app.c as.h input-scrub.c macro.c sb.c Log Message: Apply https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=4d74aab7aa562fe79d4669cdad0c32610531cbc0#patch1 to fix the vax issue (thanks @tsutsu for finding the patch) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/binutils/dist/gas/app.c cvs rdiff -u -r1.1.1.9 -r1.2 src/external/gpl3/binutils/dist/gas/as.h cvs rdiff -u -r1.1.1.8 -r1.2 \ src/external/gpl3/binutils/dist/gas/input-scrub.c \ src/external/gpl3/binutils/dist/gas/macro.c \ src/external/gpl3/binutils/dist/gas/sb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/binutils/dist/gas/app.c diff -u src/external/gpl3/binutils/dist/gas/app.c:1.3 src/external/gpl3/binutils/dist/gas/app.c:1.4 --- src/external/gpl3/binutils/dist/gas/app.c:1.3 Sat Jan 28 09:54:43 2023 +++ src/external/gpl3/binutils/dist/gas/app.c Sun Jan 29 18:39:12 2023 @@ -1537,3 +1537,16 @@ do_scrub_chars (size_t (*get) (char *, s last_char = to[-1]; return to - tostart; } + +/* Return amount of pending input. */ + +size_t +do_scrub_pending (void) +{ + size_t len = 0; + if (saved_input) + len += saved_input_len; + if (state == -1) + len += strlen (out_string); + return len; +} Index: src/external/gpl3/binutils/dist/gas/as.h diff -u src/external/gpl3/binutils/dist/gas/as.h:1.1.1.9 src/external/gpl3/binutils/dist/gas/as.h:1.2 --- src/external/gpl3/binutils/dist/gas/as.h:1.1.1.9 Fri Dec 23 14:01:15 2022 +++ src/external/gpl3/binutils/dist/gas/as.h Sun Jan 29 18:39:12 2023 @@ -460,6 +460,7 @@ void input_scrub_insert_file (char *); char * input_scrub_new_file (const char *); char * input_scrub_next_buffer (char **bufp); size_t do_scrub_chars (size_t (*get) (char *, size_t), char *, size_t); +size_t do_scrub_pending (void); bool scan_for_multibyte_characters (const unsigned char *, const unsigned char *, bool); int gen_to_words (LITTLENUM_TYPE *, int, long); int had_err (void); Index: src/external/gpl3/binutils/dist/gas/input-scrub.c diff -u src/external/gpl3/binutils/dist/gas/input-scrub.c:1.1.1.8 src/external/gpl3/binutils/dist/gas/input-scrub.c:1.2 --- src/external/gpl3/binutils/dist/gas/input-scrub.c:1.1.1.8 Fri Dec 23 14:01:16 2022 +++ src/external/gpl3/binutils/dist/gas/input-scrub.c Sun Jan 29 18:39:12 2023 @@ -278,9 +278,11 @@ input_scrub_include_sb (sb *from, char * next_saved_file = input_scrub_push (position); - /* Allocate sufficient space: from->len + optional newline. */ + /* Allocate sufficient space: from->len plus optional newline + plus two ".linefile " directives, plus a little more for other + expansion. */ newline = from->len >= 1 && from->ptr[0] != '\n'; - sb_build (&from_sb, from->len + newline); + sb_build (&from_sb, from->len + newline + 2 * sizeof (".linefile") + 30); if (expansion == expanding_repeat && from_sb_expansion >= expanding_macro) expansion = expanding_nested; from_sb_expansion = expansion; Index: src/external/gpl3/binutils/dist/gas/macro.c diff -u src/external/gpl3/binutils/dist/gas/macro.c:1.1.1.8 src/external/gpl3/binutils/dist/gas/macro.c:1.2 --- src/external/gpl3/binutils/dist/gas/macro.c:1.1.1.8 Fri Dec 23 14:01:16 2022 +++ src/external/gpl3/binutils/dist/gas/macro.c Sun Jan 29 18:39:12 2023 @@ -1056,6 +1056,8 @@ macro_expand_body (sb *in, sb *out, form loclist = f; } + if (!err && (out->len == 0 || out->ptr[out->len - 1] != '\n')) + sb_add_char (out, '\n'); return err; } Index: src/external/gpl3/binutils/dist/gas/sb.c diff -u src/external/gpl3/binutils/dist/gas/sb.c:1.1.1.8 src/external/gpl3/binutils/dist/gas/sb.c:1.2 --- src/external/gpl3/binutils/dist/gas/sb.c:1.1.1.8 Fri Dec 23 14:01:17 2022 +++ src/external/gpl3/binutils/dist/gas/sb.c Sun Jan 29 18:39:12 2023 @@ -119,11 +119,12 @@ sb_scrub_and_add_sb (sb *ptr, sb *s) So we loop until the input S is consumed. */ while (1) { - size_t copy = s->len - (scrub_position - s->ptr); + size_t copy = s->len - (scrub_position - s->ptr) + do_scrub_pending (); if (copy == 0) break; sb_check (ptr, copy); - ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len, copy); + ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len, + ptr->max - ptr->len); } sb_to_scrub = 0;