aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-13 16:40:28 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-13 16:40:28 -0300
commit5a5a834975d135054e803b90711fcb9deb6511b8 (patch)
tree9b028d3e480b677192a6da06271f38599cb33569 /liolib.c
parent45c430eac04b070a996437b79e40656942a4c7d4 (diff)
downloadlua-5a5a834975d135054e803b90711fcb9deb6511b8.tar.gz
lua-5a5a834975d135054e803b90711fcb9deb6511b8.tar.bz2
lua-5a5a834975d135054e803b90711fcb9deb6511b8.zip
new API function 'lua_rotate'
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/liolib.c b/liolib.c
index 41fa8555..37371401 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 2.121 2014/04/15 16:46:45 roberto Exp roberto $ 2** $Id: liolib.c,v 2.122 2014/05/11 14:46:19 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*/
@@ -319,14 +319,12 @@ static int io_readline (lua_State *L);
319 319
320 320
321static void aux_lines (lua_State *L, int toclose) { 321static void aux_lines (lua_State *L, int toclose) {
322 int i;
323 int n = lua_gettop(L) - 1; /* number of arguments to read */ 322 int n = lua_gettop(L) - 1; /* number of arguments to read */
324 /* ensure that arguments will fit here and into 'io_readline' stack */ 323 /* ensure that arguments will fit here and into 'io_readline' stack */
325 luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options"); 324 luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options");
326 lua_pushvalue(L, 1); /* file handle */
327 lua_pushinteger(L, n); /* number of arguments to read */ 325 lua_pushinteger(L, n); /* number of arguments to read */
328 lua_pushboolean(L, toclose); /* close/not close file when finished */ 326 lua_pushboolean(L, toclose); /* close/not close file when finished */
329 for (i = 1; i <= n; i++) lua_pushvalue(L, i + 1); /* copy arguments */ 327 lua_rotate(L, 2, 2); /* move 'n' and 'toclose' to their positions */
330 lua_pushcclosure(L, io_readline, 3 + n); 328 lua_pushcclosure(L, io_readline, 3 + n);
331} 329}
332 330