aboutsummaryrefslogtreecommitdiff
path: root/loslib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-10-05 09:18:03 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-10-05 09:18:03 -0300
commit8bc33a088c99c21493dee173fb394003f3331454 (patch)
tree5a15a2aabacec6934819b559838326ed2e260074 /loslib.c
parentc3eb89544fd6c435443ae0da7aa5b12491ed9689 (diff)
downloadlua-8bc33a088c99c21493dee173fb394003f3331454.tar.gz
lua-8bc33a088c99c21493dee173fb394003f3331454.tar.bz2
lua-8bc33a088c99c21493dee173fb394003f3331454.zip
'os.exit' acceps booleans as status (for EXIT_SUCESS and EXIT_FAILURE)
Diffstat (limited to 'loslib.c')
-rw-r--r--loslib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/loslib.c b/loslib.c
index 6baebd91..95ec7395 100644
--- a/loslib.c
+++ b/loslib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loslib.c,v 1.30 2010/07/02 11:38:13 roberto Exp roberto $ 2** $Id: loslib.c,v 1.31 2010/07/02 12:01:53 roberto Exp roberto $
3** Standard Operating System library 3** Standard Operating System library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -276,7 +276,11 @@ static int os_setlocale (lua_State *L) {
276 276
277 277
278static int os_exit (lua_State *L) { 278static int os_exit (lua_State *L) {
279 int status = luaL_optint(L, 1, EXIT_SUCCESS); 279 int status;
280 if (lua_isboolean(L, 1))
281 status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
282 else
283 status = luaL_optint(L, 1, EXIT_SUCCESS);
280 if (lua_toboolean(L, 2)) 284 if (lua_toboolean(L, 2))
281 lua_close(L); 285 lua_close(L);
282 exit(status); 286 exit(status);