| 12300 | |
| 12301 | |
| 12302 | static int io_readline (lua_State *L) { |
| 12303 | FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); |
| 12304 | int sucess; |
| 12305 | if (f == NULL) /* file is already closed? */ |
| 12306 | luaL_error(L, "file is already closed"); |
| 12307 | sucess = read_line(L, f); |
| 12308 | if (ferror(f)) |
| 12309 | return luaL_error(L, "%s", strerror(errno)); |
| 12310 | if (sucess) return 1; |
| 12311 | else { /* EOF */ |
| 12312 | if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ |
| 12313 | lua_settop(L, 0); |
| 12314 | lua_pushvalue(L, lua_upvalueindex(1)); |
| 12315 | aux_close(L); /* close it */ |
| 12316 | } |
| 12317 | return 0; |
| 12318 | } |
| 12319 | } |
| 12320 | |
| 12321 | /* }====================================================== */ |
| 12322 |
nothing calls this directly
no test coverage detected