From d1f220217beadc102a8d44b8e930a92a9f54b001 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 27 Mar 2002 12:30:41 -0300 Subject: when possible, library functions accept nil as none --- liolib.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'liolib.c') diff --git a/liolib.c b/liolib.c index ab394eb4..0f0be08c 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 1.131 2002/02/08 22:39:56 roberto Exp roberto $ +** $Id: liolib.c,v 1.132 2002/03/20 12:54:08 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -406,7 +406,7 @@ static int io_seek (lua_State *L) { static int io_flush (lua_State *L) { - FILE *f = (lua_isnone(L, 1)) ? (FILE *)(NULL) : + FILE *f = (lua_isnoneornil(L, 1)) ? (FILE *)(NULL) : (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE)); return pushresult(L, fflush(f) == 0); } @@ -541,7 +541,7 @@ static int io_date (lua_State *L) { static int io_time (lua_State *L) { - if (lua_isnone(L, 1)) /* called without args? */ + if (lua_isnoneornil(L, 1)) /* called without args? */ lua_pushnumber(L, time(NULL)); /* return current time */ else { time_t t; @@ -581,8 +581,7 @@ static int io_setloc (lua_State *L) { "numeric", "time", NULL}; const char *l = lua_tostring(L, 1); int op = luaL_findstring(luaL_opt_string(L, 2, "all"), catnames); - luaL_arg_check(L, l || lua_isnil(L, 1) || lua_isnone(L, 1), 1, - "string expected"); + luaL_arg_check(L, l || lua_isnoneornil(L, 1), 1, "string expected"); luaL_arg_check(L, op != -1, 2, "invalid option"); lua_pushstring(L, setlocale(cat[op], l)); return 1; -- cgit v1.2.3-55-g6feb