# HG changeset patch # User jbe # Date 1432070122 -7200 # Node ID 08cf8e1865e9e534c64bfa12e84d3eb20b6ce0df # Parent 2a5bd37034c699e17cf027985b31ce0db15472d5 Accept max length of zero for read methods diff -r 2a5bd37034c6 -r 08cf8e1865e9 moonbridge_io.c --- a/moonbridge_io.c Fri May 15 16:42:50 2015 +0200 +++ b/moonbridge_io.c Tue May 19 23:15:22 2015 +0200 @@ -175,7 +175,7 @@ char *terminatorpos; ssize_t bytesread; handle = luaL_checkudata(L, 1, MOONBR_IO_HANDLE_MT_REGKEY); - maxread = luaL_optinteger(L, 2, 0); + maxread = luaL_optinteger(L, 2, -1); terminatorstr = luaL_optlstring(L, 3, "", &terminatorlen); if (terminatorlen) { luaL_argcheck(L, terminatorlen == 1, 3, "single byte expected"); @@ -202,7 +202,7 @@ remaining = -1; terminatorpos = NULL; if ( - maxread > 0 && + maxread >= 0 && handle->readbufin - handle->readbufout >= (size_t)maxread - luabufcnt ) { remaining = (size_t)maxread - luabufcnt;