All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Akira Yokosawa <akiyks@gmail.com>
Cc: perfbook@vger.kernel.org
Subject: Re: [PATCH] Add scripts to check 'verbbox' env usage
Date: Mon, 12 Sep 2016 16:28:57 -0700	[thread overview]
Message-ID: <20160912232857.GY3851@linux.vnet.ibm.com> (raw)
In-Reply-To: <3f7df98d-5c2f-e4eb-73c5-4a2e19eb76ac@gmail.com>

On Tue, Sep 13, 2016 at 07:12:34AM +0900, Akira Yokosawa wrote:
> On 2016/09/12 08:49:50 -0700, Paul E. McKenney wrote:
> > On Tue, Sep 13, 2016 at 12:08:11AM +0900, Akira Yokosawa wrote:
> >> >From 177cdd60c2cfe8798547ad260bb821feeb896133 Mon Sep 17 00:00:00 2001
> >> From: Akira Yokosawa <akiyks@gmail.com>
> >> Date: Mon, 12 Sep 2016 23:39:22 +0900
> >> Subject: [PATCH] Add scripts to check 'verbbox' env usage
> >>
> >> This commit adds scripts to search modification candidates
> >> for enclosing "verbbox" environment within "figure" environment.
> >>
> >> At the top of perfbook directory, the command
> >>
> >> $ sh utilities/doverbboxcheck.sh
> >>
> >> will show \begin{figure} statements to be moved ahead of
> >> "verbbox" environment.
> >>
> >> Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
> >> ---
> >>  utilities/doverbboxcheck.sh | 36 +++++++++++++++++++++++++++
> >>  utilities/verbboxcheck.pl   | 59 +++++++++++++++++++++++++++++++++++++++++++++
> >>  2 files changed, 95 insertions(+)
> >>  create mode 100644 utilities/doverbboxcheck.sh
> >>  create mode 100644 utilities/verbboxcheck.pl
> >>
> >> diff --git a/utilities/doverbboxcheck.sh b/utilities/doverbboxcheck.sh
> >> new file mode 100644
> >> index 0000000..2801bf1
> >> --- /dev/null
> >> +++ b/utilities/doverbboxcheck.sh
> >> @@ -0,0 +1,36 @@
> >> +#!/bin/sh
> >> +#
> >> +# Apply verbboxcheck.pl for all .tex files
> >> +#
> >> +# This program is free software; you can redistribute it and/or modify
> >> +# it under the terms of the GNU General Public License as published by
> >> +# the Free Software Foundation; either version 2 of the License, or
> >> +# (at your option) any later version.
> >> +#
> >> +# This program is distributed in the hope that it will be useful,
> >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >> +# GNU General Public License for more details.
> >> +#
> >> +# You should have received a copy of the GNU General Public License
> >> +# along with this program; if not, you can access it online at
> >> +# http://www.gnu.org/licenses/gpl-2.0.html.
> >> +#
> >> +# Copyright (C) Akira Yokosawa, 2016
> >> +#
> >> +# Authors: Akira Yokosawa <akiyks@gmain.com>
> >> +
> >> +# check if companion script exists
> >> +if ! test -e utilities/verbboxcheck.pl
> >> +then
> >> +	echo "utilities/verrboxcheck.pl not found."
> >> +	exit 1
> >> +fi
> >> +texfiles=`find . -name '*.tex' -print`
> >> +for i in $texfiles
> >> +do
> >> +	basename="${i%.tex}"
> >> +#	echo $basename
> >> +	perl ./utilities/verbboxcheck.pl $basename.tex
> >> +done
> >> +
> >> diff --git a/utilities/verbboxcheck.pl b/utilities/verbboxcheck.pl
> >> new file mode 100644
> >> index 0000000..976a41f
> >> --- /dev/null
> >> +++ b/utilities/verbboxcheck.pl
> >> @@ -0,0 +1,59 @@
> >> +#!/usr/bin/perl
> >> +#
> >> +# Check usage pattern of "verbbox" environment
> >> +#
> >> +# This program is free software; you can redistribute it and/or modify
> >> +# it under the terms of the GNU General Public License as published by
> >> +# the Free Software Foundation; either version 2 of the License, or
> >> +# (at your option) any later version.
> >> +#
> >> +# This program is distributed in the hope that it will be useful,
> >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >> +# GNU General Public License for more details.
> >> +#
> >> +# You should have received a copy of the GNU General Public License
> >> +# along with this program; if not, you can access it online at
> >> +# http://www.gnu.org/licenses/gpl-2.0.html.
> >> +#
> >> +# Copyright (C) Akira Yokosawa, 2016
> >> +#
> >> +# Authors: Akira Yokosawa <akiyks@gmail.com>
> >> +
> >> +my $line_now;
> >> +my $line_prev;
> >> +my $line_prev_prev;
> >> +my $in_figure = 0;
> >> +my $interval = 0;
> >> +my $line_num;
> >> +my $fig_line;
> >> +my $fig_line_num;
> >> +my $infile = $ARGV[0];
> >> +
> >> +$line_prev_prev = <>;
> >> +$line_prev = <>;
> >> +$line_now = <>;
> >> +$line_num = 3;
> >> +
> >> +while($line_now) {
> >> +    if ($in_figure == 1) {
> > 
> > Doesn't this need to be not-equal rather than equal?  Or is the fact
> > that I haven't written perl for 20 years becoming apparent?  ;-)
> 
> Ah, this should have been
> 
> +while($line_now) {
> +    if ($in_figure) {
> 
> Also, there remain unnecessary variables I used in a preliminary version.
> I'm sending a v2 of the patch. Hope it makes more sense.

OK, please color me confused.  Don't you want to list the occurrences
of \theverbbox that are -not- within a figure?

						Thanx, Paul

> >> +	if ($line_now =~ /\\theverbbox/) {
> >> +	    print "$infile:$fig_line_num:$fig_line";
> >> +	    $in_figure = 0;
> >> +	}
> >> +	$interval++;
> >> +    }
> >> +    if ($line_now =~ /\\begin\{figure\}/) {
> >> +	$in_figure = 1;
> >> +	$fig_line = $line_now;
> >> +	$fig_line_num = $line_num;
> >> +    }
> >> +    if ($interval > 3) {
> >> +	$in_figure = 0;
> >> +	$interval = 0;
> >> +    }
> >> +    $line_prev_prev = $line_prev;
> >> +    $line_prev = $line_now;
> >> +    $line_now = <>;
> >> +    $line_num++;
> >> +}
> >> -- 
> >> 1.9.1
> >>
> > 
> > 
> 


  reply	other threads:[~2016-09-12 23:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 15:08 [PATCH] Add scripts to check 'verbbox' env usage Akira Yokosawa
2016-09-12 15:49 ` Paul E. McKenney
2016-09-12 22:12   ` Akira Yokosawa
2016-09-12 23:28     ` Paul E. McKenney [this message]
2016-09-13 12:09       ` Akira Yokosawa
2016-09-13 14:08         ` Paul E. McKenney
2016-09-13 15:16           ` Akira Yokosawa
2016-09-12 22:15 ` [PATCH v2] " 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=20160912232857.GY3851@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akiyks@gmail.com \
    --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.