diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-11 11:54:14 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-11 11:54:14 -0200 |
| commit | 3b06f983ae0e57b90cdeb500c84bb524e5c3635b (patch) | |
| tree | 7325ada043c7c2f0a2641bb0d6bfd9b16b002850 | |
| parent | 51316f9df7aacb54633a3e9b910a070590ac6259 (diff) | |
| download | lua-3b06f983ae0e57b90cdeb500c84bb524e5c3635b.tar.gz lua-3b06f983ae0e57b90cdeb500c84bb524e5c3635b.tar.bz2 lua-3b06f983ae0e57b90cdeb500c84bb524e5c3635b.zip | |
Details
- in 'luaB_tonumber', do not need to "checkany" when argument
is a number.
- in 'lua_resume', the call to 'luaD_rawrunprotected' cannot return
a status equal to -1.
| -rw-r--r-- | lbaselib.c | 2 | ||||
| -rw-r--r-- | ldo.c | 29 |
2 files changed, 14 insertions, 17 deletions
| @@ -68,7 +68,6 @@ static const char *b_str2int (const char *s, int base, lua_Integer *pn) { | |||
| 68 | 68 | ||
| 69 | static int luaB_tonumber (lua_State *L) { | 69 | static 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 { |
| @@ -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)); |
