/* macro.c - macro support for gas
- Copyright (C) 1994-2016 Free Software Foundation, Inc.
+ Copyright (C) 1994-2019 Free Software Foundation, Inc.
Written by Steve and Judy Chamberlain of Cygnus Support,
sac@cygnus.com
anyway, there's not an obviously better fix here. */
if (strncasecmp (ptr->ptr + i, "linefile", 8) == 0)
{
- char *saved_input_line_pointer = input_line_pointer;
char saved_eol_char = ptr->ptr[ptr->len];
ptr->ptr[ptr->len] = '\0';
- input_line_pointer = ptr->ptr + i + 8;
+ temp_ilp (ptr->ptr + i + 8);
s_app_line (0);
+ restore_ilp ();
ptr->ptr[ptr->len] = saved_eol_char;
- input_line_pointer = saved_input_line_pointer;
ptr->len = line_start;
}
}
{
int nest = 0;
idx++;
- while ((in->ptr[idx] != '>' || nest)
- && idx < in->len)
+ while (idx < in->len
+ && (in->ptr[idx] != '>' || nest))
{
if (in->ptr[idx] == '!')
{
{
if (in->len > idx + 2 && in->ptr[idx + 1] == '\'' && ISBASE (in->ptr[idx]))
{
- while (!ISSEP (in->ptr[idx]))
+ while (idx < in->len && !ISSEP (in->ptr[idx]))
sb_add_char (out, in->ptr[idx++]);
}
else if (in->ptr[idx] == '%' && macro_alternate)
{
offsetT val;
- char buf[20];
+ char buf[64];
/* Turns the next expression into a string. */
/* xgettext: no-c-format */
}
else
{
- char *br_buf = (char *) xmalloc (1);
+ char *br_buf = XNEWVEC (char, 1);
char *in_br = br_buf;
*in_br = '\0';
--in_br;
else
{
- br_buf = (char *) xmalloc (strlen (in_br) + 2);
+ br_buf = XNEWVEC (char, strlen (in_br) + 2);
strcpy (br_buf + 1, in_br);
free (in_br);
in_br = br_buf;
{
formal_entry *formal;
- formal = (formal_entry *) xmalloc (sizeof (formal_entry));
+ formal = XNEW (formal_entry);
sb_new (&formal->name);
sb_new (&formal->def);
const char *
define_macro (size_t idx, sb *in, sb *label,
size_t (*get_line) (sb *),
- char *file, unsigned int line,
+ const char *file, unsigned int line,
const char **namep)
{
macro_entry *macro;
sb name;
const char *error = NULL;
- macro = (macro_entry *) xmalloc (sizeof (macro_entry));
+ macro = XNEW (macro_entry);
sb_new (¯o->sub);
sb_new (&name);
macro->file = file;
}
else
{
- /* Permit macro parameter substition delineated with
+ /* Permit macro parameter substitution delineated with
an '&' prefix and optional '&' suffix. */
src = sub_actual (src + 1, in, &t, formal_hash, '&', out, 0);
}
{
/* Sub in the macro invocation number. */
- char buffer[10];
+ char buffer[12];
src++;
sprintf (buffer, "%d", macro_number);
sb_add_string (out, buffer);
if (is_name_ender (*s))
++s;
- copy = (char *) alloca (s - line + 1);
- memcpy (copy, line, s - line);
- copy[s - line] = '\0';
+ copy = xmemdup0 (line, s - line);
for (cls = copy; *cls != '\0'; cls ++)
*cls = TOLOWER (*cls);
macro = (macro_entry *) hash_find (macro_hash, copy);
+ free (copy);
if (macro == NULL)
return 0;
macro_entry *macro;
len = strlen (name);
- copy = (char *) alloca (len + 1);
+ copy = XNEWVEC (char, len + 1);
for (i = 0; i < len; ++i)
copy[i] = TOLOWER (name[i]);
copy[i] = '\0';
free_macro (macro);
}
else
- as_warn (_("Attempt to purge non-existant macro `%s'"), copy);
+ as_warn (_("Attempt to purge non-existing macro `%s'"), copy);
+ free (copy);
}
/* Handle the MRI IRP and IRPC pseudo-ops. These are handled as a