From 0f6e558eac04910772a3d415ff2c144947d66d77 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 30 Sep 2023 07:07:40 -0700 Subject: [PATCH] add fault check --- lib/Perl/Tidy/Formatter.pm | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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; -- 2.39.5