From: Steve Hancock Date: Sun, 2 May 2021 04:14:07 +0000 (-0700) Subject: Correct brace types mismarked by tokenizer X-Git-Tag: 20210402.01~58 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=dac97cba4558595d8441579b3b587f6ccca8e209;p=perltidy.git Correct brace types mismarked by tokenizer --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 3410b651..6bd766f9 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -4943,6 +4943,19 @@ sub dump_verbatim { return; } +my %wU; +my %wiq; + +BEGIN { + + # added 'U' to fix cases b1125 b1126 b1127 + my @q = qw(w U); + @{wU}{@q} = (1) x scalar(@q); + + @q = qw(w i q Q G C Z); + @{wiq}{@q} = (1) x scalar(@q); +} + sub respace_tokens { my $self = shift; @@ -6045,7 +6058,9 @@ sub respace_tokens { $Knn2 = $self->K_next_nonblank( $Knn1, $rLL_new ) if defined($Knn1); $type_nn1 = $rLL_new->[$Knn1]->[_TYPE_] if ( defined($Knn1) ); $type_nn2 = $rLL_new->[$Knn2]->[_TYPE_] if ( defined($Knn2) ); - if ( $type_nn1 eq 'w' && $type_nn2 =~ /^[wiqQGCZ]$/ ) { + + # if ( $type_nn1 =~ /^[wU]$/ && $type_nn2 =~ /^[wiqQGCZ]$/ ) { + if ( $wU{$type_nn1} && $wiq{$type_nn2} ) { $is_list = 0; } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 377f1ba7..b4ce52a1 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,16 @@ =over 4 +=item B + +This is a generalization of commit 7d23bf4 to fix some additional cases +found in random testing in which the type of a curly brace could not be +determined in the tokenizer and was not being corrected by the formatter. + +This fixes cases b1125 b1126 b1127. + +2 May 2021. + =item B Random testing produced several cases in which the flags -bbx=2 -lp and -xci