From: Vincent Pit Date: Tue, 12 Jul 2016 14:52:50 +0000 (-0300) Subject: Properly handle heredocs X-Git-Tag: rt115392 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=9c2c446caee84d8556c07d6175b0fabe88c1de3a;p=perl%2Fmodules%2Findirect.git Properly handle heredocs This fixes RT #115392. --- diff --git a/MANIFEST b/MANIFEST index 9c3bb7e..7f3d8d6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -52,6 +52,7 @@ t/lib/indirect/TestRequired5/c0.pm t/lib/indirect/TestRequired5/d0.pm t/lib/indirect/TestRequired6.pm t/lib/indirect/TestRequiredGlobal.pm +t/testcases/rt115392.pl xsh/caps.h xsh/debug.h xsh/hints.h diff --git a/Makefile.PL b/Makefile.PL index 430cc53..a084ca5 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -65,6 +65,7 @@ my %PREREQ_PM = ( my %BUILD_REQUIRES =( 'Config' => 0, 'ExtUtils::MakeMaker' => 0, + 'File::Spec' => 0, 'IO::Handle' => 0, 'IO::Select' => 0, 'IPC::Open3' => 0, diff --git a/indirect.xs b/indirect.xs index 9e8dc99..ee702c6 100644 --- a/indirect.xs +++ b/indirect.xs @@ -146,6 +146,9 @@ static SV *indirect_hint(pTHX) { # ifndef PL_lex_inwhat # define PL_lex_inwhat PL_parser->lex_inwhat # endif +# ifndef PL_multi_close +# define PL_multi_close PL_parser->multi_close +# endif #else # ifndef PL_linestr # define PL_linestr PL_Ilinestr @@ -159,6 +162,9 @@ static SV *indirect_hint(pTHX) { # ifndef PL_lex_inwhat # define PL_lex_inwhat PL_Ilex_inwhat # endif +# ifndef PL_multi_close +# define PL_multi_close PL_Imulti_close +# endif #endif /* ... Safe version of call_sv() ........................................... */ @@ -333,8 +339,11 @@ static OP *indirect_ck_const(pTHX_ OP *o) { if (SvPOK(sv) && (SvTYPE(sv) >= SVt_PV)) { STRLEN pos; + const char *bufptr; + + bufptr = PL_multi_close == '<' ? PL_bufptr : PL_oldbufptr; - if (indirect_find(sv, PL_oldbufptr, &pos)) { + if (indirect_find(sv, bufptr, &pos)) { STRLEN len; /* If the constant is equal to the current package name, try to look for diff --git a/t/50-external.t b/t/50-external.t index ebf123f..60ed244 100644 --- a/t/50-external.t +++ b/t/50-external.t @@ -5,7 +5,7 @@ use warnings; use Config; -use Test::More tests => 6; +use Test::More tests => 7; use lib 't/lib'; use VPIT::TestHelpers 'run_perl'; @@ -67,3 +67,13 @@ SKIP: { skip RUN_PERL_FAILED() => ($tests - 1) unless defined $status; is $status, 0, 'indirect and local END blocks executed at the end of a forked process'; } + +SKIP: { + my $status; + for my $run (1 .. 10) { + $status = run_perl_file 't/testcases/rt115392.pl'; + skip RUN_PERL_FAILED() => 1 unless defined $status; + last if $status; + } + is $status, 0, 'RT #115392'; +} diff --git a/t/testcases/rt115392.pl b/t/testcases/rt115392.pl new file mode 100644 index 0000000..9fd84ad --- /dev/null +++ b/t/testcases/rt115392.pl @@ -0,0 +1,19 @@ +no indirect; + +<<'END_CODE1'; +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +END_CODE1 + +<<'END_CODE2'; +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxxxx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