]> git.donarmstrong.com Git - perltidy.git/commitdiff
improved treatment of long lines with here targets
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 8 Sep 2020 15:20:55 +0000 (08:20 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 8 Sep 2020 15:20:55 +0000 (08:20 -0700)
bin/perltidy
lib/Perl/Tidy/Formatter.pm
t/snippets/expect/here_long.def
t/snippets/expect/here_long.here_long
t/snippets/here_long.in
t/snippets/packing_list.txt
t/snippets21.t
t/snippets22.t

index c8753c4a2e8b3d0c85d8cc24a4de014afc99fc71..a6f65a713a0e45a146074d7cf837e23ac3dfe593 100755 (executable)
@@ -3613,9 +3613,9 @@ allow perltidy to parse interactive VMS scripts, but it should be used
 for any script which is normally invoked with C<perl -x>.
 
 Please note: do not use this flag unless you are sure your script needs it.
-Parsing errors can occur if it does not have a hash-bang.  For example, if the
-actual first hash-bang is in a here-doc, a parsing error will occur because the
-tokenization will begin in the middle of the here-doc.
+Parsing errors can occur if it does not have a hash-bang, or, for example, if
+the actual first hash-bang is in a here-doc. In that case a parsing error will
+occur because the tokenization will begin in the middle of the here-doc.
 
 =item  Making a file unreadable
 
index 305b647866c7f53b933bf792da4ee9e341e16f77..f55336409fd88c4a46a3dcb9754ca05b27da937f 100644 (file)
@@ -3056,18 +3056,6 @@ sub respace_tokens {
                 $rtoken_vars->[_TOKEN_] = $token;
             }
 
-            # change code type to be NIN at a here target to avoid breaking the line
-            elsif ( $type eq 'h' ) {
-
-                # 'VB' = Verbatim - line goes out verbatim
-                # 'FS' = Format Skipping - line goes out verbatim, no blanks
-                # 'IO' = Indent Only - only indentation may be changed
-                unless ( $CODE_type && $CODE_type =~ /^(VB|FS|IO)$/ ) {
-                    $CODE_type = 'NIN';
-                    $line_of_tokens->{_code_type} = $CODE_type;
-                }
-            }
-
             # patch to add space to something like "x10"
             # This avoids having to split this token in the pre-tokenizer
             elsif ( $type eq 'n' ) {
@@ -13861,7 +13849,7 @@ sub get_seqno {
                 }
             }
             else {
-                $strength = NO_BREAK;
+                $strength = NO_BREAK + 1;
             }
 
             #---------------------------------------------------------------
index 4a75504eac23afabb4f0ff30645fab9b456806e0..259b9907b3c031d1083829165ba652d4a9a225cd 100644 (file)
@@ -1,4 +1,4 @@
-# must not break first line regardless of value of maximum-line-length
+# must not break after here target regardless of maximum-line-length
 $sth = $dbh->prepare(<<"END_OF_SELECT") or die "Couldn't prepare SQL";
     SELECT COUNT(duration),SUM(duration) 
     FROM logins WHERE username='$user'
index 4a75504eac23afabb4f0ff30645fab9b456806e0..d8998ca18375a73e6988c595ba28b51049b2726c 100644 (file)
@@ -1,5 +1,6 @@
-# must not break first line regardless of value of maximum-line-length
-$sth = $dbh->prepare(<<"END_OF_SELECT") or die "Couldn't prepare SQL";
+# must not break after here target regardless of maximum-line-length
+$sth = $dbh->prepare(
+    <<"END_OF_SELECT") or die "Couldn't prepare SQL";
     SELECT COUNT(duration),SUM(duration) 
     FROM logins WHERE username='$user'
 END_OF_SELECT
index c4548912f79a4c88dc26b127f9572c5ca82473e1..f34d97fe32b72123408112fe1faf546b13d03274 100644 (file)
@@ -1,4 +1,4 @@
-# must not break first line regardless of value of maximum-line-length
+# must not break after here target regardless of maximum-line-length
 $sth= $dbh->prepare (<<"END_OF_SELECT") or die "Couldn't prepare SQL" ;
     SELECT COUNT(duration),SUM(duration) 
     FROM logins WHERE username='$user'
index f4cd202e044a9b66b99aff996bb640ac05bf0cfc..c1c2cd6fc8be52293f36088439dbccc59b560ef9 100644 (file)
 ../snippets21.t        nib.nib2
 ../snippets21.t        scbb-csc.def
 ../snippets21.t        scbb-csc.scbb-csc
+../snippets21.t        here_long.def
+../snippets22.t        here_long.here_long
 ../snippets3.t ce_wn1.ce_wn
 ../snippets3.t ce_wn1.def
 ../snippets3.t colin.colin
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets21.t        here_long.def
-../snippets22.t        here_long.here_long
index 6f684e722a2e99310878915ff418d5238be95f1b..5133d03e32f6dc3f97071ea4c5aef18f862e779f 100644 (file)
@@ -99,7 +99,7 @@ else {                    # We're the third word to have this
 ----------
 
         'here_long' => <<'----------',
-# must not break first line regardless of value of maximum-line-length
+# must not break after here target regardless of maximum-line-length
 $sth= $dbh->prepare (<<"END_OF_SELECT") or die "Couldn't prepare SQL" ;
     SELECT COUNT(duration),SUM(duration) 
     FROM logins WHERE username='$user'
@@ -786,7 +786,7 @@ sub perlmod_install_advice {
             source => "here_long",
             params => "def",
             expect => <<'#19...........',
-# must not break first line regardless of value of maximum-line-length
+# must not break after here target regardless of maximum-line-length
 $sth = $dbh->prepare(<<"END_OF_SELECT") or die "Couldn't prepare SQL";
     SELECT COUNT(duration),SUM(duration) 
     FROM logins WHERE username='$user'
index 6a04e27d244ae5f94e016f1b5bf09fdefcb38aa3..782c7c48e4ec2e123c142f8630eacdb105e364b6 100644 (file)
@@ -26,7 +26,7 @@ BEGIN {
     $rsources = {
 
         'here_long' => <<'----------',
-# must not break first line regardless of value of maximum-line-length
+# must not break after here target regardless of maximum-line-length
 $sth= $dbh->prepare (<<"END_OF_SELECT") or die "Couldn't prepare SQL" ;
     SELECT COUNT(duration),SUM(duration) 
     FROM logins WHERE username='$user'
@@ -44,8 +44,9 @@ END_OF_SELECT
             source => "here_long",
             params => "here_long",
             expect => <<'#1...........',
-# must not break first line regardless of value of maximum-line-length
-$sth = $dbh->prepare(<<"END_OF_SELECT") or die "Couldn't prepare SQL";
+# must not break after here target regardless of maximum-line-length
+$sth = $dbh->prepare(
+    <<"END_OF_SELECT") or die "Couldn't prepare SQL";
     SELECT COUNT(duration),SUM(duration) 
     FROM logins WHERE username='$user'
 END_OF_SELECT