From b49dd7c340dbe68a28c8a976cd6a1429ca8aafff Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Mon, 4 Jan 2021 03:00:45 +0000
Subject: CTAN sync 202101040300

---
 support/latex-make/latex-make.dtx | 72 ++++++++++++++++++++++-----------------
 1 file changed, 40 insertions(+), 32 deletions(-)

(limited to 'support/latex-make/latex-make.dtx')

diff --git a/support/latex-make/latex-make.dtx b/support/latex-make/latex-make.dtx
index 0aae87bd55..d780dedb39 100644
--- a/support/latex-make/latex-make.dtx
+++ b/support/latex-make/latex-make.dtx
@@ -2,7 +2,7 @@
 %
 %<*dtx>
           \ProvidesFile{latex-make.dtx}
-[2020/06/01 v2.4.0 Fix bugs with new LaTeX core]
+[2021/01/03 v2.4.2 No changes in latex-make.dtx]
 %</dtx>
 %    \fi
 % \iffalse
@@ -116,6 +116,8 @@
 % \changes{v2.3.0}{2018/10/17}{Add DEPENDS-EXCLUDE, add doc and
 % support for local texmf tree}
 % \changes{v2.4.0}{2020/06/01}{Support inkscape version >= 1.0}
+% \changes{v2.4.1}{2020/07/10}{Fix encoding problem with latexfilter.pl}
+% \changes{v2.4.2}{2021/01/03}{No changes in latex-make.dtx}
 %
 % \makeatletter
 % \def\SpecialOptionIndex#1{\@bsphack
@@ -1975,9 +1977,8 @@ if __name__ == "__main__":
 
 """
 
-stdin : the original xfig file
-stdout : the output xfig file
-args : all depths we want to keep
+stdin : the original LaTeX log file
+stdout : the output filtered log file
 
 """
 
@@ -1986,6 +1987,7 @@ import optparse
 import os.path
 import re
 import sys
+import io
 
 def main():
     parser = optparse.OptionParser()
@@ -1997,34 +1999,40 @@ def main():
     warnerror_re = re.compile(r"^(LaTeX|Package|Class)( (.*))? (Warning:|Error:)")
     fullbox_re = re.compile(r"^(Underfull|Overfull) \\[hv]box")
     accu = ''
-    for line in sys.stdin:
-        if display > 0:
-            display -= 1
-        if line[0:4].lower() in ('info', 'warn') or line[0:5].lower() == 'error':
-            display = 0
-        line_groups = warnerror_re.match(line)
-        if line_groups:
-            start_line = line_groups.group(3)
-            if not start_line:
-                start_line = ''
-            if line_groups.group(2):
-                start_line = "(" + start_line + ")"
-            display = 1
-            in_display = 1
-        elif (start_line != '') and (line[0:len(start_line)] == start_line):
-            display = 1
-        elif line == "\n":
-            in_display = 0
-        elif line[0:4] == 'Chap':
-            display = 1
-        elif fullbox_re.match(line):
-            display = 2
-        if display:
-            print(accu, end="")
-            accu = line
-        elif in_display:
-            print(accu[0:-1], end="")
-            accu = line
+    # PDFLaTeX log file is not really in latin-1 (in T1 more exactly)
+    # but all bytes are corrects in latin-1, so python won't stop
+    # while parsing log.
+    # Without specifying this encoding (ie using default utf-8), we
+    # can get decode errors (UnicodeDecodeError: 'utf-8' codec can't decode byte...)
+    with io.open(sys.stdin.fileno(),'r',encoding='latin-1') as sin:
+        for line in sin:
+            if display > 0:
+                display -= 1
+            if line[0:4].lower() in ('info', 'warn') or line[0:5].lower() == 'error':
+                display = 0
+            line_groups = warnerror_re.match(line)
+            if line_groups:
+                start_line = line_groups.group(3)
+                if not start_line:
+                    start_line = ''
+                if line_groups.group(2):
+                    start_line = "(" + start_line + ")"
+                display = 1
+                in_display = 1
+            elif (start_line != '') and (line[0:len(start_line)] == start_line):
+                display = 1
+            elif line == "\n":
+                in_display = 0
+            elif line[0:4] == 'Chap':
+                display = 1
+            elif fullbox_re.match(line):
+                display = 2
+            if display:
+                print(accu, end="")
+                accu = line
+            elif in_display:
+                print(accu[0:-1], end="")
+                accu = line
 
 if __name__ == "__main__":
     main()
-- 
cgit v1.2.3

