forked from Imagelibrary/binutils-gdb
gas: adjust handling of quotes for .irpc
The present handling of inner double quotes can lead to very strange
diagnostics. Follow one of the two possible interpretations of the doc:
@dots{} referring to possibly multiple white space separated
@var{values}, each of which may be quoted. The original implementation,
prior to 465e561723 ("PR gas/3856"), hints at the other possible
interpretation: When quoted there's only a single @var{values}, with
inner quotes taken as ordinary characters. That, however, seems overall
less useful to me.
While touching the documentation, mirror the (inverse) spelling
correction (@section line inconsistent with actual description) to .irp
as well.
This commit is contained in:
@@ -5859,7 +5859,7 @@ processing must also be performed upon the symbols as well.
|
|||||||
@end ifset
|
@end ifset
|
||||||
|
|
||||||
@node Irp
|
@node Irp
|
||||||
@section @code{.irp @var{symbol},@var{values}}@dots{}
|
@section @code{.irp @var{symbol},@var{value}}@dots{}
|
||||||
|
|
||||||
@cindex @code{irp} directive
|
@cindex @code{irp} directive
|
||||||
Evaluate a sequence of statements assigning different values to @var{symbol}.
|
Evaluate a sequence of statements assigning different values to @var{symbol}.
|
||||||
@@ -5893,12 +5893,13 @@ For some caveats with the spelling of @var{symbol}, see also @ref{Macro}.
|
|||||||
|
|
||||||
@cindex @code{irpc} directive
|
@cindex @code{irpc} directive
|
||||||
Evaluate a sequence of statements assigning different values to @var{symbol}.
|
Evaluate a sequence of statements assigning different values to @var{symbol}.
|
||||||
The sequence of statements starts at the @code{.irpc} directive, and is
|
The sequence of statements starts at the line following the @code{.irpc}
|
||||||
terminated by an @code{.endr} directive. For each character in @var{value},
|
directive, and is terminated by an @code{.endr} directive. For each character
|
||||||
@var{symbol} is set to the character, and the sequence of statements is
|
in each (possibly double quoted) @var{values}, @var{symbol} is set to the
|
||||||
assembled. If no @var{value} is listed, the sequence of statements is
|
character, and the sequence of statements is assembled. If no @var{values} is
|
||||||
assembled once, with @var{symbol} set to the null string. To refer to
|
listed, the sequence of statements is assembled once, with @var{symbol} set to
|
||||||
@var{symbol} within the sequence of statements, use @var{\symbol}.
|
the null string. To refer to @var{symbol} within the sequence of statements,
|
||||||
|
use @var{\symbol}.
|
||||||
|
|
||||||
For example, assembling
|
For example, assembling
|
||||||
|
|
||||||
|
|||||||
20
gas/macro.c
20
gas/macro.c
@@ -1369,12 +1369,6 @@ expand_irp (int irpc, size_t idx, sb *in, sb *out, size_t (*get_line) (sb *))
|
|||||||
{
|
{
|
||||||
bool in_quotes = false;
|
bool in_quotes = false;
|
||||||
|
|
||||||
if (irpc && in->ptr[idx] == '"')
|
|
||||||
{
|
|
||||||
in_quotes = true;
|
|
||||||
++idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (idx < in->len)
|
while (idx < in->len)
|
||||||
{
|
{
|
||||||
if (!irpc)
|
if (!irpc)
|
||||||
@@ -1383,16 +1377,14 @@ expand_irp (int irpc, size_t idx, sb *in, sb *out, size_t (*get_line) (sb *))
|
|||||||
{
|
{
|
||||||
if (in->ptr[idx] == '"')
|
if (in->ptr[idx] == '"')
|
||||||
{
|
{
|
||||||
size_t nxt;
|
in_quotes = ! in_quotes;
|
||||||
|
++idx;
|
||||||
|
|
||||||
if (irpc)
|
if (! in_quotes)
|
||||||
in_quotes = ! in_quotes;
|
|
||||||
|
|
||||||
nxt = sb_skip_white (idx + 1, in);
|
|
||||||
if (nxt >= in->len)
|
|
||||||
{
|
{
|
||||||
idx = nxt;
|
idx = sb_skip_white (idx, in);
|
||||||
break;
|
if (idx >= in->len)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb_reset (&f.actual);
|
sb_reset (&f.actual);
|
||||||
|
|||||||
18
gas/testsuite/gas/macros/irpc-quote.l
Normal file
18
gas/testsuite/gas/macros/irpc-quote.l
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# This should match the output of gas irpc-quote.s.
|
||||||
|
#...
|
||||||
|
> <
|
||||||
|
>a<
|
||||||
|
>b<
|
||||||
|
>c<
|
||||||
|
>d<
|
||||||
|
> <
|
||||||
|
>e<
|
||||||
|
>f<
|
||||||
|
>1<
|
||||||
|
>2<
|
||||||
|
> <
|
||||||
|
>3<
|
||||||
|
>4<
|
||||||
|
>5<
|
||||||
|
>6<
|
||||||
|
> <
|
||||||
6
gas/testsuite/gas/macros/irpc-quote.s
Normal file
6
gas/testsuite/gas/macros/irpc-quote.s
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.irpc c, " ab" cd " ef"
|
||||||
|
.print ">\c<"
|
||||||
|
.endr
|
||||||
|
.irpc c, "12 " 34 "56 "
|
||||||
|
.print ">\c<"
|
||||||
|
.endr
|
||||||
@@ -109,3 +109,5 @@ run_list_test count
|
|||||||
# AIX targets need an extended regexp to match "\+".
|
# AIX targets need an extended regexp to match "\+".
|
||||||
setup_xfail "avr-*-*" "cris*-*-*" "msp430-*-*" "z80-*-*" "*-*-aix*"
|
setup_xfail "avr-*-*" "cris*-*-*" "msp430-*-*" "z80-*-*" "*-*-aix*"
|
||||||
run_list_test irp-count
|
run_list_test irp-count
|
||||||
|
|
||||||
|
run_list_test irpc-quote
|
||||||
|
|||||||
Reference in New Issue
Block a user