]> git.donarmstrong.com Git - perltidy.git/commitdiff
remove unused code
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 23 Jul 2022 16:47:44 +0000 (09:47 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 23 Jul 2022 16:47:44 +0000 (09:47 -0700)
CHANGES.md
dev-bin/perltidy_random_run.pl
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/Tokenizer.pm

index 9cbb82be313cff077b5eb44e128a44408d296f16..5faa68feda6acf1cd7b26a6347e04be06a5c16e9 100644 (file)
       created for the formatted output.  This caused the inode to change.  For
       the new default method, -bm='copy', the input is copied to the backup
       and then the input file is reopened and rewritten. This preserves the
-      file inode. Before using the --backup-and-modify-in-place
-      parameter please verify that it works correctly in your environment and
-      operating system.
+      file inode.  Tests have not produced any problems with this change, but
+      before using the --backup-and-modify-in-place parameter please verify
+      that it works correctly in your environment and operating system.
 
     - Fix undefined value message when perltidy -D is used (git #104)
 
     - Added parameter --delete-repeated-commas (-drc) to delete repeated
-      commas. This is off by default. For example, given this line:
+      commas. This is off by default. I added this option after discovering
+      an unwanted repeated comma in the perltidy source. For example, given:
 
             ignoreSpec( $file, "file",, \%spec, \%Rspec );
 
       # perltidy -drc:
             ignoreSpec( $file, "file", \%spec, \%Rspec );
 
-    - Fixed a minor inconsistency in html colors when -html is used.
-      Previously, a '->' at the end of a line got a black color by default,
-      but a '->' within a line got the color of the following identifier.
-      Now all pointers get the same color, which is black by default.
+    - Fixed an inconsistency in html colors near pointers when -html is used.
+      Previously, a '->' at the end of a line got the 'punctuation color', black
+      by default but a '->' before an identifier got the color of the following
+      identifier. Now all pointers get the same color, which is black by default.
+      Also, previously a word following a '->' was given the color of a bareword,
+      black by default, but now it is given the color of an identifier.
 
 ## 2022 06 13
 
index 27ee802b69045334f5eba4d6c741b04e9023f26b..59c2b8627e08c511145dc6d5b26aeaa7f27aab75 100755 (executable)
@@ -798,7 +798,7 @@ if ( -e $basename ) {
     for ( my $j = 1 ; $j < 99 ; $j++ ) {
         $ext   = 'ba' . $j;
         $bname = "$basename.$ext";
-        next if ( -e $bname );
+        next if ( -e $bname || -e $bname . ".gz" );
         system "mv $basename $bname";
         last;
     }
index c09eb58575d3f17226bfef841b40f0fb31f7ca35..869eed2813e5f3a4bb7c52a179989333950b10be 100644 (file)
@@ -2522,7 +2522,7 @@ BEGIN {
 
     # The following hash is used to skip over needless if tests.
     # Be sure to update it when adding new checks in its block.
-    my @q = qw(k w C m - Q);
+    my @q = qw(k w C m - Q);
     push @q, '#';
     @is_special_ws_type{@q} = (1) x scalar(@q);
 
@@ -2720,17 +2720,10 @@ sub set_whitespace_flags {
         #---------------------------------------------------------------
         # The hash '%is_special_ws_type' significantly speeds up this routine,
         # but be sure to update it if a new check is added.
-        # Currently has types: qw(k w C m - Q #)
+        # Currently has types: qw(k w C m - Q #)
         if ( $is_special_ws_type{$type} ) {
-            if ( $type eq 'i' ) {
 
-                # never a space before ->
-                if ( substr( $token, 0, 2 ) eq '->' ) {
-                    $ws = WS_NO;
-                }
-            }
-
-            elsif ( $type eq 'k' ) {
+            if ( $type eq 'k' ) {
 
                 # Keywords 'for', 'foreach' are special cases for -kpit since
                 # the opening paren does not always immediately follow the
@@ -2763,11 +2756,6 @@ sub set_whitespace_flags {
             # retain any space between '-' and bare word
             elsif ( $type eq 'w' || $type eq 'C' ) {
                 $ws = WS_OPTIONAL if $last_type eq '-';
-
-                # never a space before ->
-                if ( substr( $token, 0, 2 ) eq '->' ) {
-                    $ws = WS_NO;
-                }
             }
 
             # retain any space between '-' and bare word; for example
@@ -6637,55 +6625,6 @@ sub respace_tokens_inner_loop {
                 }
             }
 
-            # Split identifiers with leading arrows, inserting blanks
-            # if necessary.  It is easier and safer here than in the
-            # tokenizer.  For example '->new' becomes two tokens, '->'
-            # and 'new' with a possible blank between.
-            #
-            # Note: there is a related patch in sub set_whitespace_flags
-            elsif (length($token) > 2
-                && substr( $token, 0, 2 ) eq '->'
-                && $token =~ /^\-\>(.*)$/
-                && $1 )
-            {
-
-                my $token_save = $1;
-                my $type_save  = $type;
-
-                # Change '-> new'  to '->new'
-                $token_save =~ s/^\s+//g;
-
-                # store a blank to left of arrow if necessary
-                my $Kprev = $self->K_previous_nonblank($KK);
-                if (   defined($Kprev)
-                    && $rLL->[$Kprev]->[_TYPE_] ne 'b'
-                    && $rOpts_add_whitespace
-                    && $want_left_space{'->'} == WS_YES )
-                {
-                    my $rcopy = copy_token_as_type( $rtoken_vars, 'b', SPACE );
-                    $self->store_token($rcopy);
-                }
-
-                # then store the arrow
-                my $rcopy = copy_token_as_type( $rtoken_vars, '->', '->' );
-                $self->store_token($rcopy);
-
-                # store a blank after the arrow if requested
-                # added for issue git #33
-                if ( $want_right_space{'->'} == WS_YES ) {
-                    my $rcopy_b =
-                      copy_token_as_type( $rtoken_vars, 'b', SPACE );
-                    $self->store_token($rcopy_b);
-                }
-
-                # then reset the current token to be the remainder,
-                # and reset the whitespace flag according to the arrow
-                $token = $rtoken_vars->[_TOKEN_] = $token_save;
-                $type  = $rtoken_vars->[_TYPE_]  = $type_save;
-                $self->store_token($rtoken_vars);
-                next;
-            }
-
             # Trim certain spaces in identifiers
             if ( $type eq 'i' ) {
 
index 91ee888f2ea66e7eaa5a8a670d1ae0c45afe976f..eddc1809528fd31c369b866e692b51c1bba7c6ba 100644 (file)
@@ -29,9 +29,6 @@ use constant DEVEL_MODE   => 0;
 use constant EMPTY_STRING => q{};
 use constant SPACE        => q{ };
 
-# This can be removed after testing
-use constant OLD_POINTER_LOGIC => 0;
-
 use Perl::Tidy::LineBuffer;
 use Carp;
 
@@ -3319,27 +3316,6 @@ EOM
     sub do_POINTER {
 
         #  '->'
-
-        # OLD POINTER LOGIC:
-        # if -> points to a bare word, we must scan for an identifier,
-        # otherwise something like ->y would look like the y operator
-
-        # NOTE: this will currently allow things like
-        #     '->@array'    '->*VAR'  '->%hash'
-        # to get parsed as identifiers, even though these are not currently
-        # allowed syntax.  To catch syntax errors like this we could first
-        # check that the next character and skip this call if it is one of
-        # ' @ % * '.  A disadvantage with doing this is that this would
-        # have to be fixed if the perltidy syntax is ever extended to make
-        # any of these valid.  So for now this check is not done.
-
-        # POINTER_LOGIC update, Part 1: make pointers separate tokens
-        # and look backwards when scanning the next thing.  This makes the
-        # logic independent of any line breaks and comments between the '->'
-        # and the next tokens.
-        if (OLD_POINTER_LOGIC) {
-            scan_simple_identifier();
-        }
         return;
     } ## end sub do_POINTER
 
@@ -3926,13 +3902,6 @@ EOM
         #    true if this token ends the current line
         #    false otherwise
 
-        # Patch for c043, part 3: A bareword after '->' expects a TERM
-        # FIXME: It would be cleaner to give method calls a new type 'M'
-        # and update sub operator_expected to handle this.
-        if ( $last_nonblank_type eq '->' ) {
-            $expecting = TERM;
-        }
-
         my ( $next_nonblank_token, $i_next ) =
           find_next_nonblank_token( $i, $rtokens, $max_token_index );
 
@@ -3968,10 +3937,19 @@ EOM
 
         # They may also need to check and set various flags
 
+        # Scan a bare word following a -> as an identifier; it could
+        # have a long package name.  Fixes c037, c041.
+        if ( $last_nonblank_token eq '->' ) {
+            scan_bare_identifier();
+
+            # a bareward after '->' gets type 'i'
+            $type = 'i';
+        }
+
         # Quote a word followed by => operator
         # unless the word __END__ or __DATA__ and the only word on
         # the line.
-        if (  !$is_END_or_DATA
+        elsif ( !$is_END_or_DATA
             && $next_nonblank_token eq '='
             && $rtokens->[ $i_next + 1 ] eq '>' )
         {
@@ -3996,25 +3974,6 @@ EOM
             $type = 'w';
         }
 
-        # Scan a bare word following a -> as an identifier; it could
-        # have a long package name.  Fixes c037, c041.
-        elsif ( $last_nonblank_token eq '->' ) {
-            scan_bare_identifier();
-
-            # POINTER_LOGIC update, Part 2: a bareward after '->' gets type 'i'
-            if (OLD_POINTER_LOGIC) {
-
-                # OLD_POINTER_LOGIC to catch a '->' on previous line:
-                # Patch for c043, part 4; use type 'w' after a '->'.
-                # This is just a safety check on sub scan_bare_identifier,
-                # which should get this case correct.
-                $type = 'w';
-            }
-            else {
-                $type = 'i';
-            }
-        }
-
         # handle operator x (now we know it isn't $x=)
         elsif (
                $expecting == OPERATOR