diff options
| author | Mike Pall <mike> | 2015-07-10 03:45:25 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2015-07-10 03:45:25 +0200 |
| commit | 5874c212918c5feb55d93ac9f1b3a41948e8fd92 (patch) | |
| tree | 8a463ffcde373bd0f2c1e7355e1420b10e3d5fb9 | |
| parent | 28d872886957d3942232d86be3183ef5434794d5 (diff) | |
| parent | 575bfe50286cd8f7645d571177a2e84b5c307d71 (diff) | |
| download | luajit-5874c212918c5feb55d93ac9f1b3a41948e8fd92.tar.gz luajit-5874c212918c5feb55d93ac9f1b3a41948e8fd92.tar.bz2 luajit-5874c212918c5feb55d93ac9f1b3a41948e8fd92.zip | |
Merge branch 'master' into v2.1
| -rw-r--r-- | src/lib_io.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib_io.c b/src/lib_io.c index 8836d052..2aa83474 100644 --- a/src/lib_io.c +++ b/src/lib_io.c | |||
| @@ -273,6 +273,15 @@ static int io_file_iter(lua_State *L) | |||
| 273 | return n; | 273 | return n; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | static int io_file_lines(lua_State *L) | ||
| 277 | { | ||
| 278 | int n = (int)(L->top - L->base); | ||
| 279 | if (n > LJ_MAX_UPVAL) | ||
| 280 | lj_err_caller(L, LJ_ERR_UNPACK); | ||
| 281 | lua_pushcclosure(L, io_file_iter, n); | ||
| 282 | return 1; | ||
| 283 | } | ||
| 284 | |||
| 276 | /* -- I/O file methods ---------------------------------------------------- */ | 285 | /* -- I/O file methods ---------------------------------------------------- */ |
| 277 | 286 | ||
| 278 | #define LJLIB_MODULE_io_method | 287 | #define LJLIB_MODULE_io_method |
| @@ -356,8 +365,7 @@ LJLIB_CF(io_method_setvbuf) | |||
| 356 | LJLIB_CF(io_method_lines) | 365 | LJLIB_CF(io_method_lines) |
| 357 | { | 366 | { |
| 358 | io_tofile(L); | 367 | io_tofile(L); |
| 359 | lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base)); | 368 | return io_file_lines(L); |
| 360 | return 1; | ||
| 361 | } | 369 | } |
| 362 | 370 | ||
| 363 | LJLIB_CF(io_method___gc) | 371 | LJLIB_CF(io_method___gc) |
| @@ -487,8 +495,7 @@ LJLIB_CF(io_lines) | |||
| 487 | } else { /* io.lines() iterates over stdin. */ | 495 | } else { /* io.lines() iterates over stdin. */ |
| 488 | setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT)); | 496 | setudataV(L, L->base, IOSTDF_UD(L, GCROOT_IO_INPUT)); |
| 489 | } | 497 | } |
| 490 | lua_pushcclosure(L, io_file_iter, (int)(L->top - L->base)); | 498 | return io_file_lines(L); |
| 491 | return 1; | ||
| 492 | } | 499 | } |
| 493 | 500 | ||
| 494 | LJLIB_CF(io_type) | 501 | LJLIB_CF(io_type) |
