From: Steve Hancock Date: Tue, 29 Oct 2019 19:12:37 +0000 (-0700) Subject: code cleanups X-Git-Tag: 20191203~13 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e8fd5d822014e33695ccf2e893ea27109d69deb5;p=perltidy.git code cleanups --- diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 825f3315..f0106612 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -273,7 +273,7 @@ sub catfile { my $test_file = $path . $name; my ( $test_name, $test_path ) = fileparse($test_file); return $test_file if ( $test_name eq $name ); - return if ( $^O eq 'VMS' ); + return if ( $^O eq 'VMS' ); # this should work at least for Windows and Unix: $test_file = $path . '/' . $name; @@ -1812,7 +1812,7 @@ sub generate_options { $add_option->( 'trim-pod', 'trp', '!' ); $add_option->( 'want-left-space', 'wls', '=s' ); $add_option->( 'want-right-space', 'wrs', '=s' ); - $add_option->( 'space-prototype-paren', 'spp', '=i' ); + $add_option->( 'space-prototype-paren', 'spp', '=i' ); ######################################## $category = 4; # Comment controls diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index d537b9c6..cafe0d6f 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -151,7 +151,7 @@ sub check_options { # Check Tokenizer parameters my $rOpts = shift; - %is_sub = ( ); + %is_sub = (); $is_sub{'sub'} = 1; # Install any aliases to 'sub' @@ -6193,7 +6193,7 @@ sub scan_identifier_do { # In something like '$${' we have type '$$' (and only # part of an identifier) && !( $identifier =~ /\$$/ && $tok eq '{' ) - && ( $identifier !~ /^(sub |package )$/ ) + && ( $identifier !~ /^(sub |package )$/ ) ) { $type = 'i'; diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index af12cb62..326f5267 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -2581,6 +2581,12 @@ sub delete_unmatched_tokens { # is_deeply( $foo->hash_int, {}, "hash_int - correct contents" ); $is_marginal ||= ( $all_high_level && $raw_tokb eq '{' ); + # lines with differing number of alignment tokens are marginal + # except for assignments + $is_marginal ||= + ( $previous_maximum_jmax_seen != $previous_minimum_jmax_seen ) + && !$is_assignment{$raw_tokb}; + # See if the lines end with semicolons... my $rpatterns0 = $group_lines[0]->get_rpatterns(); my $rpatterns1 = $group_lines[1]->get_rpatterns(); @@ -2681,14 +2687,8 @@ sub delete_unmatched_tokens { } } - my $do_not_align = - - # don't align if it was just a marginal match - $is_marginal - - # or lines with differing number of alignment tokens - || ( $previous_maximum_jmax_seen != $previous_minimum_jmax_seen - && !$leading_equals ); + # don't align if it was just a marginal match + my $do_not_align = $is_marginal; # But try to convert them into a simple comment group if the first line # a has side comment