diff options
author | Lua Team <team@lua.org> | 2005-09-09 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2005-09-09 12:00:00 +0000 |
commit | bd80c4ee9b6d9464cf9f3ff4ee41890d8b3ca9e6 (patch) | |
tree | e1d7c1b341ccb9a3a1fb044ac6e67b5a5e0259b7 /src/loslib.c | |
parent | bf6b5550cdfbc0c4a3a4577776ad76628d80718e (diff) | |
download | lua-github-bd80c4ee9b6d9464cf9f3ff4ee41890d8b3ca9e6.tar.gz |
Lua 5.1-alpha5.1-alpha
Diffstat (limited to 'src/loslib.c')
-rw-r--r-- | src/loslib.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/loslib.c b/src/loslib.c index 52532143..4cee7ba5 100644 --- a/src/loslib.c +++ b/src/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.9 2005/05/17 19:49:15 roberto Exp $ +** $Id: loslib.c,v 1.13 2005/09/09 18:22:46 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -93,6 +93,8 @@ static void setfield (lua_State *L, const char *key, int value) { } static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ lua_pushboolean(L, value); lua_setfield(L, -2, key); } @@ -197,9 +199,8 @@ static int io_setloc (lua_State *L) { static const char *const catnames[] = {"all", "collate", "ctype", "monetary", "numeric", "time", NULL}; const char *l = lua_tostring(L, 1); - int op = luaL_findstring(luaL_optstring(L, 2, "all"), catnames); + int op = luaL_checkoption(L, 2, "all", catnames); luaL_argcheck(L, l || lua_isnoneornil(L, 1), 1, "string expected"); - luaL_argcheck(L, op != -1, 2, "invalid option"); lua_pushstring(L, setlocale(cat[op], l)); return 1; } @@ -210,7 +211,7 @@ static int io_exit (lua_State *L) { return 0; /* to avoid warnings */ } -static const luaL_reg syslib[] = { +static const luaL_Reg syslib[] = { {"clock", io_clock}, {"date", io_date}, {"difftime", io_difftime}, @@ -230,7 +231,7 @@ static const luaL_reg syslib[] = { LUALIB_API int luaopen_os (lua_State *L) { - luaL_openlib(L, LUA_OSLIBNAME, syslib, 0); + luaL_register(L, LUA_OSLIBNAME, syslib); return 1; } |