* [PATCH] macro code cleanup
@ 2005-05-09 15:57 Jan Beulich
2005-05-10 0:28 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2005-05-09 15:57 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 4456 bytes --]
Some cleanup in the macro handling code.
Built and tested natively on x86_64-unknown-linux-gnu and as cross tools
for a large number of targets.
Jan
gas/
2005-05-09 Jan Beulich <jbeulich@novell.com>
* macro.c (get_any_string): Remove the two last parameters. Replace
references to the former expand parameter by using macro_alternate.
Simplify loop condition for checking for end-of-string.
(get_string): Remove redunant call to sb_skip_white.
(do_formals): Remove two last arguments to get_any_string.
(macro_expand): Likewise.
(expand_irp): Likewise.
--- /home/jbeulich/src/binutils/mainline/2005-05-06/gas/macro.c 2005-05-06 08:46:28.000000000 +0200
+++ 2005-05-06/gas/macro.c 2005-05-09 11:57:31.739244312 +0200
@@ -70,7 +70,7 @@ extern void *alloca ();
static int get_token (int, sb *, sb *);
static int getstring (int, sb *, sb *);
-static int get_any_string (int, sb *, sb *, int, int);
+static int get_any_string (int, sb *, sb *);
static formal_entry *new_formal (void);
static void del_formal (formal_entry *);
static int do_formals (macro_entry *, int, sb *);
@@ -304,8 +304,6 @@ get_token (int idx, sb *in, sb *name)
static int
getstring (int idx, sb *in, sb *acc)
{
- idx = sb_skip_white (idx, in);
-
while (idx < in->len
&& (in->ptr[idx] == '"'
|| (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
@@ -390,7 +388,7 @@ getstring (int idx, sb *in, sb *acc)
*/
static int
-get_any_string (int idx, sb *in, sb *out, int expand, int pretend_quoted)
+get_any_string (int idx, sb *in, sb *out)
{
sb_reset (out);
idx = sb_skip_white (idx, in);
@@ -402,9 +400,7 @@ get_any_string (int idx, sb *in, sb *out
while (!ISSEP (in->ptr[idx]))
sb_add_char (out, in->ptr[idx++]);
}
- else if (in->ptr[idx] == '%'
- && macro_alternate
- && expand)
+ else if (in->ptr[idx] == '%' && macro_alternate)
{
int val;
char buf[20];
@@ -421,9 +417,7 @@ get_any_string (int idx, sb *in, sb *out
|| (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
|| (macro_alternate && in->ptr[idx] == '\''))
{
- if (macro_alternate
- && ! macro_strip_at
- && expand)
+ if (macro_alternate && ! macro_strip_at)
{
/* Keep the quotes. */
sb_add_char (out, '\"');
@@ -439,14 +433,11 @@ get_any_string (int idx, sb *in, sb *out
else
{
while (idx < in->len
- && (in->ptr[idx] == '"'
- || in->ptr[idx] == '\''
- || pretend_quoted
- || (in->ptr[idx] != ' '
- && in->ptr[idx] != '\t'
- && in->ptr[idx] != ','
- && (in->ptr[idx] != '<'
- || (! macro_alternate && ! macro_mri)))))
+ && in->ptr[idx] != ' '
+ && in->ptr[idx] != '\t'
+ && in->ptr[idx] != ','
+ && (in->ptr[idx] != '<'
+ || (! macro_alternate && ! macro_mri)))
{
if (in->ptr[idx] == '"'
|| in->ptr[idx] == '\'')
@@ -555,7 +546,7 @@ do_formals (macro_entry *macro, int idx,
if (idx < in->len && in->ptr[idx] == '=')
{
/* Got a default. */
- idx = get_any_string (idx + 1, in, &formal->def, 1, 0);
+ idx = get_any_string (idx + 1, in, &formal->def);
idx = sb_skip_white (idx, in);
if (formal->type == FORMAL_REQUIRED)
{
@@ -1040,7 +1031,7 @@ macro_expand (int idx, sb *in, macro_ent
n->next = m->formals;
m->formals = n;
- idx = get_any_string (idx, in, &n->actual, 1, 0);
+ idx = get_any_string (idx, in, &n->actual);
}
}
}
@@ -1090,7 +1081,7 @@ macro_expand (int idx, sb *in, macro_ent
m->name);
sb_reset (&ptr->actual);
}
- idx = get_any_string (idx + 1, in, &ptr->actual, 0, 0);
+ idx = get_any_string (idx + 1, in, &ptr->actual);
if (ptr->actual.len > 0)
++narg;
}
@@ -1129,7 +1120,7 @@ macro_expand (int idx, sb *in, macro_ent
}
if (f->type != FORMAL_VARARG)
- idx = get_any_string (idx, in, &f->actual, 1, 0);
+ idx = get_any_string (idx, in, &f->actual);
else
{
sb_add_buffer (&f->actual, in->ptr + idx, in->len - idx);
@@ -1350,7 +1341,7 @@ expand_irp (int irpc, int idx, sb *in, s
while (idx < in->len)
{
if (!irpc)
- idx = get_any_string (idx, in, &f.actual, 1, 0);
+ idx = get_any_string (idx, in, &f.actual);
else
{
if (in->ptr[idx] == '"')
[-- Attachment #2: binutils-mainline-macro-cleanup.patch --]
[-- Type: text/plain, Size: 4320 bytes --]
Some cleanup in the macro handling code.
Built and tested natively on x86_64-unknown-linux-gnu and as cross tools
for a large number of targets.
Jan
gas/
2005-05-09 Jan Beulich <jbeulich@novell.com>
* macro.c (get_any_string): Remove the two last parameters. Replace
references to the former expand parameter by using macro_alternate.
Simplify loop condition for checking for end-of-string.
(get_string): Remove redunant call to sb_skip_white.
(do_formals): Remove two last arguments to get_any_string.
(macro_expand): Likewise.
(expand_irp): Likewise.
--- /home/jbeulich/src/binutils/mainline/2005-05-06/gas/macro.c 2005-05-06 08:46:28.000000000 +0200
+++ 2005-05-06/gas/macro.c 2005-05-09 11:57:31.739244312 +0200
@@ -70,7 +70,7 @@ extern void *alloca ();
static int get_token (int, sb *, sb *);
static int getstring (int, sb *, sb *);
-static int get_any_string (int, sb *, sb *, int, int);
+static int get_any_string (int, sb *, sb *);
static formal_entry *new_formal (void);
static void del_formal (formal_entry *);
static int do_formals (macro_entry *, int, sb *);
@@ -304,8 +304,6 @@ get_token (int idx, sb *in, sb *name)
static int
getstring (int idx, sb *in, sb *acc)
{
- idx = sb_skip_white (idx, in);
-
while (idx < in->len
&& (in->ptr[idx] == '"'
|| (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
@@ -390,7 +388,7 @@ getstring (int idx, sb *in, sb *acc)
*/
static int
-get_any_string (int idx, sb *in, sb *out, int expand, int pretend_quoted)
+get_any_string (int idx, sb *in, sb *out)
{
sb_reset (out);
idx = sb_skip_white (idx, in);
@@ -402,9 +400,7 @@ get_any_string (int idx, sb *in, sb *out
while (!ISSEP (in->ptr[idx]))
sb_add_char (out, in->ptr[idx++]);
}
- else if (in->ptr[idx] == '%'
- && macro_alternate
- && expand)
+ else if (in->ptr[idx] == '%' && macro_alternate)
{
int val;
char buf[20];
@@ -421,9 +417,7 @@ get_any_string (int idx, sb *in, sb *out
|| (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
|| (macro_alternate && in->ptr[idx] == '\''))
{
- if (macro_alternate
- && ! macro_strip_at
- && expand)
+ if (macro_alternate && ! macro_strip_at)
{
/* Keep the quotes. */
sb_add_char (out, '\"');
@@ -439,14 +433,11 @@ get_any_string (int idx, sb *in, sb *out
else
{
while (idx < in->len
- && (in->ptr[idx] == '"'
- || in->ptr[idx] == '\''
- || pretend_quoted
- || (in->ptr[idx] != ' '
- && in->ptr[idx] != '\t'
- && in->ptr[idx] != ','
- && (in->ptr[idx] != '<'
- || (! macro_alternate && ! macro_mri)))))
+ && in->ptr[idx] != ' '
+ && in->ptr[idx] != '\t'
+ && in->ptr[idx] != ','
+ && (in->ptr[idx] != '<'
+ || (! macro_alternate && ! macro_mri)))
{
if (in->ptr[idx] == '"'
|| in->ptr[idx] == '\'')
@@ -555,7 +546,7 @@ do_formals (macro_entry *macro, int idx,
if (idx < in->len && in->ptr[idx] == '=')
{
/* Got a default. */
- idx = get_any_string (idx + 1, in, &formal->def, 1, 0);
+ idx = get_any_string (idx + 1, in, &formal->def);
idx = sb_skip_white (idx, in);
if (formal->type == FORMAL_REQUIRED)
{
@@ -1040,7 +1031,7 @@ macro_expand (int idx, sb *in, macro_ent
n->next = m->formals;
m->formals = n;
- idx = get_any_string (idx, in, &n->actual, 1, 0);
+ idx = get_any_string (idx, in, &n->actual);
}
}
}
@@ -1090,7 +1081,7 @@ macro_expand (int idx, sb *in, macro_ent
m->name);
sb_reset (&ptr->actual);
}
- idx = get_any_string (idx + 1, in, &ptr->actual, 0, 0);
+ idx = get_any_string (idx + 1, in, &ptr->actual);
if (ptr->actual.len > 0)
++narg;
}
@@ -1129,7 +1120,7 @@ macro_expand (int idx, sb *in, macro_ent
}
if (f->type != FORMAL_VARARG)
- idx = get_any_string (idx, in, &f->actual, 1, 0);
+ idx = get_any_string (idx, in, &f->actual);
else
{
sb_add_buffer (&f->actual, in->ptr + idx, in->len - idx);
@@ -1350,7 +1341,7 @@ expand_irp (int irpc, int idx, sb *in, s
while (idx < in->len)
{
if (!irpc)
- idx = get_any_string (idx, in, &f.actual, 1, 0);
+ idx = get_any_string (idx, in, &f.actual);
else
{
if (in->ptr[idx] == '"')
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] macro code cleanup
2005-05-09 15:57 [PATCH] macro code cleanup Jan Beulich
@ 2005-05-10 0:28 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2005-05-10 0:28 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
On Mon, May 09, 2005 at 05:20:57PM +0200, Jan Beulich wrote:
> * macro.c (get_any_string): Remove the two last parameters. Replace
> references to the former expand parameter by using macro_alternate.
> Simplify loop condition for checking for end-of-string.
> (get_string): Remove redunant call to sb_skip_white.
> (do_formals): Remove two last arguments to get_any_string.
> (macro_expand): Likewise.
> (expand_irp): Likewise.
OK.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-09 23:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-09 15:57 [PATCH] macro code cleanup Jan Beulich
2005-05-10 0:28 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).