aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c10
-rw-r--r--ldo.c45
-rw-r--r--ldo.h14
-rw-r--r--lfunc.c5
-rw-r--r--lfunc.h4
-rw-r--r--lgc.c2
-rw-r--r--llimits.h6
-rw-r--r--lstate.c6
-rw-r--r--lstate.h8
-rw-r--r--lstring.c2
10 files changed, 56 insertions, 46 deletions
diff --git a/lapi.c b/lapi.c
index 7b30617f..b3062072 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1070,7 +1070,7 @@ static void f_call (lua_State *L, void *ud) {
1070LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, 1070LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
1071 lua_KContext ctx, lua_KFunction k) { 1071 lua_KContext ctx, lua_KFunction k) {
1072 struct CallS c; 1072 struct CallS c;
1073 int status; 1073 TStatus status;
1074 ptrdiff_t func; 1074 ptrdiff_t func;
1075 lua_lock(L); 1075 lua_lock(L);
1076 api_check(L, k == NULL || !isLua(L->ci), 1076 api_check(L, k == NULL || !isLua(L->ci),
@@ -1107,14 +1107,14 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
1107 } 1107 }
1108 adjustresults(L, nresults); 1108 adjustresults(L, nresults);
1109 lua_unlock(L); 1109 lua_unlock(L);
1110 return status; 1110 return APIstatus(status);
1111} 1111}
1112 1112
1113 1113
1114LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, 1114LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
1115 const char *chunkname, const char *mode) { 1115 const char *chunkname, const char *mode) {
1116 ZIO z; 1116 ZIO z;
1117 int status; 1117 TStatus status;
1118 lua_lock(L); 1118 lua_lock(L);
1119 if (!chunkname) chunkname = "?"; 1119 if (!chunkname) chunkname = "?";
1120 luaZ_init(L, &z, reader, data); 1120 luaZ_init(L, &z, reader, data);
@@ -1131,7 +1131,7 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
1131 } 1131 }
1132 } 1132 }
1133 lua_unlock(L); 1133 lua_unlock(L);
1134 return status; 1134 return APIstatus(status);
1135} 1135}
1136 1136
1137 1137
@@ -1154,7 +1154,7 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) {
1154 1154
1155 1155
1156LUA_API int lua_status (lua_State *L) { 1156LUA_API int lua_status (lua_State *L) {
1157 return L->status; 1157 return APIstatus(L->status);
1158} 1158}
1159 1159
1160 1160
diff --git a/ldo.c b/ldo.c
index 31c00a21..3f9c8b7d 100644
--- a/ldo.c
+++ b/ldo.c
@@ -97,11 +97,11 @@
97struct lua_longjmp { 97struct lua_longjmp {
98 struct lua_longjmp *previous; 98 struct lua_longjmp *previous;
99 luai_jmpbuf b; 99 luai_jmpbuf b;
100 volatile int status; /* error code */ 100 volatile TStatus status; /* error code */
101}; 101};
102 102
103 103
104void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { 104void luaD_seterrorobj (lua_State *L, TStatus errcode, StkId oldtop) {
105 switch (errcode) { 105 switch (errcode) {
106 case LUA_ERRMEM: { /* memory error? */ 106 case LUA_ERRMEM: { /* memory error? */
107 setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ 107 setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */
@@ -125,7 +125,7 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
125} 125}
126 126
127 127
128l_noret luaD_throw (lua_State *L, int errcode) { 128l_noret luaD_throw (lua_State *L, TStatus errcode) {
129 if (L->errorJmp) { /* thread has an error handler? */ 129 if (L->errorJmp) { /* thread has an error handler? */
130 L->errorJmp->status = errcode; /* set status */ 130 L->errorJmp->status = errcode; /* set status */
131 LUAI_THROW(L, L->errorJmp); /* jump to it */ 131 LUAI_THROW(L, L->errorJmp); /* jump to it */
@@ -133,7 +133,7 @@ l_noret luaD_throw (lua_State *L, int errcode) {
133 else { /* thread has no error handler */ 133 else { /* thread has no error handler */
134 global_State *g = G(L); 134 global_State *g = G(L);
135 errcode = luaE_resetthread(L, errcode); /* close all upvalues */ 135 errcode = luaE_resetthread(L, errcode); /* close all upvalues */
136 L->status = cast_byte(errcode); 136 L->status = errcode;
137 if (g->mainthread->errorJmp) { /* main thread has a handler? */ 137 if (g->mainthread->errorJmp) { /* main thread has a handler? */
138 setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */ 138 setobjs2s(L, g->mainthread->top.p++, L->top.p - 1); /* copy error obj. */
139 luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ 139 luaD_throw(g->mainthread, errcode); /* re-throw in main thread */
@@ -149,7 +149,7 @@ l_noret luaD_throw (lua_State *L, int errcode) {
149} 149}
150 150
151 151
152int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { 152TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
153 l_uint32 oldnCcalls = L->nCcalls; 153 l_uint32 oldnCcalls = L->nCcalls;
154 struct lua_longjmp lj; 154 struct lua_longjmp lj;
155 lj.status = LUA_OK; 155 lj.status = LUA_OK;
@@ -751,8 +751,8 @@ void luaD_callnoyield (lua_State *L, StkId func, int nResults) {
751** particular, field CIST_RECST preserves the error status across these 751** particular, field CIST_RECST preserves the error status across these
752** multiple runs, changing only if there is a new error. 752** multiple runs, changing only if there is a new error.
753*/ 753*/
754static int finishpcallk (lua_State *L, CallInfo *ci) { 754static TStatus finishpcallk (lua_State *L, CallInfo *ci) {
755 int status = getcistrecst(ci); /* get original status */ 755 TStatus status = getcistrecst(ci); /* get original status */
756 if (l_likely(status == LUA_OK)) /* no error? */ 756 if (l_likely(status == LUA_OK)) /* no error? */
757 status = LUA_YIELD; /* was interrupted by an yield */ 757 status = LUA_YIELD; /* was interrupted by an yield */
758 else { /* error */ 758 else { /* error */
@@ -792,14 +792,15 @@ static void finishCcall (lua_State *L, CallInfo *ci) {
792 /* don't need to reset CIST_CLSRET, as it will be set again anyway */ 792 /* don't need to reset CIST_CLSRET, as it will be set again anyway */
793 } 793 }
794 else { 794 else {
795 int status = LUA_YIELD; /* default if there were no errors */ 795 TStatus status = LUA_YIELD; /* default if there were no errors */
796 lua_KFunction kf = ci->u.c.k; /* continuation function */
796 /* must have a continuation and must be able to call it */ 797 /* must have a continuation and must be able to call it */
797 lua_assert(ci->u.c.k != NULL && yieldable(L)); 798 lua_assert(kf != NULL && yieldable(L));
798 if (ci->callstatus & CIST_YPCALL) /* was inside a 'lua_pcallk'? */ 799 if (ci->callstatus & CIST_YPCALL) /* was inside a 'lua_pcallk'? */
799 status = finishpcallk(L, ci); /* finish it */ 800 status = finishpcallk(L, ci); /* finish it */
800 adjustresults(L, LUA_MULTRET); /* finish 'lua_callk' */ 801 adjustresults(L, LUA_MULTRET); /* finish 'lua_callk' */
801 lua_unlock(L); 802 lua_unlock(L);
802 n = (*ci->u.c.k)(L, status, ci->u.c.ctx); /* call continuation */ 803 n = (*kf)(L, APIstatus(status), ci->u.c.ctx); /* call continuation */
803 lua_lock(L); 804 lua_lock(L);
804 api_checknelems(L, n); 805 api_checknelems(L, n);
805 } 806 }
@@ -901,7 +902,7 @@ static void resume (lua_State *L, void *ud) {
901** (status == LUA_YIELD), or an unprotected error ('findpcall' doesn't 902** (status == LUA_YIELD), or an unprotected error ('findpcall' doesn't
902** find a recover point). 903** find a recover point).
903*/ 904*/
904static int precover (lua_State *L, int status) { 905static TStatus precover (lua_State *L, TStatus status) {
905 CallInfo *ci; 906 CallInfo *ci;
906 while (errorstatus(status) && (ci = findpcall(L)) != NULL) { 907 while (errorstatus(status) && (ci = findpcall(L)) != NULL) {
907 L->ci = ci; /* go down to recovery functions */ 908 L->ci = ci; /* go down to recovery functions */
@@ -914,7 +915,7 @@ static int precover (lua_State *L, int status) {
914 915
915LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, 916LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
916 int *nresults) { 917 int *nresults) {
917 int status; 918 TStatus status;
918 lua_lock(L); 919 lua_lock(L);
919 if (L->status == LUA_OK) { /* may be starting a coroutine */ 920 if (L->status == LUA_OK) { /* may be starting a coroutine */
920 if (L->ci != &L->base_ci) /* not in base level? */ 921 if (L->ci != &L->base_ci) /* not in base level? */
@@ -936,14 +937,14 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
936 if (l_likely(!errorstatus(status))) 937 if (l_likely(!errorstatus(status)))
937 lua_assert(status == L->status); /* normal end or yield */ 938 lua_assert(status == L->status); /* normal end or yield */
938 else { /* unrecoverable error */ 939 else { /* unrecoverable error */
939 L->status = cast_byte(status); /* mark thread as 'dead' */ 940 L->status = status; /* mark thread as 'dead' */
940 luaD_seterrorobj(L, status, L->top.p); /* push error message */ 941 luaD_seterrorobj(L, status, L->top.p); /* push error message */
941 L->ci->top.p = L->top.p; 942 L->ci->top.p = L->top.p;
942 } 943 }
943 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield 944 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield
944 : cast_int(L->top.p - (L->ci->func.p + 1)); 945 : cast_int(L->top.p - (L->ci->func.p + 1));
945 lua_unlock(L); 946 lua_unlock(L);
946 return status; 947 return APIstatus(status);
947} 948}
948 949
949 950
@@ -988,7 +989,7 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx,
988*/ 989*/
989struct CloseP { 990struct CloseP {
990 StkId level; 991 StkId level;
991 int status; 992 TStatus status;
992}; 993};
993 994
994 995
@@ -1005,7 +1006,7 @@ static void closepaux (lua_State *L, void *ud) {
1005** Calls 'luaF_close' in protected mode. Return the original status 1006** Calls 'luaF_close' in protected mode. Return the original status
1006** or, in case of errors, the new status. 1007** or, in case of errors, the new status.
1007*/ 1008*/
1008int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status) { 1009TStatus luaD_closeprotected (lua_State *L, ptrdiff_t level, TStatus status) {
1009 CallInfo *old_ci = L->ci; 1010 CallInfo *old_ci = L->ci;
1010 lu_byte old_allowhooks = L->allowhook; 1011 lu_byte old_allowhooks = L->allowhook;
1011 for (;;) { /* keep closing upvalues until no more errors */ 1012 for (;;) { /* keep closing upvalues until no more errors */
@@ -1027,9 +1028,9 @@ int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status) {
1027** thread information ('allowhook', etc.) and in particular 1028** thread information ('allowhook', etc.) and in particular
1028** its stack level in case of errors. 1029** its stack level in case of errors.
1029*/ 1030*/
1030int luaD_pcall (lua_State *L, Pfunc func, void *u, 1031TStatus luaD_pcall (lua_State *L, Pfunc func, void *u, ptrdiff_t old_top,
1031 ptrdiff_t old_top, ptrdiff_t ef) { 1032 ptrdiff_t ef) {
1032 int status; 1033 TStatus status;
1033 CallInfo *old_ci = L->ci; 1034 CallInfo *old_ci = L->ci;
1034 lu_byte old_allowhooks = L->allowhook; 1035 lu_byte old_allowhooks = L->allowhook;
1035 ptrdiff_t old_errfunc = L->errfunc; 1036 ptrdiff_t old_errfunc = L->errfunc;
@@ -1091,10 +1092,10 @@ static void f_parser (lua_State *L, void *ud) {
1091} 1092}
1092 1093
1093 1094
1094int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 1095TStatus luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
1095 const char *mode) { 1096 const char *mode) {
1096 struct SParser p; 1097 struct SParser p;
1097 int status; 1098 TStatus status;
1098 incnny(L); /* cannot yield during parsing */ 1099 incnny(L); /* cannot yield during parsing */
1099 p.z = z; p.name = name; p.mode = mode; 1100 p.z = z; p.name = name; p.mode = mode;
1100 p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0; 1101 p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0;
diff --git a/ldo.h b/ldo.h
index b52a353f..ea1655e1 100644
--- a/ldo.h
+++ b/ldo.h
@@ -67,8 +67,9 @@
67/* type of protected functions, to be ran by 'runprotected' */ 67/* type of protected functions, to be ran by 'runprotected' */
68typedef void (*Pfunc) (lua_State *L, void *ud); 68typedef void (*Pfunc) (lua_State *L, void *ud);
69 69
70LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 70LUAI_FUNC void luaD_seterrorobj (lua_State *L, TStatus errcode, StkId oldtop);
71LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 71LUAI_FUNC TStatus luaD_protectedparser (lua_State *L, ZIO *z,
72 const char *name,
72 const char *mode); 73 const char *mode);
73LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, 74LUAI_FUNC void luaD_hook (lua_State *L, int event, int line,
74 int fTransfer, int nTransfer); 75 int fTransfer, int nTransfer);
@@ -78,8 +79,9 @@ LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
78LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); 79LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults);
79LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 80LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
80LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 81LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
81LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); 82LUAI_FUNC TStatus luaD_closeprotected (lua_State *L, ptrdiff_t level,
82LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 83 TStatus status);
84LUAI_FUNC TStatus luaD_pcall (lua_State *L, Pfunc func, void *u,
83 ptrdiff_t oldtop, ptrdiff_t ef); 85 ptrdiff_t oldtop, ptrdiff_t ef);
84LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres); 86LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres);
85LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror); 87LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror);
@@ -87,8 +89,8 @@ LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror);
87LUAI_FUNC void luaD_shrinkstack (lua_State *L); 89LUAI_FUNC void luaD_shrinkstack (lua_State *L);
88LUAI_FUNC void luaD_inctop (lua_State *L); 90LUAI_FUNC void luaD_inctop (lua_State *L);
89 91
90LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 92LUAI_FUNC l_noret luaD_throw (lua_State *L, TStatus errcode);
91LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 93LUAI_FUNC TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
92 94
93#endif 95#endif
94 96
diff --git a/lfunc.c b/lfunc.c
index 0ea05e00..d6853ff8 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -140,7 +140,8 @@ static void checkclosemth (lua_State *L, StkId level) {
140** the 'level' of the upvalue being closed, as everything after that 140** the 'level' of the upvalue being closed, as everything after that
141** won't be used again. 141** won't be used again.
142*/ 142*/
143static void prepcallclosemth (lua_State *L, StkId level, int status, int yy) { 143static void prepcallclosemth (lua_State *L, StkId level, TStatus status,
144 int yy) {
144 TValue *uv = s2v(level); /* value being closed */ 145 TValue *uv = s2v(level); /* value being closed */
145 TValue *errobj; 146 TValue *errobj;
146 if (status == CLOSEKTOP) 147 if (status == CLOSEKTOP)
@@ -224,7 +225,7 @@ static void poptbclist (lua_State *L) {
224** Close all upvalues and to-be-closed variables up to the given stack 225** Close all upvalues and to-be-closed variables up to the given stack
225** level. Return restored 'level'. 226** level. Return restored 'level'.
226*/ 227*/
227StkId luaF_close (lua_State *L, StkId level, int status, int yy) { 228StkId luaF_close (lua_State *L, StkId level, TStatus status, int yy) {
228 ptrdiff_t levelrel = savestack(L, level); 229 ptrdiff_t levelrel = savestack(L, level);
229 luaF_closeupval(L, level); /* first, close the upvalues */ 230 luaF_closeupval(L, level); /* first, close the upvalues */
230 while (L->tbclist.p >= level) { /* traverse tbc's down to that level */ 231 while (L->tbclist.p >= level) { /* traverse tbc's down to that level */
diff --git a/lfunc.h b/lfunc.h
index 342389e4..d6aad3a6 100644
--- a/lfunc.h
+++ b/lfunc.h
@@ -44,7 +44,7 @@
44 44
45 45
46/* special status to close upvalues preserving the top of the stack */ 46/* special status to close upvalues preserving the top of the stack */
47#define CLOSEKTOP (-1) 47#define CLOSEKTOP (LUA_ERRERR + 1)
48 48
49 49
50LUAI_FUNC Proto *luaF_newproto (lua_State *L); 50LUAI_FUNC Proto *luaF_newproto (lua_State *L);
@@ -54,7 +54,7 @@ LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
54LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 54LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
55LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); 55LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level);
56LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level); 56LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level);
57LUAI_FUNC StkId luaF_close (lua_State *L, StkId level, int status, int yy); 57LUAI_FUNC StkId luaF_close (lua_State *L, StkId level, TStatus status, int yy);
58LUAI_FUNC void luaF_unlinkupval (UpVal *uv); 58LUAI_FUNC void luaF_unlinkupval (UpVal *uv);
59LUAI_FUNC lu_mem luaF_protosize (Proto *p); 59LUAI_FUNC lu_mem luaF_protosize (Proto *p);
60LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 60LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
diff --git a/lgc.c b/lgc.c
index 1e9f7569..8a82b6d9 100644
--- a/lgc.c
+++ b/lgc.c
@@ -953,7 +953,7 @@ static void GCTM (lua_State *L) {
953 setgcovalue(L, &v, udata2finalize(g)); 953 setgcovalue(L, &v, udata2finalize(g));
954 tm = luaT_gettmbyobj(L, &v, TM_GC); 954 tm = luaT_gettmbyobj(L, &v, TM_GC);
955 if (!notm(tm)) { /* is there a finalizer? */ 955 if (!notm(tm)) { /* is there a finalizer? */
956 int status; 956 TStatus status;
957 lu_byte oldah = L->allowhook; 957 lu_byte oldah = L->allowhook;
958 lu_byte oldgcstp = g->gcstp; 958 lu_byte oldgcstp = g->gcstp;
959 g->gcstp |= GCSTPGC; /* avoid GC steps */ 959 g->gcstp |= GCSTPGC; /* avoid GC steps */
diff --git a/llimits.h b/llimits.h
index d98171ae..d206e9e1 100644
--- a/llimits.h
+++ b/llimits.h
@@ -41,6 +41,12 @@ typedef unsigned char lu_byte;
41typedef signed char ls_byte; 41typedef signed char ls_byte;
42 42
43 43
44/* Type for thread status/error codes */
45typedef lu_byte TStatus;
46
47/* The C API still uses 'int' for status/error codes */
48#define APIstatus(st) cast_int(st)
49
44/* maximum value for size_t */ 50/* maximum value for size_t */
45#define MAX_SIZET ((size_t)(~(size_t)0)) 51#define MAX_SIZET ((size_t)(~(size_t)0))
46 52
diff --git a/lstate.c b/lstate.c
index 0e1cb01e..18ab4900 100644
--- a/lstate.c
+++ b/lstate.c
@@ -320,7 +320,7 @@ void luaE_freethread (lua_State *L, lua_State *L1) {
320} 320}
321 321
322 322
323int luaE_resetthread (lua_State *L, int status) { 323TStatus luaE_resetthread (lua_State *L, TStatus status) {
324 CallInfo *ci = L->ci = &L->base_ci; /* unwind CallInfo list */ 324 CallInfo *ci = L->ci = &L->base_ci; /* unwind CallInfo list */
325 setnilvalue(s2v(L->stack.p)); /* 'function' entry for basic 'ci' */ 325 setnilvalue(s2v(L->stack.p)); /* 'function' entry for basic 'ci' */
326 ci->func.p = L->stack.p; 326 ci->func.p = L->stack.p;
@@ -340,12 +340,12 @@ int luaE_resetthread (lua_State *L, int status) {
340 340
341 341
342LUA_API int lua_closethread (lua_State *L, lua_State *from) { 342LUA_API int lua_closethread (lua_State *L, lua_State *from) {
343 int status; 343 TStatus status;
344 lua_lock(L); 344 lua_lock(L);
345 L->nCcalls = (from) ? getCcalls(from) : 0; 345 L->nCcalls = (from) ? getCcalls(from) : 0;
346 status = luaE_resetthread(L, L->status); 346 status = luaE_resetthread(L, L->status);
347 lua_unlock(L); 347 lua_unlock(L);
348 return status; 348 return APIstatus(status);
349} 349}
350 350
351 351
diff --git a/lstate.h b/lstate.h
index 635f41d2..b47a4e9b 100644
--- a/lstate.h
+++ b/lstate.h
@@ -339,8 +339,8 @@ typedef struct global_State {
339*/ 339*/
340struct lua_State { 340struct lua_State {
341 CommonHeader; 341 CommonHeader;
342 lu_byte status;
343 lu_byte allowhook; 342 lu_byte allowhook;
343 TStatus status;
344 unsigned short nci; /* number of items in 'ci' list */ 344 unsigned short nci; /* number of items in 'ci' list */
345 StkIdRel top; /* first free slot in the stack */ 345 StkIdRel top; /* first free slot in the stack */
346 global_State *l_G; 346 global_State *l_G;
@@ -352,10 +352,10 @@ struct lua_State {
352 GCObject *gclist; 352 GCObject *gclist;
353 struct lua_State *twups; /* list of threads with open upvalues */ 353 struct lua_State *twups; /* list of threads with open upvalues */
354 struct lua_longjmp *errorJmp; /* current error recover point */ 354 struct lua_longjmp *errorJmp; /* current error recover point */
355 CallInfo base_ci; /* CallInfo for first level (C calling Lua) */ 355 CallInfo base_ci; /* CallInfo for first level (C host) */
356 volatile lua_Hook hook; 356 volatile lua_Hook hook;
357 ptrdiff_t errfunc; /* current error handling function (stack index) */ 357 ptrdiff_t errfunc; /* current error handling function (stack index) */
358 l_uint32 nCcalls; /* number of nested (non-yieldable | C) calls */ 358 l_uint32 nCcalls; /* number of nested non-yieldable or C calls */
359 int oldpc; /* last pc traced */ 359 int oldpc; /* last pc traced */
360 int basehookcount; 360 int basehookcount;
361 int hookcount; 361 int hookcount;
@@ -438,7 +438,7 @@ LUAI_FUNC void luaE_checkcstack (lua_State *L);
438LUAI_FUNC void luaE_incCstack (lua_State *L); 438LUAI_FUNC void luaE_incCstack (lua_State *L);
439LUAI_FUNC void luaE_warning (lua_State *L, const char *msg, int tocont); 439LUAI_FUNC void luaE_warning (lua_State *L, const char *msg, int tocont);
440LUAI_FUNC void luaE_warnerror (lua_State *L, const char *where); 440LUAI_FUNC void luaE_warnerror (lua_State *L, const char *where);
441LUAI_FUNC int luaE_resetthread (lua_State *L, int status); 441LUAI_FUNC TStatus luaE_resetthread (lua_State *L, TStatus status);
442 442
443 443
444#endif 444#endif
diff --git a/lstring.c b/lstring.c
index 0c89a51b..b5c8f89f 100644
--- a/lstring.c
+++ b/lstring.c
@@ -329,7 +329,7 @@ TString *luaS_newextlstr (lua_State *L,
329 if (!falloc) 329 if (!falloc)
330 f_pintern(L, &ne); /* just internalize string */ 330 f_pintern(L, &ne); /* just internalize string */
331 else { 331 else {
332 int status = luaD_rawrunprotected(L, f_pintern, &ne); 332 TStatus status = luaD_rawrunprotected(L, f_pintern, &ne);
333 (*falloc)(ud, cast_voidp(s), len + 1, 0); /* free external string */ 333 (*falloc)(ud, cast_voidp(s), len + 1, 0); /* free external string */
334 if (status != LUA_OK) /* memory error? */ 334 if (status != LUA_OK) /* memory error? */
335 luaM_error(L); /* re-raise memory error */ 335 luaM_error(L); /* re-raise memory error */