diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-04-15 10:07:22 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-04-15 10:07:22 (GMT) |
commit | b54406ffc1f268bdb88f9512f500f04e0bc0be2f (patch) | |
tree | 19f183ade4dcf0f11ce15400234c0bf75f9c4a48 | |
parent | 93e3a238d03fe4237ec76d361f83547cf268ab29 (diff) | |
download | tcl-b54406ffc1f268bdb88f9512f500f04e0bc0be2f.zip tcl-b54406ffc1f268bdb88f9512f500f04e0bc0be2f.tar.gz tcl-b54406ffc1f268bdb88f9512f500f04e0bc0be2f.tar.bz2 |
* generic/tclZlib.c (ZlibTransformSetOption): [Bug 3517696]: Make
flushing work correctly in a pushed compressing channel transform.
-rw-r--r-- | ChangeLog | 24 | ||||
-rw-r--r-- | generic/tclZlib.c | 22 | ||||
-rw-r--r-- | tests/zlib.test | 12 |
3 files changed, 39 insertions, 19 deletions
@@ -1,7 +1,12 @@ +2012-04-15 Donal K. Fellows <dkf@users.sf.net> + + * generic/tclZlib.c (ZlibTransformSetOption): [Bug 3517696]: Make + flushing work correctly in a pushed compressing channel transform. + 2012-04-12 Jan Nijtmans <nijtmans@users.sf.net> - * generic/tclInt.decls: [Bug 3514475]: remove TclpGetTimeZone - * generic/tclIntDecls.h: and TclpGetTZName + * generic/tclInt.decls: [Bug 3514475]: Remove TclpGetTimeZone and + * generic/tclIntDecls.h: TclpGetTZName * generic/tclIntPlatDecls.h: * generic/tclStubInit.c: * unix/tclUnixTime.c: @@ -9,20 +14,21 @@ 2012-04-11 Jan Nijtmans <nijtmans@users.sf.net> - * win/tclWinInit.c: [Bug 3448512]: clock scan "1958-01-01" fails only - * win/tcl.m4: in debug compilation. + * win/tclWinInit.c: [Bug 3448512]: clock scan "1958-01-01" fails + * win/tcl.m4: only in debug compilation. * win/configure: * unix/tcl.m4: Use NDEBUG consistantly meaning: no debugging. * unix/configure: * generic/tclBasic.c: - * library/dde/pkgIndex.tcl Use [::tcl::pkgconfig get debug] in stead + * library/dde/pkgIndex.tcl Use [::tcl::pkgconfig get debug] instead * library/reg/pkgIndex.tcl of [info exists ::tcl_platform(debug)] ***POTENTIAL INCOMPATIBILITY*** - The variables $tcl_platform(debug) and $tcl_platform(threaded) no longer - exist. They don't belong in the tcl_platform array, were never documented, - disturbed the platform-1.1 test, $tcl_platform(debug) was only available - on Windows anyway, and TIP #59 provides a much better alternative. + The variables $tcl_platform(debug) and $tcl_platform(threaded) no + longer exist. They don't belong in the tcl_platform array, were never + documented, disturbed the platform-1.1 test, $tcl_platform(debug) was + only available on Windows anyway, and TIP #59 provides a much better + alternative. 2012-04-10 Donal K. Fellows <dkf@users.sf.net> diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 81012dc..341f8e0 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -2495,27 +2495,29 @@ ZlibTransformSetOption( /* not used */ */ cd->outStream.avail_in = 0; - do { + while (1) { int e; cd->outStream.next_out = (Bytef *) cd->outBuffer; cd->outStream.avail_out = cd->outAllocated; e = deflate(&cd->outStream, flushType); - if (e != Z_OK) { + if (e == Z_BUF_ERROR) { + break; + } else if (e != Z_OK) { ConvertError(interp, e); return TCL_ERROR; + } else if (cd->outStream.avail_out == 0) { + break; } - if (cd->outStream.avail_out > 0) { - if (Tcl_WriteRaw(cd->parent, cd->outBuffer, - PTR2INT(cd->outStream.next_out)) < 0) { - Tcl_AppendResult(interp, "problem flushing channel: ", - Tcl_PosixError(interp), NULL); - return TCL_ERROR; - } + if (Tcl_WriteRaw(cd->parent, cd->outBuffer, + cd->outStream.next_out - (Bytef*)cd->outBuffer) < 0) { + Tcl_AppendResult(interp, "problem flushing channel: ", + Tcl_PosixError(interp), NULL); + return TCL_ERROR; } - } while (cd->outStream.avail_out > 0); + } return TCL_OK; } diff --git a/tests/zlib.test b/tests/zlib.test index 236e6b6..3aaca29 100644 --- a/tests/zlib.test +++ b/tests/zlib.test @@ -156,6 +156,18 @@ test zlib-8.3 {zlib transformation and fileevent} -constraints zlib -setup { close $srv removeFile $file } -result 81920-->81920 +test zlib-8.4 {transformation and flushing: Bug 3517696} -setup { + set file [makeFile {} test.z] + set fd [open $file w] +} -constraints zlib -body { + zlib push compress $fd + puts $fd "qwertyuiop" + fconfigure $fd -flush sync + puts $fd "qwertyuiop" +} -cleanup { + catch {close $fd} + removeFile $file +} -result {} test zlib-9.1 "check fcopy with push" -constraints zlib -setup { set sfile [makeFile {} testsrc.gz] |