diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-11-09 12:10:43 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-11-09 12:10:43 -0200 |
commit | ea382b0be136a9abc80281d6950afddc4f25edb9 (patch) | |
tree | 2a0579b72954dcb454a21c64b716e08cd9e283a5 /liolib.c | |
parent | 6d8d282e0f6fc74f2499a9ab3971613115fdf0f9 (diff) | |
download | lua-ea382b0be136a9abc80281d6950afddc4f25edb9.tar.gz lua-ea382b0be136a9abc80281d6950afddc4f25edb9.tar.bz2 lua-ea382b0be136a9abc80281d6950afddc4f25edb9.zip |
small bug: error message in 'io.lines' is not the error number
Diffstat (limited to 'liolib.c')
-rw-r--r-- | liolib.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.103 2011/08/02 18:00:01 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.104 2011/09/13 21:09:04 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -488,9 +488,10 @@ static int io_readline (lua_State *L) { | |||
488 | if (!lua_isnil(L, -n)) /* read at least one value? */ | 488 | if (!lua_isnil(L, -n)) /* read at least one value? */ |
489 | return n; /* return them */ | 489 | return n; /* return them */ |
490 | else { /* first result is nil: EOF or error */ | 490 | else { /* first result is nil: EOF or error */ |
491 | if (!lua_isnil(L, -1)) /* is there error information? */ | 491 | if (n > 1) { /* is there error information? */ |
492 | return luaL_error(L, "%s", lua_tostring(L, -1)); /* error */ | 492 | /* 2nd result is error message */ |
493 | /* else EOF */ | 493 | return luaL_error(L, "%s", lua_tostring(L, -n + 1)); |
494 | } | ||
494 | if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ | 495 | if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ |
495 | lua_settop(L, 0); | 496 | lua_settop(L, 0); |
496 | lua_pushvalue(L, lua_upvalueindex(1)); | 497 | lua_pushvalue(L, lua_upvalueindex(1)); |