]> git.donarmstrong.com Git - perltidy.git/commitdiff
add check for non-ascii characters
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 8 Dec 2024 15:30:19 +0000 (07:30 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 8 Dec 2024 15:30:19 +0000 (07:30 -0800)
dev-bin/check_text.pl

index c3622a5f31a8a3edbc9a43f6e4d6c5144638fc4f..bd8429fa6c2b8906d0eaacc909afdd49b3c762fe 100755 (executable)
@@ -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";
 }