diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-02-25 16:41:54 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-02-25 16:41:54 -0300 |
commit | 7d6b78ee7934a00fbc69ab04ba36aa420db8ba76 (patch) | |
tree | a655966993d4879491b66b150fb3089e3d4dcf8b /ltablib.c | |
parent | 5f3ad5731ebf6d80a4282462d7ce19d6906b8a2d (diff) | |
download | lua-7d6b78ee7934a00fbc69ab04ba36aa420db8ba76.tar.gz lua-7d6b78ee7934a00fbc69ab04ba36aa420db8ba76.tar.bz2 lua-7d6b78ee7934a00fbc69ab04ba36aa420db8ba76.zip |
in 'table.move', destination table can be source table even if
given as an explicit extra argument
Diffstat (limited to 'ltablib.c')
-rw-r--r-- | ltablib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.91 2015/12/14 11:57:38 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.92 2016/02/08 12:55:19 roberto Exp roberto $ |
3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -139,7 +139,7 @@ static int tmove (lua_State *L) { | |||
139 | n = e - f + 1; /* number of elements to move */ | 139 | n = e - f + 1; /* number of elements to move */ |
140 | luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, | 140 | luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, |
141 | "destination wrap around"); | 141 | "destination wrap around"); |
142 | if (t > e || t <= f || tt != 1) { | 142 | if (t > e || t <= f || (tt != 1 && !lua_compare(L, 1, tt, LUA_OPEQ))) { |
143 | for (i = 0; i < n; i++) { | 143 | for (i = 0; i < n; i++) { |
144 | lua_geti(L, 1, f + i); | 144 | lua_geti(L, 1, f + i); |
145 | lua_seti(L, tt, t + i); | 145 | lua_seti(L, tt, t + i); |
@@ -152,7 +152,7 @@ static int tmove (lua_State *L) { | |||
152 | } | 152 | } |
153 | } | 153 | } |
154 | } | 154 | } |
155 | lua_pushvalue(L, tt); /* return "to table" */ | 155 | lua_pushvalue(L, tt); /* return destination table */ |
156 | return 1; | 156 | return 1; |
157 | } | 157 | } |
158 | 158 | ||