Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Another step on the road to implementation. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | tip-400-impl |
Files: | files | file ages | folders |
SHA1: |
928447f7d296af45746c28b27b9dac14 |
User & Date: | dkf 2012-03-31 15:16:45 |
Context
2012-04-05
| ||
16:29 | merge trunk check-in: f24817c9e5 user: dkf tags: tip-400-impl | |
2012-03-31
| ||
15:16 | Another step on the road to implementation. check-in: 928447f7d2 user: dkf tags: tip-400-impl | |
14:06 | D'oh! check-in: 9e464ab00d user: dkf tags: tip-400-impl | |
Changes
Changes to generic/tclZlib.c.
︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 70 71 72 73 | int format; /* Flags from the TCL_ZLIB_FORMAT_* */ int level; /* Default 5, 0-9 */ int flush; /* Stores the flush param for deferred the * decompression. */ int wbits; /* The encoded compression mode, so we can * restart the stream if necessary. */ Tcl_Command cmd; /* Token for the associated Tcl command. */ } ZlibStreamHandle; /* * Structure used for stacked channel compression and decompression. */ typedef struct { | > > > | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | int format; /* Flags from the TCL_ZLIB_FORMAT_* */ int level; /* Default 5, 0-9 */ int flush; /* Stores the flush param for deferred the * decompression. */ int wbits; /* The encoded compression mode, so we can * restart the stream if necessary. */ Tcl_Command cmd; /* Token for the associated Tcl command. */ Tcl_Obj *compDictObj; /* Byte-array object containing compression * dictionary (not dictObj!) to use if * necessary. */ } ZlibStreamHandle; /* * Structure used for stacked channel compression and decompression. */ typedef struct { |
︙ | ︙ | |||
205 206 207 208 209 210 211 212 213 214 215 216 217 218 | switch (code) { case Z_STREAM_ERROR: codeStr = "STREAM"; break; case Z_DATA_ERROR: codeStr = "DATA"; break; case Z_MEM_ERROR: codeStr = "MEM"; break; case Z_BUF_ERROR: codeStr = "BUF"; break; case Z_VERSION_ERROR: codeStr = "VERSION"; break; default: codeStr = "unknown"; codeStr2 = codeStrBuf; sprintf(codeStrBuf, "%d", code); break; } Tcl_SetObjResult(interp, Tcl_NewStringObj(zError(code), -1)); | > | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | switch (code) { case Z_STREAM_ERROR: codeStr = "STREAM"; break; case Z_DATA_ERROR: codeStr = "DATA"; break; case Z_MEM_ERROR: codeStr = "MEM"; break; case Z_BUF_ERROR: codeStr = "BUF"; break; case Z_VERSION_ERROR: codeStr = "VERSION"; break; case Z_NEED_DICT: codeStr = "NEED_DICT"; break; default: codeStr = "unknown"; codeStr2 = codeStrBuf; sprintf(codeStrBuf, "%d", code); break; } Tcl_SetObjResult(interp, Tcl_NewStringObj(zError(code), -1)); |
︙ | ︙ | |||
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | zshPtr->interp = interp; zshPtr->mode = mode; zshPtr->format = format; zshPtr->level = level; zshPtr->wbits = wbits; zshPtr->currentInput = NULL; zshPtr->streamEnd = 0; memset(&zshPtr->stream, 0, sizeof(z_stream)); /* * No output buffer available yet */ if (mode == TCL_ZLIB_STREAM_DEFLATE) { e = deflateInit2(&zshPtr->stream, level, Z_DEFLATED, wbits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); } else { e = inflateInit2(&zshPtr->stream, wbits); } if (e != Z_OK) { ConvertError(interp, e); goto error; | > > > > > > > > > | 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | zshPtr->interp = interp; zshPtr->mode = mode; zshPtr->format = format; zshPtr->level = level; zshPtr->wbits = wbits; zshPtr->currentInput = NULL; zshPtr->streamEnd = 0; zshPtr->compDictObj = NULL; memset(&zshPtr->stream, 0, sizeof(z_stream)); /* * No output buffer available yet */ if (mode == TCL_ZLIB_STREAM_DEFLATE) { e = deflateInit2(&zshPtr->stream, level, Z_DEFLATED, wbits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); if (e == Z_OK && zshPtr->compDictObj) { int dictLen; unsigned char *dictBytes = Tcl_GetByteArrayFromObj(zshPtr->compDictObj, &dictLen); e = deflateSetDictionary(&zshPtr->stream, dictBytes, (unsigned) dictLen); } } else { e = inflateInit2(&zshPtr->stream, wbits); } if (e != Z_OK) { ConvertError(interp, e); goto error; |
︙ | ︙ | |||
614 615 616 617 618 619 620 621 622 623 624 625 626 627 | if (zshandlePtr) { *zshandlePtr = (Tcl_ZlibStream) zshPtr; } return TCL_OK; error: ckfree(zshPtr); return TCL_ERROR; } /* *---------------------------------------------------------------------- * | > > > | 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | if (zshandlePtr) { *zshandlePtr = (Tcl_ZlibStream) zshPtr; } return TCL_OK; error: if (zshPtr->compDictObj) { Tcl_DecrRefCount(zshPtr->compDictObj); } ckfree(zshPtr); return TCL_ERROR; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
721 722 723 724 725 726 727 728 729 730 731 732 733 734 | } if (zshPtr->outData) { Tcl_DecrRefCount(zshPtr->outData); } if (zshPtr->currentInput) { Tcl_DecrRefCount(zshPtr->currentInput); } ckfree(zshPtr); } /* *---------------------------------------------------------------------- * | > > > | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | } if (zshPtr->outData) { Tcl_DecrRefCount(zshPtr->outData); } if (zshPtr->currentInput) { Tcl_DecrRefCount(zshPtr->currentInput); } if (zshPtr->compDictObj) { Tcl_DecrRefCount(zshPtr->compDictObj); } ckfree(zshPtr); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
773 774 775 776 777 778 779 780 781 782 783 784 785 786 | /* * No output buffer available yet. */ if (zshPtr->mode == TCL_ZLIB_STREAM_DEFLATE) { e = deflateInit2(&zshPtr->stream, zshPtr->level, Z_DEFLATED, zshPtr->wbits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); } else { e = inflateInit2(&zshPtr->stream, zshPtr->wbits); } if (e != Z_OK) { ConvertError(zshPtr->interp, e); /* TODO:cleanup */ | > > > > > > > > | 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 | /* * No output buffer available yet. */ if (zshPtr->mode == TCL_ZLIB_STREAM_DEFLATE) { e = deflateInit2(&zshPtr->stream, zshPtr->level, Z_DEFLATED, zshPtr->wbits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY); if (e == Z_OK && zshPtr->compDictObj) { int dictLen; unsigned char *dictBytes = Tcl_GetByteArrayFromObj(zshPtr->compDictObj, &dictLen); e = deflateSetDictionary(&zshPtr->stream, dictBytes, (unsigned) dictLen); } } else { e = inflateInit2(&zshPtr->stream, zshPtr->wbits); } if (e != Z_OK) { ConvertError(zshPtr->interp, e); /* TODO:cleanup */ |
︙ | ︙ | |||
1087 1088 1089 1090 1091 1092 1093 | * And remove it from the list */ Tcl_ListObjReplace(NULL, zshPtr->inData, 0, 1, 0, NULL); } } | > | > > > > > > > > > > > > > > | 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 | * And remove it from the list */ Tcl_ListObjReplace(NULL, zshPtr->inData, 0, 1, 0, NULL); } } while (1) { e = inflate(&zshPtr->stream, zshPtr->flush); if (e != Z_NEED_DICT || zshPtr->compDictObj == NULL) { break; } else { int dictLen; unsigned char *dictBytes = Tcl_GetByteArrayFromObj(zshPtr->compDictObj,&dictLen); e = inflateSetDictionary(&zshPtr->stream, dictBytes, (unsigned) dictLen); if (e != Z_OK) { break; } } } Tcl_ListObjLength(NULL, zshPtr->inData, &listLen); while ((zshPtr->stream.avail_out > 0) && (e == Z_OK || e == Z_BUF_ERROR) && (listLen > 0)) { /* * State: We have not satisfied the request yet and there may be * more to inflate. |
︙ | ︙ | |||
1141 1142 1143 1144 1145 1146 1147 | Tcl_ListObjReplace(NULL, zshPtr->inData, 0, 1, 0, NULL); listLen--; /* * And call inflate again. */ | > | > > > > > > > > > > > > > > > | 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 | Tcl_ListObjReplace(NULL, zshPtr->inData, 0, 1, 0, NULL); listLen--; /* * And call inflate again. */ while (1) { e = inflate(&zshPtr->stream, zshPtr->flush); if (e != Z_NEED_DICT || zshPtr->compDictObj == NULL) { break; } else { int dictLen; unsigned char *dictBytes = Tcl_GetByteArrayFromObj(zshPtr->compDictObj, &dictLen); e = inflateSetDictionary(&zshPtr->stream, dictBytes, (unsigned) dictLen); if (e != Z_OK) { break; } } } } if (zshPtr->stream.avail_out > 0) { Tcl_SetByteArrayLength(data, existing + count - zshPtr->stream.avail_out); } if (!(e==Z_OK || e==Z_STREAM_END || e==Z_BUF_ERROR)) { Tcl_SetByteArrayLength(data, existing); |
︙ | ︙ | |||
2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 | Tcl_ZlibAdler32( unsigned int adler, const char *buf, int len) { return 0; } #endif /* HAVE_ZLIB */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ | > > > > > > > | 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 | Tcl_ZlibAdler32( unsigned int adler, const char *buf, int len) { return 0; } void * Tcl_ZlibStreamGetZstreamp( Tcl_ZlibStream zshandle) { return NULL; } #endif /* HAVE_ZLIB */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |