[tex4ht-commits] [SCM] tex4ht updated: r735 - trunk/lit

michal_h21 at gnu.org.ua michal_h21 at gnu.org.ua
Sun Jun 7 23:25:45 CEST 2020


Author: michal_h21
Date: 2020-06-08 00:25:45 +0300 (Mon, 08 Jun 2020)
New Revision: 735

Modified:
   trunk/lit/checklog.lua
Log:
Enable checking of multiple log files

Modified: trunk/lit/checklog.lua
===================================================================
--- trunk/lit/checklog.lua	2020-06-07 14:43:29 UTC (rev 734)
+++ trunk/lit/checklog.lua	2020-06-07 21:25:45 UTC (rev 735)
@@ -9,34 +9,41 @@
 -- the following library is part of make4ht
 local error_logparser = require("make4ht-errorlogparser")
 
-local input_file = arg[1]
+local function parse_log(content)
+  -- log parsing can be expensive on time, don't do it if we don't have
+  -- any error message in the log file
+  if content:match("\n!") then
+    local errors = error_logparser.parse(content)
+    if #errors > 0 then
+      print("Checking " .. input_file)
+      print("Errors found:")
+      for _, err in ipairs(errors) do
+        print(err.filename or "?", err.line or "?", err.error)
+      end
+      os.exit(1)
+    end
+  end
+end
+
 local content 
 -- the log file can be passed as filename argument, or piped from shell
-if input_file then
-  local ext = input_file:match("%.([^%.]+)$")
-  if not ext then
-    input_file = input_file .. ".log"
-  elseif ext ~="log" then
-    input_file = input_file:gsub("[^%.]+$", "log")
+
+if #arg > 0 then
+  for _, input_file in ipairs(arg) do
+    local ext = input_file:match("%.([^%.]+)$")
+    if not ext then
+      input_file = input_file .. ".log"
+    elseif ext ~="log" then
+      input_file = input_file:gsub("[^%.]+$", "log")
+    end
+    local f = io.open(input_file, "r")
+    content = f:read("*all")
+    f:close()
+    parse_log(content)
   end
-
-  local f = io.open(input_file, "r")
-  content = f:read("*all")
 else
   -- read from STDIN
   content = io.read("*all")
+  parse_log(content)
 end
--- log parsing can be expensive on time, don't do it if we don't have
--- any error message in the log file
-if content:match("\n!") then
-  local errors = error_logparser.parse(content)
-  if #errors > 0 then
-    print("Checking " .. input_file)
-    print("Errors found:")
-    for _, err in ipairs(errors) do
-      print(err.filename or "?", err.line or "?", err.error)
-    end
-    os.exit(1)
-  end
-end
 



More information about the tex4ht-commits mailing list.