From dac97cba4558595d8441579b3b587f6ccca8e209 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 1 May 2021 21:14:07 -0700 Subject: [PATCH] Correct brace types mismarked by tokenizer --- lib/Perl/Tidy/Formatter.pm | 17 ++++++++++++++++- local-docs/BugLog.pod | 10 ++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) 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 -- 2.39.5