You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
buf = _cpp_builtin_macro_text (pfile, node);
len = ustrlen (buf);
- nbuf = alloca (len + 1);
+ nbuf = (char *) alloca (len + 1);
memcpy (nbuf, buf, len);
nbuf[len]='\n';
{
_cpp_buff *buff = _cpp_get_buff (pfile, len);
unsigned char *buf = BUFF_FRONT (buff);
- len = cpp_spell_token (pfile, token, buf) - buf;
+ len = cpp_spell_token (pfile, token, buf, true) - buf;
dest = cpp_quote_string (dest, buf, len);
_cpp_release_buff (pfile, buff);
}
else
- dest = cpp_spell_token (pfile, token, dest);
+ dest = cpp_spell_token (pfile, token, dest, true);
if (token->type == CPP_OTHER && token->val.str.text[0] == '\\')
backslash_count++;
lhs = *plhs;
len = cpp_token_len (lhs) + cpp_token_len (rhs) + 1;
- buf = alloca (len);
- end = cpp_spell_token (pfile, lhs, buf);
+ buf = (unsigned char *) alloca (len);
+ end = cpp_spell_token (pfile, lhs, buf, false);
/* Avoid comment headers, since they are still processed in stage 3.
It is simpler to insert a space here, rather than modifying the
false doesn't work, since we want to clear the PASTE_LEFT flag. */
if (lhs->type == CPP_DIV && rhs->type != CPP_EQ)
*end++ = ' ';
- end = cpp_spell_token (pfile, rhs, end);
+ end = cpp_spell_token (pfile, rhs, end, false);
*end = '\n';
cpp_push_buffer (pfile, buf, end - buf, /* from_stage3 */ true);
{
cpp_token *token = _cpp_temp_token (pfile);
token->type = (*paste_flag)->type;
- token->val.str = (*paste_flag)->val.str;
+ token->val = (*paste_flag)->val;
if (src->flags & PASTE_LEFT)
token->flags = (*paste_flag)->flags | PASTE_LEFT;
else
/* Loop, reading in the arguments. */
capacity = 256;
- arg->expanded = xmalloc (capacity * sizeof (cpp_token *));
+ arg->expanded = XNEWVEC (const cpp_token *, capacity);
push_ptoken_context (pfile, NULL, NULL, arg->first, arg->count + 1);
for (;;)
if (arg->expanded_count + 1 >= capacity)
{
capacity *= 2;
- arg->expanded = xrealloc (arg->expanded,
- capacity * sizeof (cpp_token *));
+ arg->expanded = XRESIZEVEC (const cpp_token *, arg->expanded,
+ capacity);
}
token = cpp_get_token (pfile);
cpp_token *t = _cpp_temp_token (pfile);
t->type = result->type;
t->flags = result->flags | NO_EXPAND;
- t->val.str = result->val.str;
+ t->val = result->val;
result = t;
}
len = macro->paramc * sizeof (union _cpp_hashnode_value);
if (len > pfile->macro_buffer_len)
{
- pfile->macro_buffer = xrealloc (pfile->macro_buffer, len);
+ pfile->macro_buffer = XRESIZEVEC (unsigned char, pfile->macro_buffer,
+ len);
pfile->macro_buffer_len = len;
}
((union _cpp_hashnode_value *) pfile->macro_buffer)[macro->paramc - 1]
/* Success. Commit or allocate the parameter array. */
if (pfile->hash_table->alloc_subobject)
{
- cpp_hashnode **params = pfile->hash_table->alloc_subobject
- (sizeof (cpp_hashnode *) * macro->paramc);
+ cpp_hashnode **params =
+ (cpp_hashnode **) pfile->hash_table->alloc_subobject
+ (sizeof (cpp_hashnode *) * macro->paramc);
memcpy (params, macro->params,
sizeof (cpp_hashnode *) * macro->paramc);
macro->params = params;
macro->fun_like = 1;
}
else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE))
- cpp_error (pfile, CPP_DL_PEDWARN,
- "ISO C requires whitespace after the macro name");
+ {
+ /* While ISO C99 requires whitespace before replacement text
+ in a macro definition, ISO C90 with TC1 allows there characters
+ from the basic source character set. */
+ if (CPP_OPTION (pfile, c99))
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "ISO C99 requires whitespace after the macro name");
+ else
+ {
+ int warntype = CPP_DL_WARNING;
+ switch (ctoken->type)
+ {
+ case CPP_ATSIGN:
+ case CPP_AT_NAME:
+ case CPP_OBJC_STRING:
+ /* '@' is not in basic character set. */
+ warntype = CPP_DL_PEDWARN;
+ break;
+ case CPP_OTHER:
+ /* Basic character set sans letters, digits and _. */
+ if (strchr ("!\"#%&'()*+,-./:;<=>?[\\]^{|}~",
+ ctoken->val.str.text[0]) == NULL)
+ warntype = CPP_DL_PEDWARN;
+ break;
+ default:
+ /* All other tokens start with a character from basic
+ character set. */
+ break;
+ }
+ cpp_error (pfile, warntype,
+ "missing whitespace after the macro name");
+ }
+ }
if (macro->fun_like)
token = lex_expansion_token (pfile, macro);
/* Commit or allocate the memory. */
if (pfile->hash_table->alloc_subobject)
{
- cpp_token *tokns = pfile->hash_table->alloc_subobject (sizeof (cpp_token)
- * macro->count);
+ cpp_token *tokns =
+ (cpp_token *) pfile->hash_table->alloc_subobject (sizeof (cpp_token)
+ * macro->count);
memcpy (tokns, macro->exp.tokens, sizeof (cpp_token) * macro->count);
macro->exp.tokens = tokns;
}
bool ok;
if (pfile->hash_table->alloc_subobject)
- macro = pfile->hash_table->alloc_subobject (sizeof (cpp_macro));
+ macro = (cpp_macro *) pfile->hash_table->alloc_subobject
+ (sizeof (cpp_macro));
else
macro = (cpp_macro *) _cpp_aligned_alloc (pfile, sizeof (cpp_macro));
macro->line = pfile->directive_line;
if (len > pfile->macro_buffer_len)
{
- pfile->macro_buffer = xrealloc (pfile->macro_buffer, len);
+ pfile->macro_buffer = XRESIZEVEC (unsigned char,
+ pfile->macro_buffer, len);
pfile->macro_buffer_len = len;
}
buffer += NODE_LEN (macro->params[token->val.arg_no - 1]);
}
else
- buffer = cpp_spell_token (pfile, token, buffer);
+ buffer = cpp_spell_token (pfile, token, buffer, false);
if (token->flags & PASTE_LEFT)
{