From 183d7c49afba5e1adbc2c2df657a0fd216b85194 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Thu, 9 Jun 2016 13:53:05 +0300 Subject: Fix term.isatty Pass '1' instead of '-1' to luaL_checkudata when getting the file argument to use the first argument, not the last. Error messages generated by luaL_checkudata are improved. Also, this happens to fix a crash on Lua 5.1.0 caused by a Lua bug. --- core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core.c b/core.c index 0bffb92..7a14408 100644 --- a/core.c +++ b/core.c @@ -10,7 +10,7 @@ static int lua_isatty(lua_State *L) { - FILE **fp = (FILE **) luaL_checkudata(L, -1, LUA_FILEHANDLE); + FILE **fp = (FILE **) luaL_checkudata(L, 1, LUA_FILEHANDLE); lua_pushboolean(L, isatty(fileno(*fp))); return 1; -- cgit v1.2.3-55-g6feb