[luatex] Problems using node.setglue (r6317)

Deepak Jois deepak.jois at gmail.com
Thu Apr 27 08:31:40 CEST 2017


Not sure if there was something unclear about my earlier message. Anyway,
since I did not receive any response, I decided to dig into the source
myself, and it seems a bug was introduced in r6219 and is in the file
source/texk/web2c/luatexdir/lua/lnodelib.c:

The code below (starting at line 3201) always returns an error. That seems
wrong. Any comments?

===
static int lua_nodelib_set_glue(lua_State * L)
{
    halfword n = *check_isnode(L, 1);
    int top = lua_gettop(L) ;
    if (n) {
        halfword t = type(n);
        if (t == glue_node || t == glue_spec_node || t == math_node) {
            width(n)         = ((top > 1 && lua_type(L, 2) == LUA_TNUMBER))
? lua_roundnumber(L,2) : 0;
            stretch(n)       = ((top > 2 && lua_type(L, 3) == LUA_TNUMBER))
? lua_roundnumber(L,3) : 0;
            shrink(n)        = ((top > 3 && lua_type(L, 4) == LUA_TNUMBER))
? lua_roundnumber(L,4) : 0;
            stretch_order(n) = ((top > 4 && lua_type(L, 5) == LUA_TNUMBER))
? lua_tointeger(L,5) : 0;
            shrink_order(n)  = ((top > 5 && lua_type(L, 6) == LUA_TNUMBER))
? lua_tointeger(L,6) : 0;
        }
    }
    return luaL_error(L, "glue (spec) expected");
    return 0;
}

==

I believe it should be something like:

==
static int lua_nodelib_set_glue(lua_State * L)
{
    halfword n = *check_isnode(L, 1);
    int top = lua_gettop(L) ;
    if (n) {
        halfword t = type(n);
        if (t == glue_node || t == glue_spec_node || t == math_node) {
            width(n)         = ((top > 1 && lua_type(L, 2) == LUA_TNUMBER))
? lua_roundnumber(L,2) : 0;
            stretch(n)       = ((top > 2 && lua_type(L, 3) == LUA_TNUMBER))
? lua_roundnumber(L,3) : 0;
            shrink(n)        = ((top > 3 && lua_type(L, 4) == LUA_TNUMBER))
? lua_roundnumber(L,4) : 0;
            stretch_order(n) = ((top > 4 && lua_type(L, 5) == LUA_TNUMBER))
? lua_tointeger(L,5) : 0;
            shrink_order(n)  = ((top > 5 && lua_type(L, 6) == LUA_TNUMBER))
? lua_tointeger(L,6) : 0;
            return 0;
        }
    }
    return luaL_error(L, "glue (spec) expected");
}
==

On Thu, Apr 20, 2017 at 2:27 PM, Deepak Jois <deepak.jois at gmail.com> wrote:

> I just compiled the latest LuaTeX at r6317 and some code that worked
> earlier doesn’t anymore.
>
> This fails with error message  (font_params is defined earlier): "glue
> (spec) expected"
>
>      n = node.new("glue", 13)
>      node.setglue(n, font_params.space, font_params.space_stretch,
> font_params.space_shrink)
>
> but changing to this works:
>
>       n = node.new("glue", 13)
>       n.width = font_params.space
>       n.stretch = font_params.space_stretch
>       n.shrink = font_params.space_shrink
>
> I am using the node.setglue function as instructed the manual. Am I doing
> something wrong?
>
> Deepak
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/luatex/attachments/20170427/9f636d0a/attachment.html>


More information about the luatex mailing list