Off-by-one error in node.protect_glyph?
Greetings, it looks like node.protect_glyph changes a subtype of 256 to 512, and node.unprotect_glyph does not change a subtype of 256 to 0. Are the following changes correct: --- a/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -6151,7 +6151,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) #define protect_one_indeed(n) \ if (n != null) { \ int s = subtype(n); \ - if (s <= 256) { \ + if (s < 256) { \ subtype(n) = (quarterword) (s == 1 ? 256 : 256 + s); \ } \ } @@ -6162,7 +6162,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) while (h != null) { \ if (type(h) == glyph_node) { \ int s = subtype(h); \ - if (s <= 256) { \ + if (s < 256) { \ subtype(h) = (quarterword) (s == 1 ? 256 : 256 + s); \ } \ } \ @@ -6182,7 +6182,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) #define unprotect_one_indeed(n) \ if (n != null) { \ int s = subtype(n); \ - if (s > 256) { \ + if (s >= 256) { \ subtype(n) = (quarterword) (s - 256); \ } \ } @@ -6193,7 +6193,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) while (h != null) { \ if (type(h) == glyph_node) { \ int s = subtype(h); \ - if (s <= 256) { \ + if (s >= 256) { \ subtype(h) = (quarterword) (s - 256); \ } \ } \
On 2/15/2026 4:15 AM, David Chiang wrote:
Greetings, it looks like node.protect_glyph changes a subtype of 256 to 512, and node.unprotect_glyph does not change a subtype of 256 to 0. Are the following changes correct:
We're not going to touch that logic: (un)protection changes the subtype of a glyph node. The native tex font handler sets some in the 0..255 range and other mechanisms are free to use these or patch them, also for larger values, but we make an exception for 256 which can be used when no subtype is set which makes it possible to disable unprotection. We're two decades down the road with luatex and such features so we're not going to change that. One can use other subtype values if needed but one also needs to keep in mind how that works with other lua code in a macro package that has assumptions wrt those subtypes. Or one can use attributes.
--- a/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -6151,7 +6151,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) #define protect_one_indeed(n) \ if (n != null) { \ int s = subtype(n); \ - if (s <= 256) { \ + if (s < 256) { \ subtype(n) = (quarterword) (s == 1 ? 256 : 256 + s); \ } \ } @@ -6162,7 +6162,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) while (h != null) { \ if (type(h) == glyph_node) { \ int s = subtype(h); \ - if (s <= 256) { \ + if (s < 256) { \ subtype(h) = (quarterword) (s == 1 ? 256 : 256 + s); \ } \ } \ @@ -6182,7 +6182,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) #define unprotect_one_indeed(n) \ if (n != null) { \ int s = subtype(n); \ - if (s > 256) { \ + if (s >= 256) { \ subtype(n) = (quarterword) (s - 256); \ } \ } @@ -6193,7 +6193,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) while (h != null) { \ if (type(h) == glyph_node) { \ int s = subtype(h); \ - if (s <= 256) { \ + if (s >= 256) { \ subtype(h) = (quarterword) (s - 256); \ } \ } \
_______________________________________________ dev-luatex mailing list -- dev-luatex@ntg.nl To unsubscribe send an email to dev-luatex-leave@ntg.nl
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Sun, 15 Feb 2026 at 04:16, David Chiang
Greetings, it looks like node.protect_glyph changes a subtype of 256 to 512, and node.unprotect_glyph does not change a subtype of 256 to 0. Are the following changes correct:
--- a/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -6151,7 +6151,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) #define protect_one_indeed(n) \ if (n != null) { \ int s = subtype(n); \ - if (s <= 256) { \ + if (s < 256) { \ subtype(n) = (quarterword) (s == 1 ? 256 : 256 + s); \ } \ } @@ -6162,7 +6162,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) while (h != null) { \ if (type(h) == glyph_node) { \ int s = subtype(h); \ - if (s <= 256) { \ + if (s < 256) { \ subtype(h) = (quarterword) (s == 1 ? 256 : 256 + s); \ } \ } \ @@ -6182,7 +6182,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) #define unprotect_one_indeed(n) \ if (n != null) { \ int s = subtype(n); \ - if (s > 256) { \ + if (s >= 256) { \ subtype(n) = (quarterword) (s - 256); \ } \ } @@ -6193,7 +6193,7 @@ static int lang_tex_direct_hyphenating(lua_State * L) while (h != null) { \ if (type(h) == glyph_node) { \ int s = subtype(h); \ - if (s <= 256) { \ + if (s >= 256) { \ subtype(h) = (quarterword) (s - 256); \ } \ } \
checking. -- luigi
participants (3)
-
David Chiang -
Hans Hagen -
luigi scarso