aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-03-27 12:30:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-03-27 12:30:41 -0300
commitd1f220217beadc102a8d44b8e930a92a9f54b001 (patch)
tree01e599fc7808818ad008599f192b57d32e97c995 /liolib.c
parent405e3a4597d6f935a7ac224ce67dce660e69c7be (diff)
downloadlua-d1f220217beadc102a8d44b8e930a92a9f54b001.tar.gz
lua-d1f220217beadc102a8d44b8e930a92a9f54b001.tar.bz2
lua-d1f220217beadc102a8d44b8e930a92a9f54b001.zip
when possible, library functions accept nil as none
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/liolib.c b/liolib.c
index ab394eb4..0f0be08c 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.131 2002/02/08 22:39:56 roberto Exp roberto $ 2** $Id: liolib.c,v 1.132 2002/03/20 12:54:08 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -406,7 +406,7 @@ static int io_seek (lua_State *L) {
406 406
407 407
408static int io_flush (lua_State *L) { 408static int io_flush (lua_State *L) {
409 FILE *f = (lua_isnone(L, 1)) ? (FILE *)(NULL) : 409 FILE *f = (lua_isnoneornil(L, 1)) ? (FILE *)(NULL) :
410 (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE)); 410 (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE));
411 return pushresult(L, fflush(f) == 0); 411 return pushresult(L, fflush(f) == 0);
412} 412}
@@ -541,7 +541,7 @@ static int io_date (lua_State *L) {
541 541
542 542
543static int io_time (lua_State *L) { 543static int io_time (lua_State *L) {
544 if (lua_isnone(L, 1)) /* called without args? */ 544 if (lua_isnoneornil(L, 1)) /* called without args? */
545 lua_pushnumber(L, time(NULL)); /* return current time */ 545 lua_pushnumber(L, time(NULL)); /* return current time */
546 else { 546 else {
547 time_t t; 547 time_t t;
@@ -581,8 +581,7 @@ static int io_setloc (lua_State *L) {
581 "numeric", "time", NULL}; 581 "numeric", "time", NULL};
582 const char *l = lua_tostring(L, 1); 582 const char *l = lua_tostring(L, 1);
583 int op = luaL_findstring(luaL_opt_string(L, 2, "all"), catnames); 583 int op = luaL_findstring(luaL_opt_string(L, 2, "all"), catnames);
584 luaL_arg_check(L, l || lua_isnil(L, 1) || lua_isnone(L, 1), 1, 584 luaL_arg_check(L, l || lua_isnoneornil(L, 1), 1, "string expected");
585 "string expected");
586 luaL_arg_check(L, op != -1, 2, "invalid option"); 585 luaL_arg_check(L, op != -1, 2, "invalid option");
587 lua_pushstring(L, setlocale(cat[op], l)); 586 lua_pushstring(L, setlocale(cat[op], l));
588 return 1; 587 return 1;