** 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) */
| 347 | ** *) a variable number of format arguments (rest of the stack) |
| 348 | */ |
| 349 | static void aux_lines (lua_State *L, int toclose) { |
| 350 | int n = lua_gettop(L) - 1; /* number of arguments to read */ |
| 351 | luaL_argcheck(L, n <= MAXARGLINE, MAXARGLINE + 2, "too many arguments"); |
| 352 | lua_pushvalue(L, 1); /* file */ |
| 353 | lua_pushinteger(L, n); /* number of arguments to read */ |
| 354 | lua_pushboolean(L, toclose); /* close/not close file when finished */ |
| 355 | lua_rotate(L, 2, 3); /* move the three values to their positions */ |
| 356 | lua_pushcclosure(L, io_readline, 3 + n); |
| 357 | } |
| 358 | |
| 359 | |
| 360 | static int f_lines (lua_State *L) { |
no test coverage detected