[PATCH 6/8] Makefile: Add optional recipe to detect conflict in page group object

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

 



>From 91e7ad2b3e5dfae239d3f4e64d92b7c21ba9ed75 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@xxxxxxxxx>
Date: Sat, 23 Feb 2019 19:26:57 +0900
Subject: [PATCH 6/8] Makefile: Add optional recipe to detect conflict in page group object

As long as "page group objects" are identical, setting
\pdfsuppresswarningpagegroup variable done in the previous commit
is safe.

This commit adds an optional recipe in ".svn -> .pdf"
transformation to extract page group object from the generated .pdf
file, and to compare it with the expected one given in "pagegroup".

The added recipe is enabled only when an environment variable
"PERFBOOK_CHKPAGEGROUP" is set "on". The check requires a command
named "qpdf", which is available on most Linux distributions.

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 .gitignore                |  2 ++
 Makefile                  | 16 +++++++++++++++-
 pagegroup                 |  6 ++++++
 utilities/extpagegroup.pl | 37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 pagegroup
 create mode 100755 utilities/extpagegroup.pl

diff --git a/.gitignore b/.gitignore
index 34bbb85..ebd5e98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,8 @@
 *.svgi
 *.fcv
 *.ltms
+*.pdfp
+*.pdfq
 perfbook_flat.tex
 qqz.tex
 contrib.tex
diff --git a/Makefile b/Makefile
index 338669a..648091a 100644
--- a/Makefile
+++ b/Makefile
@@ -64,6 +64,7 @@ FIG2EPS := $(shell which fig2eps 2>/dev/null)
 A2PING := $(shell which a2ping 2>/dev/null)
 INKSCAPE := $(shell which inkscape 2>/dev/null)
 LATEXPAND := $(shell which latexpand 2>/dev/null)
+QPDF := $(shell which qpdf 2>/dev/null)
 
 # required fonts
 STEELFONT := $(shell fc-list | grep -c -i steel)
@@ -115,6 +116,8 @@ else
 	targ = $(default)
 endif
 
+chkpagegroup = $(PERFBOOK_CHKPAGEGROUP)
+
 .PHONY: all touchsvg clean distclean neatfreak 2c ls-unused $(ABBREVTARGETS) mslm perfbook-mslm.pdf mslmmsg help
 all: $(targ)
 
@@ -285,6 +288,16 @@ else
 endif
 	@inkscape --export-pdf=$@ $<i > /dev/null 2>&1
 	@rm -f $<i
+ifeq ($(chkpagegroup),on)
+ifndef QPDF
+	$(error qpdf not found. Please install it)
+endif
+	@echo "checking page group in $@"
+	@qpdf --qdf $@ $@q
+	@./utilities/extpagegroup.pl < $@q > $@p
+	@diff -q -w $@p pagegroup
+	@rm -f $@q $@p
+endif
 
 CodeSamples/snippets.d: $(SOURCES_OF_SNIPPET) $(GEN_SNIPPET_D)
 	sh ./utilities/gen_snippet_d.sh
@@ -333,7 +346,8 @@ clean:
 	find . -name '*.aux' -o -name '*.blg' \
 		-o -name '*.dvi' -o -name '*.log' \
 		-o -name '*.qqz' -o -name '*.toc' -o -name '*.bbl' \
-		-o -name '*.fcv' -o -name '*.ltms' | xargs rm -f
+		-o -name '*.fcv' -o -name '*.ltms' \
+		-o -name '*.pdfp' -o -name '*.pdfq' | xargs rm -f
 	rm -f perfbook_flat.tex perfbook*.out perfbook-*.tex
 	rm -f $(LATEXGENERATED)
 	rm -f CodeSamples/snippets.mk CodeSamples/snippets.d
diff --git a/pagegroup b/pagegroup
new file mode 100644
index 0000000..4cc4650
--- /dev/null
+++ b/pagegroup
@@ -0,0 +1,6 @@
+  /Group <<
+    /CS /DeviceRGB
+    /I true
+    /S /Transparency
+    /Type /Group
+  >>
diff --git a/utilities/extpagegroup.pl b/utilities/extpagegroup.pl
new file mode 100755
index 0000000..67c206d
--- /dev/null
+++ b/utilities/extpagegroup.pl
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Extract "page group object" in PDF generated by Inkscape
+#
+# Copyright (C) Akira Yokosawa, 2019
+#
+# Authors: Akira Yokosawa <akiyks@xxxxxxxxx>
+
+use strict;
+use warnings;
+
+my $line;
+my $in_pagegroup = 0;
+
+while($line = <>) {
+    if ($in_pagegroup == 3) {
+	$in_pagegroup = 0;
+	print $line;
+    }
+    if ($in_pagegroup == 2) {
+	if ($line =~ /\/Group/) {
+	    $in_pagegroup = 3;
+	}
+	print $line;
+    }
+    if ($in_pagegroup == 1) {
+	if ($line =~ /\/Group/) {
+	    $in_pagegroup = 2;
+	    print $line;
+	}
+    }
+    if ($in_pagegroup == 0 && $line =~ /\/Contents/) {
+	$in_pagegroup = 1;
+    }
+    if (eof) { last; }
+}
-- 
2.7.4





[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