** Calls 'luaF_close' in protected mode. Return the original status ** or, in case of errors, the new status. */
| 1057 | ** or, in case of errors, the new status. |
| 1058 | */ |
| 1059 | TStatus luaD_closeprotected (lua_State *L, ptrdiff_t level, TStatus status) { |
| 1060 | CallInfo *old_ci = L->ci; |
| 1061 | lu_byte old_allowhooks = L->allowhook; |
| 1062 | for (;;) { /* keep closing upvalues until no more errors */ |
| 1063 | struct CloseP pcl; |
| 1064 | pcl.level = restorestack(L, level); pcl.status = status; |
| 1065 | status = luaD_rawrunprotected(L, &closepaux, &pcl); |
| 1066 | if (l_likely(status == LUA_OK)) /* no more errors? */ |
| 1067 | return pcl.status; |
| 1068 | else { /* an error occurred; restore saved state and repeat */ |
| 1069 | L->ci = old_ci; |
| 1070 | L->allowhook = old_allowhooks; |
| 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | |
| 1076 | /* |
no test coverage detected