aboutsummaryrefslogtreecommitdiff
path: root/loslib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-10-21 11:47:42 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-10-21 11:47:42 -0200
commit053e87314596e48588a929791012def7818ec989 (patch)
treee5ce2b8bdf03da3dbdac087bf62824b49e7d40f0 /loslib.c
parent9f4211310fcea9ebf08f4884f8665520c1b8d85f (diff)
downloadlua-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.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/loslib.c b/loslib.c
index caf75543..d3cd31b8 100644
--- a/loslib.c
+++ b/loslib.c
@@ -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
126static int io_date (lua_State *L) { 126static 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);