** Auxiliary function to create the iteration function for 'lines'. ** The iteration function is a closure over 'io_readline', with ** the following upvalues: ** 1) The file being read (first value in the stack) ** 2) the number of arguments to read ** 3) a boolean, true iff file has to be closed when finished ('toclose') ** *) a variable number of format arguments (rest of the stack) */
| 361 | ** *) a variable number of format arguments (rest of the stack) |
| 362 | */ |
| 363 | static void aux_lines (lua_State *L, int toclose) { |
| 364 | int n = lua_gettop(L) - 1; /* number of arguments to read */ |
| 365 | luaL_argcheck(L, n <= MAXARGLINE, MAXARGLINE + 2, "too many arguments"); |
| 366 | lua_pushvalue(L, 1); /* file */ |
| 367 | lua_pushinteger(L, n); /* number of arguments to read */ |
| 368 | lua_pushboolean(L, toclose); /* close/not close file when finished */ |
| 369 | lua_rotate(L, 2, 3); /* move the three values to their positions */ |
| 370 | lua_pushcclosure(L, io_readline, 3 + n); |
| 371 | } |
| 372 | |
| 373 | |
| 374 | static int f_lines (lua_State *L) { |
no test coverage detected