diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-06-06 15:42:21 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-06-06 15:42:21 -0300 |
commit | 3ad03b331de36025a5daed76bc1984cc6288e6b4 (patch) | |
tree | 4fc66202a453fb0ec4a2af04492e4ad0bf62e5a0 | |
parent | 86add535d8ee1936c8ff2e9e74e8024377e7b296 (diff) | |
download | lua-3ad03b331de36025a5daed76bc1984cc6288e6b4.tar.gz lua-3ad03b331de36025a5daed76bc1984cc6288e6b4.tar.bz2 lua-3ad03b331de36025a5daed76bc1984cc6288e6b4.zip |
optional size for 'setvbuf'
-rw-r--r-- | liolib.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.61 2005/05/25 13:21:26 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.62 2005/06/06 13:30:52 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 | */ |
@@ -442,7 +442,9 @@ static int f_setvbuf (lua_State *L) { | |||
442 | static const char *const modenames[] = {"no", "full", "line", NULL}; | 442 | static const char *const modenames[] = {"no", "full", "line", NULL}; |
443 | FILE *f = tofile(L); | 443 | FILE *f = tofile(L); |
444 | int op = luaL_checkoption(L, 2, NULL, modenames); | 444 | int op = luaL_checkoption(L, 2, NULL, modenames); |
445 | return pushresult(L, setvbuf(f, NULL, mode[op], 0) == 0, NULL); | 445 | lua_Integer sz = luaL_optinteger(L, 3, BUFSIZ); |
446 | int res = setvbuf(f, NULL, mode[op], sz); | ||
447 | return pushresult(L, res == 0, NULL); | ||
446 | } | 448 | } |
447 | 449 | ||
448 | 450 | ||