mirror of
https://github.com/lua/lua
synced 2025-03-24 22:52:51 +03:00
'os.exit' acceps booleans as status (for EXIT_SUCESS and EXIT_FAILURE)
This commit is contained in:
parent
c3eb89544f
commit
8bc33a088c
8
loslib.c
8
loslib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: loslib.c,v 1.30 2010/07/02 11:38:13 roberto Exp roberto $
|
** $Id: loslib.c,v 1.31 2010/07/02 12:01:53 roberto Exp roberto $
|
||||||
** Standard Operating System library
|
** Standard Operating System library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -276,7 +276,11 @@ static int os_setlocale (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
static int os_exit (lua_State *L) {
|
static int os_exit (lua_State *L) {
|
||||||
int status = luaL_optint(L, 1, EXIT_SUCCESS);
|
int status;
|
||||||
|
if (lua_isboolean(L, 1))
|
||||||
|
status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
|
else
|
||||||
|
status = luaL_optint(L, 1, EXIT_SUCCESS);
|
||||||
if (lua_toboolean(L, 2))
|
if (lua_toboolean(L, 2))
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
exit(status);
|
exit(status);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user