** Call the C function 'func' in protected mode, restoring basic ** thread information ('allowhook', etc.) and in particular ** its stack level in case of errors. */
| 740 | ** its stack level in case of errors. |
| 741 | */ |
| 742 | int luaD_pcall (lua_State *L, Pfunc func, void *u, |
| 743 | ptrdiff_t old_top, ptrdiff_t ef) { |
| 744 | int status; |
| 745 | CallInfo *old_ci = L->ci; |
| 746 | lu_byte old_allowhooks = L->allowhook; |
| 747 | ptrdiff_t old_errfunc = L->errfunc; |
| 748 | L->errfunc = ef; |
| 749 | status = luaD_rawrunprotected(L, func, u); |
| 750 | if (unlikely(status != LUA_OK)) { /* an error occurred? */ |
| 751 | StkId oldtop = restorestack(L, old_top); |
| 752 | L->ci = old_ci; |
| 753 | L->allowhook = old_allowhooks; |
| 754 | status = luaF_close(L, oldtop, status); |
| 755 | oldtop = restorestack(L, old_top); /* previous call may change stack */ |
| 756 | luaD_seterrorobj(L, status, oldtop); |
| 757 | luaD_shrinkstack(L); |
| 758 | } |
| 759 | L->errfunc = old_errfunc; |
| 760 | return status; |
| 761 | } |
| 762 | |
| 763 | |
| 764 |
no test coverage detected