From 7192afafeeb1a96b3de60af90a72cd8762b09d94 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 2 Jul 2010 08:38:13 -0300 Subject: new module policy: C modules do not create globals and do not register themselves with 'require' (let 'require' do its work); new auxiliary functions luaL_newlib/luaL_newlibtable/luaL_setfuncs/luaL_requiref. Old luaL_register will be deprecated. --- liolib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'liolib.c') diff --git a/liolib.c b/liolib.c index 6a290098..a26aff5a 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.87 2010/03/17 21:37:37 roberto Exp roberto $ +** $Id: liolib.c,v 2.88 2010/03/26 20:58:11 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -615,8 +615,9 @@ LUAMOD_API int luaopen_io (lua_State *L) { createmeta(L); /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ newenv(L, io_fclose); /* upvalue for all io functions at index 1 */ - lua_pushvalue(L, -1); /* copy to be consumed by 'openlib' */ - luaL_openlib(L, LUA_IOLIBNAME, iolib, 1); /* new module at index 2 */ + luaL_newlibtable(L, iolib); /* new module at index 2 */ + lua_pushvalue(L, 1); /* copy of env to be consumed by 'setfuncs' */ + luaL_setfuncs(L, iolib, 1); /* create (and set) default files */ newenv(L, io_noclose); /* environment for default files at index 3 */ createstdfile(L, stdin, IO_INPUT, "stdin"); -- cgit v1.2.3-55-g6feb