diff options
author | dgp <dgp@users.sourceforge.net> | 2014-03-21 19:07:02 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-03-21 19:07:02 (GMT) |
commit | 3f34a93b419605f7c7c193421dbe3cb1d1d81499 (patch) | |
tree | dc32068ad23d73ad28eb2ef17e15a036e1fe379d | |
parent | 72ae8dccf119510f1b175a9a2243a87069cef308 (diff) | |
download | tcl-dgp_eof.zip tcl-dgp_eof.tar.gz tcl-dgp_eof.tar.bz2 |
Correct some faulty assumptions in the zlib transformation input driver.
dgp_eof
BRANCHED - some other EOF matters need checking before this is trunk ready.
-rw-r--r-- | generic/tclZlib.c | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 9bceb4c..787e66d 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -3012,52 +3012,22 @@ ZlibTransformInput( return -1; } else if (readBytes == 0) { /* - * Check wether we hit on EOF in 'parent' or not. If not, - * differentiate between blocking and non-blocking modes. In - * non-blocking mode we ran temporarily out of data. Signal this - * to the caller via EWOULDBLOCK and error return (-1). In the - * other cases we simply return what we got and let the caller - * wait for more. On the other hand, if we got an EOF we have to - * convert and flush all waiting partial data. - */ - - if (!Tcl_Eof(cd->parent)) { - /* - * The state of the seek system is unchanged! - */ - - if ((gotBytes == 0) && (cd->flags & ASYNC)) { - *errorCodePtr = EWOULDBLOCK; - return -1; - } - return gotBytes; - } - - /* - * (Semi-)Eof in parent. - * - * Now this is a bit different. The partial data waiting is - * converted and returned. + * The 'parent' is at EOF. It will not deliver us any more + * bytes. Make one last decompression attempt where we flush + * the streams. */ if (ResultGenerate(cd, 0, Z_SYNC_FLUSH, errorCodePtr) != TCL_OK) { return -1; } - if (Tcl_DStringLength(&cd->decompressed) == 0) { - /* - * The drain delivered nothing. Time to deliver what we've - * got. - */ - - return gotBytes; - } - /* - * Reset eof, force caller to drain result buffer. + * Note that in the case where gotBytes == 0 (nothing in + * the decompressed buffer to begin with) and the flush + * also produce no new output, we are returning 0, which + * signals the EOF to our caller. */ - - ((Channel *) cd->parent)->state->flags &= ~CHANNEL_EOF; + return gotBytes + ResultCopy(cd, buf, toRead); } else /* readBytes > 0 */ { /* * Transform the read chunk, which was not empty. Anything we get |