moonbridge

changeset 153:08cf8e1865e9

Accept max length of zero for read methods
author jbe
date Tue May 19 23:15:22 2015 +0200 (2015-05-19)
parents 2a5bd37034c6
children 831f2d4b2d73 8ab33bfb47e7
files moonbridge_io.c
line diff
     1.1 --- a/moonbridge_io.c	Fri May 15 16:42:50 2015 +0200
     1.2 +++ b/moonbridge_io.c	Tue May 19 23:15:22 2015 +0200
     1.3 @@ -175,7 +175,7 @@
     1.4    char *terminatorpos;
     1.5    ssize_t bytesread;
     1.6    handle = luaL_checkudata(L, 1, MOONBR_IO_HANDLE_MT_REGKEY);
     1.7 -  maxread = luaL_optinteger(L, 2, 0);
     1.8 +  maxread = luaL_optinteger(L, 2, -1);
     1.9    terminatorstr = luaL_optlstring(L, 3, "", &terminatorlen);
    1.10    if (terminatorlen) {
    1.11      luaL_argcheck(L, terminatorlen == 1, 3, "single byte expected");
    1.12 @@ -202,7 +202,7 @@
    1.13      remaining = -1;
    1.14      terminatorpos = NULL;
    1.15      if (
    1.16 -      maxread > 0 &&
    1.17 +      maxread >= 0 &&
    1.18        handle->readbufin - handle->readbufout >= (size_t)maxread - luabufcnt
    1.19      ) {
    1.20        remaining = (size_t)maxread - luabufcnt;

Impressum / About Us