diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-25 10:21:26 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-25 10:21:26 -0300 |
| commit | e8a7ecb982effdfc1148098b288c6ac7130f756e (patch) | |
| tree | 5229dadc11873122ff55042e1d08f545d25bb839 /liolib.c | |
| parent | 38da9d568a4702a6f9405882db56c2a2aa3189c1 (diff) | |
| download | lua-e8a7ecb982effdfc1148098b288c6ac7130f756e.tar.gz lua-e8a7ecb982effdfc1148098b288c6ac7130f756e.tar.bz2 lua-e8a7ecb982effdfc1148098b288c6ac7130f756e.zip | |
luaL_findstring -> luaL_checkoption
Diffstat (limited to 'liolib.c')
| -rw-r--r-- | liolib.c | 8 |
1 files changed, 3 insertions, 5 deletions
| @@ -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 | ||
