Index: ossp-pkg/sio/sio.c RCS File: /v/ossp/cvs/ossp-pkg/sio/sio.c,v rcsdiff -q -kk '-r1.17' '-r1.18' -u '/v/ossp/cvs/ossp-pkg/sio/sio.c,v' 2>/dev/null --- sio.c 2002/11/29 13:04:15 1.17 +++ sio.c 2002/11/29 15:33:20 1.18 @@ -558,7 +558,8 @@ if (n == 0) { rc = sio_strategy(sio, h); - if (rc != SIO_OK) return SIO_RC(rc); + if (rc != SIO_OK) + return SIO_RC(rc); n = al_bytes(src); if (n == 0) @@ -566,22 +567,24 @@ } - if (label == NULL) { - datastart = 0; - datasize = n; - } else if (al_spanlabel(src, 0, n, label, &datastart, &datasize) != AL_OK) { - datastart = 0; - datasize = 0; - } + while (n > 0) { + if (label == NULL) { + datastart = 0; + datasize = n; + } else if (al_spanlabel(src, 0, n, label, &datastart, &datasize) != AL_OK) + break; + + /* + * clamp to requested size + */ + if (datasize > n) + datasize = n; - /* - * clamp to requested size - */ - if (datasize > n) - datasize = n; + /* XXX - error handling ? */ + (void) al_splice(src, datastart, datasize, NULL, al); - /* XXX - error handling ? */ - (void) al_splice(src, datastart, datasize, NULL, al); + n -= datasize; + } return SIO_OK; } @@ -676,16 +679,22 @@ if (arc != AL_OK) return SIO_RC(SIO_ERR_INT); rc = sio_input(sio, al, n, SIO_LABEL_DATA(sio)); - if (rc == SIO_OK && al_bytes(al) > 0) - al_flatten(al, 0, n, AL_FORWARD, NULL, dst, actualp); - else { - rc = sio_input(sio, al, n, SIO_LABEL_ERROR(sio)); - if (rc == SIO_OK && al_bytes(al) > 0) - sio->error_flag = 1; + if (rc == SIO_OK) { + if (al_bytes(al) > 0) + al_flatten(al, 0, n, AL_FORWARD, NULL, dst, actualp); else { - rc = sio_input(sio, al, n, SIO_LABEL_EOF(sio)); - if (rc == SIO_OK && al_bytes(al) > 0) - sio->eof_flag = 1; + rc = sio_input(sio, al, n, SIO_LABEL_ERROR(sio)); + if (rc == SIO_OK) { + if (al_bytes(al) > 0) + sio->error_flag = 1; + else { + rc = sio_input(sio, al, n, SIO_LABEL_EOF(sio)); + if (rc == SIO_OK) { + if (al_bytes(al) > 0) + sio->eof_flag = 1; + } + } + } } }