All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Add script to detect collisions in commandchars
@ 2019-01-26 15:07 Akira Yokosawa
  2019-01-26 15:10 ` [PATCH 1/3] Add checkfcv.pl Akira Yokosawa
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Akira Yokosawa @ 2019-01-26 15:07 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

Hi Paul,

I mentioned in an earlier patch submission that to add collision
check of commandchars in fcvextract.pl was on my to-do list.

It turned out that fcvextract.pl is already complicated and
I changed my mind to add a separate script to check .fcv files for
the collisions.

Patch #1 adds the script as utilities/checkfcv.pl.
Patch #2 adds the invocations of the script in Makefile. It also
suppresses the echo of commands in the recipes.
Patch #3 fixes a couple of collisions detected by the script.

The two collisions were made by myself.  This automatic check
looks promising to me.

        Thanks, Akira
--
Akira Yokosawa (3):
  Add checkfcv.pl
  Makefile: Invoke checkfcv.pl in -> .fcv recipes
  CodeSamples: Fix commandchars collision

 CodeSamples/defer/route_hazptr.c                   |  2 +-
 .../formal/litmus/C-ISA2+o-r+a-r+a-r+a-o.litmus    |  2 +-
 Makefile                                           |  8 ++-
 utilities/checkfcv.pl                              | 78 ++++++++++++++++++++++
 4 files changed, 85 insertions(+), 5 deletions(-)
 create mode 100755 utilities/checkfcv.pl

-- 
2.7.4


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

* [PATCH 1/3] Add checkfcv.pl
  2019-01-26 15:07 [PATCH 0/3] Add script to detect collisions in commandchars Akira Yokosawa
@ 2019-01-26 15:10 ` Akira Yokosawa
  2019-01-26 15:11 ` [PATCH 2/3] Makefile: Invoke checkfcv.pl in -> .fcv recipes Akira Yokosawa
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Akira Yokosawa @ 2019-01-26 15:10 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

From 52700b8b23649a19e02f4b9a5736c0d9056c06e4 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@gmail.com>
Date: Sat, 26 Jan 2019 20:48:16 +0900
Subject: [PATCH 1/3] Add checkfcv.pl

Add a script to detect collisions in commandchars choice

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 utilities/checkfcv.pl | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100755 utilities/checkfcv.pl

diff --git a/utilities/checkfcv.pl b/utilities/checkfcv.pl
new file mode 100755
index 0000000..94621ba
--- /dev/null
+++ b/utilities/checkfcv.pl
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Check LaTeX source of snippet extracted by fcvextract.pl
+#
+# Copyright (C) Akira Yokosawa, 2019
+#
+# Authors: Akira Yokosawa <akiyks@gmail.com>
+
+use strict;
+use warnings;
+
+my $line;
+my $lnlbl_re;
+my $checking = 0;
+my $linelabel_re = qr/\\begin\{linelabel\}\[([^\]]*)\]/ ;
+my $end_linelabel_re = qr/\\end\{linelabel\}/ ;
+my $Verbatim_cmd_re = qr/\\begin\{Verbatim[LNU]\}\[commandchars=(.{6}).*\]/ ;
+my $Verbatim_re = qr/\\begin\{Verbatim[LNU]\}/ ;
+my $end_Verbatim_re = qr/\\end\{Verbatim[LNU]\}/ ;
+my $commandchars = "";
+my $esc_bsl;
+my $esc_open;
+my $esc_close;
+my $esc_bsl_re;
+my $esc_open_re;
+my $esc_close_re;
+my $line_count = 0;
+
+my $fcv_file = $ARGV[0];
+open(my $fh, '<:encoding(UTF-8)', $fcv_file)
+    or die "Could not open file '$fcv_file' $!";
+
+while($line = <$fh>) {
+    $line_count = $line_count + 1;
+    if ($line =~ /$linelabel_re/) {
+	$checking = 1;
+    }
+    if ($checking == 3) {
+	if ($line =~ /$end_linelabel_re/) {
+	    $checking = 4;
+	}
+    }
+    if ($checking == 2) {
+	if ($line =~ /$end_Verbatim_re/) {
+	    $checking = 3;
+	} elsif ($commandchars =~ /\S/) {
+	    $_ = $line;
+	    s/$lnlbl_re//;
+	    if (/$esc_bsl_re/ || /$esc_open_re/ || /$esc_close_re/) {
+		die "commandchars collision detected in $fcv_file, line: $line_count\n$line\n";
+	    }
+	}
+    }
+    if ($checking == 1) {
+	if ($line =~ /$Verbatim_cmd_re/) {
+	    $commandchars = $1;
+	    $esc_bsl = substr $commandchars, 0, 2;
+	    $esc_open = substr $commandchars, 2, 2;
+	    $esc_close = substr $commandchars, 4, 2;
+	    $lnlbl_re = $esc_bsl."lnlbl".$esc_open.".*".$esc_close;
+	    $esc_bsl_re = qr/$esc_bsl/;
+	    $esc_open_re = qr/$esc_open/;
+	    $esc_close_re = qr/$esc_close/;
+	    $checking = 2;
+	} elsif ($line =~ /$Verbatim_re/) {
+	    $checking = 2;
+	}
+    }
+    if (eof) {
+	last;
+    }
+}
+if ($checking == 4) {
+    exit 0;
+} else {
+    die "incomplete fcv file $fcv_file\n";
+}
-- 
2.7.4



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

* [PATCH 2/3] Makefile: Invoke checkfcv.pl in -> .fcv recipes
  2019-01-26 15:07 [PATCH 0/3] Add script to detect collisions in commandchars Akira Yokosawa
  2019-01-26 15:10 ` [PATCH 1/3] Add checkfcv.pl Akira Yokosawa
