diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-21 11:47:42 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-21 11:47:42 -0200 |
commit | 053e87314596e48588a929791012def7818ec989 (patch) | |
tree | e5ce2b8bdf03da3dbdac087bf62824b49e7d40f0 /loslib.c | |
parent | 9f4211310fcea9ebf08f4884f8665520c1b8d85f (diff) | |
download | lua-053e87314596e48588a929791012def7818ec989.tar.gz lua-053e87314596e48588a929791012def7818ec989.tar.bz2 lua-053e87314596e48588a929791012def7818ec989.zip |
new macro luaL_opt to avoid evaluating defaults when no needed
Diffstat (limited to 'loslib.c')
-rw-r--r-- | loslib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loslib.c,v 1.12 2005/08/26 17:36:32 roberto Exp roberto $ | 2 | ** $Id: loslib.c,v 1.13 2005/09/09 18:22:46 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 | */ |
@@ -125,8 +125,8 @@ static int getfield (lua_State *L, const char *key, int d) { | |||
125 | 125 | ||
126 | static int io_date (lua_State *L) { | 126 | static int io_date (lua_State *L) { |
127 | const char *s = luaL_optstring(L, 1, "%c"); | 127 | const char *s = luaL_optstring(L, 1, "%c"); |
128 | lua_Number n = luaL_optnumber(L, 2, -1); | 128 | time_t t = lua_isnoneornil(L, 2) ? time(NULL) : |
129 | time_t t = (n == -1) ? time(NULL) : (time_t)n; | 129 | (time_t)luaL_checknumber(L, 2); |
130 | struct tm *stm; | 130 | struct tm *stm; |
131 | if (*s == '!') { /* UTC? */ | 131 | if (*s == '!') { /* UTC? */ |
132 | stm = gmtime(&t); | 132 | stm = gmtime(&t); |