aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppmacro.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r--gcc/cppmacro.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c
index 11ac09f12e1..2298c854ec5 100644
--- a/gcc/cppmacro.c
+++ b/gcc/cppmacro.c
@@ -1626,6 +1626,7 @@ cpp_macro_definition (cpp_reader *pfile, const cpp_hashnode *node)
len += NODE_LEN (macro->params[i]) + 1; /* "," */
}
+ /* This should match below where we fill in the buffer. */
if (CPP_OPTION (pfile, traditional))
len += _cpp_replacement_text_len (macro);
else
@@ -1637,11 +1638,14 @@ cpp_macro_definition (cpp_reader *pfile, const cpp_hashnode *node)
if (token->type == CPP_MACRO_ARG)
len += NODE_LEN (macro->params[token->val.arg_no - 1]);
else
- len += cpp_token_len (token) + 1; /* Includes room for ' '. */
+ len += cpp_token_len (token);
+
if (token->flags & STRINGIFY_ARG)
len++; /* "#" */
if (token->flags & PASTE_LEFT)
len += 3; /* " ##" */
+ if (token->flags & PREV_WHITE)
+ len++; /* " " */
}
}
@@ -1701,10 +1705,10 @@ cpp_macro_definition (cpp_reader *pfile, const cpp_hashnode *node)
if (token->type == CPP_MACRO_ARG)
{
- len = NODE_LEN (macro->params[token->val.arg_no - 1]);
memcpy (buffer,
- NODE_NAME (macro->params[token->val.arg_no - 1]), len);
- buffer += len;
+ NODE_NAME (macro->params[token->val.arg_no - 1]),
+ NODE_LEN (macro->params[token->val.arg_no - 1]));
+ buffer += NODE_LEN (macro->params[token->val.arg_no - 1]);
}
else
buffer = cpp_spell_token (pfile, token, buffer);