6 static int lc_xpcall (lua_State
*L
) {
8 int n_arg
= lua_gettop(L
);
9 /* f, msgh, p1, p2... */
10 luaL_argcheck(L
, n_arg
>= 2, 2, "value expected");
11 lua_pushvalue(L
, 1); /* f to top */
12 lua_pushvalue(L
, 2); /* msgh to top */
13 lua_replace(L
, 1); /* msgh to 1 */
14 lua_replace(L
, 2); /* f to 2 */
15 /* msgh, f, p1, p2... */
16 ret
= lua_pcall(L
, n_arg
- 2, LUA_MULTRET
, 1);
17 lua_pushboolean(L
, ret
== 0);
22 int luaopen_util_compat(lua_State
*L
) {
23 lua_createtable(L
, 0, 2);
25 lua_pushcfunction(L
, lc_xpcall
);
26 lua_setfield(L
, -2, "xpcall");