mirror of https://github.com/rusefi/lua.git
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.
This commit is contained in:
parent
51316f9df7
commit
3b06f983ae
|
@ -68,7 +68,6 @@ static const char *b_str2int (const char *s, int base, lua_Integer *pn) {
|
||||||
|
|
||||||
static int luaB_tonumber (lua_State *L) {
|
static int luaB_tonumber (lua_State *L) {
|
||||||
if (lua_isnoneornil(L, 2)) { /* standard conversion? */
|
if (lua_isnoneornil(L, 2)) { /* standard conversion? */
|
||||||
luaL_checkany(L, 1);
|
|
||||||
if (lua_type(L, 1) == LUA_TNUMBER) { /* already a number? */
|
if (lua_type(L, 1) == LUA_TNUMBER) { /* already a number? */
|
||||||
lua_settop(L, 1); /* yes; return it */
|
lua_settop(L, 1); /* yes; return it */
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -79,6 +78,7 @@ static int luaB_tonumber (lua_State *L) {
|
||||||
if (s != NULL && lua_stringtonumber(L, s) == l + 1)
|
if (s != NULL && lua_stringtonumber(L, s) == l + 1)
|
||||||
return 1; /* successful conversion to number */
|
return 1; /* successful conversion to number */
|
||||||
/* else not a number */
|
/* else not a number */
|
||||||
|
luaL_checkany(L, 1); /* (but there must be some parameter) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
29
ldo.c
29
ldo.c
|
@ -678,22 +678,19 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
|
||||||
L->nny = 0; /* allow yields */
|
L->nny = 0; /* allow yields */
|
||||||
api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
|
api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
|
||||||
status = luaD_rawrunprotected(L, resume, &nargs);
|
status = luaD_rawrunprotected(L, resume, &nargs);
|
||||||
if (unlikely(status == -1)) /* error calling 'lua_resume'? */
|
/* continue running after recoverable errors */
|
||||||
status = LUA_ERRRUN;
|
while (errorstatus(status) && recover(L, status)) {
|
||||||
else { /* continue running after recoverable errors */
|
/* unroll continuation */
|
||||||
while (errorstatus(status) && recover(L, status)) {
|
status = luaD_rawrunprotected(L, unroll, &status);
|
||||||
/* unroll continuation */
|
}
|
||||||
status = luaD_rawrunprotected(L, unroll, &status);
|
if (likely(!errorstatus(status)))
|
||||||
}
|
lua_assert(status == L->status); /* normal end or yield */
|
||||||
if (likely(!errorstatus(status)))
|
else { /* unrecoverable error */
|
||||||
lua_assert(status == L->status); /* normal end or yield */
|
status = luaF_close(L, L->stack, status); /* close all upvalues */
|
||||||
else { /* unrecoverable error */
|
L->status = cast_byte(status); /* mark thread as 'dead' */
|
||||||
status = luaF_close(L, L->stack, status); /* close all upvalues */
|
luaD_seterrorobj(L, status, L->stack + 1); /* push error message */
|
||||||
L->status = cast_byte(status); /* mark thread as 'dead' */
|
L->ci = &L->base_ci; /* back to the original C level */
|
||||||
luaD_seterrorobj(L, status, L->stack + 1); /* push error message */
|
L->ci->top = L->top;
|
||||||
L->ci = &L->base_ci; /* back to the original C level */
|
|
||||||
L->ci->top = L->top;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*nresults = (status == LUA_YIELD) ? L->ci->u2.nyield
|
*nresults = (status == LUA_YIELD) ? L->ci->u2.nyield
|
||||||
: cast_int(L->top - (L->ci->func + 1));
|
: cast_int(L->top - (L->ci->func + 1));
|
||||||
|
|
Loading…
Reference in New Issue