Re: [luatex] Problems using node.setglue (r6317)

2017-04-27 Thread Hans Hagen

On 4/27/2017 8:31 AM, Deepak Jois wrote:

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?


indeed, the "return 0" needs to be moved

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-


Re: [luatex] Problems using node.setglue (r6317)

2017-04-27 Thread Deepak Jois
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  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
>