From: Steve Hancock Date: Sun, 19 Jan 2020 15:31:17 +0000 (-0800) Subject: patched problem parsing here target in quote in pattern replacement string X-Git-Tag: 20200619~139 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=83e3df50e0efeb77b36cfc0d7839030065bb4040;p=perltidy.git patched problem parsing here target in quote in pattern replacement string --- diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 2c445b79..a82aa9d8 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -2776,8 +2776,13 @@ sub prepare_for_a_new_file { } # For an 'e' quote modifier we must scan the replacement - # text for here-doc targets. - if ($saw_modifier_e) { + # text for here-doc targets... + # but if the modifier starts a new line we can skip + # this because either the here doc will be fully + # contained in the replacement text (so we can + # ignore it) or Perl will not find it. + # See test 'here2.in'. + if ( $saw_modifier_e && $i_tok >= 0 ) { my $rht = scan_replacement_text($qs1); diff --git a/t/snippets/expect/here2.def b/t/snippets/expect/here2.def new file mode 100644 index 00000000..a7ffe242 --- /dev/null +++ b/t/snippets/expect/here2.def @@ -0,0 +1,6 @@ +$_ = ""; +s|(?:)|"${\< $bb{$key}\n"; } +---------- + + 'here2' => <<'----------', +$_ = ""; +s|(?:)|"${\< <<'----------', @@ -405,6 +415,19 @@ foreach my $key ( keys %bb ) { } #18........... }, + + 'here2.def' => { + source => "here2", + params => "def", + expect => <<'#19...........', +$_ = ""; +s|(?:)|"${\<