aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lcorolib.c4
-rw-r--r--lstate.c10
-rw-r--r--ltests.c2
-rw-r--r--lua.h7
-rw-r--r--manual/manual.of40
5 files changed, 41 insertions, 22 deletions
diff --git a/lcorolib.c b/lcorolib.c
index 40b880b1..c64adf08 100644
--- a/lcorolib.c
+++ b/lcorolib.c
@@ -76,7 +76,7 @@ static int luaB_auxwrap (lua_State *L) {
76 if (l_unlikely(r < 0)) { /* error? */ 76 if (l_unlikely(r < 0)) { /* error? */
77 int stat = lua_status(co); 77 int stat = lua_status(co);
78 if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ 78 if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */
79 stat = lua_resetthread(co, L); /* close its tbc variables */ 79 stat = lua_closethread(co, L); /* close its tbc variables */
80 lua_assert(stat != LUA_OK); 80 lua_assert(stat != LUA_OK);
81 lua_xmove(co, L, 1); /* move error message to the caller */ 81 lua_xmove(co, L, 1); /* move error message to the caller */
82 } 82 }
@@ -172,7 +172,7 @@ static int luaB_close (lua_State *L) {
172 int status = auxstatus(L, co); 172 int status = auxstatus(L, co);
173 switch (status) { 173 switch (status) {
174 case COS_DEAD: case COS_YIELD: { 174 case COS_DEAD: case COS_YIELD: {
175 status = lua_resetthread(co, L); 175 status = lua_closethread(co, L);
176 if (status == LUA_OK) { 176 if (status == LUA_OK) {
177 lua_pushboolean(L, 1); 177 lua_pushboolean(L, 1);
178 return 1; 178 return 1;
diff --git a/lstate.c b/lstate.c
index 1fbefb4b..1e925e5a 100644
--- a/lstate.c
+++ b/lstate.c
@@ -339,7 +339,7 @@ int luaE_resetthread (lua_State *L, int status) {
339} 339}
340 340
341 341
342LUA_API int lua_resetthread (lua_State *L, lua_State *from) { 342LUA_API int lua_closethread (lua_State *L, lua_State *from) {
343 int status; 343 int status;
344 lua_lock(L); 344 lua_lock(L);
345 L->nCcalls = (from) ? getCcalls(from) : 0; 345 L->nCcalls = (from) ? getCcalls(from) : 0;
@@ -349,6 +349,14 @@ LUA_API int lua_resetthread (lua_State *L, lua_State *from) {
349} 349}
350 350
351 351
352/*
353** Deprecated! Use 'lua_closethread' instead.
354*/
355LUA_API int lua_resetthread (lua_State *L) {
356 return lua_closethread(L, NULL);
357}
358
359
352LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { 360LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
353 int i; 361 int i;
354 lua_State *L; 362 lua_State *L;
diff --git a/ltests.c b/ltests.c
index 4a0a6af1..7d184c0d 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1533,7 +1533,7 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
1533 lua_newthread(L1); 1533 lua_newthread(L1);
1534 } 1534 }
1535 else if EQ("resetthread") { 1535 else if EQ("resetthread") {
1536 lua_pushinteger(L1, lua_resetthread(L1, L)); 1536 lua_pushinteger(L1, lua_resetthread(L1)); /* deprecated */
1537 } 1537 }
1538 else if EQ("newuserdata") { 1538 else if EQ("newuserdata") {
1539 lua_newuserdata(L1, getnum); 1539 lua_newuserdata(L1, getnum);
diff --git a/lua.h b/lua.h
index 01927c6d..fd16cf80 100644
--- a/lua.h
+++ b/lua.h
@@ -18,10 +18,10 @@
18 18
19#define LUA_VERSION_MAJOR "5" 19#define LUA_VERSION_MAJOR "5"
20#define LUA_VERSION_MINOR "4" 20#define LUA_VERSION_MINOR "4"
21#define LUA_VERSION_RELEASE "5" 21#define LUA_VERSION_RELEASE "6"
22 22
23#define LUA_VERSION_NUM 504 23#define LUA_VERSION_NUM 504
24#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 5) 24#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 6)
25 25
26#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 26#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
27#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE 27#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
@@ -163,7 +163,8 @@ extern const char lua_ident[];
163LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); 163LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
164LUA_API void (lua_close) (lua_State *L); 164LUA_API void (lua_close) (lua_State *L);
165LUA_API lua_State *(lua_newthread) (lua_State *L); 165LUA_API lua_State *(lua_newthread) (lua_State *L);
166LUA_API int (lua_resetthread) (lua_State *L, lua_State *from); 166LUA_API int (lua_closethread) (lua_State *L, lua_State *from);
167LUA_API int (lua_resetthread) (lua_State *L); /* Deprecated! */
167 168
168LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 169LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
169 170
diff --git a/manual/manual.of b/manual/manual.of
index ac1d7e60..f8d8ddd4 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -3167,6 +3167,27 @@ when called through this function.
3167 3167
3168} 3168}
3169 3169
3170@APIEntry{int lua_closethread (lua_State *L, lua_State *from);|
3171@apii{0,?,-}
3172
3173Resets a thread, cleaning its call stack and closing all pending
3174to-be-closed variables.
3175Returns a status code:
3176@Lid{LUA_OK} for no errors in the thread
3177(either the original error that stopped the thread or
3178errors in closing methods),
3179or an error status otherwise.
3180In case of error,
3181leaves the error object on the top of the stack.
3182
3183The parameter @id{from} represents the coroutine that is resetting @id{L}.
3184If there is no such coroutine,
3185this parameter can be @id{NULL}.
3186
3187(This function was introduced in @N{release 5.4.6}.)
3188
3189}
3190
3170@APIEntry{int lua_compare (lua_State *L, int index1, int index2, int op);| 3191@APIEntry{int lua_compare (lua_State *L, int index1, int index2, int op);|
3171@apii{0,0,e} 3192@apii{0,0,e}
3172 3193
@@ -4160,23 +4181,12 @@ and then pops the top element.
4160 4181
4161} 4182}
4162 4183
4163@APIEntry{int lua_resetthread (lua_State *L, lua_State *from);| 4184@APIEntry{int lua_resetthread (lua_State *L);|
4164@apii{0,?,-} 4185@apii{0,?,-}
4165 4186
4166Resets a thread, cleaning its call stack and closing all pending 4187This function is deprecated;
4167to-be-closed variables. 4188it is equivalent to @Lid{lua_closethread} with
4168Returns a status code: 4189@id{from} being @id{NULL}.
4169@Lid{LUA_OK} for no errors in the thread
4170(either the original error that stopped the thread or
4171errors in closing methods),
4172or an error status otherwise.
4173In case of error,
4174leaves the error object on the top of the stack.
4175
4176The parameter @id{from} represents the coroutine that is resetting @id{L}.
4177If there is no such coroutine,
4178this parameter can be @id{NULL}.
4179(This parameter was introduced in @N{release 5.4.5}.)
4180 4190
4181} 4191}
4182 4192