[PATCH 1/3] qqz: Add script to reorder lines in qqz.tex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From fadc8d4c0b240dd49570a60b627a6e81256d511f Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@xxxxxxxxx>
Date: Mon, 9 Jan 2017 18:04:24 +0900
Subject: [PATCH 1/3] qqz: Add script to reorder lines in qqz.tex

This script moves some \QuickE{} to prevent white boxes from
becoming widows at the end of Answers which finish with an
"enumerate" or "figure" environment.

Excerpt of diff by this script is as follows:

@@ -2468,8 +2468,8 @@
                and~\ref{chp:Deferred Processing}.
        \item   The polling loops result in poor energy efficiency.
                An event-driven design is preferable.
-       \end{enumerate}
 \QuickE{}
+       \end{enumerate}
 \QuickQ{}
        On the \path{count_stat.c} row of
        Table~\ref{tab:count:Statistical Counter Performance on Power-6},
@@ -4527,6 +4527,7 @@
        \co{synchronize_sched()} with \co{synchronize_rcu()},
        perhaps as shown in
        Figure~\ref{fig:defer:Using RCU to Wait for Mythical Preemptible NMIs to Finish}.
+\QuickE{}
 %
 \begin{figure}[tb]
 {\scriptsize
@@ -4573,7 +4574,6 @@
 \label{fig:defer:Using RCU to Wait for Mythical Preemptible NMIs to Finish}
 \end{figure}
 %
-\QuickE{}
 \QuickQ{}
        Why do some of the cells in
        Table~\ref{tab:defer:RCU Wait-to-Finish APIs}

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 utilities/qqzreorder.pl | 88 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 utilities/qqzreorder.pl

diff --git a/utilities/qqzreorder.pl b/utilities/qqzreorder.pl
new file mode 100644
index 0000000..197d5a0
--- /dev/null
+++ b/utilities/qqzreorder.pl
@@ -0,0 +1,88 @@
+#!/usr/bin/perl
+#
+# Move line of \QuickE{} below \end{enumerate} to just above
+# the \end{enumerate}.
+# Move line of \QuickE{} below \end{figure} to above
+# \begin{figure} corresponding to it.
+#
+# 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, 2017
+#
+# Authors: Akira Yokosawa <akiyks@xxxxxxxxx>
+
+my $line;
+my $after_end_enum = 0;
+my $in_figure = 0;
+my $after_figure = 0;
+my $line_idx = 1;
+my @line_buf;
+
+$line_buf[1] = <>;
+while($line = <>) {
+    if ($after_end_enum) {
+	if ($line =~ /\\QuickE\{\}/) {
+	    print $line;
+	} else {
+	    print $line_buf[1];
+	    $line_buf[1] = $line;
+	}
+	$after_end_enum = 0;
+	next;
+    }
+    if ($in_figure) {
+	if ($line =~ /\\end\{figure\}/) {
+	    $after_figure = 1;
+	    $in_figure = 0;
+	}
+	$line_buf[++$line_idx] = $line;
+	next;
+    }
+    if ($after_figure) {
+	if ($line =~ /%/) {
+	    $line_buf[++$line_idx] = $line;
+	    next;
+	}
+	if ($line =~ /\\QuickE\{\}/) {
+	    print $line;
+	    for my $i (1 .. $line_idx-1) {
+		print $line_buf[$i];
+	    }
+	    $line_buf[1] = $line_buf[$line_idx];
+	} else {
+	    for my $i (1 .. $line_idx) {
+		print $line_buf[$i];
+	    }
+	    $line_buf[1] = $line;
+	}
+	$line_idx = 1;
+	$after_figure = 0;
+	next;
+    }
+    if ($line =~ /\\end\{enumerate\}/) {
+	print $line_buf[1];
+	$line_buf[1] = $line;
+	$after_end_enum = 1;
+	next;
+    }
+    if ($line =~ /\\begin\{figure\}/) {
+	$in_figure = 1;
+	$line_buf[++$line_idx] = $line;
+	next;
+    }
+    print $line_buf[1];
+    $line_buf[1] = $line;
+}
+print $line_buf[1];
-- 
2.7.4


--
To unsubscribe from this list: send the line "unsubscribe perfbook" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux