From: Steve Hancock Date: Tue, 26 Sep 2023 01:15:27 +0000 (-0700) Subject: added some checks on leading whitespace X-Git-Tag: 20230912.02~10 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4031a9011ef4053367bd0d11fadd2ab358f86fad;p=perltidy.git added some checks on leading whitespace --- diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 9264bfd3..9fb9ff9d 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -5231,11 +5231,15 @@ EOM # Any leading whitespace? if ( $spaces > 0 ) { + # Verify that the leading whitespace is all whitespace if (DEVEL_MODE) { + + # A change must have been made to the line text after + # $spaces was calculated my $leading_space = substr( $input_line, 0, $spaces ); if ( $leading_space =~ /\S/ ) { $self->Fault(<Fault(<{_guessed_indentation_level} = int( $spaces / $rOpts_indent_columns ); } + elsif ($spaces) { + + # Negative space count - should never happen + DEVEL_MODE && $self->Fault(<Fault(<[0] eq 'b' + && !( $in_quote && $quote_type eq 'Q' ) ) + { + + # Shouldn't happen if calling sub did trim operation correctly. + DEVEL_MODE && $self->Fault(<