On 3/7/2020 2:13 PM, Marcel Fabian Krüger wrote:
Hi,
according to the documentation for `append_to_vlist_filter`:
The prevdepth is also optional
so it should be allowed to only return a box in which case the prevdepth
value shouldn't change.
But if we actually try this:
\directlua{
callback.register("append_to_vlist_filter", function(b)
return b
end)
}
abc
\bye
LuaTeX answers with
warning (pdf backend): no pages of output.
because it discards all boxes. This is caused by a bug in luanode.c,
lua_appendtovlist_callback:
The callback is called with lua_pcall(Luas, 4, 2, 0). Then LuaTeX tries
to determine if one or two values have been returned by looking at the
type of slot -1: If this is a number, the second return value have been
a number and it is evaluated as new prevdepth. Otherwise
else if (lua_type(Luas, -1) != LUA_TNIL) {
p = check_isnode(Luas, -1);
*result = *p;
}
is evaluated to scan for a single return value which is a node. But because
lua_pcall(Luas, 4, 2, 0) explicitly requested two return values, a
callback with one return values would result in a stack where the one
return value is followed by `nil`. Therefore this `if` block is not
entered.
The problem can be fixed by always looking at stack slot -2 for the
returned node:
actually we can as well accept nil then so that one can discard something
if (lua_type(Luas, -2) == LUA_TUSERDATA) {
halfword* p = lmt_check_isnode(Luas, -2);
*result = *p;
} else if (lua_type(Luas, -2) == LUA_TNIL) {
*result = null;
} else {
normal_warning("append to vlist","error: node or nil expected");
}
if (lua_type(Luas, -1) == LUA_TNUMBER) {
*next_depth = lmt_roundnumber(Luas, -1);
*prev_set = 1;
}
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
_______________________________________________
dev-luatex mailing list
dev-luatex@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-luatex