From 78b3e6a4d976332ada4d30abc9c59abf05a80428 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 15 Jan 2024 07:23:36 -0800 Subject: [PATCH] fix b1464 --- dev-bin/run_convergence_tests.pl.data | 18 +++++++++++++++++ dev-bin/run_convergence_tests.pl.expect | 8 ++++++++ lib/Perl/Tidy/Formatter.pm | 27 +++++++++++++++---------- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 3cc9d388..31a9c41e 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -11881,6 +11881,24 @@ die sprintf( --delete-old-whitespace --opening-paren-right +==> b1464.in <== +while ( + $^O !~ /Win32/ and + + my $pid = fork() +) { + my $status = waitpid $pid, 0; + warn "Server restarting in $config->{delay} seconds"; + sleep $config->{delay}; +} + +==> b1464.par <== +--opening-brace-always-on-right +--keep-old-blank-lines=0 +--break-after-all-operators +--keyword-group-blanks-size='2.8' +--keyword-group-blanks-before=2 + ==> b148.in <== # state 1 @yydgoto=( diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect index d7b3327b..7e18b398 100644 --- a/dev-bin/run_convergence_tests.pl.expect +++ b/dev-bin/run_convergence_tests.pl.expect @@ -8039,6 +8039,14 @@ die sprintf( ); +==> b1464 <== +while ( $^O !~ /Win32/ and + my $pid = fork() ) { + my $status = waitpid $pid, 0; + warn "Server restarting in $config->{delay} seconds"; + sleep $config->{delay}; +} + ==> b148 <== # state 1 @yydgoto=( diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 85900d2f..2dda478b 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -12576,6 +12576,20 @@ sub is_in_block_by_i { return; } ## end sub is_in_block_by_i +sub is_in_block_by_K { + my ( $self, $KK ) = @_; + + # returns true if + # token at $KK is contained in a BLOCK + # or is at root level + # or there is some kind of error (i.e. unbalanced file) + # returns false otherwise + + my $parent_seqno = $self->parent_seqno_by_K($KK); + return SEQ_ROOT if ( !$parent_seqno || $parent_seqno eq SEQ_ROOT ); + return $self->[_rblock_type_of_seqno_]->{$parent_seqno}; +} ## end sub is_in_block_by_K + sub is_in_list_by_i { my ( $self, $i ) = @_; @@ -12590,16 +12604,6 @@ sub is_in_list_by_i { return; } ## end sub is_in_list_by_i -sub is_list_by_K { - - # Return true if token K is in a list - my ( $self, $KK ) = @_; - - my $parent_seqno = $self->parent_seqno_by_K($KK); - return unless defined($parent_seqno); - return $self->[_ris_list_by_seqno_]->{$parent_seqno}; -} ## end sub is_list_by_K - sub is_list_by_seqno { # Return true if the immediate contents of a container appears to be a @@ -17500,7 +17504,8 @@ EOM # Do not look for keywords in lists ( keyword 'my' can occur in # lists, see case b760); fixed for c048. - if ( $self->is_list_by_K($K_first) ) { + # Switch from ->is_list_by_K to !->is_in_block_by_K to fix b1464 + if ( !$self->is_in_block_by_K($K_first) ) { if ( $ibeg >= 0 ) { $iend = $i } next; } -- 2.39.5