diff options
Diffstat (limited to 'support')
-rwxr-xr-x | support/texlogsieve/texlogsieve | 182 | ||||
-rw-r--r-- | support/texlogsieve/texlogsieve.1 | 2 | ||||
-rw-r--r-- | support/texlogsieve/texlogsieve.pdf | bin | 59004 -> 59279 bytes | |||
-rw-r--r-- | support/texlogsieve/texlogsieve.tex | 14 |
4 files changed, 157 insertions, 41 deletions
diff --git a/support/texlogsieve/texlogsieve b/support/texlogsieve/texlogsieve index b93431aa78..3520efd744 100755 --- a/support/texlogsieve/texlogsieve +++ b/support/texlogsieve/texlogsieve @@ -784,6 +784,7 @@ function registerHandlers() table.insert(beginningOfLineHandlers, citationHandler) table.insert(beginningOfLineHandlers, referenceHandler) table.insert(beginningOfLineHandlers, labelHandler) + table.insert(beginningOfLineHandlers, unusedLabelHandler) table.insert(beginningOfLineHandlers, genericLatexHandler) table.insert(beginningOfLineHandlers, latex23MessageHandler) table.insert(beginningOfLineHandlers, genericLatexVariantIHandler) @@ -821,6 +822,7 @@ function registerSummaries() table.insert(summaries, underOverSummary) table.insert(summaries, missingCharSummary) table.insert(summaries, repetitionsSummary) + table.insert(summaries, unusedLabelsSummary) table.insert(summaries, citationsSummary) table.insert(summaries, referencesSummary) table.insert(summaries, labelsSummary) @@ -1002,7 +1004,7 @@ Options: --version if vars.version then - print("texlogsieve 1.1.3") + print("texlogsieve 1.2.0") print("Copyright (C) 2021, 2022 Nelson Lago <lago@ime.usp.br>") print("License GPLv3+: GNU GPL version 3 or later " .. "<https://gnu.org/licenses/gpl.html>.") @@ -1443,6 +1445,7 @@ function adjustSeverity(msg) "The morewrites package is unnecessary", 'Unused \\captionsetup%b[]', "Unknown feature `' in font %b`'", -- empty feature, not a problem + "Package refcheck Warning: Unused label %b`'", -- we process these specially } DEFAULT_FORCED_WARNING = {} @@ -2741,6 +2744,9 @@ beginningOfLineDebugStringsHandler.patterns = { -- From libertinust1math.sty '^amsthm loaded', '^amsthm NOT loaded', + + -- refcheck + '^options: showrefs, showcites, msgs, chckunlbld', } @@ -2881,6 +2887,8 @@ beginningOfLineInfoStringsHandler.patterns = { .. '%S+, %S+ Mbit/s\n' .. 'extracting files from ' .. filepat .. '%.%.%.\n' .. '======================================================================', + "^Label %b`' newly defined as it shall be overriden\n" + .. "although it is yet undefined", } @@ -3304,6 +3312,7 @@ end -- citationHandler -- referenceHandler -- labelHandler +-- unusedLabelHandler -- (from genericLatexHandler) -- -- They differ from the prototype by the set of patterns to search for, by @@ -3314,7 +3323,9 @@ citationHandler = genericLatexHandler:new() citationHandler.patterns = { "^(LaTeX)%s+(Warning): (Citation) ('.-') on page (.-) undefined", + "^(LaTeX)%s+(Warning): (Citation) (%b`') on page (.-) undefined", "^(LaTeX)%s+(Warning): (Citation) ('.-') undefined", + "^(LaTeX)%s+(Warning): (Citation) (%b`') undefined", } function citationHandler:unpackData(data) @@ -3361,6 +3372,34 @@ function labelHandler:newMessage() return labelMessage:new() end +-- These messages are generated by the package refcheck +unusedLabelHandler = genericLatexHandler:new() + +unusedLabelHandler.patterns = { + "^(Package)%s+(refcheck)%s+(Warning): Unused label (%b`')", +} + +function unusedLabelHandler:unpackData(data) + local last = data[1] + local what = data[2] + local name = data[3] + local severity = data[4] + local key = string.sub(data[5], 2, -2) -- remove quotes + + self.message.what = what + self.message.name = name + self.message.severity = self:parseSeverity(severity) + self.message.key = key + self:findPrefix(last, name, what) + self.message.prefix = self.prefix + + self:unwrapLines() + self.message.content = Lines.current +end + +function unusedLabelHandler:newMessage() + return unusedLabelMessage:new() +end ------------------------------------------------------------------------------- -- providesHandler @@ -4803,6 +4842,12 @@ function labelMessage:toSummary() labelsSummary:add(self) end +unusedLabelMessage = Message:new() + +function unusedLabelMessage:toSummary() + unusedLabelsSummary:add(self) +end + --[[ ##################################################################### ]]-- --[[ ############################ SUMMARIES ############################## ]]-- @@ -4849,7 +4894,7 @@ function SummaryPrototype:alreadySeen(msg) end -- we use this for --no-ref-detail and --no-cite-detail -function SummaryPrototype:showDetails() +function SummaryPrototype:detailed() return true end @@ -4863,7 +4908,7 @@ function SummaryPrototype:toString() if self.header ~= "" then if COLOR then self.header = green(self.header) end - if self:showDetails() then + if self:detailed() then self.header = self.header .. '\n' else self.header = self.header .. ' ' @@ -4884,16 +4929,18 @@ function SummaryPrototype:processAllMessages() for _, messagesSublist in pairsSortedByKeys(self.messages) do local tmp = self:processSingleMessageList(messagesSublist) if tmp ~= "" then - if self:showDetails() then - allText = allText .. '\n\n' .. tmp + if self:detailed() then + allText = allText .. '\n' .. tmp else allText = allText .. ", " .. tmp end end end - -- remove leading '\n\n' or ', ' - return string.sub(allText, 3) + -- remove leading '\n' or ', ' + local _, last = string.find(allText, '^[\n, ]+') + if last then allText = string.sub(allText, last +1) end + return allText end -- This is where we process each individual sublist, generating @@ -4903,23 +4950,35 @@ function SummaryPrototype:processSingleMessageList(messages) return "" end --- This receives a list of (equal) messages and returns --- the list of pages and files where they were found. +-- This receives a list of (equal) messages and returns the list of pages +-- and files where they were found. For messages that the program "sees" +-- as equal even if they include different line numbers (such as undefined +-- references), this also shows the line numbers grouped by input file. +-- If there is a line number but not a file name (this should not really +-- happen), the line number is *not* shown; not great, but fixing this is +-- more trouble than it's worth. function SummaryPrototype:pageAndFileList(messages) - -- Build a Set with the page numbers to eliminate repetitions... + -- Build Sets with the page numbers and file names + -- to eliminate repetitions... local pages = {} local files = {} for _, msg in ipairs(messages) do if msg.physicalPage ~= nil then pages[msg.physicalPage] = true end + if msg.filename ~= nil then - files[msg.filename] = true + if files[msg.filename] == nil then + files[msg.filename] = {} + end + if msg.linenum ~= "" then + table.insert(files[msg.filename], msg.linenum) + end end end - -- and convert it to a "normal" table so we can sort it + -- and convert them to "normal" tables so we can sort them local tmp = {} for page, _ in pairs(pages) do -- not ipairs! table.insert(tmp, page) @@ -4928,14 +4987,34 @@ function SummaryPrototype:pageAndFileList(messages) table.sort(pages) tmp = {} - for file, _ in pairs(files) do - table.insert(tmp, file) + for filename, listOfLines in pairs(files) do + local text = filename + if next(listOfLines) ~= nil then -- check if the table is empty + -- same thing here for the list of lines: generate a Set to + -- eliminate duplicates, turn it into an array and sort it + local setOfLines = {} + for _, line in ipairs(listOfLines) do + setOfLines[line] = true + end + + listOfLines = {} + for line, _ in pairs(setOfLines) do + table.insert(listOfLines, line) + end + table.sort(listOfLines) + + local lines = listToCommaSeparatedString(listOfLines, + "line", "lines") + + text = text .. ": " .. lines + end + table.insert(tmp, text) end files = tmp table.sort(files) - pages = listToCommaSeparatedString(pages) - files = listToCommaSeparatedString(files) + pages = listToCommaSeparatedString(pages, "page", "pages") + files = listToCommaSeparatedString(files, "file", "files", ';') return pages, files end @@ -4958,11 +5037,11 @@ function repetitionsSummary:processSingleMessageList(messages) local where if pages ~= "" and files ~= "" then - where = 'in pages ' .. pages .. ' (files ' .. files .. ') - ' + where = 'in ' .. pages .. ' (' .. files .. ') - ' elseif pages == "" and files ~= "" then - where = 'in files ' .. files .. ' - ' + where = 'in ' .. files .. ' - ' elseif pages ~= "" and files == "" then - where = 'in pages ' .. pages .. ' - ' + where = 'in ' .. pages .. ' - ' end local content = messages[1]:toString() @@ -4988,8 +5067,11 @@ function missingCharSummary:processSingleMessageList(messages) local char = messages[1].char local font = messages[1].font - text = 'char ' .. char .. ', font ' .. font .. '\n' - .. 'in pages ' .. pages .. " (files " .. files .. ")" + text = 'char ' .. char .. ', font ' .. font + + if COLOR then text = red(text) end + + text = text .. ' in ' .. pages .. " (" .. files .. ")" return text end @@ -4999,7 +5081,7 @@ citationsSummary = SummaryPrototype:new() citationsSummary.bypassMostFilters = true citationsSummary.header = 'Undefined citations:' -function citationsSummary:showDetails() +function citationsSummary:detailed() return DETAILED_CITATION_SUMMARY end @@ -5034,9 +5116,9 @@ function citationsSummary:processSingleMessageList(messages) local key = messages[1].key if key == "" then key = '???' end - if self:showDetails() then - text = key .. '\n' - .. 'in pages ' .. pages .. " (files " .. files .. ")" + if self:detailed() then + if COLOR then key = red(key) end + text = key .. ' in ' .. pages .. " (" .. files .. ")" else text = key end @@ -5048,7 +5130,7 @@ end referencesSummary = citationsSummary:new() referencesSummary.header = 'Undefined references:' -function referencesSummary:showDetails() +function referencesSummary:detailed() return DETAILED_REFERENCE_SUMMARY end @@ -5057,11 +5139,31 @@ labelsSummary = citationsSummary:new() labelsSummary.header = 'Multiply defined labels:' -- LaTeX does not supply details for these -function labelsSummary:showDetails() +function labelsSummary:detailed() return false end +unusedLabelsSummary = citationsSummary:new() +unusedLabelsSummary.header = 'Unused labels:' + +function unusedLabelsSummary:processSingleMessageList(messages) + local text = "" + local pages, files = self:pageAndFileList(messages) + local key = messages[1].key + if key == "" then key = '???' end + + if self:detailed() then + if COLOR then key = red(key) end + text = key .. ' in ' .. pages .. " (" .. files .. ")" + else + text = key + end + + return text +end + + -- This is a little different from the others; we do not want to -- treat different messages differently, only report that there were -- under/overfull boxes in pages X, Y, and Z. So we store messages @@ -5098,8 +5200,7 @@ function underOverSummary:toString() else output = "Under/overfull boxes" if COLOR then output = green(output) end - output = output .. " in pages " - .. pages .. " (files " .. files .. ")" + output = output .. " in " .. pages .. " (" .. files .. ")" end @@ -5194,16 +5295,23 @@ function pairsSortedByKeys (t, f) return iter end -function listToCommaSeparatedString(list) - local tmp = "" - for _, item in ipairs(list) do - tmp = tmp .. ", " .. item - end +function listToCommaSeparatedString(list, singular, plural, sep) + sep = sep or ',' + if #list == 0 then return end - local _, last = string.find(tmp, '^, ') - if last ~= nil then tmp = string.sub(tmp, last +1) end + local tmp + if #list == 1 then + tmp = singular .. " " + else + tmp = plural .. " " + end - return tmp + for _, item in ipairs(list) do + tmp = tmp .. item .. sep .. " " + end + + tmp = string.sub(tmp, 1, -3) -- remove the final ", " + return tmp end function green(s) diff --git a/support/texlogsieve/texlogsieve.1 b/support/texlogsieve/texlogsieve.1 index 0e45920647..4628d1ec54 100644 --- a/support/texlogsieve/texlogsieve.1 +++ b/support/texlogsieve/texlogsieve.1 @@ -1,4 +1,4 @@ -.TH TEXLOGSIEVE "1" "April 2022" "texlogsieve 1.1.3" "User Commands" +.TH TEXLOGSIEVE "1" "July 2022" "texlogsieve 1.2.0" "User Commands" .SH NAME diff --git a/support/texlogsieve/texlogsieve.pdf b/support/texlogsieve/texlogsieve.pdf Binary files differindex 4bac5034a6..f37bc1ab30 100644 --- a/support/texlogsieve/texlogsieve.pdf +++ b/support/texlogsieve/texlogsieve.pdf diff --git a/support/texlogsieve/texlogsieve.tex b/support/texlogsieve/texlogsieve.tex index 9d7d2d751b..6270e27ffe 100644 --- a/support/texlogsieve/texlogsieve.tex +++ b/support/texlogsieve/texlogsieve.tex @@ -77,12 +77,19 @@ \changes{1.1.2}{2022/03/14}{Fix bug unwrapping lines starting with ``]''} \changes{1.1.3}{2022/04/22}{Be more careful with continuation lines in error msgs} +\changes{1.2.0}{2022/07/21}{Fix bug with missing citations} +\changes{1.2.0}{2022/07/21}{Colored keys with missing citations / chars} +\changes{1.2.0}{2022/07/21}{Improved example latexmkrc in TIPS section} +\changes{1.2.0}{2022/07/21}{Summary messages include line numbers} +\changes{1.2.0}{2022/07/21}{Summary messages use singular and plural + for pages and files} +\changes{1.2.0}{2022/07/21}{Add unused labels to summary} \begin{document} \title{\textsf{texlogsieve}:\thanks{This document -corresponds to \textsf{texlogsieve}~1.1.3, -dated~2022-04-22.}\\[.3\baselineskip] +corresponds to \textsf{texlogsieve}~1.2.0, +dated~2022-07-21.}\\[.3\baselineskip] {\normalsize(yet another program to)\\[-.6\baselineskip]} {\large filter and summarize \LaTeX\ log files} } @@ -115,7 +122,7 @@ a summary report. Highlights: \end{abstract} -\section{Introduction} +\section*{Introduction} The \LaTeX\ log file is very verbose, which is useful when debugging but a hindrance during document preparation, as warnings such as ``missing @@ -470,6 +477,7 @@ $silent = 1; # This adds "-interaction batchmode" $silence_logfile_warnings = 1; END { + local $?; # do not override previous exit status if (-s "$root_filename.blg" and open my $bibfile, '<', "$root_filename.blg") { |