]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix undefined variable reference in development version
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 10 Aug 2021 19:54:51 +0000 (12:54 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 10 Aug 2021 19:54:51 +0000 (12:54 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 71e3653283da3852f7d4a25c916a23a7bf04fb38..0a23345f31fd46a0e883923f9ce47816b5c24e94 100644 (file)
@@ -4732,7 +4732,21 @@ EOM
                               if ( $rblock_type->[$j] );
                         }
                         elsif ( $is_closing_token{$token} ) {
-                            $nesting_depth--;
+
+                            # The opening depth should always be defined, and
+                            # it should equal $nesting_depth-1.  To protect
+                            # against unforseen error conditions, however, we
+                            # will check this and fix things if necessary.  For
+                            # a test case see issue c055.
+                            my $opening_depth =
+                              $rdepth_of_opening_seqno->[$seqno];
+                            if ( !defined($opening_depth) ) {
+                                $opening_depth = $nesting_depth--;
+                                $opening_depth = 0 if ( $opening_depth < 0 );
+                                $rdepth_of_opening_seqno->[$seqno] =
+                                  $opening_depth;
+                            }
+                            $nesting_depth = $opening_depth;
                             $sign = -1;
                         }
                         elsif ( $token eq '?' ) {
index 989c058594fded1691523fa65264aee22c11cf73..7c162ebff669062101c2b533d02b5ab1421a7bb2 100644 (file)
@@ -2,6 +2,20 @@
 
 =over 4
 
+=item B<Fix undefined variable reference in development version>
+
+In testing, the following unbalanced snippet caused a reference to an undefined
+value in the current development version (but not in the current released
+version).
+
+        if($CPAN::Config->{term_is_latin}){
+                $swhat=~s{([\xC0-\xDF])([\x80-\xBF])}{chr(ord($1)<<6&0xC0|ord($2)&0x3F)}eg;}if($self->colorize_output){if($CPAN::DEBUG&&$swhat=~/^Debug\(/){
+                        $ornament=$CPAN::Config->{colorize_debug}||"black on_cyan";}
+
+A check has been added to fix this.
+
+10 Aug 2021.
+
 =item B<Fix formatting instability, b1192>
 
 Testing with random parameters produced unstable formatting with the