[Dev-luatex] Bug in \letcharcode

Marcel Krüger tex at 2krueger.de
Mon Oct 22 21:57:15 CEST 2018


Hi,

in the implementation of \letcharcode LuaTeX calls `set_token_info(cur_cs, cur_cs + cs_token_flag);`.
This is weird, because the first argument to `set_token_info` is supposed to be a pointer to a one-word node  as returned by `get_avail` and not a `cs`.

I've got a document where this caused LuaTeX to overwrite a random token in a different macro every time `\letcharcode` was called.
The active token isn't stored anywhere, so this can be fixed by just omitting `set_token_info`.


Best regards
Marcel Krüger



Suggested patch:

diff --git a/source/texk/web2c/luatexdir/tex/maincontrol.c b/source/texk/web2c/luatexdir/tex/maincontrol.c
index 05e385b27..25acf1ea9 100644
--- a/source/texk/web2c/luatexdir/tex/maincontrol.c
+++ b/source/texk/web2c/luatexdir/tex/maincontrol.c
@@ -2698,9 +2698,7 @@ void prefixed_command(void)
                     /*tex |letcharcode| */
                     scan_int();
                     if (cur_val > 0) {
-                        cur_cs = active_to_cs(cur_val, true);
-                        set_token_info(cur_cs, cur_cs + cs_token_flag);
-                        p = cur_cs;
+                        p = active_to_cs(cur_val, true);
                         do {
                             get_token();
                         } while (cur_cmd == spacer_cmd);



More information about the dev-luatex mailing list