@ 2019-01-26 15:11 ` Akira Yokosawa
  2019-01-26 15:12 ` [PATCH 3/3] CodeSamples: Fix commandchars collision Akira Yokosawa
  2019-01-26 16:15 ` [PATCH 0/3] Add script to detect collisions in commandchars Paul E. McKenney
  3 siblings, 0 replies; 5+ messages in thread
From: Akira Yokosawa @ 2019-01-26 15:11 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

From 1aeb3e922c7d588e21bf269c63b62b6ea4fd0c7a Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@gmail.com>
Date: Sat, 26 Jan 2019 21:56:28 +0900
Subject: [PATCH 2/3] Makefile: Invoke checkfcv.pl in -> .fcv recipes

Also suppress echo of commands in these recipes.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 Makefile | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 6ef4629..2ed7500 100644
--- a/Makefile
+++ b/Makefile
@@ -254,15 +254,17 @@ CodeSamples/snippets.d: $(SOURCES_OF_SNIPPET) $(GEN_SNIPPET_D)
 
 $(FCVSNIPPETS):
 	@echo "$< --> $@"
-	utilities/fcvextract.pl $< $(subst +,\\+,$(subst @,:,$(basename $(notdir $@)))) > $@
+	@utilities/fcvextract.pl $< $(subst +,\\+,$(subst @,:,$(basename $(notdir $@)))) > $@
+	@utilities/checkfcv.pl $@
 
 $(FCVSNIPPETS_VIA_LTMS):
 	@echo "$< --> $@"
-	utilities/fcvextract.pl $< $(subst +,\\+,$(subst @,:,$(basename $(notdir $@)))) > $@
+	@utilities/fcvextract.pl $< $(subst +,\\+,$(subst @,:,$(basename $(notdir $@)))) > $@
+	@utilities/checkfcv.pl $@
 
 $(FCVSNIPPETS_LTMS):
 	@echo "$< --> $@"
-	utilities/reorder_ltms.pl $< > $@
+	@utilities/reorder_ltms.pl $< > $@
 
 help:
 	@echo "Official targets (Latin Modern Typewriter for monospace font):"
-- 
2.7.4



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

* [PATCH 3/3] CodeSamples: Fix commandchars collision
  2019-01-26 15:07 [PATCH 0/3] Add script to detect collisions in commandchars Akira Yokosawa
  2019-01-26 15:10 ` [PATCH 1/3] Add checkfcv.pl Akira Yokosawa
  2019-01-26 15:11 ` [PATCH 2/3] Makefile: Invoke checkfcv.pl in -> .fcv recipes Akira Yokosawa
@ 2019-01-26 15:12 ` Akira Yokosawa
  2019-01-26 16:15 ` [PATCH 0/3] Add script to detect collisions in commandchars Paul E. McKenney
  3 siblings, 0 replies; 5+ messages in thread
From: Akira Yokosawa @ 2019-01-26 15:12 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

From c09a36aaa2f6fbb56f61e4d39785ee3601b919da Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@gmail.com>
Date: Sat, 26 Jan 2019 21:56:37 +0900
Subject: [PATCH 3/3] CodeSamples: Fix commandchars collision

These collision were detected by checkfcv.pl.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 CodeSamples/defer/route_hazptr.c                        | 2 +-
 CodeSamples/formal/litmus/C-ISA2+o-r+a-r+a-r+a-o.litmus | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/CodeSamples/defer/route_hazptr.c b/CodeSamples/defer/route_hazptr.c
index 1d777cf..2f3dd63 100644
--- a/CodeSamples/defer/route_hazptr.c
+++ b/CodeSamples/defer/route_hazptr.c
@@ -23,7 +23,7 @@
 #include "hazptr.h"
 
 /* Route-table entry to be included in the routing list. */
-//\begin{snippet}[labelbase=ln:defer:route_hazptr:lookup,commandchars=\\\[\]]
+//\begin{snippet}[labelbase=ln:defer:route_hazptr:lookup,commandchars=\\\@\$]
 struct route_entry {
 	struct hazptr_head hh;				//\lnlbl{hh}
 	struct route_entry *re_next;
diff --git a/CodeSamples/formal/litmus/C-ISA2+o-r+a-r+a-r+a-o.litmus b/CodeSamples/formal/litmus/C-ISA2+o-r+a-r+a-r+a-o.litmus
index b899369..962d1ce 100644
--- a/CodeSamples/formal/litmus/C-ISA2+o-r+a-r+a-r+a-o.litmus
+++ b/CodeSamples/formal/litmus/C-ISA2+o-r+a-r+a-r+a-o.litmus
@@ -1,5 +1,5 @@
 C C-ISA2+o-r+a-r+a-r+a-o
-//\begin[snippet][labelbase=ln:formal:litmus:C-ISA2+o-r+a-r+a-r+a-o:whole,commandchars=\\\@\$]
+//\begin[snippet][labelbase=ln:formal:litmus:C-ISA2+o-r+a-r+a-r+a-o:whole,commandchars=\@\[\]]
 {
 }
 
-- 
2.7.4



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

* Re: [PATCH 0/3] Add script to detect collisions in commandchars
  2019-01-26 15:07 [PATCH 0/3] Add script to detect collisions in commandchars Akira Yokosawa
                   ` (2 preceding siblings ...)
  2019-01-26 15:12 ` [PATCH 3/3] CodeSamples: Fix commandchars collision Akira Yokosawa
@ 2019-01-26 16:15 ` Paul E. McKenney
  3 siblings, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2019-01-26 16:15 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Sun, Jan 27, 2019 at 12:07:32AM +0900, Akira Yokosawa wrote:
