]> git.donarmstrong.com Git - perltidy.git/commitdiff
minor code cleanups
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 19 Sep 2021 15:10:25 +0000 (08:10 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 19 Sep 2021 15:10:25 +0000 (08:10 -0700)
MANIFEST
MANIFEST.SKIP
bin/perltidy
lib/Perl/Tidy/Formatter.pm
t/snippets/dump_negated_switches.pl

index 3e7239d7d3f8d13cb5311847c25609434f162b85..4a47753a53ecbaed2225f0392e4ff43d6befdd3f 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,3 @@
-.github/workflows/perltest.yml
 .pre-commit-hooks.yaml
 bin/perltidy
 BUGS.md
index 883dc63e16774d80e934e2013d134bbc3d98885c..b01027e528890ab48276146e41b717cae72665d2 100644 (file)
@@ -84,7 +84,9 @@
 -[\d\.\_]+\.tar
 -[\d\.\_]+\.tar\.gz
 
+
 # Github files
+\.github
 \.travis\.yml
 
 # Jekyl file
index 05956e1035b04fe74acadb0239cf4a369988af5a..8a50fb446d57585200b73e454aa0eab98d3835dd 100755 (executable)
@@ -4724,8 +4724,8 @@ The following list shows all short parameter names which allow a prefix
  osbc   osbr   otr    ple    pod    pvl    q      sac    sbc    sbl
  scbb   schb   scp    scsb   sct    se     sfp    sfs    skp    sob
  sobb   sohb   sop    sosb   sot    ssc    st     sts    t      tac
- tbc    toc    tp     tqw    trp    ts     tsc    tso    vmll   w
- wn     x      xci    xs
+ tbc    toc    tp     tqw    trp    ts     tsc    tso    vbc    vc
vmll   vsc    w      wn     x      xci    xs
 
 Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be
 used.
index 99e37ba10d9e13492881bab2b63ea294c2f695ee..b5baf84e34b06a491ddc9c60c1150e532fa536f8 100644 (file)
@@ -11534,8 +11534,6 @@ EOM
             my $token         = $rtoken_vars->[_TOKEN_];
             my $type          = $rtoken_vars->[_TYPE_];
             my $type_sequence = $rtoken_vars->[_TYPE_SEQUENCE_];
-            my $block_type =
-              $type_sequence ? $rblock_type_of_seqno->{$type_sequence} : undef;
 
             # If we are continuing after seeing a right curly brace, flush
             # buffer unless we see what we are looking for, as in
@@ -11548,6 +11546,26 @@ EOM
                 $rbrace_follower = undef;
             }
 
+            my ( $block_type, $is_opening_BLOCK, $is_closing_BLOCK );
+            if ($type_sequence) {
+
+                $block_type = $rblock_type_of_seqno->{$type_sequence};
+
+                if (   $block_type
+                    && $token eq $type
+                    && $block_type ne 't'
+                    && !$rshort_nested->{$type_sequence} )
+                {
+
+                    if ( $type eq '{' ) {
+                        $is_opening_BLOCK = 1;
+                    }
+                    elsif ( $type eq '}' ) {
+                        $is_closing_BLOCK = 1;
+                    }
+                }
+            }
+
             # Get next nonblank on this line
             my $next_nonblank_token      = '';
             my $next_nonblank_token_type = 'b';
@@ -11568,18 +11586,6 @@ EOM
             # or closing BLOCK, followed by a side comment, those sections
             # of code will handle this flag separately.
             $side_comment_follows = ( $next_nonblank_token_type eq '#' );
-            my $is_opening_BLOCK =
-              (      $type eq '{'
-                  && $token eq '{'
-                  && $block_type
-                  && !$rshort_nested->{$type_sequence}
-                  && $block_type ne 't' );
-            my $is_closing_BLOCK =
-              (      $type eq '}'
-                  && $token eq '}'
-                  && $block_type
-                  && !$rshort_nested->{$type_sequence}
-                  && $block_type ne 't' );
 
             if (   $side_comment_follows
                 && !$is_opening_BLOCK
@@ -21432,8 +21438,9 @@ sub pad_token {
             }
         }
 
-        # Lines with just 1 token do not have alignments
-        # so we can process them immediately.
+        # ----------------------------------------------------------
+        # Shortcut 1: Lines with just 1 token do not have alignments
+        # ----------------------------------------------------------
         if ( $iend == $ibeg ) {
             @tokens        = ();
             @fields        = ( $tokens_to_go[$ibeg] );
@@ -21452,7 +21459,9 @@ sub pad_token {
             }
         }
 
-        # Optimization: process lines without alignments immediately
+        # -------------------------------------------
+        # Shortcut 2: handle lines without alignments
+        # -------------------------------------------
         if ( !$has_alignment ) {
             @tokens        = ();
             @fields        = ( join( '', @tokens_to_go[ $ibeg .. $iend ] ) );
@@ -21462,6 +21471,9 @@ sub pad_token {
             return ( \@tokens, \@fields, \@patterns, \@field_lengths );
         }
 
+        # --------------------
+        # Loop over all tokens
+        # --------------------
         my $j = 0;    # field index
 
         $patterns[0] = "";
index 4c5d65777e907cb3fd861b71c12a3fa6887ab1a7..a74dd95e4540b3f452da058bc3eebfe136f508d1 100755 (executable)
@@ -81,6 +81,7 @@ foreach my $word ( sort (@short_list, @special) ) {
     $line .= $word;
     $count++;
     if ( $count == $WORDS_PER_LINE ) {
+        $line =~ s/\s+$//;
         print "$line\n";
         $count = 0;
         $line  = " ";