| 246 | |
| 247 | |
| 248 | static int io_lines (lua_State *L) { |
| 249 | if (lua_isnoneornil(L, 1)) { /* no arguments? */ |
| 250 | /* will iterate over default input */ |
| 251 | lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); |
| 252 | return f_lines(L); |
| 253 | } |
| 254 | else { |
| 255 | const char *filename = luaL_checkstring(L, 1); |
| 256 | FILE **pf = newfile(L); |
| 257 | *pf = fopen(filename, "r"); |
| 258 | if (*pf == NULL) |
| 259 | fileerror(L, 1, filename); |
| 260 | aux_lines(L, lua_gettop(L), 1); |
| 261 | return 1; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | |
| 266 | /* |
nothing calls this directly
no test coverage detected