[latex3-commits] [git/LaTeX3-latex3-l3build] master: Cleaner normalization of binary content (fb32ba9)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Aug 2 21:28:31 CEST 2018


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/fb32ba9fd88b36261be647bf344bd6911084c99e

>---------------------------------------------------------------

commit fb32ba9fd88b36261be647bf344bd6911084c99e
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Aug 2 20:28:31 2018 +0100

    Cleaner normalization of binary content


>---------------------------------------------------------------

fb32ba9fd88b36261be647bf344bd6911084c99e
 l3build-check.lua       |   25 ++++++++++++++-----------
 l3build.dtx             |    9 ++++++---
 testfiles/00-test-2.tpf |    7 +++++--
 3 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/l3build-check.lua b/l3build-check.lua
index c84f3b2..7cac25a 100644
--- a/l3build-check.lua
+++ b/l3build-check.lua
@@ -493,31 +493,34 @@ local function normalise_pdf(pdffile,npdffile)
   close(file)
   local new_content = ""
   local stream_content = ""
+  local binary = false
   local stream = false
   for line in gmatch(contents, "([^\n]*)\n") do
     if stream then
       if match(line,"endstream") then
         stream = false
-        local binary = false
+        if binary then
+          new_content = new_content .. "[BINARY STREAM]" .. os_newline
+        else
+           new_content = new_content .. stream_content .. line .. os_newline
+        end
+        binary = false
+      else
         for i = 0, 31 do
-          if match(stream_content,char(i)) then
+          if match(line,char(i)) then
             binary = true
             break
           end
         end
-        if binary then
-          new_content = new_content .. "[BINARY STREAM]\n"
-        else
-          new_content = new_content .. stream_content
+        if not binary and not match(line, "^ *$") then
+          stream_content = stream_content .. line .. os_newline
         end
-      else
-        stream_content = stream_content .. line
       end
     elseif match(line,"^stream$") then
+      binary = false
       stream = true
-      stream_content = ""
-    end
-    if not match(line, "^ *$") and not stream then
+      stream_content = "stream" .. os_newline
+    elseif not match(line, "^ *$") then
       new_content = new_content .. line .. os_newline
     end
   end
diff --git a/l3build.dtx b/l3build.dtx
index e6f015a..7ace0fa 100644
--- a/l3build.dtx
+++ b/l3build.dtx
@@ -1115,9 +1115,12 @@
 % outlined above. However, there are cases where the detail of output structure
 % is important. This can only be fully tested by comparing PDF structure.
 % To support this, \pkg{l3build} can be instructed to build and compare
-% PDF files by setting up tests in \texttt{.pvt} files. The resulting
-% \texttt{.tpf} output is a digested form of the PDF, which can be compared
-% as text.
+% PDF files by setting up tests in \texttt{.pvt} files. The following
+% normalization takes place:
+% \begin{itemize}
+%   \item Replacement of binary streams by the marker |[BINARY STREAM]|
+%   \item Removal of blank lines
+% \end{itemize}
 %
 % Testing on the result of typesetting \texttt{.pvt} files is carried out using
 % only the standard engine, as aspects of PDF files are not identical between
diff --git a/testfiles/00-test-2.tpf b/testfiles/00-test-2.tpf
index a9ffe7b..6020b9a 100644
--- a/testfiles/00-test-2.tpf
+++ b/testfiles/00-test-2.tpf
@@ -4,7 +4,11 @@
 <<
 /Length 73        
 >>
-BT/F15 9.9626 Tf 92.921 759.927 Td [(#$%&)]TJ 0 -23.91 Td [(#$%&)]TJETendstream
+stream
+BT
+/F15 9.9626 Tf 92.921 759.927 Td [(#$%&)]TJ 0 -23.91 Td [(#$%&)]TJ
+ET
+endstream
 endobj
 2 0 obj
 <<
@@ -32,7 +36,6 @@ endobj
 /Length 8480      
 >>
 [BINARY STREAM]
-endstream
 endobj
 8 0 obj
 <<





More information about the latex3-commits mailing list