I noticed a buglet in my script (I forgot to do case-insensitive
matching). So, here's a new, improved version:
tchk () {
#
# tchk - Check $T against $OldT for correct sort order.
#
# Note: Neither $T nor $OldT may contain spaces!
#
# Usage: tchk
if [ $# -ne 0 ]; then
echo "!!! tchk: usage error"
fi
perl -e '
{
$OldS="'"$OldS"'"; $S="'"$S"'";
$OldT="'"$OldT"'"; $T="'"$T"'";
# Handle "intro" weirdness.
if ($S ne $OldS) { # new section
if ($T ne "intro") {
print "!!! missing intro: S=$S, T=$T\n";
}
exit;
}
if ($T eq "intro") {
print "!!! misplaced intro: S=$S, T=$T\n";
exit;
}
$OldT = "" if ($OldT eq "intro");
# Now do simple (:-) matching.
$Tst = lc($T);
$OldTst = lc($OldT);
if ($Tst eq $OldTst) { # cross-case match
if ($T lt $OldT) {
print "!!! broken cross-case match: S=$S, T=$T, OldT=$OldT\n";
exit;
}
} else {
$Tst =~ s|(.)| $1|g;
$OldTst =~ s|(.)| $1|g;
$Tst =~ s| ([a-z])|2$1|g;
$OldTst =~ s| ([a-z])|2$1|g;
$Tst =~ s| (\d)|1$1|g;
$OldTst =~ s| (\d)|1$1|g;
$Tst =~ s| |0|g;
$OldTst =~ s| |0|g;
if ($Tst lt $OldTst) {
print "!!! sequence error: S=$S, T=$T, OldT=$OldT\n";
exit;
}
}
}
'
OldS=$S
OldT=$T
}
--
email: [EMAIL PROTECTED]; phone: +1 650-873-7841
http://www.cfcl.com/rdm - my home page, resume, etc.
http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc - Prime Time Freeware's Darwin Collection