From 3ad03b331de36025a5daed76bc1984cc6288e6b4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 6 Jun 2005 15:42:21 -0300 Subject: [PATCH] optional size for 'setvbuf' --- liolib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/liolib.c b/liolib.c index f80eff99..ed641a26 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.61 2005/05/25 13:21:26 roberto Exp roberto $ +** $Id: liolib.c,v 2.62 2005/06/06 13:30:52 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -442,7 +442,9 @@ static int f_setvbuf (lua_State *L) { static const char *const modenames[] = {"no", "full", "line", NULL}; FILE *f = tofile(L); int op = luaL_checkoption(L, 2, NULL, modenames); - return pushresult(L, setvbuf(f, NULL, mode[op], 0) == 0, NULL); + lua_Integer sz = luaL_optinteger(L, 3, BUFSIZ); + int res = setvbuf(f, NULL, mode[op], sz); + return pushresult(L, res == 0, NULL); }