summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-05-01 08:29:11 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-05-01 08:29:11 (GMT)
commita0fbc952a8b199b3bc07bf4dbef4d504a9eae73e (patch)
treef1f1b08d636e42a846a20c89cb041ff56a8bb0a7
parent8ee166780cbfe234c62b815deec072a75c5dc9ad (diff)
downloadtcl-a0fbc952a8b199b3bc07bf4dbef4d504a9eae73e.zip
tcl-a0fbc952a8b199b3bc07bf4dbef4d504a9eae73e.tar.gz
tcl-a0fbc952a8b199b3bc07bf4dbef4d504a9eae73e.tar.bz2
first actual test of doing something with a compression dictionary
-rw-r--r--generic/tclZlib.c16
-rw-r--r--tests/zlib.test15
2 files changed, 25 insertions, 6 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index a1b8afc..1fe5b05 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -2272,11 +2272,7 @@ ZlibPushSubcmd(
}
if (ZlibStackChannelTransform(interp, mode, format, level, chan,
- headerObj, NULL) == NULL) {
- return TCL_ERROR;
- }
- if ((compDictObj != NULL) && (Tcl_SetChannelOption(interp, chan,
- "-dictionary", TclGetString(compDictObj)) != TCL_OK)) {
+ headerObj, compDictObj) == NULL) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp, objv[3]);
@@ -2762,6 +2758,7 @@ ZlibTransformSetOption( /* not used */
if (optionName && (strcmp(optionName, "-dictionary") == 0)
&& (cd->format != TCL_ZLIB_FORMAT_GZIP)) {
Tcl_Obj *compDictObj;
+ int code;
TclNewStringObj(compDictObj, value, strlen(value));
Tcl_IncrRefCount(compDictObj);
@@ -2770,7 +2767,14 @@ ZlibTransformSetOption( /* not used */
TclDecrRefCount(cd->compDictObj);
}
cd->compDictObj = compDictObj;
- // TODO: consider whether to apply immediately
+ if (cd->mode == TCL_ZLIB_STREAM_DEFLATE) {
+ code = SetDeflateDictionary(&cd->outStream, compDictObj);
+ if (code != Z_OK) {
+ ConvertError(interp, code);
+ return TCL_ERROR;
+ }
+ }
+ return TCL_OK;
}
if (haveFlushOpt && optionName && strcmp(optionName, "-flush") == 0) {
diff --git a/tests/zlib.test b/tests/zlib.test
index 017243b..05b5ed5 100644
--- a/tests/zlib.test
+++ b/tests/zlib.test
@@ -188,6 +188,21 @@ test zlib-8.6 {transformation and fconfigure} -setup {
catch {close $fd}
removeFile $file
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -translation lf} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -translation lf -checksum 0} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -translation lf}}
+test zlib-8.7 {transformtion and fconfigure} -setup {
+ lassign [chan pipe] inSide outSide
+ set msg [string repeat "am i all that i am at all? i am all that i am!" 400]
+ set dict "thatallam i "
+} -constraints zlib -body {
+ zlib push compress $outSide -dictionary $dict
+ fconfigure $outSide -blocking 0 -translation binary -buffering none
+ fconfigure $inSide -blocking 0 -translation binary
+ puts -nonewline $outSide $msg
+ chan pop $outSide
+ string length [read $inSide]
+} -cleanup {
+ catch {close $outSide}
+ catch {close $inSide}
+} -result 103
test zlib-9.1 "check fcopy with push" -constraints zlib -setup {
set sfile [makeFile {} testsrc.gz]