From: Steve Hancock Date: Sun, 8 Dec 2024 15:30:19 +0000 (-0800) Subject: add check for non-ascii characters X-Git-Tag: 20240903.08~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=33cd73fe6c7c41c39f08d3453b547bfbfa45ceed;p=perltidy.git add check for non-ascii characters --- diff --git a/dev-bin/check_text.pl b/dev-bin/check_text.pl index c3622a5f..bd8429fa 100755 --- a/dev-bin/check_text.pl +++ b/dev-bin/check_text.pl @@ -1,22 +1,29 @@ #!/usr/bin/perl -w use strict; -# Perform some basic checks on text: -# - report lines with lengths > 80 -# - report any tabs -# - report lines with ending spaces +# Scan text and report +# - lines with lengths > 80 +# - tabs +# - lines with ending spaces +# - non-ascii characters my $too_long; +my $too_long_no_left_space; my $has_tab; my $has_ending_space; +my $non_ascii; my $lno = 0; -#while ( my $line = <$fh> ) { while ( my $line = <> ) { $lno++; chomp $line; my $excess = length($line) - 80; - if ( $excess > 0 && $line =~ /^\s/ ) { - print "$lno:x=$excess:$line\n"; - $too_long++; + if ( $excess > 0 ) { + if ( $line =~ /^\s/ ) { + print "$lno:x=$excess:$line\n"; + $too_long++; + } + else { + $too_long_no_left_space++; + } } if ( $line =~ /\t/ ) { print "$lno:tabs:$line\n"; @@ -26,13 +33,25 @@ while ( my $line = <> ) { print "$lno:end spaces:$line\n"; $has_ending_space++; } + if ( $line =~ /[^[:ascii:]]/ ) { + print "$lno:non-ascii:$line\n"; + $non_ascii++; + } } +print "\n"; if ($too_long) { - print "$too_long lines exceed 80 chars:\n"; + print "$too_long lines with leading space exceed 80 chars\n"; +} +if ($too_long_no_left_space) { + print +"$too_long_no_left_space left adjusted lines exceed 80 chars(not shown)\n"; } if ($has_tab) { - print "$has_tab lines contain tabs:\n"; + print "$has_tab lines contain tabs\n"; } if ($has_ending_space) { - print "$has_ending_space lines end in a space:\n"; + print "$has_ending_space lines end in a space\n"; +} +if ($non_ascii) { + print "$non_ascii lines have non-ascii characters\n"; }