Support os.exit(status|true|false [,close]) (from Lua 5.2).

This commit is contained in:
Mike Pall 2010-11-22 22:39:06 +01:00
parent 367ff0cdaa
commit 7338456796

View File

@ -92,8 +92,15 @@ LJLIB_CF(os_getenv)
LJLIB_CF(os_exit)
{
exit(lj_lib_optint(L, 1, EXIT_SUCCESS));
return 0; /* to avoid warnings */
int status;
if (L->base < L->top && tvisbool(L->base))
status = boolV(L->base) ? EXIT_SUCCESS : EXIT_FAILURE;
else
status = lj_lib_optint(L, 1, EXIT_SUCCESS);
if (L->base+1 < L->top && tvistruecond(L->base+1))
lua_close(L);
exit(status);
return 0; /* Unreachable. */
}
LJLIB_CF(os_clock)