diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-04-26 15:19:49 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2006-04-26 15:19:49 -0300 |
commit | c351392940608702bfed0fa0a4c7d035ad31dbce (patch) | |
tree | df75c22d4bb4a39ed7043e1204106d17b4cd6328 | |
parent | 18330b6091696f2900d89e8ddef6fb548a3ac84d (diff) | |
download | lua-github-c351392940608702bfed0fa0a4c7d035ad31dbce.tar.gz |
details
-rw-r--r-- | loslib.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.17 2006/01/27 13:54:31 roberto Exp roberto $ +** $Id: loslib.c,v 1.18 2006/03/09 18:08:22 roberto Exp roberto $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -123,8 +123,7 @@ static int getfield (lua_State *L, const char *key, int d) { static int os_date (lua_State *L) { const char *s = luaL_optstring(L, 1, "%c"); - time_t t = lua_isnoneornil(L, 2) ? time(NULL) : - (time_t)luaL_checknumber(L, 2); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); struct tm *stm; if (*s == '!') { /* UTC? */ stm = gmtime(&t); @@ -196,9 +195,8 @@ static int os_setlocale (lua_State *L) { LC_NUMERIC, LC_TIME}; static const char *const catnames[] = {"all", "collate", "ctype", "monetary", "numeric", "time", NULL}; - const char *l = lua_tostring(L, 1); + const char *l = luaL_optstring(L, 1, NULL); int op = luaL_checkoption(L, 2, "all", catnames); - luaL_argcheck(L, l || lua_isnoneornil(L, 1), 1, "string expected"); lua_pushstring(L, setlocale(cat[op], l)); return 1; } |