summaryrefslogtreecommitdiff
path: root/src/lib_io.c
diff options
context:
space:
mode:
authorMike Pall <mike>2009-12-08 19:49:20 +0100
committerMike Pall <mike>2009-12-08 19:49:20 +0100
commit1d1fed48a002dfc0919135911057ebc255a53e0a (patch)
treec5c6643908374bb8f02f4c7691332d32f6645986 /src/lib_io.c
parent55b16959717084884fd4a0cbae6d19e3786c20c7 (diff)
downloadluajit-1d1fed48a002dfc0919135911057ebc255a53e0a.tar.gz
luajit-1d1fed48a002dfc0919135911057ebc255a53e0a.tar.bz2
luajit-1d1fed48a002dfc0919135911057ebc255a53e0a.zip
RELEASE LuaJIT-2.0.0-beta2v2.0.0-beta2
Diffstat (limited to 'src/lib_io.c')
-rw-r--r--src/lib_io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib_io.c b/src/lib_io.c
index 01623258..aefe4213 100644
--- a/src/lib_io.c
+++ b/src/lib_io.c
@@ -523,8 +523,11 @@ static void io_fenv_new(lua_State *L, int narr, lua_CFunction cls)
523 523
524LUALIB_API int luaopen_io(lua_State *L) 524LUALIB_API int luaopen_io(lua_State *L)
525{ 525{
526 LJ_LIB_REG_(L, NULL, io_method); 526 lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE);
527 lua_setfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); 527 if (tvisnil(L->top-1)) {
528 LJ_LIB_REG_(L, NULL, io_method);
529 lua_setfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE);
530 }
528 io_fenv_new(L, 0, lj_cf_io_pipe_close); /* top-3 */ 531 io_fenv_new(L, 0, lj_cf_io_pipe_close); /* top-3 */
529 io_fenv_new(L, 2, lj_cf_io_file_close); /* top-2 */ 532 io_fenv_new(L, 2, lj_cf_io_file_close); /* top-2 */
530 LJ_LIB_REG(L, io); 533 LJ_LIB_REG(L, io);
@@ -532,7 +535,7 @@ LUALIB_API int luaopen_io(lua_State *L)
532 io_std_new(L, stdin, IO_INPUT, "stdin"); 535 io_std_new(L, stdin, IO_INPUT, "stdin");
533 io_std_new(L, stdout, IO_OUTPUT, "stdout"); 536 io_std_new(L, stdout, IO_OUTPUT, "stdout");
534 io_std_new(L, stderr, 0, "stderr"); 537 io_std_new(L, stderr, 0, "stderr");
535 lua_pop(L, 1); 538 L->top--;
536 return 1; 539 return 1;
537} 540}
538 541