mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 16:39:36 +00:00
ParseXS: fix handling of empty C_ARGS etc
GH#23407
My recent refactoring work on ParseXS made the parser go into an
infinite loop on multiline_merged nodes such as C_ARGS when there was no
text, e.g.
void
foo(int a)
C_ARGS:
This commit is contained in:
parent
b0823b6ac8
commit
d2d154ba92
@ -3648,7 +3648,7 @@ sub parse {
|
||||
$self->SUPER::parse($pxs); # set file/line_no, read lines
|
||||
|
||||
my @lines = @{$self->{lines}};
|
||||
shift @lines while $lines[0] !~ /\S/;
|
||||
shift @lines while @lines && $lines[0] !~ /\S/;
|
||||
# XXX ParseXS originally didn't include a trailing \n,
|
||||
# so we carry on doing the same.
|
||||
$self->{text} = join "\n", @lines;
|
||||
|
||||
10
dist/ExtUtils-ParseXS/t/001-basic.t
vendored
10
dist/ExtUtils-ParseXS/t/001-basic.t
vendored
@ -1656,6 +1656,16 @@ EOF
|
||||
[ 0, 0, qr/\Qfoo(a, b , bar, c? c : "boo!")/, "" ],
|
||||
],
|
||||
|
||||
[
|
||||
"autocall args empty C_ARGS",
|
||||
[ Q(<<'EOF') ],
|
||||
|void
|
||||
|foo(int a)
|
||||
| C_ARGS:
|
||||
EOF
|
||||
[ 0, 0, qr/\Qfoo()/, "" ],
|
||||
],
|
||||
|
||||
[
|
||||
# Whether this is sensible or not is another matter.
|
||||
# For now, just check that it works as-is.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user