** Call the C function 'func' in protected mode, restoring basic ** thread information ('allowhook', etc.) and in particular ** its stack level in case of errors. */
| 883 | ** its stack level in case of errors. |
| 884 | */ |
| 885 | int luaD_pcall (lua_State *L, Pfunc func, void *u, |
| 886 | ptrdiff_t old_top, ptrdiff_t ef) { |
| 887 | int status; |
| 888 | CallInfo *old_ci = L->ci; |
| 889 | lu_byte old_allowhooks = L->allowhook; |
| 890 | ptrdiff_t old_errfunc = L->errfunc; |
| 891 | L->errfunc = ef; |
| 892 | status = luaD_rawrunprotected(L, func, u); |
| 893 | if (l_unlikely(status != LUA_OK)) { /* an error occurred? */ |
| 894 | L->ci = old_ci; |
| 895 | L->allowhook = old_allowhooks; |
| 896 | status = luaD_closeprotected(L, old_top, status); |
| 897 | luaD_seterrorobj(L, status, restorestack(L, old_top)); |
| 898 | luaD_shrinkstack(L); /* restore stack size in case of overflow */ |
| 899 | } |
| 900 | L->errfunc = old_errfunc; |
| 901 | return status; |
| 902 | } |
| 903 | |
| 904 | |
| 905 |
no test coverage detected