All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akira Yokosawa <akiyks@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: perfbook@vger.kernel.org, Akira Yokosawa <akiyks@gmail.com>
Subject: [PATCH -perfbook 08/11] periodcheck: Improve regex
Date: Tue, 17 Aug 2021 19:35:43 +0900	[thread overview]
Message-ID: <e66a446c-d4fa-e52a-de12-9e81e0ab2cf5@gmail.com> (raw)
In-Reply-To: <9f71d7d5-b9bb-ceeb-6acb-e889821eeeb9@gmail.com>

Add patterns to catch end-of-sentence punctuation marks in front
of quotation marks and/or parentheses.

Also add patterns to treat lines ending with "\\" as exceptions.

Add autodate.tex to the exception list in periodcheck.sh.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 utilities/periodcheck.pl | 17 +++++++++++------
 utilities/periodcheck.sh |  1 +
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/utilities/periodcheck.pl b/utilities/periodcheck.pl
index f46052c5..9d1985d1 100755
--- a/utilities/periodcheck.pl
+++ b/utilities/periodcheck.pl
@@ -60,9 +60,9 @@ sub check_line {
     }
     unless ($skip) {
 	$safe = 1;
-	if ($line =~ /^(?=[\s]*+[^%])[^%]*[A-Z][\.\?\!\:][\)\}\']*$/ ||
-	    $line =~ /^(?=[\s]*+[^%])[^%]*[A-Z][\.\?\!\:]\\footnote/ ||
-	    $line =~ /^(?=[\s]*+[^%])[^%]*[Aa]crm?\{.+\}[\.\?\!\:][\)\}\']*$/ ) {
+	if ($line =~ /^(?=[\s]*+[^%])[^%]*[A-Z][\)\']*[\.\?\!\:][\)\}\']*$/ ||
+	    $line =~ /^(?=[\s]*+[^%])[^%]*[A-Z][\)\']*[\.\?\!\:]\\footnote/ ||
+	    $line =~ /^(?=[\s]*+[^%])[^%]*[Aa]crm?\{.+\}[\)\']*[\.\?\!\:][\)\}\']*$/ ) {
 	    $safe = 0;
 	    if ($next_line =~ /^\s*$/ || $next_line =~ /^\s*%/ ||
 		$next_line =~ /\\item/ ||
@@ -72,9 +72,14 @@ sub check_line {
 		$safe = 1;
 	    }
 	}
-	if ($line =~ /^(?=[\s]*+[^%])[^%]*[a-z\}][\.\?\!][\)\}\']*\s[^\\]+/ ||
-	    $line =~ /^(?=[\s]*+[^%])[^%]*.*:[\)\}\']*\s[^\\]+/) {
+	if ($line =~ /^(?=[\s]*+[^%])[^%]*[a-z][\)\}\']*[\.\?\!][\)\}\']*\s+[^%]/ ||
+#	    $line =~ /^(?=[\s]*+[^%])[^%]*.*\.[\)\}\']*\s+[^%]/ ||  # Uncomment for full check
+	    $line =~ /^(?=[\s]*+[^%])[^%]*.*:[\)\}\']*\s+[^%]/ ) {
 	    $safe = 0;
+	    if ($line =~ /^(?=[\s]*+[^%])[^%]*[a-z][\)\}\']*[\.\?\!][\)\}\']*\s+\\\\/ ||
+		$line =~ /^(?=[\s]*+[^%])[^%]*.*[\.:][\)\}\']*\s+\\\\/ ) {
+		$safe = 1;
+	    }
 	}
 	if ($line =~ /^(?=[\s]*+[^%])[^%]*[^~]\\cite/) {
 	    $safe = 0;
@@ -82,7 +87,7 @@ sub check_line {
 		$safe = 1;
 	    }
 	}
-	if ($line =~ /^(?=[\s]*+[^%])[^%]*\\\@[\.\?\!\:][\)\}\']*\s+[^\s%]+/){
+	if ($line =~ /^(?=[\s]*+[^%])[^%]*\\\@[\.\?\!\:][\)\}\']*\s+[^%]/){
 	    $safe = 0;
 	}
 	unless ($safe) {
diff --git a/utilities/periodcheck.sh b/utilities/periodcheck.sh
index d6cd7510..4fff091b 100755
--- a/utilities/periodcheck.sh
+++ b/utilities/periodcheck.sh
@@ -11,6 +11,7 @@ do
 	./glsdict.tex) ;;
 	./origpub.tex) ;;
 	./contrib.tex) ;;
+	./autodate.tex) ;;
 	./future/HTMtable*) ;;
 	./appendix/styleguide*) ;;
 	*) tex_sources="$tex_sources $f" ;;
-- 
2.17.1



  parent reply	other threads:[~2021-08-17 10:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 10:14 [PATCH -perfbook 00/11] Break and capitalize after colon, take four Akira Yokosawa
2021-08-17 10:16 ` [PATCH -perfbook 01/11] appendix, glossary: Break and capitalize after colon Akira Yokosawa
2021-08-17 10:18 ` [PATCH -perfbook 02/11] glossary: Put missing question mark Akira Yokosawa
2021-08-17 10:19 ` [PATCH -perfbook 03/11] treewide: Adjust punctuation convention Akira Yokosawa
2021-08-17 10:21 ` [PATCH -perfbook 04/11] Add \ignorespaces command to \IfEbookSize and \IfSansSerif Akira Yokosawa
2021-08-17 18:29   ` Paul E. McKenney
2021-08-17 20:22     ` Paul E. McKenney
2021-08-17 23:31     ` Akira Yokosawa
2021-08-17 23:50       ` Paul E. McKenney
2021-08-17 10:23 ` [PATCH -perfbook 05/11] datastruct: Use \tco{} inside inline enumerate list Akira Yokosawa
2021-08-17 10:29 ` [PATCH -perfbook 06/11] periodcheck: Add colon-related checks Akira Yokosawa
2021-08-17 10:33 ` [PATCH -perfbook 07/11] cleverefcheck: Check lower-case word after \item Akira Yokosawa
2021-08-17 10:35 ` Akira Yokosawa [this message]
2021-08-17 10:37 ` [PATCH -perfbook 09/11] periodcheck: Use counter to prevent false negatives Akira Yokosawa
2021-08-17 10:39 ` [PATCH -perfbook 10/11] cleverefcheck: Add pattern to catch typo in indexing macros Akira Yokosawa
2021-08-17 10:40 ` [PATCH -perfbook 11/11] Makefile: Rename periodcheck --> punctcheck Akira Yokosawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e66a446c-d4fa-e52a-de12-9e81e0ab2cf5@gmail.com \
    --to=akiyks@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=perfbook@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.