| 12446 | |
| 12447 | |
| 12448 | LUALIB_API int luaopen_io (lua_State *L) { |
| 12449 | createmeta(L); |
| 12450 | /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ |
| 12451 | newfenv(L, io_fclose); |
| 12452 | lua_replace(L, LUA_ENVIRONINDEX); |
| 12453 | /* open library */ |
| 12454 | luaL_register(L, LUA_IOLIBNAME, iolib); |
| 12455 | /* create (and set) default files */ |
| 12456 | newfenv(L, io_noclose); /* close function for default files */ |
| 12457 | createstdfile(L, stdin, IO_INPUT, "stdin"); |
| 12458 | createstdfile(L, stdout, IO_OUTPUT, "stdout"); |
| 12459 | createstdfile(L, stderr, 0, "stderr"); |
| 12460 | lua_pop(L, 1); /* pop environment for default files */ |
| 12461 | lua_getfield(L, -1, "popen"); |
| 12462 | newfenv(L, io_pclose); /* create environment for 'popen' */ |
| 12463 | lua_setfenv(L, -2); /* set fenv for 'popen' */ |
| 12464 | lua_pop(L, 1); /* pop 'popen' */ |
| 12465 | return 1; |
| 12466 | } |
| 12467 | |
| 12468 | /* |
| 12469 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ |
nothing calls this directly
no test coverage detected