| 302 | |
| 303 | |
| 304 | static int g_iofile (lua_State *L, const char *f, const char *mode) { |
| 305 | if (!lua_isnoneornil(L, 1)) { |
| 306 | const char *filename = lua_tostring(L, 1); |
| 307 | if (filename) |
| 308 | opencheck(L, filename, mode); |
| 309 | else { |
| 310 | tofile(L); /* check that it's a valid file handle */ |
| 311 | lua_pushvalue(L, 1); |
| 312 | } |
| 313 | lua_setfield(L, LUA_REGISTRYINDEX, f); |
| 314 | } |
| 315 | /* return current value */ |
| 316 | lua_getfield(L, LUA_REGISTRYINDEX, f); |
| 317 | return 1; |
| 318 | } |
| 319 | |
| 320 | |
| 321 | static int io_input (lua_State *L) { |
no test coverage detected