[latex3-commits] [git/LaTeX3-latex3-latex2e] develop: Don't return true in LuaTeX list callbacks (c0381814)
Marcel Fabian Krüger
tex at 2krueger.de
Wed Nov 17 08:59:47 CET 2021
Repository : https://github.com/latex3/latex2e
On branch : develop
Link : https://github.com/latex3/latex2e/commit/c038181414defe3b335380cc9521f2c692bd8012
>---------------------------------------------------------------
commit c038181414defe3b335380cc9521f2c692bd8012
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Mon Nov 8 09:17:07 2021 +0100
Don't return true in LuaTeX list callbacks
>---------------------------------------------------------------
c038181414defe3b335380cc9521f2c692bd8012
base/changes.txt | 1 +
base/doc/ltnews35.tex | 5 +++++
base/ltluatex.dtx | 19 ++++++-------------
base/ltshipout.dtx | 5 +++--
base/testfiles/tlb-ltluatex-001.luatex.tlg | 2 +-
5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index e4391479..79d9ec7e 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -10,6 +10,7 @@ are not part of the distribution.
* ltluatex.dtx:
Classify [hv]pack_quality callbacks as exclusive
+ Never pass true to the engine for LuaTeX list callbacks
================================================================================
All changes above are only part of the development branch for the next release.
diff --git a/base/doc/ltnews35.tex b/base/doc/ltnews35.tex
index b701339a..6b5d4816 100644
--- a/base/doc/ltnews35.tex
+++ b/base/doc/ltnews35.tex
@@ -155,6 +155,11 @@ The previous type \texttt{list} resulted in incorrect parameters when multiple
handlers were set, therefore this only makes an existing restriction more
explicit.
+Additionally the return value \texttt{true} for \texttt{list} callbacks is now
+handled internally and no longer passed on to the engine. This simplifies the
+handling of these callbacks and makes it easier to provide consistent
+interfaces for user defined \texttt{list} callbacks.
+
\subsection{???}
%
\githubissue{???}
diff --git a/base/ltluatex.dtx b/base/ltluatex.dtx
index 1f8598ff..612e1354 100644
--- a/base/ltluatex.dtx
+++ b/base/ltluatex.dtx
@@ -1518,11 +1518,11 @@ end
% Handler for |list| callbacks.
% \changes{v1.0k}{2015/12/02}{resolve name and i.description (PHG)}
% \changes{v1.1s}{2020/12/02}{Fix return value of list callbacks}
+% \changes{v1.1w}{2021/11/17}{Never pass on \texttt{true} return values for list callbacks}
% \begin{macrocode}
local function list_handler(name)
return function(head, ...)
local ret
- local alltrue = true
for _,i in ipairs(callbacklist[name]) do
ret = i.func(head, ...)
if ret == false then
@@ -1533,18 +1533,17 @@ local function list_handler(name)
return false
end
if ret ~= true then
- alltrue = false
head = ret
end
end
- return alltrue and true or head
+ return head
end
end
% \end{macrocode}
% Default for user-defined |list| and |reverselist| callbacks without explicit default.
% \begin{macrocode}
-local function list_handler_default()
- return true
+local function list_handler_default(head)
+return head
end
% \end{macrocode}
% Handler for |reverselist| callbacks.
@@ -1553,7 +1552,6 @@ end
local function reverselist_handler(name)
return function(head, ...)
local ret
- local alltrue = true
local callbacks = callbacklist[name]
for i = #callbacks, 1, -1 do
local cb = callbacks[i]
@@ -1566,11 +1564,10 @@ local function reverselist_handler(name)
return false
end
if ret ~= true then
- alltrue = false
head = ret
end
end
- return alltrue and true or head
+ return head
end
end
% \end{macrocode}
@@ -1901,14 +1898,10 @@ callback_register("mlist_to_hlist", function(head, display_type, need_penalties)
if current == false then
flush_list(head)
return nil
- elseif current == true then
- current = head
end
current = call_callback("mlist_to_hlist", current, display_type, need_penalties)
local post = call_callback("post_mlist_to_hlist_filter", current, display_type, need_penalties)
- if post == true then
- return current
- elseif post == false then
+ if post == false then
flush_list(current)
return nil
end
diff --git a/base/ltshipout.dtx b/base/ltshipout.dtx
index 7f6555d1..9e7bf4be 100644
--- a/base/ltshipout.dtx
+++ b/base/ltshipout.dtx
@@ -741,8 +741,9 @@
luatexbase.create_callback('pre_shipout_filter', 'list')
local~call, getbox, setbox = luatexbase.call_callback, tex.getbox, tex.setbox~
lua.get_functions_table()[\the \@@_finalize_box:] = function()
- local~result = call('pre_shipout_filter', getbox(\the \l_shipout_box))
- if~not (result == true) then~
+ local head = getbox(\the \l_shipout_box)
+ local~result = call('pre_shipout_filter', head)
+ if~not (result == head) then~
setbox(\the \l_shipout_box, result~or~nil)
end~
end
diff --git a/base/testfiles/tlb-ltluatex-001.luatex.tlg b/base/testfiles/tlb-ltluatex-001.luatex.tlg
index 7f07f32d..53c7483d 100644
--- a/base/testfiles/tlb-ltluatex-001.luatex.tlg
+++ b/base/testfiles/tlb-ltluatex-001.luatex.tlg
@@ -7,7 +7,7 @@ stack traceback:
^^I[C]: in function 'error'
^^I./ltluatex.lua:110: in upvalue 'module_error'
^^I./ltluatex.lua:117: in upvalue 'luatexbase_error'
-^^I./ltluatex.lua:432: in field 'create_callback'
+^^I./ltluatex.lua:428: in field 'create_callback'
^^I[\directlua]:1: in main chunk.
l. ...}
The lua interpreter ran into a problem, so the
More information about the latex3-commits
mailing list.