]> git.donarmstrong.com Git - perltidy.git/commitdiff
patched problem parsing here target in quote in pattern replacement string
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 19 Jan 2020 15:31:17 +0000 (07:31 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 19 Jan 2020 15:31:17 +0000 (07:31 -0800)
lib/Perl/Tidy/Tokenizer.pm
t/snippets/expect/here2.def [new file with mode: 0644]
t/snippets/here2.in [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets16.t

index 2c445b7960cef801595b49e238539139f251f2b5..a82aa9d8a685cd7dfaff21c0376939c5d12691dc 100644 (file)
@@ -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 (file)
index 0000000..a7ffe24
--- /dev/null
@@ -0,0 +1,6 @@
+$_ = "";
+s|(?:)|"${\<<END}"
+ok $test - here2.in "" in multiline s///e outside eval
+END
+|e;
+print $_ || "not ok $test\n";
diff --git a/t/snippets/here2.in b/t/snippets/here2.in
new file mode 100644 (file)
index 0000000..a7ffe24
--- /dev/null
@@ -0,0 +1,6 @@
+$_ = "";
+s|(?:)|"${\<<END}"
+ok $test - here2.in "" in multiline s///e outside eval
+END
+|e;
+print $_ || "not ok $test\n";
index a9736c668ea7b21867e3f6e8e9d1f1d42268be1b..a959c9d458c9e362810c04acae7f706c2e7a2720 100644 (file)
 ../snippets16.t        ndsm1.ndsm
 ../snippets16.t        rt131288.def
 ../snippets16.t        rt130394.rt130394
+../snippets16.t        git18.def
 ../snippets2.t angle.def
 ../snippets2.t arrows1.def
 ../snippets2.t arrows2.def
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets16.t        git18.def
+../snippets16.t        here2.def
index a4cb2be2ba5d1bf7292d11627d2a371635573e1b..20da519ff6ade1d4539860c215de65fd30a33464 100644 (file)
@@ -19,6 +19,7 @@
 #16 rt131288.def
 #17 rt130394.rt130394
 #18 git18.def
+#19 here2.def
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -110,6 +111,15 @@ my %bb = (
 foreach my $key ( keys %bb ) {
     print "key='$key' => $bb{$key}\n";
 }
+----------
+
+        'here2' => <<'----------',
+$_ = "";
+s|(?:)|"${\<<END}"
+ok $test - here2.in "" in multiline s///e outside eval
+END
+|e;
+print $_ || "not ok $test\n";
 ----------
 
         'multiple_equals' => <<'----------',
@@ -405,6 +415,19 @@ foreach my $key ( keys %bb ) {
 }
 #18...........
         },
+
+        'here2.def' => {
+            source => "here2",
+            params => "def",
+            expect => <<'#19...........',
+$_ = "";
+s|(?:)|"${\<<END}"
+ok $test - here2.in "" in multiline s///e outside eval
+END
+|e;
+print $_ || "not ok $test\n";
+#19...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};