** Interface to 'lua_pcall', which sets appropriate message function ** and C-signal handler. Used to run all chunks. */
| 79 | ** and C-signal handler. Used to run all chunks. |
| 80 | */ |
| 81 | static int docall(lua_State *L, int narg, int nres) { |
| 82 | int status; |
| 83 | int base = lua_gettop(L) - narg; /* function index */ |
| 84 | lua_pushcfunction(L, msghandler); /* push message handler */ |
| 85 | lua_insert(L, base); /* put it under function and args */ |
| 86 | globalL = L; /* to be available to 'laction' */ |
| 87 | signal(SIGINT, laction); /* set C-signal handler */ |
| 88 | status = lua_pcall(L, narg, nres, base); |
| 89 | signal(SIGINT, SIG_DFL); /* reset C-signal handler */ |
| 90 | if (lua_gettop(L) > 0) |
| 91 | lua_remove(L, base); /* remove message handler from the stack */ |
| 92 | return status; |
| 93 | } |
| 94 | |
| 95 | /* |
| 96 | ** Check whether 'status' is not OK and, if so, prints the error |
no test coverage detected