Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make the -buffersize option to '$zstream add' function correctly instead of having its value just be discarded unceremoniously. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
41f72bd027238ad602bd2d678d09ff59 |
User & Date: | dkf 2011-08-08 21:41:15 |
Context
2011-08-09
| ||
05:57 | Change the signature of TclParseHex(), such that it can now parse up to 8 hex characters check-in: 0ef52956a9 user: jan.nijtmans tags: trunk | |
2011-08-08
| ||
21:41 | Make the -buffersize option to '$zstream add' function correctly instead of having its value just be... check-in: 41f72bd027 user: dkf tags: trunk | |
18:32 | merge release to trunk check-in: 99580352a4 user: dgp tags: trunk | |
Changes
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2011-08-07 Donal K. Fellows <[email protected]> * generic/tclOOInfo.c (InfoClassCallCmd): [Bug 3387082]: Plug memory leak in call chain introspection. 2011-08-06 Kevin B, Kenny <[email protected]> | > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 2011-08-08 Donal K. Fellows <[email protected]> * generic/tclZlib.c (ZlibStreamCmd): Make the -buffersize option to '$zstream add' function correctly instead of having its value just be discarded unceremoniously. Also generate error codes from more of the code, not just the low-level code but also the Tcl infrastructure. 2011-08-07 Donal K. Fellows <[email protected]> * generic/tclOOInfo.c (InfoClassCallCmd): [Bug 3387082]: Plug memory leak in call chain introspection. 2011-08-06 Kevin B, Kenny <[email protected]> |
︙ | ︙ |
Changes to generic/tclZlib.c.
︙ | ︙ | |||
572 573 574 575 576 577 578 579 580 581 582 583 584 585 | Tcl_DStringAppend(&cmdname, "::tcl::zlib::streamcmd_", -1); Tcl_DStringAppend(&cmdname, Tcl_GetString(Tcl_GetObjResult(interp)), -1); if (Tcl_GetCommandInfo(interp, Tcl_DStringValue(&cmdname), &cmdinfo) == 1) { Tcl_SetResult(interp, "BUG: Stream command name already exists", TCL_STATIC); Tcl_DStringFree(&cmdname); goto error; } Tcl_ResetResult(interp); /* * Create the command. | > | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | Tcl_DStringAppend(&cmdname, "::tcl::zlib::streamcmd_", -1); Tcl_DStringAppend(&cmdname, Tcl_GetString(Tcl_GetObjResult(interp)), -1); if (Tcl_GetCommandInfo(interp, Tcl_DStringValue(&cmdname), &cmdinfo) == 1) { Tcl_SetResult(interp, "BUG: Stream command name already exists", TCL_STATIC); Tcl_SetErrorCode(interp, "TCL", "BUG", "EXISTING_CMD", NULL); Tcl_DStringFree(&cmdname); goto error; } Tcl_ResetResult(interp); /* * Create the command. |
︙ | ︙ | |||
894 895 896 897 898 899 900 901 902 903 904 905 906 907 | int e, size, outSize; Tcl_Obj *obj; if (zshPtr->streamEnd) { if (zshPtr->interp) { Tcl_SetResult(zshPtr->interp, "already past compressed stream end", TCL_STATIC); } return TCL_ERROR; } if (zshPtr->mode == TCL_ZLIB_STREAM_DEFLATE) { zshPtr->stream.next_in = Tcl_GetByteArrayFromObj(data, &size); zshPtr->stream.avail_in = size; | > | 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 | int e, size, outSize; Tcl_Obj *obj; if (zshPtr->streamEnd) { if (zshPtr->interp) { Tcl_SetResult(zshPtr->interp, "already past compressed stream end", TCL_STATIC); Tcl_SetErrorCode(zshPtr->interp, "TCL", "ZIP", "CLOSED", NULL); } return TCL_ERROR; } if (zshPtr->mode == TCL_ZLIB_STREAM_DEFLATE) { zshPtr->stream.next_in = Tcl_GetByteArrayFromObj(data, &size); zshPtr->stream.avail_in = size; |
︙ | ︙ | |||
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | */ if (zshPtr->stream.avail_in > 0) { if (zshPtr->interp) { Tcl_SetResult(zshPtr->interp, "Unexpected zlib internal state during decompression", TCL_STATIC); } Tcl_SetByteArrayLength(data, existing); return TCL_ERROR; } if (zshPtr->currentInput) { Tcl_DecrRefCount(zshPtr->currentInput); | > > | 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 | */ if (zshPtr->stream.avail_in > 0) { if (zshPtr->interp) { Tcl_SetResult(zshPtr->interp, "Unexpected zlib internal state during decompression", TCL_STATIC); Tcl_SetErrorCode(zshPtr->interp, "TCL", "ZIP", "STATE", NULL); } Tcl_SetByteArrayLength(data, existing); return TCL_ERROR; } if (zshPtr->currentInput) { Tcl_DecrRefCount(zshPtr->currentInput); |
︙ | ︙ | |||
1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 | * Sanity checks. */ if (mode == TCL_ZLIB_STREAM_DEFLATE && !(chanMode & TCL_WRITABLE)) { Tcl_AppendResult(interp, "compression may only be applied to writable channels", NULL); return TCL_ERROR; } if (mode == TCL_ZLIB_STREAM_INFLATE && !(chanMode & TCL_READABLE)) { Tcl_AppendResult(interp, "decompression may only be applied to readable channels", NULL); return TCL_ERROR; } /* * Parse options. */ level = Z_DEFAULT_COMPRESSION; for (i=4 ; i<objc ; i++) { if (Tcl_GetIndexFromObj(interp, objv[i], pushOptions, "option", 0, &option) != TCL_OK) { return TCL_ERROR; } switch ((enum pushOptions) option) { case poHeader: if (++i > objc-1) { Tcl_AppendResult(interp, "value missing for -header option", NULL); return TCL_ERROR; } headerObj = objv[i]; if (Tcl_DictObjSize(interp, headerObj, &dummy) != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (in -header option)"); return TCL_ERROR; } break; case poLevel: if (++i > objc-1) { Tcl_AppendResult(interp, "value missing for -level option", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i], (int *) &level) != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (in -level option)"); return TCL_ERROR; } if (level < 0 || level > 9) { extraInfoStr = "\n (in -level option)"; goto badLevel; } break; case poLimit: if (++i > objc-1) { Tcl_AppendResult(interp, "value missing for -limit option", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i], (int *) &limit) != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (in -limit option)"); return TCL_ERROR; } | > > > > > | 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 | * Sanity checks. */ if (mode == TCL_ZLIB_STREAM_DEFLATE && !(chanMode & TCL_WRITABLE)) { Tcl_AppendResult(interp, "compression may only be applied to writable channels", NULL); Tcl_SetErrorCode(interp, "TCL", "ZIP", "UNWRITABLE", NULL); return TCL_ERROR; } if (mode == TCL_ZLIB_STREAM_INFLATE && !(chanMode & TCL_READABLE)) { Tcl_AppendResult(interp, "decompression may only be applied to readable channels", NULL); Tcl_SetErrorCode(interp, "TCL", "ZIP", "UNREADABLE", NULL); return TCL_ERROR; } /* * Parse options. */ level = Z_DEFAULT_COMPRESSION; for (i=4 ; i<objc ; i++) { if (Tcl_GetIndexFromObj(interp, objv[i], pushOptions, "option", 0, &option) != TCL_OK) { return TCL_ERROR; } switch ((enum pushOptions) option) { case poHeader: if (++i > objc-1) { Tcl_AppendResult(interp, "value missing for -header option", NULL); Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL); return TCL_ERROR; } headerObj = objv[i]; if (Tcl_DictObjSize(interp, headerObj, &dummy) != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (in -header option)"); return TCL_ERROR; } break; case poLevel: if (++i > objc-1) { Tcl_AppendResult(interp, "value missing for -level option", NULL); Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i], (int *) &level) != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (in -level option)"); return TCL_ERROR; } if (level < 0 || level > 9) { extraInfoStr = "\n (in -level option)"; goto badLevel; } break; case poLimit: if (++i > objc-1) { Tcl_AppendResult(interp, "value missing for -limit option", NULL); Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i], (int *) &limit) != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (in -limit option)"); return TCL_ERROR; } |
︙ | ︙ | |||
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 | } }; return TCL_ERROR; badLevel: Tcl_AppendResult(interp, "level must be 0 to 9", NULL); if (extraInfoStr) { Tcl_AddErrorInfo(interp, extraInfoStr); } return TCL_ERROR; badBuffer: Tcl_AppendResult(interp, "buffer size must be 32 to 65536", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * ZlibStreamCmd -- | > > | 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 | } }; return TCL_ERROR; badLevel: Tcl_AppendResult(interp, "level must be 0 to 9", NULL); Tcl_SetErrorCode(interp, "TCL", "VALUE", "COMPRESSIONLEVEL", NULL); if (extraInfoStr) { Tcl_AddErrorInfo(interp, extraInfoStr); } return TCL_ERROR; badBuffer: Tcl_AppendResult(interp, "buffer size must be 32 to 65536", NULL); Tcl_SetErrorCode(interp, "TCL", "VALUE", "BUFFERSIZE", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * ZlibStreamCmd -- |
︙ | ︙ | |||
2008 2009 2010 2011 2012 2013 2014 | ZlibStreamCmd( ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Tcl_ZlibStream zstream = cd; | | | 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 | ZlibStreamCmd( ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Tcl_ZlibStream zstream = cd; int command, index, count, code, buffersize = -1, flush = -1, i; Tcl_Obj *obj; static const char *const cmds[] = { "add", "checksum", "close", "eof", "finalize", "flush", "fullflush", "get", "put", "reset", NULL }; enum zlibStreamCommands { |
︙ | ︙ | |||
2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 | } break; case ao_buffer: /* -buffer */ if (i == objc-2) { Tcl_AppendResult(interp, "\"-buffer\" option must be " "followed by integer decompression buffersize", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i+1], &buffersize) != TCL_OK) { return TCL_ERROR; } } if (flush == -2) { Tcl_AppendResult(interp, "\"-flush\", \"-fullflush\" and " "\"-finalize\" options are mutually exclusive", NULL); return TCL_ERROR; } } if (flush == -1) { flush = 0; } | > > > > > > > > > | < | | 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 | } break; case ao_buffer: /* -buffer */ if (i == objc-2) { Tcl_AppendResult(interp, "\"-buffer\" option must be " "followed by integer decompression buffersize", NULL); Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL); return TCL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[i+1], &buffersize) != TCL_OK) { return TCL_ERROR; } if (buffersize < 1 || buffersize > 65536) { Tcl_AppendResult(interp, "buffer size must be 32 to 65536", NULL); Tcl_SetErrorCode(interp, "TCL", "VALUE", "BUFFERSIZE", NULL); return TCL_ERROR; } } if (flush == -2) { Tcl_AppendResult(interp, "\"-flush\", \"-fullflush\" and " "\"-finalize\" options are mutually exclusive", NULL); Tcl_SetErrorCode(interp, "TCL", "ZIP", "EXCLUSIVE", NULL); return TCL_ERROR; } } if (flush == -1) { flush = 0; } if (Tcl_ZlibStreamPut(zstream, objv[objc-1], flush) != TCL_OK) { return TCL_ERROR; } TclNewObj(obj); code = Tcl_ZlibStreamGet(zstream, obj, buffersize); if (code == TCL_OK) { Tcl_SetObjResult(interp, obj); } else { TclDecrRefCount(obj); } return code; |
︙ | ︙ | |||
2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 | Tcl_AppendResult(interp, "\"-buffer\" option not supported here", NULL); return TCL_ERROR; } if (flush == -2) { Tcl_AppendResult(interp, "\"-flush\", \"-fullflush\" and " "\"-finalize\" options are mutually exclusive", NULL); return TCL_ERROR; } } if (flush == -1) { flush = 0; } return Tcl_ZlibStreamPut(zstream, objv[objc-1], flush); | > | 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 | Tcl_AppendResult(interp, "\"-buffer\" option not supported here", NULL); return TCL_ERROR; } if (flush == -2) { Tcl_AppendResult(interp, "\"-flush\", \"-fullflush\" and " "\"-finalize\" options are mutually exclusive", NULL); Tcl_SetErrorCode(interp, "TCL", "ZIP", "EXCLUSIVE", NULL); return TCL_ERROR; } } if (flush == -1) { flush = 0; } return Tcl_ZlibStreamPut(zstream, objv[objc-1], flush); |
︙ | ︙ | |||
2457 2458 2459 2460 2461 2462 2463 | int haveFlushOpt = (cd->mode == TCL_ZLIB_STREAM_DEFLATE); if (haveFlushOpt && optionName && strcmp(optionName, "-flush") == 0) { int flushType; if (value[0] == 'f' && strcmp(value, "full") == 0) { flushType = Z_FULL_FLUSH; | < < | < | | | > | | | > > > > | 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 | int haveFlushOpt = (cd->mode == TCL_ZLIB_STREAM_DEFLATE); if (haveFlushOpt && optionName && strcmp(optionName, "-flush") == 0) { int flushType; if (value[0] == 'f' && strcmp(value, "full") == 0) { flushType = Z_FULL_FLUSH; } else if (value[0] == 's' && strcmp(value, "sync") == 0) { flushType = Z_SYNC_FLUSH; } else { Tcl_AppendResult(interp, "unknown -flush type \"", value, "\": must be full or sync", NULL); Tcl_SetErrorCode(interp, "TCL", "VALUE", "FLUSH", NULL); return TCL_ERROR; } /* * Try to actually do the flush now. */ cd->outStream.avail_in = 0; do { int e; cd->outStream.next_out = (Bytef *) cd->outBuffer; cd->outStream.avail_out = cd->outAllocated; |
︙ | ︙ | |||
2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 | int mode, int format, int level, Tcl_Obj *dictObj, Tcl_ZlibStream *zshandle) { Tcl_SetResult(interp, "unimplemented", TCL_STATIC); return TCL_ERROR; } int Tcl_ZlibStreamClose( Tcl_ZlibStream zshandle) { | > | 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 | int mode, int format, int level, Tcl_Obj *dictObj, Tcl_ZlibStream *zshandle) { Tcl_SetResult(interp, "unimplemented", TCL_STATIC); Tcl_SetErrorCode(interp, "TCL", "UNIMPLEMENTED", NULL); return TCL_ERROR; } int Tcl_ZlibStreamClose( Tcl_ZlibStream zshandle) { |
︙ | ︙ | |||
2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 | Tcl_Interp *interp, int format, Tcl_Obj *data, int level, Tcl_Obj *gzipHeaderDictObj) { Tcl_SetResult(interp, "unimplemented", TCL_STATIC); return TCL_ERROR; } int Tcl_ZlibInflate( Tcl_Interp *interp, int format, Tcl_Obj *data, int bufferSize, Tcl_Obj *gzipHeaderDictObj) { Tcl_SetResult(interp, "unimplemented", TCL_STATIC); return TCL_ERROR; } unsigned int Tcl_ZlibCRC32( unsigned int crc, const char *buf, | > > | 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 | Tcl_Interp *interp, int format, Tcl_Obj *data, int level, Tcl_Obj *gzipHeaderDictObj) { Tcl_SetResult(interp, "unimplemented", TCL_STATIC); Tcl_SetErrorCode(interp, "TCL", "UNIMPLEMENTED", NULL); return TCL_ERROR; } int Tcl_ZlibInflate( Tcl_Interp *interp, int format, Tcl_Obj *data, int bufferSize, Tcl_Obj *gzipHeaderDictObj) { Tcl_SetResult(interp, "unimplemented", TCL_STATIC); Tcl_SetErrorCode(interp, "TCL", "UNIMPLEMENTED", NULL); return TCL_ERROR; } unsigned int Tcl_ZlibCRC32( unsigned int crc, const char *buf, |
︙ | ︙ |