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