aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-15 12:21:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-15 12:21:06 -0300
commit1ddb251d86713b03b39250a27b268fcc8c8e3c6d (patch)
treee9d6eced82c2f307ace6a928cdcabfbfee109082 /liolib.c
parentf8daddba506112cafdc980a4935e46cf358e37c1 (diff)
downloadlua-1ddb251d86713b03b39250a27b268fcc8c8e3c6d.tar.gz
lua-1ddb251d86713b03b39250a27b268fcc8c8e3c6d.tar.bz2
lua-1ddb251d86713b03b39250a27b268fcc8c8e3c6d.zip
using a more conventional handling of stack space in 'io_readline'
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/liolib.c b/liolib.c
index 37371401..5b50bbf1 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 2.122 2014/05/11 14:46:19 roberto Exp roberto $ 2** $Id: liolib.c,v 2.123 2014/05/13 19:40:28 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*/
@@ -320,8 +320,6 @@ static int io_readline (lua_State *L);
320 320
321static void aux_lines (lua_State *L, int toclose) { 321static void aux_lines (lua_State *L, int toclose) {
322 int n = lua_gettop(L) - 1; /* number of arguments to read */ 322 int n = lua_gettop(L) - 1; /* number of arguments to read */
323 /* ensure that arguments will fit here and into 'io_readline' stack */
324 luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options");
325 lua_pushinteger(L, n); /* number of arguments to read */ 323 lua_pushinteger(L, n); /* number of arguments to read */
326 lua_pushboolean(L, toclose); /* close/not close file when finished */ 324 lua_pushboolean(L, toclose); /* close/not close file when finished */
327 lua_rotate(L, 2, 2); /* move 'n' and 'toclose' to their positions */ 325 lua_rotate(L, 2, 2); /* move 'n' and 'toclose' to their positions */
@@ -507,6 +505,7 @@ static int io_readline (lua_State *L) {
507 if (isclosed(p)) /* file is already closed? */ 505 if (isclosed(p)) /* file is already closed? */
508 return luaL_error(L, "file is already closed"); 506 return luaL_error(L, "file is already closed");
509 lua_settop(L , 1); 507 lua_settop(L , 1);
508 luaL_checkstack(L, n, "too many arguments");
510 for (i = 1; i <= n; i++) /* push arguments to 'g_read' */ 509 for (i = 1; i <= n; i++) /* push arguments to 'g_read' */
511 lua_pushvalue(L, lua_upvalueindex(3 + i)); 510 lua_pushvalue(L, lua_upvalueindex(3 + i));
512 n = g_read(L, p->f, 2); /* 'n' is number of results */ 511 n = g_read(L, p->f, 2); /* 'n' is number of results */