[luatex] Assignment to tex.skip shows an unexpected behaviour
Takayuki YATO
zrbabbler at yahoo.co.jp
Fri Jun 15 19:26:33 CEST 2012
Hello,
I found a strange behavior about tex.skip array.
The LuaTeX manual says that assignment to TeX registers
through tex.count, tex.skip, etc. is local (perhaps unless
\globaldefs > 0).
Thus when I compile the following plain TeX source:
\newskip\skipA
\skipA=50pt
\begingroup
%\skipA=60pt %(*)
\message{\the\skipA}
\directlua{
local gsp = node.new(node.id("glue_spec"))
gsp.width = 100 * 0x10000
tex.skip.skipA = gsp
}
\message{\the\skipA}
\endgroup
\message{\the\skipA}
\bye
the expected terminal output will be:
50.0pt 100.0pt 50.0pt
But the actual output is:
50.0pt 100.0pt 100.0pt
that is, the assignment through tex.skip turns to be global.
The more strange fact is that uncommenting the line (*)
(thus once doing local assignment in TeX) causes the Lua
assignment local, leading to the output:
60.0pt 100.0pt 50.0pt
And finally I make the nesting one-level deeper:
\newskip\skipA
\skipA=25pt
\begingroup
\skipA=50pt
\begingroup
\directlua{
local gsp = node.new(node.id("glue_spec"))
gsp.width = 100 * 0x10000
tex.skip.skipA = gsp
}
\message{\the\skipA}
\endgroup
\message{\the\skipA} % here \skipA becomes zero!
\endgroup
\message{\the\skipA}
\bye
the resulting output is totally unreasonable:
100.0pt 0.0pt 25.0pt
I inspected the source code and found that Lua assignments
are handled by the following function:
int set_tex_skip_register(int j, halfword v)
{
//......
if (type(v) != glue_spec_node)
return 1;
word_define(j + skip_base, v); //(**)
return 0;
}
If Lua assignment should be done in the same way as in
TeX, then the line (**) should be:
define(j + skip_base, glue_ref_cmd, v);
Happy (Lua)TeXing,
Takayuki YATO
More information about the luatex
mailing list