All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -perfbook 0/9] Add script to check period spacing
@ 2021-04-27 15:03 Akira Yokosawa
  2021-04-27 15:05 ` [PATCH -perfbook 1/9] Annotate mid-sentence and end-of-sentence periods Akira Yokosawa
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Akira Yokosawa @ 2021-04-27 15:03 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

Hi Paul,

This patch set adds a set of scripts to check proper annotation
of periods to distinguish single and double spacing.

Patch 1/9 adds a couple of annotations in-development version of
the script had caught.
Patches 2/9--5/9 add and improve the set of scripts.
They are kept separate patches to show the history.
Patches 6/9--9/9 are fixes in LaTeX sources to satisfy the script.
There are quite a few sentences which end in the middle of
input lines.

After Patch 9/9 is applied, "make periodcheck" will be clean.

I'm not saying the perl script is complete.
There can still be false negatives I'm not aware of.
False positives can happen when you add new contents.

        Thanks, Akira
--
Akira Yokosawa (9):
  Annotate mid-sentence and end-of-sentence periods
  periodcheck: Add script to check missing annotation of period
  periodcheck: Add check of nbsp in front of \cite{}
  periodcheck: Improve label string matching
  periodcheck: Replace escaped percent symbol first
  treewide: Make end-of-sentence periods be at end of lines
  styleguide: Make end-of-sentence periods be at the end of lines
  treewide: Fix space in front of \cite{}
  treewide: Substitute ';' for ',' in label strings

 Makefile                             |   5 +-
 SMPdesign/SMPdesign.tex              |  36 ++--
 SMPdesign/beyond.tex                 |  15 +-
 SMPdesign/criteria.tex               |   4 +-
 SMPdesign/partexercises.tex          |  12 +-
 ack.tex                              |   2 +-
 advsync/rt.tex                       |   7 +-
 appendix/styleguide/styleguide.tex   | 237 +++++++++++++++------------
 appendix/whymb/whymemorybarriers.tex |  71 ++++----
 count/count.tex                      |  11 +-
 cpu/hwfreelunch.tex                  |   2 +-
 datastruct/datastruct.tex            |  55 ++++---
 debugging/debugging.tex              |  16 +-
 defer/defer.tex                      |   4 +-
 defer/hazptr.tex                     |   7 +-
 defer/rcuapi.tex                     |   4 +-
 defer/rcufundamental.tex             |   5 +-
 defer/refcnt.tex                     |   4 +-
 easy/easy.tex                        |   3 +-
 formal/dyntickrcu.tex                |  15 +-
 formal/ppcmem.tex                    | 184 +++++++++++----------
 formal/spinhint.tex                  | 148 +++++++++--------
 glossary.tex                         |   9 +-
 howto/howto.tex                      |   2 +-
 intro/intro.tex                      |  33 ++--
 legal.tex                            |   9 +-
 locking/locking.tex                  |   5 +-
 memorder/memorder.tex                |  12 +-
 owned/owned.tex                      |   5 +-
 together/refcnt.tex                  |   4 +-
 toolsoftrade/toolsoftrade.tex        |   9 +-
 utilities/periodcheck.pl             |  87 ++++++++++
 utilities/periodcheck.sh             |  23 +++
 33 files changed, 627 insertions(+), 418 deletions(-)
 create mode 100755 utilities/periodcheck.pl
 create mode 100755 utilities/periodcheck.sh

-- 
2.17.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH -perfbook 1/9] Annotate mid-sentence and end-of-sentence periods
  2021-04-27 15:03 [PATCH -perfbook 0/9] Add script to check period spacing Akira Yokosawa
@ 2021-04-27 15:05 ` Akira Yokosawa
  2021-04-27 15:08 ` [PATCH -perfbook 2/9] periodcheck: Add script to check missing annotation of period Akira Yokosawa
  2021-04-27 15:11 ` [PATCH -perfbook 0/9] Add script to check period spacing Akira Yokosawa
  2 siblings, 0 replies; 4+ messages in thread
From: Akira Yokosawa @ 2021-04-27 15:05 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

From ae551669fa11abdeebd8f4b99d49dfc59866398a Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@gmail.com>
Date: Fri, 23 Apr 2021 10:23:18 +0900
Subject: [PATCH -perfbook 1/9] Annotate mid-sentence and end-of-sentence periods

These were caught by the check script to be added in
the following updates.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 ack.tex             | 2 +-
 advsync/rt.tex      | 2 +-
 howto/howto.tex     | 2 +-
 locking/locking.tex | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ack.tex b/ack.tex
