aboutsummaryrefslogtreecommitdiff
path: root/gas/macro.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2005-08-08 11:15:33 +0000
committerNick Clifton <nickc@redhat.com>2005-08-08 11:15:33 +0000
commitdf40eaf977e1422cfd1a8e55de7efffdd397447a (patch)
tree2e5ec6ffcc409b1bfb5d8af4eb6409a768a0244f /gas/macro.c
parent957c6e41daa2c75e9e88c85d0076f475a5810d49 (diff)
downloadgdb-df40eaf977e1422cfd1a8e55de7efffdd397447a.zip
gdb-df40eaf977e1422cfd1a8e55de7efffdd397447a.tar.gz
gdb-df40eaf977e1422cfd1a8e55de7efffdd397447a.tar.bz2
PR 1070
* macro.c (getstring): Treat round parentheses in the same way as angle brackets. (get_any_string): Likewise.
Diffstat (limited to 'gas/macro.c')
-rw-r--r--gas/macro.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/gas/macro.c b/gas/macro.c
index afc560f..fbe2666 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -306,14 +306,19 @@ getstring (int idx, sb *in, sb *acc)
{
while (idx < in->len
&& (in->ptr[idx] == '"'
+ || in->ptr[idx] == '('
|| (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
|| (in->ptr[idx] == '\'' && macro_alternate)))
{
- if (in->ptr[idx] == '<')
+ if (in->ptr[idx] == '<'
+ || in->ptr[idx] == '(')
{
int nest = 0;
+ char start_char = in->ptr[idx];
+ char end_char = in->ptr[idx] == '<' ? '>' : ')';
+
idx++;
- while ((in->ptr[idx] != '>' || nest)
+ while ((in->ptr[idx] != end_char || nest)
&& idx < in->len)
{
if (in->ptr[idx] == '!')
@@ -323,9 +328,9 @@ getstring (int idx, sb *in, sb *acc)
}
else
{
- if (in->ptr[idx] == '>')
+ if (in->ptr[idx] == end_char)
nest--;
- if (in->ptr[idx] == '<')
+ if (in->ptr[idx] == start_char)
nest++;
sb_add_char (acc, in->ptr[idx++]);
}
@@ -382,10 +387,10 @@ getstring (int idx, sb *in, sb *acc)
/* Fetch string from the input stream,
rules:
'Bxyx<whitespace> -> return 'Bxyza
- %<char> -> return string of decimal value of x
- "<string>" -> return string
- xyx<whitespace> -> return xyz
-*/
+ %<expr> -> return string of decimal value of <expr>
+ "string" -> return string
+ (string) -> return string
+ xyx<whitespace> -> return xyz. */
static int
get_any_string (int idx, sb *in, sb *out)
@@ -404,6 +409,7 @@ get_any_string (int idx, sb *in, sb *out)
{
int val;
char buf[20];
+
/* Turns the next expression into a string. */
/* xgettext: no-c-format */
idx = (*macro_expr) (_("% operator needs absolute expression"),
@@ -414,6 +420,7 @@ get_any_string (int idx, sb *in, sb *out)
sb_add_string (out, buf);
}
else if (in->ptr[idx] == '"'
+ || in->ptr[idx] == '('
|| (in->ptr[idx] == '<' && (macro_alternate || macro_mri))
|| (macro_alternate && in->ptr[idx] == '\''))
{
@@ -443,6 +450,7 @@ get_any_string (int idx, sb *in, sb *out)
|| in->ptr[idx] == '\'')
{
char tchar = in->ptr[idx];
+
sb_add_char (out, in->ptr[idx++]);
while (idx < in->len
&& in->ptr[idx] != tchar)