aboutsummaryrefslogtreecommitdiff
path: root/gas/input-scrub.c
diff options
context:
space:
mode:
Diffstat (limited to 'gas/input-scrub.c')
-rw-r--r--gas/input-scrub.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gas/input-scrub.c b/gas/input-scrub.c
index 46dd244..adae4d4 100644
--- a/gas/input-scrub.c
+++ b/gas/input-scrub.c
@@ -264,6 +264,8 @@ input_scrub_include_file (char *filename, char *position)
void
input_scrub_include_sb (sb *from, char *position, int is_expansion)
{
+ int newline;
+
if (macro_nest > max_macro_nest)
as_fatal (_("macros nested too deeply"));
++macro_nest;
@@ -277,9 +279,11 @@ input_scrub_include_sb (sb *from, char *position, int is_expansion)
next_saved_file = input_scrub_push (position);
- sb_new (&from_sb);
+ /* Allocate sufficient space: from->len + optional newline. */
+ newline = from->len >= 1 && from->ptr[0] != '\n';
+ sb_build (&from_sb, from->len + newline);
from_sb_is_expansion = is_expansion;
- if (from->len >= 1 && from->ptr[0] != '\n')
+ if (newline)
{
/* Add the sentinel required by read.c. */
sb_add_char (&from_sb, '\n');
@@ -288,8 +292,7 @@ input_scrub_include_sb (sb *from, char *position, int is_expansion)
/* Make sure the parser looks at defined contents when it scans for
e.g. end-of-line at the end of a macro. */
- sb_add_char (&from_sb, 0);
- from_sb.len--;
+ sb_terminate (&from_sb);
sb_index = 1;