index b8cffa37..ce64d325 100644
--- a/ack.tex
+++ b/ack.tex
@@ -126,4 +126,4 @@ organizations that keep Internet and the World Wide Web up and running,
 and this one is no exception.
 
 Portions of this material are based upon work supported by the National
-Science Foundation under Grant No. CNS-0719851.
+Science Foundation under Grant No.\@ CNS-0719851.
diff --git a/advsync/rt.tex b/advsync/rt.tex
index bb8465ff..71ab0661 100644
--- a/advsync/rt.tex
+++ b/advsync/rt.tex
@@ -573,7 +573,7 @@ as depicted in
 \cref{fig:advsync:Real-Time Reflexes}.
 The hard real-time reflexes, which read from sensors and control
 actuators, run real-time on a single CPU or on special-purpose hardware
-such as an FPGA.
+such as an FPGA\@.
 The non-real-time strategy and planning portion of the application runs
 on the remaining CPUs.
 Strategy and planning activities might include statistical analysis,
diff --git a/howto/howto.tex b/howto/howto.tex
index c3d0a101..0f0ba293 100644
--- a/howto/howto.tex
+++ b/howto/howto.tex
@@ -304,7 +304,7 @@ Fortunately, there are many alternatives available to you:
 	\pplsur{Victor}{Luchangco}, and \pplsur{Michael}{Spear} did
 	catch up in their second edition by adding short sections on
 	hazard pointers and on \acr{rcu}, with the latter in the guise
-	of \acr{ebr}.
+	of \acr{ebr}\@.
 	They also include a brief history of both, albeit with an
 	abbreviated history of \acr{rcu} that picks up almost a year after
 	it was accepted into the Linux kernel and more than 20~years
diff --git a/locking/locking.tex b/locking/locking.tex
index 5313f926..6bc93e49 100644
--- a/locking/locking.tex
+++ b/locking/locking.tex
@@ -713,7 +713,7 @@ outside of a signal handler without blocking signals.
 	handler without blocking signals, a signal might be handled while
 	holding this lock.
 	The corresponding signal handler might then acquire