> Hi Paul,
> 
> I mentioned in an earlier patch submission that to add collision
> check of commandchars in fcvextract.pl was on my to-do list.
> 
> It turned out that fcvextract.pl is already complicated and
> I changed my mind to add a separate script to check .fcv files for
> the collisions.
> 
> Patch #1 adds the script as utilities/checkfcv.pl.
> Patch #2 adds the invocations of the script in Makefile. It also
> suppresses the echo of commands in the recipes.
> Patch #3 fixes a couple of collisions detected by the script.
> 
> The two collisions were made by myself.  This automatic check
> looks promising to me.

Looks promising, let's see how it goes -- queued and pushed, thank you!

							Thanx, Paul

>         Thanks, Akira
> --
> Akira Yokosawa (3):
>   Add checkfcv.pl
>   Makefile: Invoke checkfcv.pl in -> .fcv recipes
>   CodeSamples: Fix commandchars collision
> 
>  CodeSamples/defer/route_hazptr.c                   |  2 +-
>  .../formal/litmus/C-ISA2+o-r+a-r+a-r+a-o.litmus    |  2 +-
>  Makefile                                           |  8 ++-
>  utilities/checkfcv.pl                              | 78 ++++++++++++++++++++++
>  4 files changed, 85 insertions(+), 5 deletions(-)
>  create mode 100755 utilities/checkfcv.pl
> 
> -- 
> 2.7.4
> 


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

end of thread, other threads:[~2019-01-26 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-26 15:07 [PATCH 0/3] Add script to detect collisions in commandchars Akira Yokosawa
2019-01-26 15:10 ` [PATCH 1/3] Add checkfcv.pl Akira Yokosawa
2019-01-26 15:11 ` [PATCH 2/3] Makefile: Invoke checkfcv.pl in -> .fcv recipes Akira Yokosawa
2019-01-26 15:12 ` [PATCH 3/3] CodeSamples: Fix commandchars collision Akira Yokosawa
2019-01-26 16:15 ` [PATCH 0/3] Add script to detect collisions in commandchars Paul E. McKenney

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.