From e01423d17ce592ba8b28d9d2b46ac4228071a7a6 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 7 Dec 2024 15:44:21 -0800 Subject: [PATCH] utility to check for minor problems with text --- dev-bin/check_text.pl | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 dev-bin/check_text.pl diff --git a/dev-bin/check_text.pl b/dev-bin/check_text.pl new file mode 100755 index 00000000..c3622a5f --- /dev/null +++ b/dev-bin/check_text.pl @@ -0,0 +1,38 @@ +#!/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 +my $too_long; +my $has_tab; +my $has_ending_space; +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 ( $line =~ /\t/ ) { + print "$lno:tabs:$line\n"; + $has_tab++; + } + if ( $line =~ /\s+$/ ) { + print "$lno:end spaces:$line\n"; + $has_ending_space++; + } +} +if ($too_long) { + print "$too_long lines exceed 80 chars:\n"; +} +if ($has_tab) { + print "$has_tab lines contain tabs:\n"; +} +if ($has_ending_space) { + print "$has_ending_space lines end in a space:\n"; +} -- 2.39.5