** Calls 'luaF_close' in protected mode. Return the original status ** or, in case of errors, the new status. */
| 933 | ** or, in case of errors, the new status. |
| 934 | */ |
| 935 | int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status) { |
| 936 | CallInfo *old_ci = L->ci; |
| 937 | lu_byte old_allowhooks = L->allowhook; |
| 938 | for (;;) { /* keep closing upvalues until no more errors */ |
| 939 | struct CloseP pcl; |
| 940 | pcl.level = restorestack(L, level); pcl.status = status; |
| 941 | status = luaD_rawrunprotected(L, &closepaux, &pcl); |
| 942 | if (l_likely(status == LUA_OK)) /* no more errors? */ |
| 943 | return pcl.status; |
| 944 | else { /* an error occurred; restore saved state and repeat */ |
| 945 | L->ci = old_ci; |
| 946 | L->allowhook = old_allowhooks; |
| 947 | } |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | |
| 952 | /* |
no test coverage detected