aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lbaselib.c2
-rw-r--r--ldo.c29
2 files changed, 14 insertions, 17 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 201c93e3..7c0ebfec 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -68,7 +68,6 @@ static const char *b_str2int (const char *s, int base, lua_Integer *pn) {
68 68
69static int luaB_tonumber (lua_State *L) { 69static int luaB_tonumber (lua_State *L) {
70 if (lua_isnoneornil(L, 2)) { /* standard conversion? */ 70 if (lua_isnoneornil(L, 2)) { /* standard conversion? */
71 luaL_checkany(L, 1);
72 if (lua_type(L, 1) == LUA_TNUMBER) { /* already a number? */ 71 if (lua_type(L, 1) == LUA_TNUMBER) { /* already a number? */
73 lua_settop(L, 1); /* yes; return it */ 72 lua_settop(L, 1); /* yes; return it */
74 return 1; 73 return 1;
@@ -79,6 +78,7 @@ static int luaB_tonumber (lua_State *L) {
79 if (s != NULL && lua_stringtonumber(L, s) == l + 1) 78 if (s != NULL && lua_stringtonumber(L, s) == l + 1)
80 return 1; /* successful conversion to number */ 79 return 1; /* successful conversion to number */
81 /* else not a number */ 80 /* else not a number */
81 luaL_checkany(L, 1); /* (but there must be some parameter) */
82 } 82 }
83 } 83 }
84 else { 84 else {
diff --git a/ldo.c b/ldo.c
index 2762fefa..bdd7fb6d 100644
--- a/ldo.c
+++ b/ldo.c
@@ -678,22 +678,19 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
678 L->nny = 0; /* allow yields */ 678 L->nny = 0; /* allow yields */
679 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); 679 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
680 status = luaD_rawrunprotected(L, resume, &nargs); 680 status = luaD_rawrunprotected(L, resume, &nargs);
681 if (unlikely(status == -1)) /* error calling 'lua_resume'? */ 681 /* continue running after recoverable errors */
682 status = LUA_ERRRUN; 682 while (errorstatus(status) && recover(L, status)) {
683 else { /* continue running after recoverable errors */ 683 /* unroll continuation */
684 while (errorstatus(status) && recover(L, status)) { 684 status = luaD_rawrunprotected(L, unroll, &status);
685 /* unroll continuation */ 685 }
686 status = luaD_rawrunprotected(L, unroll, &status); 686 if (likely(!errorstatus(status)))
687 } 687 lua_assert(status == L->status); /* normal end or yield */
688 if (likely(!errorstatus(status))) 688 else { /* unrecoverable error */
689 lua_assert(status == L->status); /* normal end or yield */ 689 status = luaF_close(L, L->stack, status); /* close all upvalues */
690 else { /* unrecoverable error */ 690 L->status = cast_byte(status); /* mark thread as 'dead' */
691 status = luaF_close(L, L->stack, status); /* close all upvalues */ 691 luaD_seterrorobj(L, status, L->stack + 1); /* push error message */
692 L->status = cast_byte(status); /* mark thread as 'dead' */ 692 L->ci = &L->base_ci; /* back to the original C level */
693 luaD_seterrorobj(L, status, L->stack + 1); /* push error message */ 693 L->ci->top = L->top;
694 L->ci = &L->base_ci; /* back to the original C level */
695 L->ci->top = L->top;
696 }
697 } 694 }
698 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield 695 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield
699 : cast_int(L->top - (L->ci->func + 1)); 696 : cast_int(L->top - (L->ci->func + 1));