From: Steve Hancock Date: Sat, 30 Sep 2023 14:07:40 +0000 (-0700) Subject: add fault check X-Git-Tag: 20230912.03~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0f6e558eac04910772a3d415ff2c144947d66d77;p=perltidy.git add fault check --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 912eb16e..91edaa30 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -2,6 +2,28 @@ # # The Perl::Tidy::Formatter package adds indentation, whitespace, and # line breaks to the token stream + +# Usage Outline: +# +# STEP 1: initialize or re-initialze Formatter with user options +# Perl::Tidy::Formatter::check_options($rOpts); +# +# STEP 2: crate a tokenizer for the source stream +# +# STEP 3: create a formatter for the destination stream +# my $formatter = Perl::Tidy::Formatter->new( +# ... +# sink_object => $destination, +# ... +# ); +# +# STEP 4: process each input line (see sub Perl::Tidy::process_single_case) +# while ( my $line = $tokenizer->get_line() ) { +# $formatter->write_line($line); +# } +# +# STEP 4: finish formatting +# $formatter->finish_formatting($severe_error); # ##################################################################### @@ -11552,7 +11574,15 @@ sub find_nested_pairs { # Count the number of nonblank characters separating them. # Note: the $nonblank_count includes the inner opening container # but not the outer opening container, so it will be >= 1. - if ( $K_diff < 0 ) { next } # Shouldn't happen + if ( $K_diff < 0 ) { + + # Shouldn't happen + DEVEL_MODE + && Fault( +"unexpected negative index diff=$K_diff = Kio-Koo =$K_inner_opening - $K_outer_opening" + ); + next; + } my $nonblank_count = 0; my $type; my $is_name;