aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lapi.c b/lapi.c
index a1033587..7eca6b6a 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.211 2014/05/14 14:20:17 roberto Exp roberto $ 2** $Id: lapi.c,v 2.212 2014/05/14 18:32:30 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -204,9 +204,9 @@ LUA_API void lua_rotate (lua_State *L, int idx, int n) {
204 lua_lock(L); 204 lua_lock(L);
205 t = L->top - 1; /* end of stack segment being rotated */ 205 t = L->top - 1; /* end of stack segment being rotated */
206 p = index2addr(L, idx); /* start of segment */ 206 p = index2addr(L, idx); /* start of segment */
207 m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */
208 api_checkstackindex(L, idx, p); 207 api_checkstackindex(L, idx, p);
209 api_check(L, p <= m + 1 && m <= t, "invalid 'n'"); 208 api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'");
209 m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */
210 reverse(L, p, m); /* reverse the prefix with length 'n' */ 210 reverse(L, p, m); /* reverse the prefix with length 'n' */
211 reverse(L, m + 1, t); /* reverse the suffix */ 211 reverse(L, m + 1, t); /* reverse the suffix */
212 reverse(L, p, t); /* reverse the entire segment */ 212 reverse(L, p, t); /* reverse the entire segment */