summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c76
-rw-r--r--lapi.h6
-rw-r--r--ldebug.c4
-rw-r--r--ldo.c4
-rw-r--r--llimits.h12
-rw-r--r--luaconf.h12
6 files changed, 60 insertions, 54 deletions
diff --git a/lapi.c b/lapi.c
index a47c352c..7bbdf70e 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.245 2015/01/16 16:54:37 roberto Exp roberto $ 2** $Id: lapi.c,v 2.246 2015/02/11 18:47:22 roberto Exp $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -51,29 +51,29 @@ const char lua_ident[] =
51/* test for valid but not pseudo index */ 51/* test for valid but not pseudo index */
52#define isstackindex(i, o) (isvalid(o) && !ispseudo(i)) 52#define isstackindex(i, o) (isvalid(o) && !ispseudo(i))
53 53
54#define api_checkvalidindex(o) api_check(isvalid(o), "invalid index") 54#define api_checkvalidindex(l,o) api_check(l, isvalid(o), "invalid index")
55 55
56#define api_checkstackindex(i, o) \ 56#define api_checkstackindex(l, i, o) \
57 api_check(isstackindex(i, o), "index not in the stack") 57 api_check(l, isstackindex(i, o), "index not in the stack")
58 58
59 59
60static TValue *index2addr (lua_State *L, int idx) { 60static TValue *index2addr (lua_State *L, int idx) {
61 CallInfo *ci = L->ci; 61 CallInfo *ci = L->ci;
62 if (idx > 0) { 62 if (idx > 0) {
63 TValue *o = ci->func + idx; 63 TValue *o = ci->func + idx;
64 api_check(idx <= ci->top - (ci->func + 1), "unacceptable index"); 64 api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index");
65 if (o >= L->top) return NONVALIDVALUE; 65 if (o >= L->top) return NONVALIDVALUE;
66 else return o; 66 else return o;
67 } 67 }
68 else if (!ispseudo(idx)) { /* negative index */ 68 else if (!ispseudo(idx)) { /* negative index */
69 api_check(idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); 69 api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index");
70 return L->top + idx; 70 return L->top + idx;
71 } 71 }
72 else if (idx == LUA_REGISTRYINDEX) 72 else if (idx == LUA_REGISTRYINDEX)
73 return &G(L)->l_registry; 73 return &G(L)->l_registry;
74 else { /* upvalues */ 74 else { /* upvalues */
75 idx = LUA_REGISTRYINDEX - idx; 75 idx = LUA_REGISTRYINDEX - idx;
76 api_check(idx <= MAXUPVAL + 1, "upvalue index too large"); 76 api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large");
77 if (ttislcf(ci->func)) /* light C function? */ 77 if (ttislcf(ci->func)) /* light C function? */
78 return NONVALIDVALUE; /* it has no upvalues */ 78 return NONVALIDVALUE; /* it has no upvalues */
79 else { 79 else {
@@ -98,7 +98,7 @@ LUA_API int lua_checkstack (lua_State *L, int n) {
98 int res; 98 int res;
99 CallInfo *ci = L->ci; 99 CallInfo *ci = L->ci;
100 lua_lock(L); 100 lua_lock(L);
101 api_check(n >= 0, "negative 'n'"); 101 api_check(L, n >= 0, "negative 'n'");
102 if (L->stack_last - L->top > n) /* stack large enough? */ 102 if (L->stack_last - L->top > n) /* stack large enough? */
103 res = 1; /* yes; check is OK */ 103 res = 1; /* yes; check is OK */
104 else { /* no; need to grow stack */ 104 else { /* no; need to grow stack */
@@ -120,8 +120,8 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
120 if (from == to) return; 120 if (from == to) return;
121 lua_lock(to); 121 lua_lock(to);
122 api_checknelems(from, n); 122 api_checknelems(from, n);
123 api_check(G(from) == G(to), "moving among independent states"); 123 api_check(from, G(from) == G(to), "moving among independent states");
124 api_check(to->ci->top - to->top >= n, "not enough elements to move"); 124 api_check(from, to->ci->top - to->top >= n, "not enough elements to move");
125 from->top -= n; 125 from->top -= n;
126 for (i = 0; i < n; i++) { 126 for (i = 0; i < n; i++) {
127 setobj2s(to, to->top, from->top + i); 127 setobj2s(to, to->top, from->top + i);
@@ -173,13 +173,13 @@ LUA_API void lua_settop (lua_State *L, int idx) {
173 StkId func = L->ci->func; 173 StkId func = L->ci->func;
174 lua_lock(L); 174 lua_lock(L);
175 if (idx >= 0) { 175 if (idx >= 0) {
176 api_check(idx <= L->stack_last - (func + 1), "new top too large"); 176 api_check(L, idx <= L->stack_last - (func + 1), "new top too large");
177 while (L->top < (func + 1) + idx) 177 while (L->top < (func + 1) + idx)
178 setnilvalue(L->top++); 178 setnilvalue(L->top++);
179 L->top = (func + 1) + idx; 179 L->top = (func + 1) + idx;
180 } 180 }
181 else { 181 else {
182 api_check(-(idx+1) <= (L->top - (func + 1)), "invalid new top"); 182 api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top");
183 L->top += idx+1; /* 'subtract' index (index is negative) */ 183 L->top += idx+1; /* 'subtract' index (index is negative) */
184 } 184 }
185 lua_unlock(L); 185 lua_unlock(L);
@@ -209,8 +209,8 @@ LUA_API void lua_rotate (lua_State *L, int idx, int n) {
209 lua_lock(L); 209 lua_lock(L);
210 t = L->top - 1; /* end of stack segment being rotated */ 210 t = L->top - 1; /* end of stack segment being rotated */
211 p = index2addr(L, idx); /* start of segment */ 211 p = index2addr(L, idx); /* start of segment */
212 api_checkstackindex(idx, p); 212 api_checkstackindex(L, idx, p);
213 api_check((n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'"); 213 api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'");
214 m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */ 214 m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */
215 reverse(L, p, m); /* reverse the prefix with length 'n' */ 215 reverse(L, p, m); /* reverse the prefix with length 'n' */
216 reverse(L, m + 1, t); /* reverse the suffix */ 216 reverse(L, m + 1, t); /* reverse the suffix */
@@ -224,7 +224,7 @@ LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) {
224 lua_lock(L); 224 lua_lock(L);
225 fr = index2addr(L, fromidx); 225 fr = index2addr(L, fromidx);
226 to = index2addr(L, toidx); 226 to = index2addr(L, toidx);
227 api_checkvalidindex(to); 227 api_checkvalidindex(L, to);
228 setobj(L, to, fr); 228 setobj(L, to, fr);
229 if (isupvalue(toidx)) /* function upvalue? */ 229 if (isupvalue(toidx)) /* function upvalue? */
230 luaC_barrier(L, clCvalue(L->ci->func), fr); 230 luaC_barrier(L, clCvalue(L->ci->func), fr);
@@ -256,7 +256,7 @@ LUA_API int lua_type (lua_State *L, int idx) {
256 256
257LUA_API const char *lua_typename (lua_State *L, int t) { 257LUA_API const char *lua_typename (lua_State *L, int t) {
258 UNUSED(L); 258 UNUSED(L);
259 api_check(LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); 259 api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag");
260 return ttypename(t); 260 return ttypename(t);
261} 261}
262 262
@@ -326,7 +326,7 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
326 case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; 326 case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break;
327 case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; 327 case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
328 case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; 328 case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
329 default: api_check(0, "invalid option"); 329 default: api_check(L, 0, "invalid option");
330 } 330 }
331 } 331 }
332 lua_unlock(L); 332 lua_unlock(L);
@@ -534,7 +534,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
534 else { 534 else {
535 CClosure *cl; 535 CClosure *cl;
536 api_checknelems(L, n); 536 api_checknelems(L, n);
537 api_check(n <= MAXUPVAL, "upvalue index too large"); 537 api_check(L, n <= MAXUPVAL, "upvalue index too large");
538 luaC_checkGC(L); 538 luaC_checkGC(L);
539 cl = luaF_newCclosure(L, n); 539 cl = luaF_newCclosure(L, n);
540 cl->f = fn; 540 cl->f = fn;
@@ -632,7 +632,7 @@ LUA_API int lua_rawget (lua_State *L, int idx) {
632 StkId t; 632 StkId t;
633 lua_lock(L); 633 lua_lock(L);
634 t = index2addr(L, idx); 634 t = index2addr(L, idx);
635 api_check(ttistable(t), "table expected"); 635 api_check(L, ttistable(t), "table expected");
636 setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); 636 setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
637 lua_unlock(L); 637 lua_unlock(L);
638 return ttnov(L->top - 1); 638 return ttnov(L->top - 1);
@@ -643,7 +643,7 @@ LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) {
643 StkId t; 643 StkId t;
644 lua_lock(L); 644 lua_lock(L);
645 t = index2addr(L, idx); 645 t = index2addr(L, idx);
646 api_check(ttistable(t), "table expected"); 646 api_check(L, ttistable(t), "table expected");
647 setobj2s(L, L->top, luaH_getint(hvalue(t), n)); 647 setobj2s(L, L->top, luaH_getint(hvalue(t), n));
648 api_incr_top(L); 648 api_incr_top(L);
649 lua_unlock(L); 649 lua_unlock(L);
@@ -656,7 +656,7 @@ LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) {
656 TValue k; 656 TValue k;
657 lua_lock(L); 657 lua_lock(L);
658 t = index2addr(L, idx); 658 t = index2addr(L, idx);
659 api_check(ttistable(t), "table expected"); 659 api_check(L, ttistable(t), "table expected");
660 setpvalue(&k, cast(void *, p)); 660 setpvalue(&k, cast(void *, p));
661 setobj2s(L, L->top, luaH_get(hvalue(t), &k)); 661 setobj2s(L, L->top, luaH_get(hvalue(t), &k));
662 api_incr_top(L); 662 api_incr_top(L);
@@ -709,7 +709,7 @@ LUA_API int lua_getuservalue (lua_State *L, int idx) {
709 StkId o; 709 StkId o;
710 lua_lock(L); 710 lua_lock(L);
711 o = index2addr(L, idx); 711 o = index2addr(L, idx);
712 api_check(ttisfulluserdata(o), "full userdata expected"); 712 api_check(L, ttisfulluserdata(o), "full userdata expected");
713 getuservalue(L, uvalue(o), L->top); 713 getuservalue(L, uvalue(o), L->top);
714 api_incr_top(L); 714 api_incr_top(L);
715 lua_unlock(L); 715 lua_unlock(L);
@@ -779,7 +779,7 @@ LUA_API void lua_rawset (lua_State *L, int idx) {
779 lua_lock(L); 779 lua_lock(L);
780 api_checknelems(L, 2); 780 api_checknelems(L, 2);
781 o = index2addr(L, idx); 781 o = index2addr(L, idx);
782 api_check(ttistable(o), "table expected"); 782 api_check(L, ttistable(o), "table expected");
783 t = hvalue(o); 783 t = hvalue(o);
784 setobj2t(L, luaH_set(L, t, L->top-2), L->top-1); 784 setobj2t(L, luaH_set(L, t, L->top-2), L->top-1);
785 invalidateTMcache(t); 785 invalidateTMcache(t);
@@ -795,7 +795,7 @@ LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) {
795 lua_lock(L); 795 lua_lock(L);
796 api_checknelems(L, 1); 796 api_checknelems(L, 1);
797 o = index2addr(L, idx); 797 o = index2addr(L, idx);
798 api_check(ttistable(o), "table expected"); 798 api_check(L, ttistable(o), "table expected");
799 t = hvalue(o); 799 t = hvalue(o);
800 luaH_setint(L, t, n, L->top - 1); 800 luaH_setint(L, t, n, L->top - 1);
801 luaC_barrierback(L, t, L->top-1); 801 luaC_barrierback(L, t, L->top-1);
@@ -811,7 +811,7 @@ LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) {
811 lua_lock(L); 811 lua_lock(L);
812 api_checknelems(L, 1); 812 api_checknelems(L, 1);
813 o = index2addr(L, idx); 813 o = index2addr(L, idx);
814 api_check(ttistable(o), "table expected"); 814 api_check(L, ttistable(o), "table expected");
815 t = hvalue(o); 815 t = hvalue(o);
816 setpvalue(&k, cast(void *, p)); 816 setpvalue(&k, cast(void *, p));
817 setobj2t(L, luaH_set(L, t, &k), L->top - 1); 817 setobj2t(L, luaH_set(L, t, &k), L->top - 1);
@@ -830,7 +830,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
830 if (ttisnil(L->top - 1)) 830 if (ttisnil(L->top - 1))
831 mt = NULL; 831 mt = NULL;
832 else { 832 else {
833 api_check(ttistable(L->top - 1), "table expected"); 833 api_check(L, ttistable(L->top - 1), "table expected");
834 mt = hvalue(L->top - 1); 834 mt = hvalue(L->top - 1);
835 } 835 }
836 switch (ttnov(obj)) { 836 switch (ttnov(obj)) {
@@ -866,7 +866,7 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) {
866 lua_lock(L); 866 lua_lock(L);
867 api_checknelems(L, 1); 867 api_checknelems(L, 1);
868 o = index2addr(L, idx); 868 o = index2addr(L, idx);
869 api_check(ttisfulluserdata(o), "full userdata expected"); 869 api_check(L, ttisfulluserdata(o), "full userdata expected");
870 setuservalue(L, uvalue(o), L->top - 1); 870 setuservalue(L, uvalue(o), L->top - 1);
871 luaC_barrier(L, gcvalue(o), L->top - 1); 871 luaC_barrier(L, gcvalue(o), L->top - 1);
872 L->top--; 872 L->top--;
@@ -880,7 +880,7 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) {
880 880
881 881
882#define checkresults(L,na,nr) \ 882#define checkresults(L,na,nr) \
883 api_check((nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ 883 api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \
884 "results from function overflow current stack size") 884 "results from function overflow current stack size")
885 885
886 886
@@ -888,10 +888,10 @@ LUA_API void lua_callk (lua_State *L, int nargs, int nresults,
888 lua_KContext ctx, lua_KFunction k) { 888 lua_KContext ctx, lua_KFunction k) {
889 StkId func; 889 StkId func;
890 lua_lock(L); 890 lua_lock(L);
891 api_check(k == NULL || !isLua(L->ci), 891 api_check(L, k == NULL || !isLua(L->ci),
892 "cannot use continuations inside hooks"); 892 "cannot use continuations inside hooks");
893 api_checknelems(L, nargs+1); 893 api_checknelems(L, nargs+1);
894 api_check(L->status == LUA_OK, "cannot do calls on non-normal thread"); 894 api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
895 checkresults(L, nargs, nresults); 895 checkresults(L, nargs, nresults);
896 func = L->top - (nargs+1); 896 func = L->top - (nargs+1);
897 if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ 897 if (k != NULL && L->nny == 0) { /* need to prepare continuation? */
@@ -929,16 +929,16 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
929 int status; 929 int status;
930 ptrdiff_t func; 930 ptrdiff_t func;
931 lua_lock(L); 931 lua_lock(L);
932 api_check(k == NULL || !isLua(L->ci), 932 api_check(L, k == NULL || !isLua(L->ci),
933 "cannot use continuations inside hooks"); 933 "cannot use continuations inside hooks");
934 api_checknelems(L, nargs+1); 934 api_checknelems(L, nargs+1);
935 api_check(L->status == LUA_OK, "cannot do calls on non-normal thread"); 935 api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
936 checkresults(L, nargs, nresults); 936 checkresults(L, nargs, nresults);
937 if (errfunc == 0) 937 if (errfunc == 0)
938 func = 0; 938 func = 0;
939 else { 939 else {
940 StkId o = index2addr(L, errfunc); 940 StkId o = index2addr(L, errfunc);
941 api_checkstackindex(errfunc, o); 941 api_checkstackindex(L, errfunc, o);
942 func = savestack(L, o); 942 func = savestack(L, o);
943 } 943 }
944 c.func = L->top - (nargs+1); /* function to be called */ 944 c.func = L->top - (nargs+1); /* function to be called */
@@ -1103,7 +1103,7 @@ LUA_API int lua_next (lua_State *L, int idx) {
1103 int more; 1103 int more;
1104 lua_lock(L); 1104 lua_lock(L);
1105 t = index2addr(L, idx); 1105 t = index2addr(L, idx);
1106 api_check(ttistable(t), "table expected"); 1106 api_check(L, ttistable(t), "table expected");
1107 more = luaH_next(L, hvalue(t), L->top - 1); 1107 more = luaH_next(L, hvalue(t), L->top - 1);
1108 if (more) { 1108 if (more) {
1109 api_incr_top(L); 1109 api_incr_top(L);
@@ -1235,9 +1235,9 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
1235static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { 1235static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) {
1236 LClosure *f; 1236 LClosure *f;
1237 StkId fi = index2addr(L, fidx); 1237 StkId fi = index2addr(L, fidx);
1238 api_check(ttisLclosure(fi), "Lua function expected"); 1238 api_check(L, ttisLclosure(fi), "Lua function expected");
1239 f = clLvalue(fi); 1239 f = clLvalue(fi);
1240 api_check((1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); 1240 api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index");
1241 if (pf) *pf = f; 1241 if (pf) *pf = f;
1242 return &f->upvals[n - 1]; /* get its upvalue pointer */ 1242 return &f->upvals[n - 1]; /* get its upvalue pointer */
1243} 1243}
@@ -1251,11 +1251,11 @@ LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
1251 } 1251 }
1252 case LUA_TCCL: { /* C closure */ 1252 case LUA_TCCL: { /* C closure */
1253 CClosure *f = clCvalue(fi); 1253 CClosure *f = clCvalue(fi);
1254 api_check(1 <= n && n <= f->nupvalues, "invalid upvalue index"); 1254 api_check(L, 1 <= n && n <= f->nupvalues, "invalid upvalue index");
1255 return &f->upvalue[n - 1]; 1255 return &f->upvalue[n - 1];
1256 } 1256 }
1257 default: { 1257 default: {
1258 api_check(0, "closure expected"); 1258 api_check(L, 0, "closure expected");
1259 return NULL; 1259 return NULL;
1260 } 1260 }
1261 } 1261 }
diff --git a/lapi.h b/lapi.h
index 3f10e6fb..b39898eb 100644
--- a/lapi.h
+++ b/lapi.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.h,v 2.7 2009/11/27 15:37:59 roberto Exp roberto $ 2** $Id: lapi.h,v 2.8 2014/07/15 21:26:50 roberto Exp roberto $
3** Auxiliary functions from Lua API 3** Auxiliary functions from Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -11,13 +11,13 @@
11#include "llimits.h" 11#include "llimits.h"
12#include "lstate.h" 12#include "lstate.h"
13 13
14#define api_incr_top(L) {L->top++; api_check(L->top <= L->ci->top, \ 14#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
15 "stack overflow");} 15 "stack overflow");}
16 16
17#define adjustresults(L,nres) \ 17#define adjustresults(L,nres) \
18 { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 18 { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
19 19
20#define api_checknelems(L,n) api_check((n) < (L->top - L->ci->func), \ 20#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
21 "not enough elements in the stack") 21 "not enough elements in the stack")
22 22
23 23
diff --git a/ldebug.c b/ldebug.c
index f6c25db3..b51ae8b7 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.110 2015/01/02 12:52:22 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.111 2015/02/13 16:01:17 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -295,7 +295,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
295 if (*what == '>') { 295 if (*what == '>') {
296 ci = NULL; 296 ci = NULL;
297 func = L->top - 1; 297 func = L->top - 1;
298 api_check(ttisfunction(func), "function expected"); 298 api_check(L, ttisfunction(func), "function expected");
299 what++; /* skip the '>' */ 299 what++; /* skip the '>' */
300 L->top--; /* pop function */ 300 L->top--; /* pop function */
301 } 301 }
diff --git a/ldo.c b/ldo.c
index 35c3a5cc..ffe9a8da 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.134 2014/11/10 17:42:04 roberto Exp roberto $ 2** $Id: ldo.c,v 2.135 2014/11/11 17:13:39 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -619,7 +619,7 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx,
619 L->status = LUA_YIELD; 619 L->status = LUA_YIELD;
620 ci->extra = savestack(L, ci->func); /* save current 'func' */ 620 ci->extra = savestack(L, ci->func); /* save current 'func' */
621 if (isLua(ci)) { /* inside a hook? */ 621 if (isLua(ci)) { /* inside a hook? */
622 api_check(k == NULL, "hooks cannot continue after yielding"); 622 api_check(L, k == NULL, "hooks cannot continue after yielding");
623 } 623 }
624 else { 624 else {
625 if ((ci->u.c.k = k) != NULL) /* is there a continuation? */ 625 if ((ci->u.c.k = k) != NULL) /* is there a continuation? */
diff --git a/llimits.h b/llimits.h
index 7ff282ca..c711ca64 100644
--- a/llimits.h
+++ b/llimits.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llimits.h,v 1.132 2015/03/03 19:53:13 roberto Exp roberto $ 2** $Id: llimits.h,v 1.133 2015/03/04 13:31:21 roberto Exp roberto $
3** Limits, basic types, and some other 'installation-dependent' definitions 3** Limits, basic types, and some other 'installation-dependent' definitions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -88,15 +88,11 @@ typedef LUAI_UACINT l_uacInt;
88/* 88/*
89** assertion for checking API calls 89** assertion for checking API calls
90*/ 90*/
91#if defined(LUA_USE_APICHECK) 91#if !defined(luai_apicheck)
92#include <assert.h> 92#define luai_apicheck(l,e) lua_assert(e)
93#define luai_apicheck(e) assert(e)
94#else
95#define luai_apicheck(e) lua_assert(e)
96#endif 93#endif
97 94
98 95#define api_check(l,e,msg) luai_apicheck(l,(e) && msg)
99#define api_check(e,msg) luai_apicheck((e) && msg)
100 96
101 97
102/* macro to avoid warnings about unused variables */ 98/* macro to avoid warnings about unused variables */
diff --git a/luaconf.h b/luaconf.h
index 6818a172..79a9e768 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.246 2015/02/28 19:22:31 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.247 2015/03/02 16:59:01 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -639,6 +639,16 @@
639/* #define LUA_NOCVTN2S */ 639/* #define LUA_NOCVTN2S */
640/* #define LUA_NOCVTS2N */ 640/* #define LUA_NOCVTS2N */
641 641
642
643/*
644@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
645** Define it as a help when debugging C code.
646*/
647#if defined(LUA_USE_APICHECK)
648#include <assert.h>
649#define luai_apicheck(l,e) assert(e)
650#endif
651
642/* }================================================================== */ 652/* }================================================================== */
643 653
644 654