diff options
author | Peter Melnichenko <mpeterval@gmail.com> | 2016-06-09 13:53:05 +0300 |
---|---|---|
committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-06-09 13:53:05 +0300 |
commit | 183d7c49afba5e1adbc2c2df657a0fd216b85194 (patch) | |
tree | 7096bf4811235b0975bc69c7659ce491a0de902b | |
parent | 871802a4f12bfdaabd3bb217a80c92c0ae9c6119 (diff) | |
download | lua-term-183d7c49afba5e1adbc2c2df657a0fd216b85194.tar.gz lua-term-183d7c49afba5e1adbc2c2df657a0fd216b85194.tar.bz2 lua-term-183d7c49afba5e1adbc2c2df657a0fd216b85194.zip |
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.
-rw-r--r-- | core.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -10,7 +10,7 @@ | |||
10 | static int | 10 | static int |
11 | lua_isatty(lua_State *L) | 11 | lua_isatty(lua_State *L) |
12 | { | 12 | { |
13 | FILE **fp = (FILE **) luaL_checkudata(L, -1, LUA_FILEHANDLE); | 13 | FILE **fp = (FILE **) luaL_checkudata(L, 1, LUA_FILEHANDLE); |
14 | 14 | ||
15 | lua_pushboolean(L, isatty(fileno(*fp))); | 15 | lua_pushboolean(L, isatty(fileno(*fp))); |
16 | return 1; | 16 | return 1; |