From e8a7ecb982effdfc1148098b288c6ac7130f756e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 25 May 2005 10:21:26 -0300 Subject: luaL_findstring -> luaL_checkoption --- liolib.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'liolib.c') diff --git a/liolib.c b/liolib.c index f78f0245..692dd666 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.59 2005/03/18 18:01:14 roberto Exp roberto $ +** $Id: liolib.c,v 2.60 2005/05/16 21:19:00 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -400,9 +400,8 @@ static int f_seek (lua_State *L) { static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; static const char *const modenames[] = {"set", "cur", "end", NULL}; FILE *f = tofile(L); - int op = luaL_findstring(luaL_optstring(L, 2, "cur"), modenames); + int op = luaL_checkoption(L, 2, "cur", modenames); lua_Integer offset = luaL_optinteger(L, 3, 0); - luaL_argcheck(L, op != -1, 2, "invalid mode"); op = fseek(f, offset, mode[op]); if (op) return pushresult(L, 0, NULL); /* error */ @@ -417,8 +416,7 @@ static int f_setvbuf (lua_State *L) { static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; static const char *const modenames[] = {"no", "full", "line", NULL}; FILE *f = tofile(L); - int op = luaL_findstring(luaL_checkstring(L, 2), modenames); - luaL_argcheck(L, op != -1, 2, "invalid mode"); + int op = luaL_checkoption(L, 2, NULL, modenames); return pushresult(L, setvbuf(f, NULL, mode[op], 0) == 0, NULL); } -- cgit v1.2.3-55-g6feb