Subject: [PATCH -perfbook 2/2] utilities/punctcheck.sh: Check use of "\%"

Teach utilities/punctcheck.sh of the pattern for the percent sign by
adding utilities/percentcheck.pl and letting it invoked along with
utilities/punctcheck.pl.

It could be added in punctcheck.pl, but doing so would further complicate
the script.  Therefore, a dedicated script.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
diff --git a/utilities/percentcheck.pl b/utilities/percentcheck.pl
new file mode 100755
index 0000000..0fe8327
--- /dev/null
+++ b/utilities/percentcheck.pl
@@ -0,0 +1,39 @@
+#!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Check LaTeX source of percent sign
+#
+# Copyright (C) Akira Yokosawa, 2025
+#
+# Authors: Akira Yokosawa <akiyks@gmail.com>
+
+use strict;
+use warnings;
+
+my $line;
+my $line_num = 0;
+my $next_line;
+
+sub check_percent {
+    my $line_raw = $line;
+    if ($line =~ /[0-9]+(\\,)?\\%/) {
+	print $ARGV[0], ':', $line_num, ': ', $line_raw;
+	print "Hint: Use \\pct for percent sign as unit, say \\pct\\ if no punct follows.\n";
+    }
+    if ($line =~ /[0-9]+\\pct[ \s]/) {
+	print $ARGV[0], ':', $line_num, ': ', $line_raw;
+	print "Hint: Say \\pct\\ in mid-sentence.\n";
+    }
+}
+
+open(my $fh, '<:encoding(UTF-8)', $ARGV[0])
+    or die "Could not open file '$ARGV[0]' $!";
+
+$line = <$fh>;
+$line_num = 1;
+while($next_line = <$fh>) {
+    check_percent();
+    $line = $next_line;
+    $line_num++ ;
+}
+check_percent();
diff --git a/utilities/punctcheck.sh b/utilities/punctcheck.sh
index d0ade75..cf26424 100755
--- a/utilities/punctcheck.sh
+++ b/utilities/punctcheck.sh
@@ -21,4 +21,5 @@
 for g in $tex_sources
 do
 	utilities/punctcheck.pl $g
+	utilities/percentcheck.pl $g
 done