Miscellaneous feature addition patches

Hi Luigi, I've attached some small patches that I've been sitting on for a while (and forgot about until just before the TL25 freeze, sorry). These are all technically feature additions, and I'm aware that LuaTeX is frozen-ish, but the changes are mostly trivial, and there's a proven need for all of these features. I'll copy the commit messages below (and add the patches as attachments): # Add `token.fast_put_next` Currently, `token.put_next` gets the metatable for the passed token userdata object and compares it to the authoritative metatable from the registry. However, this is quite slow; in benchmarking some real-world code, this added 15% to the total runtime of the code: https://github.com/latex3/latex3/pull/1557#issuecomment-2241981665 The new function `token.fast_put_next` skips this error checking, and as such is faster. This does mean that if the passed value is a non-token userdatum, the engine will get confused and crash; however, the `node` and `node.direct` libraries already provide plenty of ways to corrupt the engine if you try hard enough, so this shouldn't be a significant issue. --- manual/luatex-tex.tex | 8 +++- .../texk/web2c/luatexdir/lua/lnewtokenlib.c | 41 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) # Support setting the environment with "os.spawn". It's not currently possible to create a new process with a custom environment, even though this is fairly useful functionality. This was requested by the l3build developers https://chat.stackexchange.com/transcript/message/65794389#65794389 since right now, l3build uses the shell to do this https://github.com/latex3/l3build/blob/f75745/l3build-file-functions.lua#L12... https://github.com/latex3/l3build/blob/f75745/l3build-file-functions.lua#L15... but this is both non-portable and error-prone. --- manual/luatex-lua.tex | 6 ++++++ source/texk/web2c/luatexdir/lua/loslibext.c | 24 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) # Permit usage of the `img` module in `texlua` mode. This is needed for a Lua-based reimplementation of `extractbb` to work without the `ffi` library; see https://github.com/gucci-on-fleek/extractbb/blob/v0.0.7/source/extractbb-scr... for further context. This may also be useful for other scripts; see https://github.com/atticus-sullivan/memoize/pull/2#issuecomment-2613860793 for another example. --- source/texk/web2c/luatexdir/lua/luastuff.c | 4 +--- source/texk/web2c/luatexdir/pdf/pdfgen.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) Thanks, -- Max

On Sat, 8 Feb 2025 at 12:27, Max Chernoff
Hi Luigi,
I've attached some small patches that I've been sitting on for a while (and forgot about until just before the TL25 freeze, sorry). These are all technically feature additions, and I'm aware that LuaTeX is frozen-ish, but the changes are mostly trivial, and there's a proven need for all of these features.
ok I will check them. -- luigi

Hi Luigi, On Sat, 2025-02-08 at 04:21 -0700, Max Chernoff wrote:
# Support setting the environment with "os.spawn". [...]
I found a couple small bugs with my implementation: 1. Passing the command-line as a table doesn't work if an environment table is added. 2. Segfaults if a zero-length environment table is passed. 3. Skips the last passed environment variable. The attached patch should fix all of these. Thanks, and sorry for the bugs, -- Max

On Tue, 11 Feb 2025 at 08:21, Max Chernoff
Hi Luigi,
On Sat, 2025-02-08 at 04:21 -0700, Max Chernoff wrote:
# Support setting the environment with "os.spawn". [...]
I found a couple small bugs with my implementation:
1. Passing the command-line as a table doesn't work if an environment table is added.
2. Segfaults if a zero-length environment table is passed.
3. Skips the last passed environment variable.
The attached patch should fix all of these.
ok, done. -- luigi
participants (2)
-
luigi scarso
-
Max Chernoff