aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/liolib.c b/liolib.c
index f78f0245..692dd666 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 2.59 2005/03/18 18:01:14 roberto Exp roberto $ 2** $Id: liolib.c,v 2.60 2005/05/16 21:19:00 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*/
@@ -400,9 +400,8 @@ static int f_seek (lua_State *L) {
400 static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; 400 static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
401 static const char *const modenames[] = {"set", "cur", "end", NULL}; 401 static const char *const modenames[] = {"set", "cur", "end", NULL};
402 FILE *f = tofile(L); 402 FILE *f = tofile(L);
403 int op = luaL_findstring(luaL_optstring(L, 2, "cur"), modenames); 403 int op = luaL_checkoption(L, 2, "cur", modenames);
404 lua_Integer offset = luaL_optinteger(L, 3, 0); 404 lua_Integer offset = luaL_optinteger(L, 3, 0);
405 luaL_argcheck(L, op != -1, 2, "invalid mode");
406 op = fseek(f, offset, mode[op]); 405 op = fseek(f, offset, mode[op]);
407 if (op) 406 if (op)
408 return pushresult(L, 0, NULL); /* error */ 407 return pushresult(L, 0, NULL); /* error */
@@ -417,8 +416,7 @@ static int f_setvbuf (lua_State *L) {
417 static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; 416 static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
418 static const char *const modenames[] = {"no", "full", "line", NULL}; 417 static const char *const modenames[] = {"no", "full", "line", NULL};
419 FILE *f = tofile(L); 418 FILE *f = tofile(L);
420 int op = luaL_findstring(luaL_checkstring(L, 2), modenames); 419 int op = luaL_checkoption(L, 2, NULL, modenames);
421 luaL_argcheck(L, op != -1, 2, "invalid mode");
422 return pushresult(L, setvbuf(f, NULL, mode[op], 0) == 0, NULL); 420 return pushresult(L, setvbuf(f, NULL, mode[op], 0) == 0, NULL);
423} 421}
424 422