-	Lock~B, so that Lock~B is acquired while holding Lock~A.
+	Lock~B, so that Lock~B is acquired while holding Lock~A\@.
 	Therefore, if we also acquire Lock~A while holding Lock~B,
 	we will have a deadlock cycle.
 	Note that this problem exists even if signals are blocked while
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH -perfbook 2/9] periodcheck: Add script to check missing annotation of period
  2021-04-27 15:03 [PATCH -perfbook 0/9] Add script to check period spacing Akira Yokosawa
  2021-04-27 15:05 ` [PATCH -perfbook 1/9] Annotate mid-sentence and end-of-sentence periods Akira Yokosawa
@ 2021-04-27 15:08 ` Akira Yokosawa
  2021-04-27 15:11 ` [PATCH -perfbook 0/9] Add script to check period spacing Akira Yokosawa
  2 siblings, 0 replies; 4+ messages in thread
From: Akira Yokosawa @ 2021-04-27 15:08 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

"make periodcheck" will do the check.

NOTE: Possible false negative/positive as of this commit:
o   A mid-sentence period is ignored when the line matches "\label{"
    or "\*ref{" pattern. It should be caught when it is outside a
    macro.
o   \cref{} can have comma-separated multiple labels as an argument.
    When one of the labels has a mid-sentence period and on a
    subsequent line in the input, it is not ignored.
o   \crefrange{}{} can also have a label string on a subsequent line.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 Makefile                 |  5 ++-
 utilities/periodcheck.pl | 76 ++++++++++++++++++++++++++++++++++++++++
 utilities/periodcheck.sh | 20 +++++++++++
 3 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100755 utilities/periodcheck.pl
 create mode 100755 utilities/periodcheck.sh

diff --git a/Makefile b/Makefile
index 4beb2c17..ea264dc5 100644
--- a/Makefile
+++ b/Makefile
@@ -192,7 +192,7 @@ BASE_DEPENDS := perfbook.tex $(foreach v,tcb 1c msns mss mstx msr msn msnt sf nq
 .PHONY: qq perfbook-qq.pdf qqmsg
 .PHONY: help help-official help-full help-semiofficial help-paper help-draft
 .PHONY: help-experimental help-prefixed
-.PHONY: paper-clean
+.PHONY: paper-clean periodcheck
 
 all: $(targ)
 
@@ -611,5 +611,8 @@ ls-unused:
 neatfreak: distclean
 	find . -name '*.pdf' | xargs rm -f
 
+periodcheck:
+	utilities/periodcheck.sh
+
 .SECONDEXPANSION:
 $(ABBREVTARGETS): %: perfbook-$$@.pdf
diff --git a/utilities/periodcheck.pl b/utilities/periodcheck.pl
new file mode 100755
index 00000000..225391ff
--- /dev/null
+++ b/utilities/periodcheck.pl
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Check LaTeX source of mid-sentence and end-of-sentence period
+#
+# Assumptions:
+#    End-of-sentence periods are at the end of input lines.
+#
+# Exceptions:
+#    LaTeX comments
+#    LaTeX labels: such as \cref{fig:xxx:foo vs. bar}
+#    Verbatim contents
+#    Table contents
+#
+# Copyright (C) Akira Yokosawa, 2021
+#
+# Authors: Akira Yokosawa <akiyks@gmail.com>
+
+use strict;
+use warnings;
+
+my $line;
+my $next_line;
+my $line_num = 0;
+my $skip = 0;
+my $safe = 0;
+my $Verbatim_begin = qr/\\begin\{Verbatim/ ;
+my $Verbatim_end = qr/\\end\{Verbatim/ ;
+my $tabular_begin = qr/\\begin\{tabula/ ;
+my $tabular_end = qr/\\end\{tabula/ ;
+
+sub check_line {
+    if ($line =~ /$Verbatim_begin/ ||
+	$line =~ /$tabular_begin/) {
+	$skip = 1;
+    }
+    unless ($skip) {
+	$safe = 1;
+	if ($line =~ /^(?=[\s]*+[^%])[^%]*[A-Z]\.$/ ||
+	    $line =~ /^(?=[\s]*+[^%])[^%]*[A-Z]\.\\footnote/ ||
+	    $line =~ /^(?=[\s]*+[^%])[^%]*[Aa]cr\{.+\}\.$/ ||
+	    $line =~ /^(?=[\s]*+[^%])[^%]*[Aa]crm\{.+\}\.$/) {
+	    $safe = 0;
+	    if ($next_line =~ /^\s*$/ || $next_line =~ /^\s*%/ ||
+		$next_line =~ /\\item/ || $next_line =~ /\\end\{quot/ ||
+		$next_line =~ /\\end\{enum/ || $next_line =~ /\\end\{item/) {
+		$safe = 1;
+	    }
+	}
+	if ($line =~ /^(?=[\s]*+[^%])[^%]*[a-z\}]\.\s[^\\]+/) {
+	    $safe = 0;
+	    if ($line =~ /ref\{/ || $line =~ /label\{/) {
+		$safe = 1;
+	    }
+	}
+	unless ($safe) {
+	    print $ARGV[0], ':', $line_num, ':', $line;
+	}
+    }
+    if ($line =~ /$Verbatim_end/ ||
+	$line =~ /$tabular_end/) {
+	$skip = 0;
+    }
+}
+
+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_line();
+    $line = $next_line;
+    $line_num++ ;
+}
+check_line();
diff --git a/utilities/periodcheck.sh b/utilities/periodcheck.sh
new file mode 100755
index 00000000..a56657f3
--- /dev/null
+++ b/utilities/periodcheck.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+tex_sources_all=`find . -name "*.tex" -print`
+tex_sources=""
+
+for f in $tex_sources_all
+do
+	case $f in
+	./perfbook*) ;;
+	./qqz*) ;;
+	./future/HTMtable*) ;;
+	./appendix/styleguide*) ;;
+	*) tex_sources="$tex_sources $f" ;;
+        esac
+done
+
+for g in $tex_sources
+do
+	utilities/periodcheck.pl $g
+done
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -perfbook 0/9] Add script to check period spacing
  2021-04-27 15:03 [PATCH -perfbook 0/9] Add script to check period spacing Akira Yokosawa
  2021-04-27 15:05 ` [PATCH -perfbook 1/9] Annotate mid-sentence and end-of-sentence periods Akira Yokosawa
  2021-04-27 15:08 ` [PATCH -perfbook 2/9] periodcheck: Add script to check missing annotation of period Akira Yokosawa
@ 2021-04-27 15:11 ` Akira Yokosawa
  2 siblings, 0 replies; 4+ messages in thread
From: Akira Yokosawa @ 2021-04-27 15:11 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

Sorry, I forgot to remove extra headers in 1/9.
Will resend v2.

        Thanks, Akira


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-27 15:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 15:03 [PATCH -perfbook 0/9] Add script to check period spacing Akira Yokosawa
2021-04-27 15:05 ` [PATCH -perfbook 1/9] Annotate mid-sentence and end-of-sentence periods Akira Yokosawa
2021-04-27 15:08 ` [PATCH -perfbook 2/9] periodcheck: Add script to check missing annotation of period Akira Yokosawa
2021-04-27 15:11 ` [PATCH -perfbook 0/9] Add script to check period spacing Akira Yokosawa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.