|
@@ -278,6 +278,15 @@ static int io_file_iter(lua_State *L)
|
|
return n;
|
|
return n;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int io_file_lines(lua_State *L)
|
|
|
|
+{
|
|
|
|
+ int n = (int)(L->top - L->base);
|
|
|
|
+ if (n > LJ_MAX_UPVAL)
|
|
|
|
+ lj_err_caller(L, LJ_ERR_UNPACK);
|
|
|
|
+ lua_pushcclosure(L, io_file_iter, n);
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
/* -- I/O file methods ---------------------------------------------------- */
|
|
/* -- I/O file methods ---------------------------------------------------- */
|
|
|
|
|
|
#define LJLIB_MODULE_io_method
|
|
#define LJLIB_MODULE_io_method
|
|
@@ -361,8 +370,7 @@ LJLIB_CF(io_method_setvbuf)
|
|
LJLIB_CF(io_method_lines)
|
|
LJLIB_CF(io_method_lines)
|
|
{
|
|
{
|
|
io_tofile(L);
|
|
io_tofile(L);
|
|
- lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base));
|
|
|
|
- return 1;
|
|
|
|
|
|
+ return io_file_lines(L);
|
|
}
|
|
}
|
|
|
|
|
|
LJLIB_CF(io_method___gc)
|
|
LJLIB_CF(io_method___gc)
|
|
@@ -492,8 +500,7 @@ LJLIB_CF(io_lines)
|
|
} else { /* io.lines() iterates over stdin. */
|
|
} else { /* io.lines() iterates over stdin. */
|
|
setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT));
|
|
setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT));
|
|
}
|
|
}
|
|
- lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base));
|
|
|
|
- return 1;
|
|
|
|
|
|
+ return io_file_lines(L);
|
|
}
|
|
}
|
|
|
|
|
|
LJLIB_CF(io_type)
|
|
LJLIB_CF(io_type)
|