diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-05 09:18:03 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-05 09:18:03 -0300 |
commit | 8bc33a088c99c21493dee173fb394003f3331454 (patch) | |
tree | 5a15a2aabacec6934819b559838326ed2e260074 /loslib.c | |
parent | c3eb89544fd6c435443ae0da7aa5b12491ed9689 (diff) | |
download | lua-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.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 | ||
278 | static int os_exit (lua_State *L) { | 278 | static 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); |