The documentation and the implementation of the two functions lua.setluaname and lua.getluaname do not match. Minimal working example (MWE): % lua.setluaname(42, '@filename') not working \directlua{ lua.setluaname(nil, 42, '@filename') } \directlua 42 {xxx} \bye This is how the parameters should be arranged in the set function: lua.setluaname(<number> n, <string> s) <string> s = lua.getluaname(<number> n) # Patch: diff --git a/manual/luatex-tex.tex b/manual/luatex-tex.tex index f8c3d5ac6..e953a1802 100644 --- a/manual/luatex-tex.tex +++ b/manual/luatex-tex.tex @@ -96,7 +96,7 @@ If you want to unset a \LUA\ name, you can assign \type {nil} to it. The functio accessors are: \startfunctioncall -lua.setluaname(<string> s,<number> n]) +lua.setluaname(<number> n, <string> s) <string> s = lua.getluaname(<number> n) \stopfunctioncall @@ -2747,7 +2747,6 @@ The options match commandline arguments from \type {kpsewhich}: If \type {--output-directory} is specified and the value is a relative pathname, the file is searched first here and then in the standard tree. - \stopsubsection \startsubsection[title={\type {init_prog}}] diff --git a/source/texk/web2c/luatexdir/lua/llualib.c b/source/texk/web2c/luatexdir/lua/llualib.c index 0586aba02..d91a9a729 100644 --- a/source/texk/web2c/luatexdir/lua/llualib.c +++ b/source/texk/web2c/luatexdir/lua/llualib.c @@ -319,8 +319,8 @@ static int set_luaname(lua_State * L) { int k; const char *s; - if (lua_gettop(L) == 3) { - k = (int) luaL_checkinteger(L, 2); + if (lua_gettop(L) == 2) { + k = (int) luaL_checkinteger(L, 1); if (k > 65535 || k < 0) { /* error */ } else { @@ -328,8 +328,8 @@ static int set_luaname(lua_State * L) free(luanames[k]); luanames[k] = NULL; } - if (lua_type(L,3) == LUA_TSTRING) { - s = lua_tostring(L, 3); + if (lua_type(L, 2) == LUA_TSTRING) { + s = lua_tostring(L, 2); if (s != NULL) luanames[k] = xstrdup(s); } @@ -340,7 +340,7 @@ static int set_luaname(lua_State * L) static int get_luaname(lua_State * L) { - int k = (int) luaL_checkinteger(L, 2); + int k = (int) luaL_checkinteger(L, 1); if (k > 65535 || k < 0) { /* error */ lua_pushnil(L);