Compare commits

..
Author SHA1 Message Date
apnadkarni d87f07df98 Merge main 2023-08-24 15:37:21 +00:00
griffin 4a4195dde8 Replace test data with something more acceptable. 2023-08-24 01:45:05 +00:00
jan.nijtmans 0290bc2e58 Merge 8.7 2023-08-23 20:18:27 +00:00
bch 264cdba5ac Tcl_Read(), Tcl_ReadChars() return Tcl_Size 2023-08-21 03:00:12 +00:00
apnadkarni bc67254346 Back out [2a01c62b1a55a] - causes tcllib failures. 2023-08-20 13:26:21 +00:00
apnadkarni df59030308 Merge 8.7 - Fix UtfToUtf16Proc 2023-08-18 07:08:55 +00:00
griffin cbaacc8765 Fix bug: Performance regression in 9.0 accessing dicts as lists [f4c01e42a7] 2023-08-17 21:03:54 +00:00
griffin 8b2e668afd Remove ineffective index operation. Shimmering is already optimal. 2023-08-17 17:37:58 +00:00
griffin ac90f7932a Working index operation, but terrible performance. (not surprising) 2023-08-17 17:16:40 +00:00
griffin 90743534a8 Fix llength function for dict types. 2023-08-16 21:36:18 +00:00
griffin c3237c427f merge bug-bc7ddc7944 (revert use of TclDuplicatePureObj) 2023-08-14 15:46:21 +00:00
apnadkarni d8efa035d1 Bug [457523]. Trivial comment edit just to close the bug 2023-08-14 12:55:16 +00:00
griffin 08461f8e8f merge trunk 2023-08-14 05:07:19 +00:00
apnadkarni ed918cb027 Bug [bc076f4f0e]. Fix large indexing broken by commit [0b05b5c750df]. Also preserves Tk bug fix [a9929f112a] 2023-08-14 03:42:58 +00:00
apnadkarni 37289addc2 Fix up tests for modified Tcl_GetIntForIndex semantics 2023-08-13 13:37:23 +00:00
apnadkarni e2d5a2cd60 Merge in fix for end+1 indices. 2023-08-13 11:56:12 +00:00
apnadkarni 5860a89267 Fix for Tk [a9929f112a] 2023-08-13 10:35:29 +00:00
apnadkarni aa0e1c2bd9 Revert [0b05b5c750df] that broke bigdata tests and lseq-1.13 2023-08-13 06:22:28 +00:00
griffin 558680d5e5 merge trunk 2023-08-13 04:29:59 +00:00
griffin baa91f87ba Rename Tcl_BumpObj() to Tcl_BounceRefCount().
After the presentation on Abstract Lists at the 2023 OpenACS/Tcl
Conference, there was a strong opinion that this function should be
renamed. The results of an informal poll had a tie between
Tcl_DoneWithObj() and Tcl_BounceRefCount(). Having seen a reference to
"Bounce" in a research paper on Ref Counting, I chose to use
Tcl_BounceRefCount().
2023-08-12 23:14:43 +00:00
griffin c29c4e023f More replacements of DuplicateObj with ListObjCopy. 2023-08-12 17:56:23 +00:00
griffin 997617cd7d Replace more DuplicateObj with ListObjCopy. 2023-08-12 04:07:57 +00:00
griffin 0a0ba9e309 Replace DuplicateObj with ListObjCopy where appropriate. 2023-08-11 17:55:27 +00:00
dgp 073b0f729a Tcl_DuplicateObj() does not need DECACHE/CACHE protections. 2023-08-11 15:09:31 +00:00
griffin bf8b4d6d18 Revert more bits. 2023-08-10 21:12:05 +00:00
griffin 45a4664dc2 Revert DupolicatePureObj back to DuplicateObj. 2023-08-10 17:48:37 +00:00
dgp 946847b4b9 silence compiler warning 2023-08-10 14:09:55 +00:00
griffin 5b6a975221 Proposed fix for bug-bc7ddc7944 2023-08-10 01:47:42 +00:00
griffin 96b27040f7 Fix uninitialized variable. 2023-08-09 22:55:25 +00:00
griffin 7dc2ed805f Corrections and additions for ObjectType Abstract List descriptions. Part of bug [30e4e9102f] 2023-08-08 22:55:50 +00:00
griffin 0d106bd729 Fix bug [30e4e9102f] - Abstract List ListIndex should return NULL when index out of range. 2023-08-08 17:10:20 +00:00
griffin 4eef7b0ff0 Implement in,ni operator for abstract lists 2023-08-08 15:21:47 +00:00
apnadkarni 59462a578f Bug [f5c01e42a7]. Disable DictAsListIndex for the time being. 2023-08-08 06:02:32 +00:00
dgp 67a433cc8e quiet test noise 2023-08-04 14:06:34 +00:00
dgp b87eac8cd9 Add DECACHE/CACHE_STACK_INFO() protections to calls out of the bytecode
execution engine to avoid panics from corrupted execution stack.
2023-08-03 20:00:01 +00:00
jan.nijtmans 89cc07aa34 Merge 8.7 2023-08-03 13:04:33 +00:00
jan.nijtmans a6714c6778 Merge 8.7 2023-08-02 20:51:52 +00:00
jan.nijtmans e97b71f139 Merge 8.7 2023-08-01 16:12:15 +00:00
jan.nijtmans 66027ff8e6 Merge 8.7 2023-08-01 15:52:03 +00:00
jan.nijtmans 911d6f8e5e Merge 8.7 2023-08-01 13:57:28 +00:00
apnadkarni c94d0732e0 Bug [76d45ec836] - mingw - tommath not copied on install 2023-08-01 13:01:25 +00:00
jan.nijtmans 2618ae962a merge-mark 2023-08-01 06:53:46 +00:00
jan.nijtmans 1625f9f678 Fix [e58d7e19e9]: Upwards compatibility of TclObjTypeHasProc() 2023-07-31 15:58:14 +00:00
jan.nijtmans fddaf810d4 Add (hopefully confincing) testcase for bug [e58d7e19e9] 2023-07-31 15:45:13 +00:00
jan.nijtmans fc19cf036c Merge bug-e58d7e19e9-demo branch: Show that everything works fine here. 2023-07-29 20:35:16 +00:00
jan.nijtmans e7cef5d811 Demo bug [e58d7e19e9] 2023-07-29 18:11:26 +00:00
apnadkarni 848c57d596 Merge 8.7 - Tcl_ListObjIndex tests 2023-07-29 06:46:16 +00:00
apnadkarni ae7471ec7e A bunch of 64 bit fixes (int->Tcl_Size) and the like. 2023-07-28 15:51:02 +00:00
jan.nijtmans 861b69164d Merge 8.7 2023-07-28 08:04:01 +00:00
apnadkarni dc033db224 Merge 8.7 Encoding doc fix 2023-07-28 05:04:44 +00:00
jan.nijtmans d74efff177 Add some implicit "-profile tcl8" to testcases 2023-07-27 16:27:21 +00:00
apnadkarni e253c3eed9 Merge trunk 2023-07-27 16:26:38 +00:00
apnadkarni 35a47e7051 Merge trunk 2023-07-27 15:32:11 +00:00
jan.nijtmans 78c6a505b7 Demonstration how to add TCL_OBJTYPE_V3, while keeping upwards compatibility: all other TCL_OBJTYPE_V? macro's continue to work 2023-07-27 13:19:48 +00:00
jan.nijtmans 503165d9c2 Proposed fix for [e58d7e19e9]: Upwards compatibility of TclObjTypeHasProc() 2023-07-27 13:10:40 +00:00
jan.nijtmans e4971bdffc Proposed fix for [e58d7e19e9]: Upwards compatibility of TclObjTypeHasProc() 2023-07-27 12:57:27 +00:00
jan.nijtmans af64c95042 merge-mark 2023-07-27 07:56:27 +00:00
jan.nijtmans 90034cb557 Merge 8.7 2023-07-27 07:52:44 +00:00
jan.nijtmans df1e155f68 Merge 8.7 2023-07-26 08:06:52 +00:00
jan.nijtmans 4dd445404b Merge 8.7 2023-07-24 15:14:46 +00:00
jan.nijtmans 545fe029f6 Merge 8.7 2023-07-24 13:32:43 +00:00
apnadkarni a3581baf86 Docs - tilde substitution and unsigned int->size_t in Tcl_Alloc 2023-07-24 05:40:38 +00:00
apnadkarni 7e80d62929 Merge trunk 2023-07-22 13:54:46 +00:00
jan.nijtmans 72fef9d4d0 Merge 8.7 2023-07-21 12:00:42 +00:00
jan.nijtmans a22f4cc167 Check for _LARGEFILE64_SOURCE after _FILE_OFFSET_BITS=64, since the latter is prefered 2023-07-21 07:11:25 +00:00
jan.nijtmans d357339eb6 Merge 8.7 2023-07-20 21:01:03 +00:00
jan.nijtmans 041458aca6 Add comment to cmdAH-24.20.[12] 2023-07-20 13:32:47 +00:00
jan.nijtmans 6a7b44b23c .... forgot to re-generate tclConfig.h.in 2023-07-20 13:07:41 +00:00
jan.nijtmans c45f83b3db Fix [d40b9c8503]: Enforcing 64-bit time_t? 2023-07-20 12:45:01 +00:00
jan.nijtmans 72db4a5deb Don't bail out when no 64-bit time is available 2023-07-20 12:41:32 +00:00
jan.nijtmans 73a790977d Rebase to 9.0 2023-07-19 16:00:31 +00:00
jan.nijtmans c510082005 Merge 8.7 2023-07-19 14:49:55 +00:00
apnadkarni 2e4dede387 Merge 8.7 - install tommath.lib 2023-07-17 16:48:17 +00:00
apnadkarni 53f75ee8c8 Merge 8.7 - update for missing TIP 548 function docs 2023-07-17 06:31:17 +00:00
apnadkarni 7791d13f5c Merge 8.7 - Bug [a366c6efee] 2023-07-16 07:23:13 +00:00
griffin 56ca2a64d7 Fix bug [c25d2cd3e6], as well as memory leaks in lsearch and concat.
Add cleanup to some tests.
Fix bug and leak in tclTestABSList.c
Correct comment in tclArithSeries.c
2023-07-16 00:24:54 +00:00
dgp e10b5cb8b9 Same fix in chanio.test 2023-07-14 15:59:12 +00:00
dgp 88dd8c1911 Move channel close commands to -cleanup so that when the (expected) error
occurs in [fcopy] we do not leave open channels lurking to interfere with
later tests.
2023-07-14 15:36:05 +00:00
dgp 20188493af dup test name 2023-07-14 14:18:18 +00:00
jan.nijtmans d08eb4bc7d Merge 8.7 2023-07-14 06:28:38 +00:00
jan.nijtmans 1e54e0ba13 Merge 8.7 2023-07-13 16:23:10 +00:00
pooryorick 0900f426bd Remove incorrect lines that were added to SetDuplicatePureObj().
SetDuplicatePureObj() is specifically not about preserving immutable string
value semantics from the orginal object to the new object.
2023-07-13 12:06:14 +00:00
apnadkarni 5ef0c1ab2d NewStringObj more efficient than NewUnicodeObj 2023-07-13 03:33:34 +00:00
jan.nijtmans 7709859190 Eliminate another compiler-warning, with -DTCL_NO_DEPRECATED=1 2023-07-12 20:02:39 +00:00
jan.nijtmans aeb6cd1eb9 One more unresolved reference (see prev commit) 2023-07-12 19:56:27 +00:00
jan.nijtmans ca2928e660 More fixes related to [c1691dc608]: 32-bit Linux regressions, like ".... undefined reference to `TclGetUnicodeFromObj'" 2023-07-12 19:36:00 +00:00
jan.nijtmans 99e286f193 Merge 8.7 2023-07-12 19:13:25 +00:00
jan.nijtmans 6b299f271e Merge 8.7 2023-07-12 15:12:20 +00:00
jan.nijtmans 6535d19542 Merge 8.7 2023-07-12 14:43:13 +00:00
apnadkarni d26b9d5751 Merge trunk 2023-07-12 08:33:31 +00:00
apnadkarni 03e22c83db Merge mark 2023-07-12 06:42:39 +00:00
griffin 62f180300b Fix foreach bug [a34733451b].
Other code cleanup discovered by code review.
2023-07-12 03:06:54 +00:00
apnadkarni 6c4636e94b Fix [54329e39c7] 2023-07-12 02:51:50 +00:00
apnadkarni 4ee94e4f67 Add test 2023-07-12 02:31:54 +00:00
apnadkarni 5073e2599b Abstract list type for strings 2023-07-11 16:48:14 +00:00
apnadkarni 04328bc720 Tweak last for performance in case of traditional lists. 2023-07-11 16:43:13 +00:00
apnadkarni d852753be2 Wrap DECACHE_STACK_INFO around Tcl_ListObjIndex call from bytecode engine. 2023-07-11 12:59:13 +00:00
apnadkarni f7429e3230 Prevent foreach memory bloat iterating within a proc 2023-07-11 11:35:01 +00:00
jan.nijtmans cd97018033 Merge 8.7 2023-07-11 09:23:33 +00:00
jan.nijtmans 7aa511f93b Merge 8.7 2023-07-10 16:07:08 +00:00
apnadkarni 481f6f184e Create new branch named "apn-string-split" 2023-07-10 11:49:25 +00:00
apnadkarni 7f10145e49 Permit large scripts > INT_MAX. Not complete because compiler source line tracking still limited. 2023-07-09 14:47:22 +00:00
apnadkarni 3edb9b4175 Create new branch named "apn-fix-scripts64" 2023-07-09 13:51:12 +00:00
jan.nijtmans 0f0bd5de07 Unbreak Windows build (broken by [765c9c37a2] due to TIP #628) 2023-07-08 20:36:56 +00:00
jan.nijtmans 35baa585da Merge-mark 2023-07-08 20:28:06 +00:00
griffin 14cb83639f Cleanup abstract list ObjType function definitions. 2023-07-07 21:06:45 +00:00
jan.nijtmans 68d6146f53 Make TIP #636 work together with TIP #628: Shared 8.7/9.0 build environment 2023-07-07 14:57:17 +00:00
jan.nijtmans ad7e9fe625 TIP #636 cleanup: Eliminate the use of Tcl_ObjTypeLength() et al, which look public but are internal and not documented anywhere. 2023-07-07 14:23:37 +00:00
griffin 1858192725 merge TIP #636 (tip-636-tcl9-644) 2023-07-07 02:56:48 +00:00
griffin e7d7e2db67 merge trunk 2023-07-06 21:37:23 +00:00
griffin 024c0aa13a merge trunk 2023-07-06 19:12:14 +00:00
jan.nijtmans 7ef194a7d1 Merge 8.7 2023-07-05 15:10:20 +00:00
apnadkarni 3106ce90c0 Merge 8.7 - Bug [5be203d6ca] - io-7.3 failure 2023-07-05 05:52:58 +00:00
griffin 70ca2e60fd merge trunk 2023-07-04 18:13:54 +00:00
jan.nijtmans 3135d809f5 Merge 8.7 2023-07-04 15:13:50 +00:00
griffin 7e59780763 merge trunk 2023-07-03 17:07:04 +00:00
jan.nijtmans 3d98702f45 Merge 8.7 2023-07-03 14:10:34 +00:00
jan.nijtmans 78c9978aa1 Fix [a5901fc953]: Version control should ignore unix/dltest/embtest 2023-07-03 08:03:03 +00:00
griffin 7968fff465 Add tests for scalar numeric values. 2023-07-03 00:33:16 +00:00
jan.nijtmans 67dfc6e7e3 Merge 8.7 2023-07-02 12:07:35 +00:00
fvogel e668c10036 merge core-8-branch (no change) 2023-07-02 09:26:53 +00:00
fvogel 32bd9fd0d2 We definitely need to build core-8-6-branch of Tcl IMHO. 2023-07-02 08:21:04 +00:00
apnadkarni 6a1f856c63 8.7 merge mark 2023-07-02 04:57:10 +00:00
apnadkarni f368137ec5 8.7 merge mark (lseq tests) 2023-07-02 04:54:33 +00:00
apnadkarni b863e0d57a Tests for [66ffafd309] 2023-07-02 03:03:30 +00:00
apnadkarni 01785b73fb Fix [66ffafd309]. DBCS infinite loop on invalid encoding 2023-07-02 02:41:59 +00:00
apnadkarni cfc103c6b8 Bug [66ffafd309] 2023-07-01 18:02:07 +00:00
griffin 7de69aeb41 merge trunk 2023-06-30 22:16:55 +00:00
griffin 04249bbcd7 Test update for bug [63530267aa]. Fix 32-bit embtest build issue. 2023-06-30 19:02:34 +00:00
griffin eb1f9c9989 merge trunk 2023-06-30 14:34:09 +00:00
jan.nijtmans da8010ca5c Merge 8.7. Remove unused TclArithSeriesObjLength() 2023-06-30 13:40:48 +00:00
jan.nijtmans 801ae4d914 Revert 'fix' for [ac874937c5], committed as part of a "Merge 8.7" commit. It's wrong, since "embtest" is expected to be an executable, not a shared library 2023-06-30 07:40:19 +00:00
griffin cd82527608 merge 8.7 2023-06-29 18:30:13 +00:00
dkf 4b6859f9dc Add timeouts to github workflows to catch runaway scripts 2023-06-29 15:13:57 +00:00
apnadkarni 13b2522d41 Merge 8.7 - Bug [6a3e2cb0f0] - invalid bytes in escape encodings 2023-06-29 11:30:51 +00:00
jan.nijtmans 3a1e74ddc5 Merge-mark 2023-06-29 07:24:20 +00:00
jan.nijtmans 324c39d51c Merge 8.7 2023-06-28 07:27:17 +00:00
jan.nijtmans e30e67e0cd Fix [https://core.tcl-lang.org/tk/tktview/a9929f112a|a9929f112a]: Bugs in the implementation of TIP #577 ('Enhanced index values for Tk') 2023-06-28 07:10:49 +00:00
jan.nijtmans e5d7a4afce Merge 9.0 2023-06-27 15:31:05 +00:00
jan.nijtmans d273c052a5 Fix [24a8c16dbd]: bigdata.test: invalid command name "testbigdata" on 32-bit 2023-06-27 12:57:13 +00:00
pooryorick 53cfe378b3 Fix previous errors in encoding.test 2023-06-27 10:07:19 +00:00
jan.nijtmans 7f18f499d0 Merge 8.7 2023-06-27 06:55:41 +00:00
jan.nijtmans e8d619b292 Merge 8.7 2023-06-26 10:12:17 +00:00
jan.nijtmans 07ea9d3df5 Merge 9.0 2023-06-23 23:18:41 +00:00
griffin bd64729686 merge trunk 2023-06-23 17:48:07 +00:00
griffin 4fdc66665f Fix build issue with no_deprecated. 2023-06-23 17:32:43 +00:00
jan.nijtmans be1a8384ef Merge 8.7 2023-06-22 20:07:18 +00:00
jan.nijtmans b8c47674a4 WIP for fixing [https://core.tcl-lang.org/tk/tktview/a9929f112a|a9929f112a] 2023-06-22 10:12:42 +00:00
jan.nijtmans 9a18abc855 merge-mark 2023-06-21 22:44:08 +00:00
jan.nijtmans eb09d3860d Merge 8.7 2023-06-21 07:18:34 +00:00
griffin 172063cace Fix bug in TEBC foreach with abstractlists 2023-06-20 22:16:54 +00:00
jan.nijtmans e26ccd75b1 Merge 8.7 2023-06-20 07:11:30 +00:00
griffin 2e4b97b87f merge trunk 2023-06-20 01:47:47 +00:00
griffin be39d74ee7 Fix crash in BC execution when str concat and abstract list lindex operations have recursive BC execution.
Add testcase for this bug.
2023-06-20 01:28:25 +00:00
apnadkarni ded49faad5 Merge 8.7 - fix tests - hardcoded port and wsl. 2023-06-19 13:39:31 +00:00
jan.nijtmans 2ebe7012db Merge 8.7 2023-06-19 12:42:00 +00:00
griffin d8ce1ffde8 merge trunk 2023-06-19 04:29:28 +00:00
jan.nijtmans 7f8e25f907 Fix [c13819225e]: Problem with lsort|lsearch -stride on 32-bit linux 2023-06-18 11:04:22 +00:00
griffin 06465624ac Clarification. 2023-06-18 01:51:10 +00:00
jan.nijtmans cf84dd6daf Proposed fix for [c13819225e]: Problem with lsort|lsearch -stride on 32-bit linux. Also fix some compiler warnings 2023-06-16 12:21:21 +00:00
oehhar 954457baf9 tip-636-tcl9-644: doc/Object.3: remove double "the" 2023-06-16 10:49:41 +00:00
griffin f1b8cb6289 Add Tcl_ObjType changes to the appropriate docs. 2023-06-15 20:45:55 +00:00
griffin 2e79331ac0 merge trunk 2023-06-13 16:59:57 +00:00
griffin 7d37ba8e63 Remove getdbl abstraction. 2023-06-13 16:47:25 +00:00
jan.nijtmans 478601a07b Merge 8.7 2023-06-13 09:12:25 +00:00
pooryorick d07e50e54a Revert unwarranted change in Tcl_CreateChannel() from [1776327edd]. 2023-06-12 04:10:52 +00:00
apnadkarni 9cf727affb Tests for invalidly encoded file names and env (TIP 671 motivation) 2023-06-11 02:34:35 +00:00
griffin dde4e1b094 merge trunk 2023-06-06 20:26:59 +00:00
griffin ac52dca2ba Clean up logic to detect failures. 2023-06-06 16:04:41 +00:00
pointsman 5140d2419c Merge 8.7 2023-06-04 22:58:07 +00:00
jan.nijtmans 9ef860c58c Merge 8.7 2023-06-03 20:03:28 +00:00
jan.nijtmans 6b77d746e1 Merge 8.7 2023-06-02 22:12:10 +00:00
jan.nijtmans b37dff78c1 Merge 8.7 2023-06-02 14:02:19 +00:00
jan.nijtmans 103eb015c0 Merge 8.7 2023-06-02 13:59:26 +00:00
jan.nijtmans 3d0413417d Merge 8.7 2023-06-01 21:04:48 +00:00
jan.nijtmans 5d5b5a4242 merge-mark 2023-05-31 14:13:19 +00:00
jan.nijtmans 6104a20928 Merge 8.7 2023-05-31 07:49:17 +00:00
jan.nijtmans 4632c037e3 Merge 8.7 2023-05-31 07:20:18 +00:00
jan.nijtmans 75bdb75689 Merge 8.7 2023-05-30 12:22:20 +00:00
jan.nijtmans af838a5d52 Merge 8.7 2023-05-29 19:41:08 +00:00
fvogel 69ae2a0f03 merge 8.7 2023-05-28 10:39:40 +00:00
griffin d4e8db78c9 Function name cleanup. 2023-05-26 17:15:12 +00:00
griffin 22306f855b merge trunk, fix leak. 2023-05-25 20:55:52 +00:00
jan.nijtmans 0657f97bc5 Eliminate some clang warnings. Only use "testbigdata" if sizeof(Tcl_Size) == sizeof(Tcl_WideInt) 2023-05-25 15:10:55 +00:00
griffin 09bc3f7033 Remove old cruft. 2023-05-25 04:38:32 +00:00
griffin ba261e8e87 merge trunk 2023-05-24 23:17:17 +00:00
griffin c3f8318a3f Cleanup abstract list definitions. 2023-05-24 20:13:20 +00:00
jan.nijtmans 231fd112f9 Merge 8.7 2023-05-24 15:29:11 +00:00
jan.nijtmans 9a6a7030e8 Remove TCL_SIZE_SMAX, not used anywhere. Some more variable which should have been Tcl_Size 2023-05-24 10:31:56 +00:00
griffin e91f967003 Merge trunk 2023-05-23 21:36:46 +00:00
jan.nijtmans 633171eda9 Merge 8.7 2023-05-23 16:15:10 +00:00
jan.nijtmans b9722ec356 Merge 8.7 2023-05-22 10:13:42 +00:00
jan.nijtmans f1e62884ba Merge 8.7 2023-05-21 23:00:20 +00:00
griffin 54a1d7e517 Fix test to be stable. 2023-05-21 20:42:14 +00:00
griffin c6cce703b5 Add cleanup to lseq tests. Fix assertion. 2023-05-20 23:24:54 +00:00
apnadkarni f19e2665d3 Fix [c9663296fd]. Also refactor memory reallocation. 2023-05-20 16:39:50 +00:00
apnadkarni 96d441c29a Minor refactor to combine alloc/realloc 2023-05-20 15:40:17 +00:00
jan.nijtmans 72dfeb60e2 merge-mark 2023-05-20 10:34:14 +00:00
apnadkarni 1b8701ee3d Merge trunk 2023-05-19 23:07:13 +00:00
apnadkarni 83d22bd1f6 Fix int/Tcl_Size pointer errors 2023-05-19 22:18:51 +00:00
apnadkarni 861c6c226a Fix build - ckalloc/ckfree not in Tcl 9 2023-05-19 21:31:18 +00:00
jan.nijtmans b0bd6fc251 Merge 8.7 2023-05-19 19:50:31 +00:00
apnadkarni 16a75f3cbf More refactoring into common code 2023-05-19 16:47:58 +00:00
dkf ee48919fcc Merge 8.7 2023-05-19 12:56:28 +00:00
griffin fa313109d6 Merge trunk 2023-05-17 16:12:25 +00:00
pooryorick 00dd4a5b56 Improve TclDuplicatePureObj(), remove unnecessary increment/decrement pairs, and add more error checking. 2023-05-17 12:44:46 +00:00
pooryorick ac555b905c New functions: TclUndoRefCount() and TclDictGetSize(). 2023-05-17 12:26:11 +00:00
pooryorick 5990382222 Fix for [5ee01098824881b5], lseq list conversion results in attempt to access
freed memory.
2023-05-17 12:09:27 +00:00
jan.nijtmans c7e670b85f Merge 8.7 2023-05-17 07:33:33 +00:00
jan.nijtmans 86e88cf233 Remove dead code 2023-05-17 07:30:54 +00:00
griffin 6781fbdf4b Add Tcl_BumpObj() used to prevent leaks from Abstract List elements.
Add Abstract List (ArithSeries) support in Tcl_ListObjIndex().
Fix obj leaks in lsearch operatations on ArithSeries.
Fix obj leaks in concat operations on ArithSeries.
Add concat and lsearch tests using lseq lists.
2023-05-17 05:09:01 +00:00
pooryorick a038d4aad3 Fix memory leaks and remove unnecessary reference count bounce. 2023-05-16 09:33:12 +00:00
jan.nijtmans 17c92b0a7a Merge 8.7 2023-05-16 06:25:19 +00:00
pooryorick 50dde26caf New function, TclDuplicatePureObj(), doesn't duplicate the string
representation when duplicating an object, unless necessary.  Remove
TclListObjCopy() in favor of TclDuplicatePureObj(), allowing internal
representation to change after the copy rather than before.
2023-05-16 05:25:31 +00:00
apnadkarni 6fa73194d5 Refactor couple more reallocations 2023-05-15 23:08:17 +00:00
pooryorick 49c4458a25 Add Tcl_DecrRefCount() missing from [4b1a20629e]. 2023-05-15 20:49:43 +00:00
apnadkarni 02563b1911 Refactor allocation in Tcl_DStringAppendElement 2023-05-15 20:23:05 +00:00
dgp 54e89ec231 merge 8.7 2023-05-15 17:37:21 +00:00
jan.nijtmans f6f92fd671 Merge 8.7 2023-05-15 11:52:39 +00:00
pooryorick 48d6b3d84c Rename TclRelaxRefCount() to TclUndoRefCount(). 2023-05-14 08:21:50 +00:00
pooryorick aafa141509 Add TclRelaxRefCount, and also try to take the fast path more often in byte-compiled [lindex]. 2023-05-13 10:59:32 +00:00
pooryorick d6ed36f134 In tclExecute.c call DECACHE_STACK_INFO() before calling TclLindexList(). 2023-05-12 23:20:26 +00:00
jan.nijtmans 14d2bc5415 Merge 8.7 2023-05-12 08:57:00 +00:00
pooryorick 4fa1fa29ae Fix failing valgrind suppression for load.test 2023-05-11 17:17:18 +00:00
pooryorick 6fbc88e2a0 Silence valgrind "still reachable" report in cmdAH.test 2023-05-11 17:07:39 +00:00
jan.nijtmans 87ff0e4ee2 put back pragma voor MSVC warning, accidently removed in previous commit 2023-05-11 15:39:30 +00:00
jan.nijtmans 847fdd28f7 Restore warning-free compilation with C++ compiler 2023-05-11 15:30:18 +00:00
pooryorick 01e71bb26c Fix Valgind report of still reachable blocks in aaa_exit.test and other test
files.
2023-05-11 13:08:59 +00:00
jan.nijtmans ce00b07d6b disable on-purpose compiler warning (MSVC) for testcase 2023-05-11 06:31:49 +00:00
apnadkarni 363a6cc4cd Refactor allocation strategy in Tcl_DStringAppend 2023-05-10 21:32:16 +00:00
jan.nijtmans 180af1f9a5 Merge 8.7 2023-05-10 20:53:49 +00:00
apnadkarni 6802927d5c Merge trunk 2023-05-10 17:25:47 +00:00
bch 909827f9ee docs: function does not "return an error", it returns TCL_ERROR, indicating an error occured 2023-05-09 22:36:38 +00:00
jan.nijtmans 293c1ff559 Left-over TCL_ENCODING_STRICT, not used any more.
Add "-profile tcl8" for testcases which don't work in strict profile
2023-05-09 16:11:58 +00:00
griffin 7b647d920a merge trunk 2023-05-09 15:58:53 +00:00
jan.nijtmans e95d2eea7f Merge 8.7 2023-05-09 13:16:25 +00:00
jan.nijtmans 77b454d1b2 size_t -> Tcl_Size (twice) 2023-05-09 09:51:47 +00:00
pooryorick 8d076e6525 Make TclLindexFlat() a litle more straightforward. 2023-05-08 14:08:44 +00:00
pooryorick af5bfc68cc Use Tcl_Size instead of size_t in two places in TclIndexEncode. 2023-05-08 11:35:45 +00:00
jan.nijtmans 1a4e52416f Merge 8.7. Restore Tcl_DStringSetLength() behavior, as suggested in [3837178c25] 2023-05-07 20:34:18 +00:00
jan.nijtmans d162c9a16d Merge 8.7 2023-05-05 21:22:29 +00:00
pooryorick f4cd60dbb4 A few corrections in comments. 2023-05-05 14:57:38 +00:00
apnadkarni d0ba759e2c Merge trunk 2023-05-05 12:36:45 +00:00
apnadkarni 3f84674ae3 Merge 8.7 - list performance tests 2023-05-05 12:35:21 +00:00
pooryorick 3e05a7babe Remove TclArithSeriesObjCopy() and use Tcl_DuplicateObj() instead. 2023-05-05 09:40:38 +00:00
apnadkarni 5940356ced Change reallocation growth to 1.5. 2023-05-05 09:17:17 +00:00
pooryorick cc71607cb8 Make some tests select an encoding profile instead of relying on the default. 2023-05-04 20:26:19 +00:00
dgp 405a099384 merge 8.7 2023-05-04 18:22:37 +00:00
apnadkarni 92dd14e77c Refactor reallocation in preparation for experimentation with different growth factors 2023-05-04 17:52:06 +00:00
jan.nijtmans 3f2bb8a029 Merge 8.7 2023-05-04 13:06:15 +00:00
dkf e2f55284cf Do not build every branch. Too expensive. 2023-05-04 08:24:01 +00:00
apnadkarni 8a45e47c4c Merge trunk 2023-05-04 05:12:11 +00:00
apnadkarni 4dd7110019 Better fallback on list reallocation failure 2023-05-04 04:48:31 +00:00
jan.nijtmans 881b147ab5 Merge 8.7 2023-05-03 15:59:09 +00:00
pointsman d40bb9d13a Removed the bug specific test constraint from the tests related to [0306a5563c] because the bug is fixed. 2023-05-03 15:18:17 +00:00
apnadkarni 688c125ec3 Fix bug-c9663296fd (in progress) 2023-05-03 13:18:05 +00:00
apnadkarni 06cc962945 Comments only. Fix blatantly obsolete ones 2023-05-03 10:01:50 +00:00
pooryorick 88760a8a81 Use Tcl_Size instead of ptrdiff_t in Tcl_ObjCmdProc2(), Tcl_CmdObjTraceProc2, and Tcl_MethodCallProc2(). 2023-05-03 09:31:08 +00:00
apnadkarni aa4247d47b Merge mark 8.7 2023-05-03 04:06:28 +00:00
apnadkarni 81b4fa2fbd Changed CHANNEL_PROFILE_* to ENCODING_PROFILE_* and moved out of tclIO.h. See below.
For whatever reason, these macros were renamed and moved to tclIO.h post-660. This is
inappropriate as those macros deal with *encoding* flags, not *channel* flags and have
relevance outside of I/O making their renaming inappropriate. Further putting them in tclIO.h
forces inclusion of that header in modules that do not otherwise need that header.
2023-05-03 04:03:36 +00:00
griffin 9aac3677ed merge trunk 2023-05-03 02:01:11 +00:00
pointsman 41aa17e389 Fix for [0306a5563c]. 2023-05-02 22:11:28 +00:00
pointsman 84d939b69a Fix for [0306a5563c]. 2023-05-02 21:50:48 +00:00
apnadkarni 60ba166da0 Merge 8.7 fix [784befb0ba] - tailcall crash 2023-05-02 17:06:38 +00:00
apnadkarni 1f5d09b497 Fix LISTREP_ASSERT 2023-05-02 11:50:03 +00:00
apnadkarni eb23b011d0 Merge trunk 2023-05-02 11:28:55 +00:00
apnadkarni 03d0f99e6c Fix [bb69c8d17e] compiled string last 2023-05-02 08:42:21 +00:00
apnadkarni 694c4505cd Change realloc strategy on fail, optimize for empty string 2023-05-02 05:38:04 +00:00
jan.nijtmans 28e5ec7db6 Add missing "deprecated" constraint 2023-05-01 15:50:02 +00:00
apnadkarni b6bc736eee Tests for [dcac54a685] 2023-05-01 12:39:43 +00:00
apnadkarni fe84f70800 Tests for [ad9361fd20] 2023-05-01 12:16:44 +00:00
apnadkarni c77055a803 Fix [d07f42998d] - argument list truncation 2023-05-01 11:41:48 +00:00
apnadkarni 3b426fffa1 Fix [ab123cfd3d] - ubsan warning in ValidateFormat 2023-05-01 10:38:12 +00:00
apnadkarni 782009ca67 Fix [ab123cfd3d] - ubsan scan warning. 2023-05-01 06:51:51 +00:00
apnadkarni e1f2905dbc Added missing bigdata constraint 2023-05-01 06:41:25 +00:00
griffin ca58c3ae9a Partial sync-up with trunk. 2023-04-30 23:09:13 +00:00
jan.nijtmans dd6950d635 Merge 8.7 2023-04-30 19:21:50 +00:00
jan.nijtmans c3cb435cf4 Fix OPTS=utf16 build for Tcl 9.0 2023-04-30 19:03:12 +00:00
jan.nijtmans 75eea66ef7 Add testcase for TclGetBytesFromObj() 2023-04-30 12:32:20 +00:00
jan.nijtmans 251211e714 Don't test compatibility macro's when TCL_NO_DEPRECATED is defined: this is expected to fail 2023-04-30 12:02:38 +00:00
apnadkarni e313582726 Fix [27b3ce2997] - check INT_MAX limit on script length 2023-04-30 10:20:19 +00:00
apnadkarni a06189323f Fix one more error message for max arg limit 2023-04-30 09:54:16 +00:00
apnadkarni 93f06f4469 Working on [d07f42998d] 2023-04-30 08:08:24 +00:00
apnadkarni 6c973cf9a2 Add tests. Panic on bytecode length limit 2023-04-29 16:16:58 +00:00
jan.nijtmans e393e2694c Add experimental testcase for TclGetBytesFromObj() 2023-04-29 16:10:56 +00:00
jan.nijtmans ef51b5aacd Resolve a TODO 2023-04-29 14:56:13 +00:00
jan.nijtmans 905633199c Merge 8.7 2023-04-29 14:50:50 +00:00
pointsman 4d289b8084 Updated from trunk. Simplified bug specific tests. 2023-04-29 14:11:36 +00:00
apnadkarni 85a2a91729 Fix [7cddd2845c] - crash with >= INT_MAX operands 2023-04-29 03:15:11 +00:00
apnadkarni 947e3f8405 Limit scripts to INT_MAX-1 bytes 2023-04-29 02:11:48 +00:00
pooryorick a6d654980e Limit memset() to "TCL_UTF_MAX=3' builds. 2023-04-28 06:43:49 +00:00
pooryorick 2fae9f1746 Add bytearray checking to TclCheckEmptyString(), and then use
TclCheckEmptyString() in Tcl_AppendObjToObj and TclStringCat() to reduce string
generation.
2023-04-27 20:54:21 +00:00
pooryorick 5eb2064b63 Fix for [f5eadcbf9a6b1b4c], passing pointer to uninitialized memory leads
Tcl_UniCharToUtf() to corrupt data.
2023-04-27 20:42:04 +00:00
pooryorick 7f433932f6 memset(0xff) instead of memset(0) to accomodate tests that fill buffer with
0xff.
2023-04-27 20:34:22 +00:00
jan.nijtmans 2e9301202d More size_t -> Tcl_Size, missed by earlier updates 2023-04-27 14:01:37 +00:00
apnadkarni 175931c905 Merge trunk 2023-04-27 13:34:55 +00:00
apnadkarni 18f61eeeeb More checks for exceeding max words 2023-04-27 12:47:08 +00:00
jan.nijtmans 372bf74334 Reduce number of needed type-casts. No change in functionality 2023-04-26 19:29:44 +00:00
griffin f9f1724b36 Fix index descrepencies (bug-fa00fbbbabe).
Fix inconsistent rounding (bug-e5f06285de).
2023-04-26 16:18:04 +00:00
jan.nijtmans cd51753d86 More size_t -> Tcl_Size changes, which were missed before. Also (experimental) make the wrapper macro's produce compiler warnings is Tcl_Size is not used. 2023-04-26 15:53:40 +00:00
apnadkarni f227a5d1ff Test fix for [0f98bce669] 2023-04-26 15:45:12 +00:00
apnadkarni 5ddcd8fea9 Fix for [7cddd2845c] (in progress) 2023-04-26 14:56:21 +00:00
jan.nijtmans fe4e51b427 Merge 8.7 2023-04-26 06:51:52 +00:00
griffin 3aaf8c0544 merge trunk, address some 32-bit issues. 2023-04-26 03:41:57 +00:00
pooryorick 76130df460 Fix for issue [f5eadcbf9a], passing pointer to uninitialized memory leads
Tcl_UniCharToUtf() to corrupt data.
2023-04-25 20:34:03 +00:00
griffin da6df4adde Add fix inconsistent rounding (bug-e5f06285de).
Compute and use the "precision" for sequences of doubles: determine the number of significant digits in the fractional part of the given arguments, and round the results to that limit.
Fix copy bug in DupArithSeriesInternalRep.
2023-04-25 00:36:30 +00:00
pointsman 1ddccee9d3 Added a test for the initial problem and another for the known remaining problem. 2023-04-24 20:21:42 +00:00
pointsman 48570b93a6 Merge trunk. 2023-04-24 20:09:40 +00:00
apnadkarni 025b74f7c7 Fix [2e3fed53ba] - binary encode uuencode 2023-04-24 17:46:14 +00:00
apnadkarni 51043c29db Fix [c719fa8716] - binary encode base64 assertion failure 2023-04-24 17:16:58 +00:00
apnadkarni 553caf0d2c Fix [9369f83649] - binary format/scan for big data 2023-04-24 16:49:34 +00:00
apnadkarni 87e417c1a1 Fix [a814ee5bbd] - string compare/equal -length for long strings 2023-04-24 16:28:21 +00:00
dgp e95eb57666 Adapt signature of TclCompileScript() to fit better after TIP 660. 2023-04-24 15:51:00 +00:00
apnadkarni 3a9a817f67 Fix [d4ede611a7] - scan bigdata 2023-04-24 14:51:20 +00:00
dgp 277effbc04 TIP 422 eliminated va_list arguments from the API of Tcl 9.
However, some of the documentation lingered on.  No more.
2023-04-24 14:22:07 +00:00
apnadkarni 9f102b5b85 Minor change to length limit checks 2023-04-24 13:54:33 +00:00
apnadkarni 642792b1c2 Fix [a550f9710b] (format bigdata) 2023-04-24 12:55:35 +00:00
apnadkarni ef5af05366 Fix for bug [d4ede611a7] (scan) 2023-04-24 10:02:23 +00:00
pointsman 439a4360b3 Fixes the examples given in [0306a5563c]. Still more to do for a full fix. 2023-04-24 09:41:04 +00:00
pooryorick 321bff2cd5 Add bytearray checking to TclCheckEmptyString(), and then use
TclCheckEmptyString() in Tcl_AppendObjToObj and TclStringCat() to reduce string
generation.
2023-04-23 23:57:17 +00:00
jan.nijtmans d252076f75 Missing !defined(TCL_NO_DEPRECATED) around TIP #616 macro's. Thanks Rolf for noticing! 2023-04-23 21:59:34 +00:00
pooryorick eb3390224b Add bytearray checking to TclCheckEmptyString(), and then use
TclCheckEmptyString() in Tcl_AppendObjToObj and TclStringCat() to reduce string
generation.

jn: See discussion on mailing list "On the changing the sourcing of scripts to using strict profiles by default" for explanation why this commit is wrong, just as [e6fe76ae6b] and [4a7b807856] (which are similar commits, disguised as different ones).
2023-04-23 11:28:19 +00:00
jan.nijtmans adab48a862 Support combination TCL_UTF_MAX=3 with TCL_NO_DEPRECATED=1 2023-04-23 10:41:40 +00:00
jan.nijtmans 11048e958a Remove TCL_8_COMPAT. No longer necessesary, because of TIP #660 2023-04-23 10:31:18 +00:00
jan.nijtmans f87dbfe42e Backout [3016169b6f], since TIP #657 (Make "-profile strict" the default in Tcl 9.0) is not accepted yet. And when it's accepted, this change won't be necessary any more. 2023-04-23 08:56:48 +00:00
jan.nijtmans dd36d764b7 Backout [e6fe76ae6b]. See build failure with -DTCL_UTF_MAX=3 [https://github.com/tcltk/tcl/actions/runs/4777092335/jobs/8492557766] 2023-04-23 08:53:23 +00:00
apnadkarni 2b41b2d12b Fix gcc type mismatch warnings exposed by disabling casts using disabletcl8api 2023-04-23 08:13:11 +00:00
apnadkarni 6f566fc406 Merge trunk 2023-04-23 07:24:49 +00:00
apnadkarni 9cd23041f3 Merge 8.7 - [d90fee06d0] (lassign) and [203792a48c] (Utf32ToUtf) 2023-04-23 05:23:01 +00:00
apnadkarni f5125db22b Bug [d4ede611a7] (scan) - in progress 2023-04-23 03:25:33 +00:00
pooryorick 08d2d4c09b Make Tcl_AppendObjToObj avoid string generation in a couple more circumstances,
and edit some documentation and comments.
2023-04-22 22:49:50 +00:00
jan.nijtmans d425f04462 Merge 8.7 2023-04-22 17:34:11 +00:00
jan.nijtmans 39180cad0e Backout [4a7b807856], It breaks the build. See: [https://github.com/tcltk/tcl/actions/runs/4771586851/jobs/8483606969] 2023-04-22 16:29:07 +00:00
jan.nijtmans 79af33ce68 Merge 8.7 2023-04-21 20:39:19 +00:00
pooryorick a3380d8151 Make Tcl_AppendObjToObj more efficient and avoid unnecessarily generating a
string representation when the object to append to is the empty string.
2023-04-21 20:32:38 +00:00
jan.nijtmans e3e6c33969 Add testcases 2023-04-21 20:26:08 +00:00
apnadkarni d39298874a Fix gcc warning about format specifier in error message 2023-04-21 10:07:08 +00:00
pooryorick b794cb03e1 Set the encoding profile to strict in Tcl_FSEvalFileEx(). 2023-04-21 09:19:51 +00:00
apnadkarni c7f27e3c87 Fix warnings generated on disable8api builds 2023-04-21 06:16:53 +00:00
apnadkarni e86259d193 Create new branch named "apn-disabletcl8api-warnings" 2023-04-21 04:56:16 +00:00
griffin 6ca1315df1 merge trunk 2023-04-21 00:35:20 +00:00
griffin b807564e68 sync with trunk. Fix lseq size bugs. 2023-04-20 18:13:36 +00:00
apnadkarni c091b78af6 Bugs [4ce858a049] (lrepeat), [f4d15772f1] (foreach), [6926a21840] (lmap). 2023-04-20 16:44:49 +00:00
dgp e359627a36 TIP 660 changes to stop warnings in --enable-symbols=mem build. 2023-04-19 19:36:40 +00:00
apnadkarni f22a5b57f7 Fix [a4617c8e90] - lsearch index truncation 2023-04-19 15:49:13 +00:00
apnadkarni 883924f1e8 Minor doc corrections 2023-04-19 14:33:40 +00:00
apnadkarni 11b8f6eb00 Fix [3c04fcdd1a] - join truncates large lists 2023-04-19 13:21:56 +00:00
apnadkarni f6830a72ec Merge apn-bigdata-tests 2023-04-19 09:49:01 +00:00
apnadkarni ae3ae231d0 Merge trunk 2023-04-19 09:18:32 +00:00
apnadkarni d4dd40b364 Merge mark with 8.7 TIP 660 manpages 2023-04-19 05:50:25 +00:00
apnadkarni f3d3725e39 Merge mark with 8.7 TIP 660 changes 2023-04-19 05:21:45 +00:00
apnadkarni e90011ea91 TIP 660 accepted. 2023-04-19 03:36:43 +00:00
apnadkarni f42b2cef2a Pick up lreplace.test and lseq.test from tip-660-with-trunk-testcases 2023-04-19 02:32:33 +00:00
apnadkarni ddefa6b172 Merge trunk 2023-04-19 02:00:26 +00:00
pooryorick 9a3cd17eb7 In DoReadChars() reset CHANNEL_ENCODING_ERROR instead of CHANNEL_BLOCKED. 2023-04-18 22:35:58 +00:00
pooryorick df0ddd7b9b Fix for [25cdcb7e8fb381fb]: Incomplete utf-8 sequence followed by eofchar
results in failed assertion.
2023-04-18 22:00:10 +00:00
pooryorick fdaffbc402 Eliminate unnecessary clearance of CHANNEL_STICKY_EOF flag. 2023-04-18 21:16:24 +00:00
jan.nijtmans 5cb63f12bd Almost a merge-mark, just remove one (size_t) cast. 2023-04-18 19:43:37 +00:00
apnadkarni d87bc3c2f0 Merge trunk 2023-04-18 16:47:40 +00:00
jan.nijtmans b30e837f58 Merge 8.7 2023-04-18 15:46:15 +00:00
pooryorick 870ad938f7 Correct CHANNEL_BLOCKED to CHANNEL_ENCODING_ERROR in Tcl_GetsObj(). 2023-04-18 10:47:46 +00:00
apnadkarni c37a94290c Fix io-75.1{4,5} on Windows. Ticket [a7a89d422a] 2023-04-18 05:18:52 +00:00
apnadkarni 60c1da90cc Merge trunk 2023-04-18 02:55:05 +00:00
pooryorick 6f003899fe Make encoding profile explicit in some tests. 2023-04-17 22:01:17 +00:00
jan.nijtmans 75f7e5328a Plug memory leak caused by [46e7091a77b71ed7|this] commit 2023-04-17 20:03:38 +00:00
pooryorick e08e6f2733 Correct some test descriptions in encoding.test. 2023-04-17 12:12:42 +00:00
pooryorick 87df69042c Fix for [eabcbd08274f2d22], [read] error persists on channel with strict
encoding after encoding is changed to binary.
2023-04-16 23:10:16 +00:00
griffin 2aed8b1bdf Fix bug-fa00fbbbabe - seq / lindex discrepancies
Replace macros with static inline functions.
Limit ArithSeries list size to LIST_MAX. This way, shimmering less likely to fail if it happens.
Speed up UpdateStringOfArithSeries.
Fixed issues around indexing into vary large lseq lists.
2023-04-16 18:36:18 +00:00
jan.nijtmans 0ceb73f34c Merge 8.7 2023-04-16 18:08:08 +00:00
apnadkarni e645e12652 Update manpages for TIP 660. Also one size_t -> Tcl_Size change in public API 2023-04-16 17:05:07 +00:00
pooryorick 898f354492 Remove unneeded ENCODING_UTF flags. 2023-04-16 14:16:51 +00:00
pooryorick 4655526dd7 Fix mistake in test io-75.14 and make some spelling corrections. 2023-04-16 12:58:24 +00:00
apnadkarni c899e77701 Merge trunk 2023-04-16 08:01:49 +00:00
apnadkarni ad32d6ed76 Merge trunk 2023-04-16 07:55:08 +00:00
apnadkarni 713ccc8bb6 Fix VC++ unused variable warning, lappend and join. 2023-04-16 05:44:19 +00:00
jan.nijtmans b37682866b Fix indenting 2023-04-15 22:11:48 +00:00
jan.nijtmans 9224a1a6c2 Fix SetResult doc 2023-04-15 19:50:28 +00:00
jan.nijtmans 8248b84e17 Merge 8.7 2023-04-15 19:13:01 +00:00
pooryorick 7962f209ac Extend test io-75.15 to read invalid bytes in binary mode and then use [gets]
to retrieve last two lines.
2023-04-15 13:25:28 +00:00
pooryorick afacee3f07 Fix for [a7a89d422a4f5dd3], Under strict encoding, [gets] returns an error instead of returning the second line.
Also, ensure that position in file does not change if [gets] return an error.
2023-04-15 11:54:27 +00:00
apnadkarni e8326222de Add missing constraint to string-equal/compare test 2023-04-15 02:10:23 +00:00
jan.nijtmans b52ee10fc7 Merge 8.7 2023-04-14 21:42:54 +00:00
apnadkarni aff6cc9141 Fixed bug-a498006438 2023-04-14 15:07:27 +00:00
apnadkarni 0db2f11f15 Merge trunk 2023-04-14 15:01:18 +00:00
pooryorick 810eabe0ef Fix for issue [718de2132f487cf2], "review use of strip on the stubs library". 2023-04-14 11:49:36 +00:00
pooryorick c8259f4fec New test for [gets] with strict encoding. Also add "\" in io-76.9, missing in
last commit.
2023-04-14 09:19:32 +00:00
pooryorick d3bb4906d1 Fix for [0cd1ae596e709259], under strict encoding, [gets] returns an error even
though a complete line is available.
2023-04-14 07:21:48 +00:00
apnadkarni ec63738e5c Merge trunk 2023-04-14 03:24:42 +00:00
apnadkarni dcd5ea5b91 Finish up list tests. Add testbigdata dict command for generating dicts 2023-04-14 03:06:44 +00:00
apnadkarni d8c2bafa2c Few more bigdata tests 2023-04-13 18:05:00 +00:00
jan.nijtmans f7c3a98827 Re-generate unix/configure 2023-04-13 16:58:03 +00:00
pooryorick d5619e30fe Rewrite documentation file SetResult.3 2023-04-13 14:31:49 +00:00
jan.nijtmans 4307d0a739 Follow-up to previous commit: Let's not break TIP #627 either. Also adapt documentation (will be needed to be done anyway) 2023-04-13 14:02:23 +00:00
jan.nijtmans 12b3b1ee00 Allow Tcl build without the Tcl 8 compat API. Derived from "disabletcl8api" branch (thanks, Rolf), but using the already existing -DTCL_NO_DEPRECATED (in Makefile) or CHECKS=nodep (makefile.vc)
Since there are Github Action builds with -DTCL_NO_DEPRECATED/CHECKS=nodep, we cannot use the Tcl 8 compat API in the core code itself any more.
2023-04-13 13:13:13 +00:00
pooryorick e40a0e13a8 Clean up Tcl_SetObjResult(). 2023-04-13 10:20:21 +00:00
pooryorick a1021c091c Remove unnecessary reference count bump in Tcl_ReadObjCmd(). 2023-04-13 09:18:53 +00:00
pooryorick a6754db559 Remove last reference to -nocomplainencoding and fix some spelling errors. 2023-04-13 07:16:20 +00:00
jan.nijtmans c3cfa1176e Merge 8.7 2023-04-13 06:18:24 +00:00
apnadkarni bce26daa76 Fix compilation on macos, test loading on mingw 2023-04-13 02:40:00 +00:00
pooryorick ca227dbb84 Remove one unnecesary call to Tcl_SetErrno() in DoReadChars(). 2023-04-13 00:12:08 +00:00
pooryorick 54ad113891 Correct the documentation of Tcl_SetObjLength. 2023-04-12 20:39:38 +00:00
pooryorick 7d767c4cb9 Remove unnecessary generation of string representation in DoReadChars. 2023-04-12 20:39:00 +00:00
jan.nijtmans f3ea1d46e1 merge-mark 2023-04-12 20:06:23 +00:00
pooryorick 786549398b Rearrange code blocks in DoReadChars to do less work when returning early. 2023-04-12 18:37:24 +00:00
jan.nijtmans ae5de56339 merge-mark 2023-04-12 18:19:37 +00:00
apnadkarni b4542dd058 Test cases for more failures 2023-04-12 17:08:02 +00:00
pooryorick b77f43bb11 Correct spelling errors in comments and documentation, but also a non-comment corrections in history.tcl and tcltest.test. 2023-04-12 14:25:41 +00:00
jan.nijtmans 3d91df2489 More int -> Tcl_Size, so (theoretically) longer lists could be handled. Thanks, Rolf! 2023-04-12 13:51:33 +00:00
jan.nijtmans a0d8d381c1 Merge 8.7 2023-04-12 09:11:21 +00:00
jan.nijtmans 9c0541d0e4 Fix [0b9200888e]: TIP #660 breaks TIP #628/#630 2023-04-12 08:58:03 +00:00
jan.nijtmans bee240eab0 Proposed fix for [0b9200888e]: TIP #660 breaks TIP #628/#630 2023-04-11 22:50:40 +00:00
pointsman 4d067d1cdf Merged disabletcl8api-win in. Which adds optional Tcl 9 API only to the windows build with native tools. And fixed the error with Tcl_GetIndexFromObjStruct(). Simplified the mess in tclDecl a bit. All problems with API calls of the core itself up to now hidden by the Tcl 8 compatibility macros are fixed. Thanks, apnadkarni. 2023-04-11 22:03:23 +00:00
apnadkarni 4acb728d29 Add tests for binary command. Add testlutil command for speeding up list tests. 2023-04-11 16:52:49 +00:00
apnadkarni 7b249ac174 scan, reg*, subst tests 2023-04-10 14:52:44 +00:00
apnadkarni 06e049afdf Fix compiler warnings and crashes. Builds and passes test suite on Windows and Ubuntu for 64-bit 2023-04-10 13:21:02 +00:00
apnadkarni b223689153 Add notcl8api to OPTS to mirror --disable-tcl8api in configure 2023-04-10 13:19:22 +00:00
apnadkarni d90b82d5ce Sloooow progress on testing bigdata 2023-04-09 16:28:02 +00:00
pointsman 7bfc449085 Experimental branch which adds configure option --disable-tcl8api which builds without the Tcl 8 compatibility API. Atm unix only. 2023-04-09 00:09:50 +00:00
apnadkarni f350cdd7cc A few more bigdata tests for strings 2023-04-08 17:19:10 +00:00
apnadkarni 3643909840 Merge 9.0 2023-04-08 08:22:20 +00:00
pointsman 9365f75b61 Editorial fix in Tcl_Panic() message. 2023-04-07 23:14:20 +00:00
pooryorick 4d73d1039b Merge bug-[fa3d9fd818fa0072]. 2023-04-06 12:24:28 +00:00
pooryorick edb446d267 Update the documentation for [chan] with regard to binary data. 2023-04-06 12:10:56 +00:00
pooryorick 20d27150a6 Remove obsolete comments. 2023-04-06 10:28:19 +00:00
pooryorick 1c1cbe4444 Further fix for [fa3d9fd818fa0072]. In ChannelState.encoding, NULL no longer
represents the binary encoding.
2023-04-06 10:03:49 +00:00
pooryorick 3749d89fa6 Merge trunk. 2023-04-06 09:41:35 +00:00
apnadkarni 9deff281ee TIP 602 - update manpages 2023-04-05 17:04:05 +00:00
jan.nijtmans 3d9106c78b Merge 8.7 2023-04-05 16:06:52 +00:00
apnadkarni e49e2ac11d Merge trunk 2023-04-05 15:49:19 +00:00
jan.nijtmans 1c6c9f56e9 Merge 8.7 2023-04-05 15:12:52 +00:00
apnadkarni 0fb466009e Fix tclStubInit gcc warnings with TCL_UTF_MAX=3 2023-04-05 11:44:02 +00:00
apnadkarni a066019d75 Export Tcl_GetSizeFromObj in stubs 2023-04-05 10:45:44 +00:00
apnadkarni 543bde3f26 Merge 9.0 2023-04-05 04:47:52 +00:00
jan.nijtmans 096c6ef84f Fix [6390566ecd]: Testcase cmdAH-4.3.13.00DC0000.tail.utf-32.tcl8.a fails sometimes 2023-04-04 22:47:27 +00:00
jan.nijtmans 2948220674 Accidental rename from TCL_8_COMPAT to TCL_SIGNED_SIZE in previous commit, so undo that 2023-04-04 21:58:38 +00:00
jan.nijtmans e5aed17b9d Merge 8.7 2023-04-04 21:55:41 +00:00
jan.nijtmans ef765324c9 TIP #628 addendum (various fixes to improve handling of 8.7 <-> 9.0 header differences) 2023-04-04 21:49:30 +00:00
apnadkarni eea17e30ab Some very initial tests for large data 2023-04-04 17:16:51 +00:00
apnadkarni 556b19bf28 Start on tests for large data 2023-04-04 17:14:44 +00:00
pooryorick e1420101e1 Fix for [fa3d9fd818fa0072], [fcopy $chan1 $chan2 -size $size] is not [puts
-nonewline $chan2 [read $chan1 -size $size].
2023-04-03 21:20:28 +00:00
pooryorick 5d3ba90d87 Fix for [fa3d9fd818fa0072], [fcopy $chan1 $chan2 -size $size] is not [puts
-nonewline $chan2 [read $chan1 -size $size].
2023-04-03 20:58:46 +00:00
pooryorick 530c3b8f01 Fix typo in test io-53.12.1. 2023-04-03 19:58:42 +00:00
pooryorick 1203f8d384 Fix typo in previous commit. 2023-04-03 19:56:56 +00:00
pooryorick 1215212601 Fix for [9ca87e6286262a62], sync fcopy buffers input in ReadChars(). 2023-04-03 17:13:19 +00:00
pooryorick 3e6eaa5776 Fix for [9ca87e6286262a62], sync fcopy buffers input in ReadChars(). 2023-04-03 17:12:11 +00:00
pooryorick 465fa239eb Failing test for [9ca87e6286262a62f], Sync fcopy buffers input in ReadChars(). 2023-04-03 16:37:27 +00:00
apnadkarni 5e5a852fe0 Bug [7e3f26c748] - TCL_MEM_DEBUG false positive 2023-04-02 13:23:33 +00:00
jan.nijtmans 17d857c579 Merge 8.7 2023-04-01 14:55:36 +00:00
apnadkarni d9bef75f08 Fix gcc warnings from prior 9.0 merge 2023-04-01 11:35:49 +00:00
jan.nijtmans baa549af6a Merge 9.0 2023-04-01 10:27:54 +00:00
jan.nijtmans ce04b407d9 Merge 8.7. Code cleanup in dltest packages 2023-04-01 08:16:03 +00:00
jan.nijtmans b6a444f634 merge-mark 2023-03-31 21:41:58 +00:00
jan.nijtmans efc68f3008 adapt iogt-2.3 expectation 2023-03-31 21:25:26 +00:00
jan.nijtmans 9a89f0e222 merge-mark 2023-03-31 19:25:52 +00:00
jan.nijtmans c5d4ce7c51 Correct other CHANNEL_PROFILE_GET() usage as well, which had the same error. Further on: 1) profile in inputEncodingFlags is always equal to profile in outputEncodingFlags, so we only have to test one of them
2) We copy from inputchannel to outputchannel, so we - really - only have to test inStatePtr->inputEncodingFlags and outStatePtr->outputEncodingFlags. 3) In Tcl 9 we only want to set sameencoding when both channels are in tcl8 mode
2023-03-31 19:14:05 +00:00
pooryorick 90f77cbdf1 Fix TclCopyChannel() incorrect use of CHANNEL_PROFILE_GET(). 2023-03-31 18:56:33 +00:00
jan.nijtmans 3eb5ddf1da Merge 8.7 2023-03-31 11:16:20 +00:00
apnadkarni a30f4dce67 Fix macos Tcl_MacOSXOpenVersionedBundleResources to use Tcl_Size 2023-03-31 11:09:05 +00:00
jan.nijtmans feac96c8b3 Merge 8.7 2023-03-30 22:22:32 +00:00
apnadkarni 5a1359a5e8 TIP 660. No compiler warnings. Tests suite pass on Win and Ubuntu 2023-03-30 18:01:48 +00:00
apnadkarni edb3e7b8d2 Create new branch named "tip-660" 2023-03-30 17:55:39 +00:00
max 67ced52076 Merge 8.7: Allow empty mode list in [chan create]. 2023-03-30 09:23:44 +00:00
dgp 5b6755494d test hygiene. Match [removeFile] arguments to [makeFile] to fix debug alerts. 2023-03-29 15:06:48 +00:00
jan.nijtmans 7d527f91fd Merge 8.7. Some size_t -> Tcl_Size in internal header files 2023-03-29 08:54:52 +00:00
pooryorick 24d6b91453 Replace bit twiddling with clear expression. 2023-03-29 06:16:03 +00:00
pooryorick ef52a3851a Remove the last occurrences of TCL_ENCODING_NOCOMPLAIN. 2023-03-28 19:30:58 +00:00
pooryorick 9576a35d02 Combine two branches in write(). 2023-03-28 19:29:21 +00:00
jan.nijtmans 4d14a84353 Minor fix in winConsole.test 2023-03-28 16:03:42 +00:00
jan.nijtmans 7854b03fa2 Fix iocmd-12.11 testcase 2023-03-28 15:50:31 +00:00
jan.nijtmans 2445b5d59b Merge 8.7 2023-03-28 07:15:41 +00:00
apnadkarni 9d87e5b616 Merge 8.7. POSIX errors update and minizip fix 2023-03-28 05:13:26 +00:00
pooryorick 0899e9d020 Remove unneeded parts from test in fileName.test. 2023-03-27 20:08:21 +00:00
jan.nijtmans f3e40e67d4 Merge 8.7 2023-03-27 14:44:28 +00:00
pooryorick 5ffb8a5035 Make the documentation of [encoding] more concise and readable. 2023-03-27 12:16:36 +00:00
jan.nijtmans d531e7af51 Merge 8.7 2023-03-27 11:43:02 +00:00
pooryorick b026d900d3 Avoid msvc "illegal indirection" error. 2023-03-27 11:13:17 +00:00
pooryorick cc28ac83dd Mark: Valgrind reports no leaks. 2023-03-26 20:04:26 +00:00
pooryorick 7a84646588 Fix memory leak in Tcl_JoinObjCmd(). 2023-03-26 19:14:36 +00:00
jan.nijtmans 83740bf7d7 Merge 8.7 2023-03-26 17:22:02 +00:00
jan.nijtmans 84a0e08557 Patch from chrstphrchvz, fixing [d40b9c8503]. Many thanks! 2023-03-26 15:51:21 +00:00
pooryorick 1df48c6782 Fix for [6d4e9d1af5bf5b7d]: Memory leak: SetFsPathFromAny, assisted by the
global literal table, causes a Tcl_Obj to reference itself.
2023-03-26 15:35:10 +00:00
griffin 879e7b7112 Merge trunk 2023-03-25 00:29:59 +00:00
jan.nijtmans fc30e5e704 Merge 8.7 2023-03-24 21:09:33 +00:00
jan.nijtmans f49e4099fe Merge 8.7 2023-03-24 20:58:04 +00:00
dgp de08e1a143 duplicate test name 2023-03-24 16:49:17 +00:00
jan.nijtmans b0a23df7d6 Merge "unchained" branch, since all it does is add a little valgrind stuff to Makefile.in.
Hopefully this will stop Nathan's useless single-commit merges (his way there would be 32 more merges left to go)
2023-03-23 16:02:33 +00:00
jan.nijtmans ae9ebe2176 Merge 8.7 2023-03-23 15:55:22 +00:00
Konrad Schwarz 3985945f96 Merge-mark 2023-03-23 07:28:41 +00:00
pooryorick a51afb0e46 Merge trunk 4dca8eb033: Make "tcltest" package use "-profile tcl8" internally,
irrespective of what the default profile is.
2023-03-22 21:39:54 +00:00
pooryorick da0251a1f4 Merge trunk b10e2b66a9: Manpage fixes. 2023-03-22 21:38:41 +00:00
pooryorick 4576880f96 Merge trunk 9aa2b65a57: TIP 656 manpages. 2023-03-22 21:37:45 +00:00
pooryorick 10423ea0ca Merge trunk 49a4c8f8fb: TIP 656 implementation. 2023-03-22 21:36:46 +00:00
pooryorick 25a166a77a Merge trunk 31788d9a4b: arm64e -> arm64, since arm64e is not available yet on
MacOS (Thanks to Stefan Sobernig).
2023-03-22 21:24:16 +00:00
pooryorick 99a897fb41 Merge trunk 5ecd70c8ce: Unbreak build, and minor cleanup. 2023-03-22 21:21:46 +00:00
pooryorick 40a90d5fce Merge trunk 43584b2ac9: If TCL_UTF_MAX=4, don't set 'exact' to 1. 2023-03-22 21:19:31 +00:00
jan.nijtmans e66310792a Merge 9.0 2023-03-22 21:15:16 +00:00
pooryorick 9837f0e993 Merge trunk 9e266d00f2: Empty 2023-03-22 21:14:38 +00:00
pooryorick 3f624f6af0 Merge core-8-branch 7f5879e9cb: Fix (minor) warning on 32-bit platforms. 2023-03-22 21:13:13 +00:00
pooryorick 9d432523a6 Merge core-8-branch 3082cb9e80: Make valgrind_foreach target in Makefile.in
properly handle interrupted tests.
2023-03-22 20:26:05 +00:00
pooryorick 7f3849495a Merge core-8-branch 7fde86610c: New script used in the "valgrind_each" target
in Makefile.in.
2023-03-22 20:15:47 +00:00
jan.nijtmans d984134999 Merge 9.0 2023-03-22 20:13:09 +00:00
jan.nijtmans f4a64c89a2 Forgot one line in previous commit, and indenting 2023-03-22 19:30:02 +00:00
jan.nijtmans 6fec8f2b6c Let's get in the 'readability' changes from the 'unchained' branch, without the need for all those partial merges. 2023-03-22 18:13:29 +00:00
jan.nijtmans 1451fc7537 Merge 8.7 2023-03-22 18:00:15 +00:00
pooryorick 178c9d17be Merge trunk 6ef2153f20: Minor cleanup (Thanks, Gustaf!). 2023-03-22 17:54:26 +00:00
pooryorick a4b2c694ce Merge trunk c1e45151b3: Remove _LARGEFILE_SOURCE64 usage. See [d690400d07]. 2023-03-22 17:53:28 +00:00
pooryorick ff8b3d5c27 Merge trunk d04c1efe83: Merge in constraint spelling fix. Keep it in case the knownBug constraint is ever removed. 2023-03-22 17:51:31 +00:00
pooryorick 511ae7efcb Merge trunk a76dee9eb4: Further fix for issue [ea69b0258a9833cb], crash when
using a channel transformation on TCP client socket.
2023-03-22 17:24:22 +00:00
pooryorick 5aedb72b9c Merge trunk a19e2f0c0b: ckfree -> Tcl_Free 2023-03-22 17:17:47 +00:00
pooryorick 364b4e65bf Merge trunk 30ba320f81: Since "unicode" is deprecated, use "utf-16" in
testcases. Otherwise -DTCL_NO_DEPRECATED build fails.
2023-03-22 17:16:42 +00:00
pooryorick e038969b66 Merge trunk 62058cafe0: Fix for issue [ea69b0258a9833cb], crash when using a
channel transformation on TCP client socket.
2023-03-22 17:15:26 +00:00
pooryorick 46d59bb7db Merge trunk 5c6fa768fe: Merge 8.6: Bug [183a1adcc0]. Buffer overflow in
Tcl_UtfToExternal.
2023-03-22 17:13:41 +00:00
pooryorick 30cce986ca Merge trunk 9db02d187b: 2 more testcases, proving utf-32 handling of surrogates
(actually: not handling!) is OK.
2023-03-22 17:11:37 +00:00
pooryorick 4fdc61a1f6 Merge trunk 6fb14ee3e: Minor bug-fix for utf-32: Only throw exception for
codepoints > +U10FFFF if "-strict" is specified. Otherwise replace with 0xFFF.
2023-03-22 17:10:54 +00:00
pooryorick 120806ee03 Merge trunk 286d6e9ab0: Fix [db7a085bd9]: encoding convertfrom -strict utf-16
accepts partial surrogates.
2023-03-22 17:09:51 +00:00
pooryorick bc309ba006 Merge trunk 8e467866ef: Forgot that \x00 is not printable anyway. 2023-03-22 17:08:35 +00:00
pooryorick 629aea4b6a Merge trunk 1bf875b575: Always output 2 hex characters in "unexpected byte sequence" exception message.
make testcases io-38.3/chan-io-38.3 independant from system encoding.
Bump version of tcltest to 2.5.6
2023-03-22 17:07:18 +00:00
pooryorick 5df2af1808 Merge trunk a0abb8bdc5: Make test less fragile to changing set of options. 2023-03-22 17:02:17 +00:00
pooryorick f8a7412ae3 Merge trunk bb76745df2: Fix cmdAH-4.3.13.00D80000.solo.utf-32le.tcl8.a testcase
from tip-656-tcl9 branch, when TCL_UTF_MAX=3.
2023-03-22 17:01:25 +00:00
pooryorick eaad662c18 Merge trunk 64c58db9fc: Adapt 2 testcases (io-39.16/io-39.16a), showing that
"-encoding" can be shortened to "-en", but not to "-e" (because there is
-eofchar too).
2023-03-22 16:58:45 +00:00
pooryorick ccf567f6a8 Merge trunk a52ac1d5fa: winFCmd-1.24 differs in error code on Win 11. 2023-03-22 16:57:08 +00:00
pooryorick 796370fa55 Merge trunk 13b04d4d60: Add "notWsl" test constraints. Clean up many testcases. 2023-03-22 16:56:08 +00:00
pooryorick 96b80a42ae Merge trunk 837dbec7cc: More -Wconversion warning fixes. 2023-03-22 16:55:24 +00:00
pooryorick 479247a5f0 Merge trunk 82bf22dad8: Add "teststringobj newunicode". Not used in testcases yet. 2023-03-22 16:53:56 +00:00
pooryorick e882c87033 Merge trunk 1997f71246: Fix [b4af93cd9f]: uninitialized bytes in http11-1.13.0. 2023-03-22 16:51:17 +00:00
pooryorick 2239eb3a90 Merge trunk fe9c231f48: Fix a few -Wconversion warnings. 2023-03-22 16:50:06 +00:00
pooryorick ce1b091802 Merge trunk 24072d92fc: testchmod fix. 2023-03-22 16:48:11 +00:00
pooryorick ce9c1b59e5 Merge trunk 04077c7b2e: Fix [95e287b956]: uninit value use in stringObj-4.2. 2023-03-22 14:11:19 +00:00
pooryorick d462ed2dd9 Merge trunk 2c4994d39e: ckfree() -> Tcl_Free(). 2023-03-22 14:09:11 +00:00
pooryorick 2a7d240b80 Merge trunk 37fc768d3: Tcl_WinTCharToUtf() is deprecated, so use Tcl_WCharToUtfDString() instead. 2023-03-22 14:08:41 +00:00
pooryorick ec7356be4c Merge trunk 9e195dccd7: Add new valgrind suppression items. 2023-03-22 14:07:38 +00:00
pooryorick 631b9cae2e Merge trunk 6b8ecafc24: A better fix for Valgrind "still reachable" report in TestcmdtokenCmd(). 2023-03-22 14:07:00 +00:00
pooryorick 88caedc3ce Merge trunk 1ad5d08ee8: Another round of -1 -> TCL_INDEX_NONE. 2023-03-22 13:59:58 +00:00
pooryorick dc7946e162 Merge trunk 7a2fc29ce0: More -1 -> TCL_INDEX_NONE. 2023-03-22 13:57:13 +00:00
pooryorick e21761aab7 Merge trunk adb38c336f: Make dltest/pkg*.c simple example how to use Tcl_Size
with Tcl_GetStringFromObj().
2023-03-22 13:55:33 +00:00
pooryorick a19bc41c3a Merge trunk aceb89781d: Protect zlib errors with check for null interp. 2023-03-22 13:54:50 +00:00
pooryorick a78ce452f2 Merge trunk: Test constraint notInCIenv no longer necessary (due to previous
fix).
2023-03-22 13:53:41 +00:00
pooryorick 438dbba007 Merge trunk: Fix [1b8df10110]: Tcl_GetTime returns wrong usec value on Windows. 2023-03-22 13:52:53 +00:00
pooryorick 6c33026c8c Merge trunk 91247f5ef8: Adapt type-casts to Tcl 9.0 signature of
Tcl_Free/Tcl_Realloc/Tcl_AttemptRealloc.
2023-03-22 13:51:45 +00:00
pooryorick 0fc4d3ef81 Merge trunk c1e87a7fe5: ckfree() shouldn't be used in Tcl 9 core code any more. 2023-03-22 13:50:49 +00:00
pooryorick bb933cb954 Merge trunk: Fix Valgrind "still reachable" report in TestcmdtokenCmd(). 2023-03-22 13:50:02 +00:00
pooryorick b523637e3b Merge trunk: Fix bug [9a978f8323], large reads > 2GB. 2023-03-22 13:48:45 +00:00
pooryorick ae0f696f21 Merge trunk: Disable more file permissions tests for WSL (not supported in
WSL/NTFS).
2023-03-22 13:46:42 +00:00
pooryorick e1e66d9209 Disable file permission tests under WSL as WSL does not support Unix file attrs
without special config.
2023-03-22 13:45:16 +00:00
pooryorick 84ad8e1eae Fix msvc build (with OPTS=symbols) 2023-03-22 13:44:15 +00:00
pooryorick 8602bafbb8 Merge trunk: Fix [f8ef6b3670] crash. TclpSysAlloc macro was truncating size
request to 32 bits on Windows.
2023-03-22 13:33:18 +00:00
pooryorick b12a433518 Merge trunk: Put back testcase io-52.20, and re-fix [4a7397e0b3]. 2023-03-22 13:31:32 +00:00
pooryorick 8f8776b56b Merge trunk: Add missing ')'. 2023-03-22 13:30:32 +00:00
pooryorick 12fbbf9df9 Merge trunk: Restore previous behavior for non-blocking mode, as for this mode
the semantics of [read]/[gets] were not broken. This was the 'some agreement'.
The change in line 8286 is necessary for both blocking and non-blocking mode:
Whenver the encoding change we need to reset the CHANNEL_ENCODING_ERROR flag.
2023-03-22 13:22:17 +00:00
pooryorick 7a69ce0ac4 Reverted [d156af9fb76dd2f4] and removed tests io-52.20 io-75.6 io-75.7, as this
commit, intended to fix issue [b8f575aa2398b0e4], breaks the semantics of
[read] and [gets]. Such a change would require an accepted TIP. See
[b8f575aa2398b0e4] for further discussion.
2023-03-22 13:16:33 +00:00
pooryorick 7b07b1df54 Merge 8.7. And fix Tcl_UtfToExternal()/Tcl_ExternalToUtf() (at least - suffucient for tclZlib.c), such that it now returns an error when src and dst *both* exceed INT_MAX. To be discussed further. 2023-03-22 13:14:39 +00:00
pooryorick a182a5bf20 Merge bug-fb368527ae. Bug [fb368527ae] Large string truncation 2023-03-22 13:13:13 +00:00
pooryorick 097fff3b0d Merge trunk: Make the descriptions in doc/Tcl.n more concise and intuitive. 2023-03-22 13:10:21 +00:00
pooryorick 574c6392d0 Merge trunk: Fix formatting issue in Tcl.n 2023-03-22 13:09:34 +00:00
pooryorick b14bccc65d Merge trunk: In case of combining TIP #494 (TCL_8_COMPAT) and #628 (building for Tcl 8.7
with 9.0 headers), ignore TCL_8_COMPAT macro. More Tcl_Size usage.
2023-03-22 13:07:50 +00:00
pooryorick ac8cf85039 Merge trunk: Fix [3d01d51bc4]: Tcl 9: Cannot write large strings to file. Also
some size_t -> Tcl_Size changes.
2023-03-22 13:06:58 +00:00
pooryorick 85461b74b3 Merge trunk: Fix [46dda6fc29] - trace crash caused by TclScanElement 2023-03-22 13:05:49 +00:00
pooryorick 30e195d456 Merge trunk: Fix [1d074b177a]. Failure to read .tclshrc 2023-03-22 13:04:46 +00:00
pooryorick a23d9c4dac Merge trunk: int -> Tcl_Size in tclEncoding.c 2023-03-22 13:03:21 +00:00
pooryorick 965d3fae6a Merge trunk: Fix [4bea02e811]: encoding convertfrom -strict ascii \x7f
generates exception Many other encodings had the same problem, and also the
reverse happened: encodings which should throw an exception with -strict but
didn't (within range 0x80-0x9F).
2023-03-22 13:01:17 +00:00
pooryorick 8088657ecc Merge trunk: Fix [d19fe0a5b]: Handling incomplete byte sequences for
utf-16/utf-32.
2023-03-22 12:35:24 +00:00
pooryorick b2f6161a18 Merge trunk: -strict for ucs-2. 2023-03-22 12:28:43 +00:00
pooryorick c258128087 Merge trunk: Fix for [885c86a9a0]: convertfrom utf8 breaks for 4 byte utf encodings. 2023-03-22 12:26:41 +00:00
pooryorick 1a13ddd24b Merge trunk: Final part of [10c2c17c32]: UTF-LE32 encoder mapping of
surrogates. Problem was in testcase, not in actual code.
2023-03-22 12:25:33 +00:00
pooryorick aeafdad0a9 Merge trunk 6ca5a8a9cd: encoding convertfrom -failindex, -strict for cesu-8. 2023-03-22 12:24:39 +00:00
pooryorick ae0658c370 Merge trunk e90924bb13: Test-case only. 2023-03-22 12:20:42 +00:00
pooryorick 3c37f824cc Merge trunk de933019a1: Fix for [bd1a60eb9c]: convertfrom utf-8 strict mode
allows surrogates in input sequence.
2023-03-22 12:19:26 +00:00
pooryorick cb4d5ce631 Merge trunk a155df4adc: (new) testcase encoding-16.15 as "knownBug": still needs a fix. 2023-03-22 12:12:14 +00:00
pooryorick 167878d3af Merge Trunk 2d036d968c: Proposed fix (and testcases) for [4a7397e0b3]: Tcl 9: fcopy with -strictencoding 1 UTF-8 channels 2023-03-22 12:02:44 +00:00
jan.nijtmans 32860a2742 Merge 8.7 2023-03-22 12:02:09 +00:00
jan.nijtmans c9bc915417 Merge 8.7 2023-03-22 10:02:28 +00:00
pooryorick 79bc1e0416 Merge trunk e851055acb: Fix documentation on "encoding" command. 2023-03-22 09:50:03 +00:00
jan.nijtmans 1e95b894cf merge-mark 2023-03-22 08:34:09 +00:00
pooryorick e0d5199463 Merge trunk c093f8b044: Renumber testscase. 2023-03-22 06:43:19 +00:00
apnadkarni e7c416995e Fix longIs64Bit->has64BitLengths else test will not run on 64-bit Wind 2023-03-22 02:39:10 +00:00
pooryorick ac8ac73e77 Remove unneeded Tcl_IncrRefCount and TclDecrRefCount. TclPtrSetVarIdx takes
ownership of newValuePtr if its refCount is 0, and either stores or frees it.
2023-03-21 23:55:12 +00:00
jan.nijtmans 4f5ae9bf24 Merge 8.7 2023-03-21 16:54:19 +00:00
jan.nijtmans afdd59e358 Merge 8.7 2023-03-21 08:45:56 +00:00
jan.nijtmans 6ff9d841db Missing backslashes in macro def 2023-03-21 08:40:08 +00:00
jan.nijtmans 28add0c150 More TclNewIndexObj() usages (for values between -1 and SIZE_MAX-1) 2023-03-20 21:06:09 +00:00
jan.nijtmans 8b0dc386ba Merge 8.7 2023-03-20 14:19:35 +00:00
jan.nijtmans cc2747afa8 Add longIs64bit constraint to lseq-4.4 (because this isn't expected to work on 32-bit platforms). Remove some unused constraints. 2023-03-20 12:08:58 +00:00
jan.nijtmans d103b73dba Fix [5ae5ffc3f4]: Problem with -failindex on 32-bit platform 2023-03-20 11:42:19 +00:00
jan.nijtmans 2475fa8cb8 Merge 8.7 2023-03-20 11:31:14 +00:00
apnadkarni 921b0dfdea Merge 8.7 - Fix http11 test hang 2023-03-20 02:38:36 +00:00
jan.nijtmans 1876fe215d Another fix: don't access (w) twice 2023-03-19 13:34:04 +00:00
jan.nijtmans 78c295898e Doesn't look like a mem-leak: It appears that Tcl_ObjSetVar2() already handles that. 2023-03-19 13:32:46 +00:00
jan.nijtmans 449998d358 Proposed fix for [5ae5ffc3f4]: Problem with -failindex on 32-bit platform. This also fixes a memory-leak. 2023-03-19 13:23:03 +00:00
jan.nijtmans 203f1d691d Merge 8.7 2023-03-19 11:58:07 +00:00
jan.nijtmans 8e6d7429e9 Merge 8.7 2023-03-19 11:45:22 +00:00
jan.nijtmans d5ac687adb Merge 8.7 2023-03-18 09:08:35 +00:00
jan.nijtmans cb121886a4 Merge 8.7 2023-03-18 08:52:25 +00:00
jan.nijtmans 036b676c8b Merge 8.7 2023-03-18 08:45:55 +00:00
apnadkarni 43218725b3 Merge 8.7 - TIP 656 manpages 2023-03-18 04:28:49 +00:00
apnadkarni 64c45c10a9 Merge mark post-656 2023-03-18 03:37:24 +00:00
apnadkarni 1a75f270bd TIP 656 accepted 2023-03-18 03:35:02 +00:00
apnadkarni b90a2e051c Merge trunk 2023-03-18 02:59:14 +00:00
jan.nijtmans 4ce715f36a Merge 8.7 2023-03-17 20:11:26 +00:00
jan.nijtmans 2d75729976 Merge 8.7 2023-03-17 16:15:16 +00:00
pooryorick 72deb9db89 Merge-Mark. 2023-03-17 08:13:44 +00:00
jan.nijtmans d81f257f99 Merge 8.7 2023-03-16 20:16:08 +00:00
apnadkarni aa14feed8b Missed two tests. Blast it :-( 2023-03-16 18:15:46 +00:00
apnadkarni e7fc2e1e1d Merge 9.0 2023-03-16 18:11:08 +00:00
apnadkarni 527e79c3a8 Fix passing of encoding state in testencoding Tcl_UtfToExternal 2023-03-16 17:54:12 +00:00
jan.nijtmans 88f9f54d4c Merge 8.7 2023-03-16 15:38:40 +00:00
jan.nijtmans 1eefaec471 Minor cleanup (Thanks, Gustaf!) 2023-03-16 11:38:20 +00:00
jan.nijtmans 93ce80a916 unicode -> utf-16. Remove some unneeded encodingProfileTodo constraints 2023-03-16 10:00:26 +00:00
apnadkarni 4d978a00ed Change -encodingprofile to -profile 2023-03-16 03:48:45 +00:00
jan.nijtmans 6f4eba042c Merge 8.7 2023-03-15 16:24:16 +00:00
dgp a0be72dbca merge 8.7 2023-03-15 13:41:05 +00:00
pooryorick f378b48b06 Further fix for issue [ea69b0258a9833cb], crash when using a channel transformation on TCP client socket. 2023-03-15 11:37:13 +00:00
jan.nijtmans ea9a0277a2 ckfree -> Tcl_Free 2023-03-15 09:11:22 +00:00
apnadkarni c5d0535121 Merge 9.0. Also fix replace profile handling of orphan surrogates 2023-03-14 17:23:47 +00:00
jan.nijtmans 76526242c0 Merge 8.7 2023-03-14 10:33:43 +00:00
pooryorick 4c26d23f06 Fix for issue [ea69b0258a9833cb], crash when using a channel transformation
on TCP client socket.
2023-03-13 20:57:59 +00:00
apnadkarni 5c3377f2e1 Merge 8.7: Bug [183a1adcc0]. Buffer overflow in Tcl_UtfToExternal 2023-03-13 15:59:11 +00:00
apnadkarni 844792f3bb Cherrypick yip-656. Start on Tcl_ExternalToUtf/Tcl_UtfToExternal tests 2023-03-12 17:10:51 +00:00
jan.nijtmans ab2c6de1ed merge-mark 2023-03-12 16:38:13 +00:00
jan.nijtmans aee8588fbc 2 more testcases, proving utf-32 handling of surrogates (actually: not handling!) is OK 2023-03-12 16:23:33 +00:00
jan.nijtmans eeee744ee2 Minor bug-fix for utf-32: Only throw exception for codepoints > +U10FFFF if "-strict" is specified. Otherwise replace with 0xFFFD 2023-03-12 16:10:52 +00:00
jan.nijtmans 63b29d841b Merge 8.7 2023-03-12 12:59:28 +00:00
jan.nijtmans 9fb3d5754a Merge 9.0. Also ckalloc -> Tcl_Alloc and ckfree -> Tcl_Free 2023-03-12 12:00:49 +00:00
jan.nijtmans a16eb9ac30 Merge 8.7 2023-03-12 11:34:03 +00:00
jan.nijtmans ed8932a4eb Merge 8.7 2023-03-12 11:28:00 +00:00
apnadkarni 5533596329 Add testencoding Tcl_ExternalToUtf/Tcl_UtfToExternal for raw testing of corresponding C functions 2023-03-11 16:47:42 +00:00
apnadkarni 93160df498 Merged 9.0. Note knownProfileBug constraint which mark questionable tests to be resolved later. 2023-03-10 15:29:36 +00:00
apnadkarni e9b9864f56 Fix parsing of fconfigure set -encoding* options 2023-03-10 07:37:55 +00:00
jan.nijtmans 23becaa71a Merge 9.0 2023-03-08 20:37:56 +00:00
jan.nijtmans ebfa9b6f2d ckalloc -> Tcl_Alloc and ckfree -> Tcl_Free 2023-03-08 09:36:14 +00:00
jan.nijtmans 73229a7e53 Merge 9.0 2023-03-07 20:13:24 +00:00
apnadkarni f4618fc2d9 Merge 9.0 - disable file perms tests on wsl 2023-03-02 08:00:48 +00:00
apnadkarni ad8dae7587 Bug [e778e3f804]. Fix error message for invalid profile name. 2023-03-02 06:29:10 +00:00
apnadkarni 806babb932 Add encoding test vector files 2023-03-02 04:48:00 +00:00
apnadkarni f736321295 Cherrypick [13537afd1b] - eliminate TCL_ENCODING_MODIFIED 2023-03-02 04:35:44 +00:00
apnadkarni a0beeb8a76 Fix Tcl_UtfToExternalDStringEx call in macos code 2023-03-01 15:39:06 +00:00
apnadkarni 0f06bb38e8 Merge 9.0. TclpSysalloc fix. 2023-03-01 08:01:51 +00:00
apnadkarni 9522e37880 Merge 9.0 2023-03-01 07:19:07 +00:00
apnadkarni 00e1068c03 Cherrypick [070225e33d]. Move setting of profile flags to lower level functions in case they are called directly 2023-02-28 17:16:25 +00:00
apnadkarni 4207c3d5c3 Tests pass modulo couple of differences in Tcl 8 and 9 default behavior to be discussed (tickets logged) 2023-02-25 06:13:21 +00:00
apnadkarni f0f2ee57f9 Compiles and runs. Tests still to be ported. 2023-02-25 03:03:46 +00:00
apnadkarni 50cafc9f13 Create new branch named "tip-656-tcl9" 2023-02-24 13:37:45 +00:00
pooryorick f365be7f4d Merge trunk. 2023-02-01 00:34:50 +00:00
pooryorick 0219b700b1 Update code comments for Tcl_UniCharToUtf(). 2023-01-30 19:37:35 +00:00
pooryorick a70ce8697c Make Tcl_UniCharToUtf() more readable. 2023-01-30 19:14:05 +00:00
pooryorick 7a5be2cdbd A branch of Tcl that does not look backwards. 2023-01-30 19:11:18 +00:00
jan.nijtmans ef7bbf24e8 code cleanup (reduce diff with trunk) 2022-12-24 09:11:56 +00:00
jan.nijtmans 4531aa608d Merge 9.0 2022-12-22 16:17:57 +00:00
griffin bc3ff73062 Make as much abstract list implementation as possible internal.
Other code cleanup also.
2022-12-21 06:59:38 +00:00
jan.nijtmans a3f8bc6993 Merge 9.0. Now really make dist tests working (again) on Windows/gcc 2022-12-20 10:58:06 +00:00
jan.nijtmans bc7cadbfec Merge 9.0. Make dist tests working (again) on Windows/gcc 2022-12-20 07:24:42 +00:00
jan.nijtmans ab239a3b1f Merge 9.0 2022-12-18 21:38:14 +00:00
jan.nijtmans 7157c6b878 Reserve a place in abstractlist for an additional function 2022-12-18 10:05:40 +00:00
jan.nijtmans 0cdcbf3481 Merge 9.0 2022-12-18 09:10:25 +00:00
jan.nijtmans 9006753369 Merge 9.0. Fix testcases 2022-12-08 14:24:20 +00:00
griffin 6b52bc1a64 Add 'getdouble' function to ObjType, used for abstractlist types. -- Experimental 2022-12-07 23:56:10 +00:00
jan.nijtmans 3836fc2905 Code cleanup (undo some unnecessary changed compared to trunk) 2022-12-01 15:57:20 +00:00
jan.nijtmans 01f2b842e8 Merge 9.0. Fix Windows build (testcases need tcl::test package). Modify TCL_OBJTYPE_V1() macro, so it checks for the number of arguments 2022-12-01 15:16:37 +00:00
griffin b22a59093e Fix bug with slice (range) operation 2022-12-01 02:10:32 +00:00
jan.nijtmans f101fd4d8b Merge 9.0. Rename TclObjTypeHasProc to ABSTRACTLIST_PROC 2022-11-30 22:05:52 +00:00
jan.nijtmans bacd42baab Merge 9.0 2022-11-30 11:13:47 +00:00
jan.nijtmans 4a8099f371 Merge 9.0 (but without the "llength" optimization) 2022-11-30 10:46:57 +00:00
jan.nijtmans 5f45d1454b Merge 9.0 2022-11-29 10:38:49 +00:00
jan.nijtmans b1ee845c02 Merge 9.0 2022-11-29 09:53:43 +00:00
jan.nijtmans 64383b33bd Simplify TclObjTypeHasProc() (a lot!) 2022-11-28 21:45:49 +00:00
jan.nijtmans 2aa92d31a0 Merge 9.0 2022-11-28 16:13:34 +00:00
jan.nijtmans feee6ec002 Merge 9.0 2022-11-25 10:14:57 +00:00
jan.nijtmans b22f30259b TCL_OBJTYPE_V0_INIT -> TCL_OBJTYPE_V0 (See TIP #644). Remove Tcl_SavedResult (See TIP #640) 2022-11-24 21:48:42 +00:00
griffin 85ff1f33c9 Sync with trunk 2022-11-24 20:31:05 +00:00
griffin a4e76a1c02 Sync with trunk 2022-11-24 03:32:46 +00:00
griffin 7b6d022905 Support multiple indicies in abstract list lindex operation.
Catch up with trunk.
2022-11-24 01:18:36 +00:00
griffin 4335a4f475 Remove unused/incomplete functions. Some cleanup. 2022-11-08 22:02:33 +00:00
griffin 3e26e1b26d Sync with trunk 2022-11-06 05:20:26 +00:00
griffin 93374294e8 Sync with trunk 2022-11-05 23:35:46 +00:00
griffin 44a73b3640 Implement abstractlist with tip-644 2022-11-04 22:47:23 +00:00
griffin 853e484a64 TIP 636 for Tcl 9 2022-11-02 22:33:01 +00:00
griffin e2e526bea8 Swap which ObjTyp ptr is used for concrete Rep to match other types. 2022-11-02 16:45:47 +00:00
griffin c5bb0bc339 Sync with core-8-branch 2022-11-01 03:18:39 +00:00
griffin 028b789aec Add missing GetType call to export decls. Change SetElement to support multiple indicies. Improve abstract list test coverage. 2022-10-31 21:50:46 +00:00
griffin bb6cdd342a Sync with core-8-branch 2022-10-28 18:53:27 +00:00
griffin a89453a9e9 Expand AbstractList regression testing. 2022-10-28 06:13:11 +00:00
griffin 119e80fb28 Sync with core-8-branch 2022-10-25 02:30:28 +00:00
griffin 6d3452eeac Add AbstractList regression test (exercise the C API) 2022-10-25 01:13:45 +00:00
griffin e38c5076fe Sync with core-8-branch 2022-10-22 21:13:54 +00:00
griffin 6f1b4d55a4 Add Replace (lreplace) function to AbstractList type, and corrisponding Tcl_AbstractListObjReplace() API. 2022-10-22 00:07:40 +00:00
griffin 8b7cf2c7eb Sync with core-8-branch 2022-10-19 22:29:46 +00:00
griffin 0bc040dc40 More work on lset support in AbstractLists 2022-10-19 04:35:15 +00:00
griffin fb722eca56 Add SetElement function to abstract lists. Fix a few bugs. 2022-10-18 01:03:19 +00:00
griffin 699ec9db36 Sync with core-8-branch 2022-10-14 22:35:01 +00:00
griffin f72344d643 Update AbstractList man page. 2022-10-14 22:06:42 +00:00
griffin 999de87fbf Sync with core-8-branch 2022-10-12 21:16:12 +00:00
griffin 48ae5e307e Modify AbstractList functions to include interp for error reporting. Other various improvements. 2022-10-11 03:49:20 +00:00
apnadkarni 80303ffb39 Generalize UpdateStringOfAbstractList 2022-10-09 06:21:43 +00:00
griffin 7468d97286 Code cleanup and reorganize 2022-10-08 22:31:32 +00:00
griffin d24ee59fb5 TIP #636 starting imiplementation. 2022-10-08 04:28:55 +00:00
griffin f2fd360d01 Sync with core-8-branch 2022-10-08 02:39:41 +00:00
griffin af613a176f Sync with core-8-branch 2022-10-07 19:14:18 +00:00
griffin 9ed6390f05 Remove redundant file references in makefiles 2022-09-30 18:33:34 +00:00
griffin 259828fa5f Sync with core-8-branch 2022-09-29 13:45:46 +00:00
jan.nijtmans a60681c2f3 Mrge 8.7. Make it work with C++, adapt win/Makefile.in to make it build on Windows with gcc 2022-09-08 14:53:35 +00:00
jan.nijtmans b9b527183a Merge 8.7 2022-09-07 13:26:09 +00:00
griffin 446587dc91 Missed change for Windows. 2022-08-28 00:45:40 +00:00
griffin 31c68fa4e7 Move all ArithSeries code to it's own file. Sync other changes wil TIP-629. 2022-08-28 00:10:13 +00:00
griffin f9e3b4dd74 Reimplement AbstrctList type structure to simplify. fix various bugs. 2022-08-19 18:08:39 +00:00
griffin 8bf1d3fbf1 Fix memory leak. 2022-08-15 15:23:24 +00:00
griffin 298667e221 Fix UpdateString to handle general case. Fix bug with elements list. 2022-08-11 16:21:39 +00:00
griffin 129d7aee61 Fix memory leak with Tcl_AbstractListObjGetElements. 2022-08-10 17:28:09 +00:00
griffin 92f5f9afc6 Make AbstractListRepPtr part of the public API as Tcl_AbstractListRepPtr.
Fix bug with ArithSeries Reverse function.
2022-08-10 04:21:16 +00:00
apnadkarni f3b81a9854 Fix Windows Visual C++ build 2022-08-09 16:07:24 +00:00
griffin 7561d600a6 Add version number to AbstractList implementation. Make sure lsort and lreplace do not shimer their input argument. 2022-08-08 23:52:43 +00:00
griffin 7030b2b274 Abstract Lists (TIP-225) initial implementation. 2022-08-08 19:38:19 +00:00
565 changed files with 28644 additions and 32849 deletions
+1 -2
View File
@@ -1,5 +1,4 @@
compat/zlib/contrib/dotzlib/readme.txt
compat/zlib/contrib/dotzlib/*.cs
compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
compat/zlib/contrib/vstudio/readme.txt
compat/zlib/contrib/vstudio/*/zlib.rc
compat/zlib/contrib/vstudio/*/zlibvc.def
+2
View File
@@ -48,9 +48,11 @@ libtommath/*.tex
macosx/configure
unix/autoMkindex.tcl
unix/dltest.marker
unix/dltest/embtest
unix/dltest/*.bundle
unix/dltest/*.dll
unix/dltest/*.dylib
unix/dltest/*.exe
unix/dltest/*.o
unix/dltest/*.sl
unix/dltest/*.so
-1
View File
@@ -22,7 +22,6 @@
# Declare files that will always have CRLF line endings on checkout.
*.bat eol=crlf
*.cs eol=crlf
*.sln eol=crlf
*.vc eol=crlf
+6
View File
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
+10 -2
View File
@@ -16,19 +16,20 @@ jobs:
matrix:
cfgopt:
- ""
- "CFLAGS=-DTCL_UTF_MAX=3"
- "CFLAGS=-DTCL_NO_DEPRECATED=1"
- "--disable-shared"
- "--enable-symbols"
- "--enable-symbols=mem"
- "--enable-symbols=all"
- "CFLAGS=-ftrapv"
defaults:
run:
shell: bash
working-directory: unix
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
timeout-minutes: 5
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
@@ -39,23 +40,30 @@ jobs:
./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
env:
CFGOPT: ${{ matrix.cfgopt }}
timeout-minutes: 5
- name: Build
run: |
make all
timeout-minutes: 5
- name: Build Test Harness
run: |
make tcltest
timeout-minutes: 5
- name: Run Tests
run: |
make test
env:
ERROR_ON_FAILURES: 1
timeout-minutes: 30
- name: Test-Drive Installation
run: |
make install
timeout-minutes: 5
- name: Create Distribution Package
run: |
make dist
timeout-minutes: 5
- name: Convert Documentation to HTML
run: |
make html-tcl
timeout-minutes: 5
+9 -2
View File
@@ -18,7 +18,8 @@ jobs:
working-directory: macosx
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
timeout-minutes: 5
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
@@ -27,11 +28,13 @@ jobs:
run: make all
env:
CFLAGS: -arch x86_64 -arch arm64
timeout-minutes: 15
- name: Run Tests
run: make test styles=develop
env:
ERROR_ON_FAILURES: 1
MAC_CI: 1
timeout-minutes: 15
clang:
runs-on: macos-11
strategy:
@@ -48,7 +51,8 @@ jobs:
working-directory: unix
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
timeout-minutes: 5
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
@@ -60,14 +64,17 @@ jobs:
env:
CFLAGS: -arch x86_64 -arch arm64
CFGOPT: ${{ matrix.cfgopt }}
timeout-minutes: 5
- name: Build
run: |
make all tcltest
env:
CFLAGS: -arch x86_64 -arch arm64
timeout-minutes: 15
- name: Run Tests
run: |
make test
env:
ERROR_ON_FAILURES: 1
MAC_CI: 1
timeout-minutes: 15
+7 -4
View File
@@ -15,9 +15,10 @@ jobs:
defaults:
run:
shell: bash
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Prepare
run: |
touch generic/tclStubInit.c generic/tclOOStubInit.c
@@ -50,11 +51,12 @@ jobs:
defaults:
run:
shell: bash
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Checkout create-dmg
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: create-dmg/create-dmg
ref: v1.0.8
@@ -112,6 +114,7 @@ jobs:
defaults:
run:
shell: msys2 {0}
timeout-minutes: 10
env:
CC: gcc
CFGOPT: --disable-symbols --disable-shared
@@ -122,7 +125,7 @@ jobs:
msystem: UCRT64
install: git mingw-w64-ucrt-x86_64-toolchain make zip
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Prepare
run: |
touch generic/tclStubInit.c generic/tclOOStubInit.c
+15 -2
View File
@@ -22,6 +22,7 @@ jobs:
matrix:
cfgopt:
- ""
- "OPTS=utf16"
- "CHECKS=nodep"
- "OPTS=static"
- "OPTS=symbols"
@@ -29,27 +30,32 @@ jobs:
# Using powershell means we need to explicitly stop on failure
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
timeout-minutes: 5
- name: Init MSVC
uses: ilammy/msvc-dev-cmd@v1
timeout-minutes: 5
- name: Build ${{ matrix.cfgopt }}
run: |
&nmake -f makefile.vc ${{ matrix.cfgopt }} all
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 5
- name: Build Test Harness ${{ matrix.cfgopt }}
run: |
&nmake -f makefile.vc ${{ matrix.cfgopt }} tcltest
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 5
- name: Run Tests ${{ matrix.cfgopt }}
run: |
&nmake -f makefile.vc ${{ matrix.cfgopt }} test
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 30
gcc:
runs-on: windows-2022
defaults:
@@ -60,6 +66,7 @@ jobs:
matrix:
cfgopt:
- ""
- "CFLAGS=-DTCL_UTF_MAX=3"
- "CFLAGS=-DTCL_NO_DEPRECATED=1"
- "--disable-shared"
- "--enable-symbols"
@@ -72,8 +79,10 @@ jobs:
with:
msystem: MINGW64
install: git mingw-w64-x86_64-toolchain make
timeout-minutes: 10
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
timeout-minutes: 5
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
@@ -84,12 +93,16 @@ jobs:
./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
env:
CFGOPT: --enable-64bit ${{ matrix.cfgopt }}
timeout-minutes: 5
- name: Build
run: make all
timeout-minutes: 5
- name: Build Test Harness
run: make tcltest
timeout-minutes: 5
- name: Run Tests
run: make test
timeout-minutes: 30
# If you add builds with Wine, be sure to define the environment variable
# CI_USING_WINE when running them so that broken tests know not to run.
+1
View File
@@ -53,6 +53,7 @@ libtommath/*.tex
macosx/configure
unix/autoMkindex.tcl
unix/dltest.marker
unix/dltest/embtest
unix/tcl.pc
unix/tclIndex
unix/pkgs/*
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tcl8</name>
<name>tcl9</name>
<comment></comment>
<projects>
</projects>
+21 -7
View File
@@ -20,6 +20,13 @@ jobs:
compiler: gcc
env:
- BUILD_DIR=unix
- name: "Linux/GCC/Shared: UTF_MAX=3"
os: linux
dist: focal
compiler: gcc
env:
- BUILD_DIR=unix
- CFGOPT="CFLAGS=-DTCL_UTF_MAX=3"
- name: "Linux/GCC/Shared: NO_DEPRECATED"
os: linux
dist: focal
@@ -76,13 +83,6 @@ jobs:
compiler: clang
env:
- BUILD_DIR=unix
- name: "Linux/Clang/Shared:NO_DEPRECATED"
os: linux
dist: xenial
compiler: clang
env:
- BUILD_DIR=unix
- CFGOPT="CFLAGS=-DTCL_NO_DEPRECATED=1"
- name: "Linux/Clang/Static"
os: linux
dist: focal
@@ -301,6 +301,13 @@ jobs:
- touch generic/tclStubInit.c generic/tclOOStubInit.c generic/tclOOScript.h
- choco install -y make zip
- cd ${BUILD_DIR}
- name: "Windows/GCC/Shared: UTF_MAX=3"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit CFLAGS=-DTCL_UTF_MAX=3"
before_install: *makepreinst
- name: "Windows/GCC/Shared: NO_DEPRECATED"
os: windows
compiler: gcc
@@ -336,6 +343,13 @@ jobs:
env:
- BUILD_DIR=win
before_install: *makepreinst
- name: "Windows/GCC-x86/Shared: UTF_MAX=3"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="CFLAGS=-DTCL_UTF_MAX=3"
before_install: *makepreinst
- name: "Windows/GCC-x86/Shared: NO_DEPRECATED"
os: windows
compiler: gcc
+15 -4
View File
@@ -1,13 +1,24 @@
# README: Tcl
This is the **Tcl 8.7a6** source distribution.
This is the **Tcl 9.0a4** source distribution.
You can get any source release of Tcl from [our distribution
site](https://sourceforge.net/projects/tcl/files/Tcl/).
8.6 (production release, daily build)
[![Build Status](https://github.com/tcltk/tcl/workflows/Linux/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-6-branch)
[![Build Status](https://github.com/tcltk/tcl/workflows/Windows/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-6-branch)
[![Build Status](https://github.com/tcltk/tcl/workflows/macOS/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-6-branch)
<br>
8.7 (in development, daily build))
[![Build Status](https://github.com/tcltk/tcl/workflows/Linux/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-branch)
[![Build Status](https://github.com/tcltk/tcl/workflows/Windows/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-branch)
[![Build Status](https://github.com/tcltk/tcl/workflows/macOS/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-branch)
<br>
9.0 (in development, daily build))
[![Build Status](https://github.com/tcltk/tcl/workflows/Linux/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Linux%22+branch%3Amain)
[![Build Status](https://github.com/tcltk/tcl/workflows/Windows/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Windows%22+branch%3Amain)
[![Build Status](https://github.com/tcltk/tcl/workflows/macOS/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22macOS%22+branch%3Amain)
## Contents
1. [Introduction](#intro)
@@ -45,7 +56,7 @@ and selling it either in whole or in part. See the file
## <a id="doc">2.</a> Documentation
Extensive documentation is available on our website.
The home page for this release, including new features, is
[here](https://www.tcl-lang.org/software/tcltk/8.7.html).
[here](https://www.tcl-lang.org/software/tcltk/9.0.html).
Detailed release notes can be found at the
[file distributions page](https://sourceforge.net/projects/tcl/files/Tcl/)
by clicking on the relevant version.
@@ -55,8 +66,8 @@ Xchange](https://www.tcl-lang.org/about/).
There have been many Tcl books on the market. Many are mentioned in
[the Wiki](https://wiki.tcl-lang.org/_/ref?N=25206).
The complete set of reference manual entries for Tcl 8.7 is [online,
here](https://www.tcl-lang.org/man/tcl8.7/).
The complete set of reference manual entries for Tcl 9.0 is [online,
here](https://www.tcl-lang.org/man/tcl9.0/).
### <a id="doc.unix">2a.</a> Unix Documentation
The `doc` subdirectory in this release contains a complete set of
+39 -1
View File
@@ -4976,7 +4976,7 @@ msgcat package (duperval, krone, nelson)
trace {add|remove|list} {variable|command} name ops command
(darley, melski)
2000-09-06 (cross-platform feature) Set ^Z (\32) as default EOF char. (hobbs)
2000-09-06 (cross-platform feature) Set ^Z (\x1A) as default EOF char. (hobbs)
2000-09-07 partial fix for bug 2460 to prevent exec mem leak on Windows for the
common case (gravereaux)
@@ -9123,6 +9123,26 @@ in this changeset (new minor version) rather than bug fixes:
- Released 8.7a3, Nov 21, 2019 --- https://core.tcl-lang.org/tcl/ for details -
Changes to 9.0a1 include all changes to the 8.7 line through 8.7a3,
plus the following, which focuses on the high-level feature changes
in this changeset (new minor version) rather than bug fixes:
2017-11-03 [TIP 114] Leading zero integer no longer means octal
2017-11-03 [TIP 278] Revise variable name resolution, solve "Creative Writing"
2017-11-03 [TIPs 330,336] Encapsulate struct Tcl_Interp
2017-11-17 [TIP 422] Remove all Tcl_*VA() routines
2017-12-15 [TIP 488] Disable magic $::tcl_precision
2018-10-08 [TIP 494] Increased support for size_t value ranges
2019-05-31 [TIP 537] 64-bit indices in regexp matching
- Released 9.0a1, Nov 25, 2019 --- https://core.tcl-lang.org/tcl/ for details -
2019-12-03 (bug)[3cd9be] Corner case in surrogate handling (nijtmans)
2019-12-09 (new) Add tcltest::(Setup|Eval|Cleanup|)Test (coulter,sebres)
@@ -9330,6 +9350,24 @@ in this changeset (new minor version) rather than bug fixes:
- Released 8.7a5, Jun 18, 2021 --- https://core.tcl-lang.org/tcl/ for details -
Changes to 9.0a3 include all changes to the 8.7 line through 8.7a5,
plus the following, which focuses on the high-level feature changes
in this changeset (new major version) rather than bug fixes:
Many of the TIPs in Tcl 8.7 mentioned above are extended further in 9.0
2020-02-28 [TIP 497] Full support for Unicode planes 1-16
2020-08-21 (bug)[43b434] improper calls to stat64()
2021-04-08 [TIP 595] Unicode-aware loadable library handling.
2021-04-30 [TIP 596] Stubs support for embedding Tcl in apps
Many internal changes to broaden support for sizes beyond 32-bits.
- Released 9.0a3, Jun 23, 2021 --- https://core.tcl-lang.org/tcl/ for details -
2021-02-02 (new) support for MacOS Big Sur updates (nijtmans)
=> platform 1.0.17
+2 -2
View File
@@ -100,7 +100,7 @@ waitpid(
} else {
prevPtr->nextPtr = waitPtr->nextPtr;
}
ckfree(waitPtr);
Tcl_Free(waitPtr);
return result;
}
@@ -156,7 +156,7 @@ waitpid(
goto waitAgain;
}
}
waitPtr = (WaitInfo *) attemptckalloc(sizeof(WaitInfo));
waitPtr = (WaitInfo *) Tcl_AttemptAlloc(sizeof(WaitInfo));
if (!waitPtr) {
errno = ENOMEM;
return -1;
+2 -2
View File
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 2.4.4...3.15.0)
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(zlib C)
set(VERSION "1.3")
set(VERSION "1.2.13")
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
+1 -19
View File
@@ -1,24 +1,6 @@
ChangeLog file for zlib
Changes in 1.3 (18 Aug 2023)
- Remove K&R function definitions and zlib2ansi
- Fix bug in deflateBound() for level 0 and memLevel 9
- Fix bug when gzungetc() is used immediately after gzopen()
- Fix bug when using gzflush() with a very small buffer
- Fix crash when gzsetparams() attempted for transparent write
- Fix test/example.c to work with FORCE_STORED
- Rewrite of zran in examples (see zran.c version history)
- Fix minizip to allow it to open an empty zip file
- Fix reading disk number start on zip64 files in minizip
- Fix logic error in minizip argument processing
- Add minizip testing to Makefile
- Read multiple bytes instead of byte-by-byte in minizip unzip.c
- Add memory sanitizer to configure (--memory)
- Various portability improvements
- Various documentation improvements
- Various spelling and typo corrections
Changes in 1.2.13 (13 Oct 2022)
- Fix configure issue that discarded provided CC definition
- Correct incorrect inputs provided to the CRC functions
@@ -1463,7 +1445,7 @@ Changes in 0.99 (27 Jan 96)
- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
- in fcalloc, normalize pointer if size > 65520 bytes
- don't use special fcalloc for 32 bit Borland C++
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc.
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
- use Z_BINARY instead of BINARY
- document that gzclose after gzdopen will close the file
- allow "a" as mode in gzopen
+1 -1
View File
@@ -4,7 +4,7 @@
If your question is not there, please check the zlib home page
http://zlib.net/ which may have more recent information.
The latest zlib FAQ is at http://zlib.net/zlib_faq.html
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
1. Is zlib Y2K-compliant?
+2 -8
View File
@@ -28,7 +28,7 @@ CPP=$(CC) -E
STATICLIB=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.3
SHAREDLIBV=libz.so.1.2.13
SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIBV)
@@ -359,14 +359,8 @@ zconf.h.cmakein: $(SRCDIR)zconf.h.in
zconf: $(SRCDIR)zconf.h.in
cp -p $(SRCDIR)zconf.h.in zconf.h
minizip-test: static
cd contrib/minizip && { CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; }
minizip-clean:
cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; }
mostlyclean: clean
clean: minizip-clean
clean:
rm -f *.o *.lo *~ \
example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
example64$(EXE) minigzip64$(EXE) \
+10 -9
View File
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.3 is a general purpose data compression library. All the code is
zlib 1.2.13 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
@@ -29,17 +29,18 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
https://marknelson.us/posts/1997/01/01/zlib-engine.html .
http://marknelson.us/1997/01/01/zlib-engine/ .
The changes made in version 1.3 are documented in the file ChangeLog.
The changes made in version 1.2.13 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
zlib is available in Java using the java.util.zip package. Follow the API
Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
zlib is available in Java using the java.util.zip package, documented at
http://java.sun.com/developer/technicalArticles/Programming/compression/ .
A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org>
can be found at https://github.com/pmqs/IO-Compress .
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
at CPAN (Comprehensive Perl Archive Network) sites, including
http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see
@@ -63,7 +64,7 @@ Notes for some targets:
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
when compiled with cc.
- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
necessary to get gzprintf working correctly. This is done by configure.
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
@@ -83,7 +84,7 @@ Acknowledgments:
Copyright notice:
(C) 1995-2023 Jean-loup Gailly and Mark Adler
(C) 1995-2022 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
+27 -5
View File
@@ -7,6 +7,8 @@
#include "zutil.h"
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#define BASE 65521U /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
@@ -58,7 +60,11 @@
#endif
/* ========================================================================= */
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
uLong ZEXPORT adler32_z(adler, buf, len)
uLong adler;
const Bytef *buf;
z_size_t len;
{
unsigned long sum2;
unsigned n;
@@ -125,12 +131,20 @@ uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
}
/* ========================================================================= */
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
uLong ZEXPORT adler32(adler, buf, len)
uLong adler;
const Bytef *buf;
uInt len;
{
return adler32_z(adler, buf, len);
}
/* ========================================================================= */
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
local uLong adler32_combine_(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off64_t len2;
{
unsigned long sum1;
unsigned long sum2;
unsigned rem;
@@ -155,10 +169,18 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
}
/* ========================================================================= */
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off_t len2;
{
return adler32_combine_(adler1, adler2, len2);
}
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off64_t len2;
{
return adler32_combine_(adler1, adler2, len2);
}
+16 -5
View File
@@ -19,8 +19,13 @@
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong sourceLen, int level) {
int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
const uInt max = (uInt)-1;
@@ -60,8 +65,12 @@ int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
/* ===========================================================================
*/
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong sourceLen) {
int ZEXPORT compress(dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
@@ -69,7 +78,9 @@ int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
uLong ZEXPORT compressBound(uLong sourceLen) {
uLong ZEXPORT compressBound(sourceLen)
uLong sourceLen;
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
(sourceLen >> 25) + 13;
}
+10 -16
View File
@@ -44,6 +44,8 @@ STATICLIB=libz.a
# extract zlib version numbers from zlib.h
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
# establish commands for library building
@@ -88,8 +90,7 @@ build64=0
gcc=0
warn=0
debug=0
address=0
memory=0
sanitize=0
old_cc="$CC"
old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)'
@@ -101,7 +102,7 @@ leave()
if test "$*" != "0"; then
echo "** $0 aborting." | tee -a configure.log
fi
rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version
rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
echo -------------------- >> configure.log
echo >> configure.log
echo >> configure.log
@@ -140,9 +141,7 @@ case "$1" in
-c* | --const) zconst=1; shift ;;
-w* | --warn) warn=1; shift ;;
-d* | --debug) debug=1; shift ;;
--sanitize) address=1; shift ;;
--address) address=1; shift ;;
--memory) memory=1; shift ;;
--sanitize) sanitize=1; shift ;;
*)
echo "unknown option: $1" | tee -a configure.log
echo "$0 --help for help" | tee -a configure.log
@@ -212,11 +211,8 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
CFLAGS="${CFLAGS} -Wall -Wextra"
fi
fi
if test $address -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
fi
if test $memory -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer"
if test $sanitize -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=address"
fi
if test $debug -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
@@ -263,10 +259,8 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
SHAREDLIB=libz$shared_ext
SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"}
if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then
AR="${CROSS_PREFIX}libtool"
elif libtool -V 2>&1 | grep Apple > /dev/null; then
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
if libtool -V 2>&1 | grep Apple > /dev/null; then
AR="libtool"
else
AR="/usr/bin/libtool"
@@ -866,7 +860,7 @@ echo prefix = $prefix >> configure.log
echo sharedlibdir = $sharedlibdir >> configure.log
echo uname = $uname >> configure.log
# update Makefile with the configure results
# udpate Makefile with the configure results
sed < ${SRCDIR}Makefile.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
+2 -2
View File
@@ -8,8 +8,8 @@ It provides Ada-style access to the ZLib C library.
Here are the main changes since ZLib.Ada 1.2:
- Attention: ZLib.Read generic routine have a initialization requirement
for Read_Last parameter now. It is a bit incompatible with previous version,
- Attension: ZLib.Read generic routine have a initialization requirement
for Read_Last parameter now. It is a bit incompartible with previous version,
but extends functionality, we could use new parameters Allow_Read_Some and
Flush now.
+2 -2
View File
@@ -65,12 +65,12 @@ procedure Test is
Time_Stamp : Ada.Calendar.Time;
procedure Generate_File;
-- Generate file of specified size with some random data.
-- Generate file of spetsified size with some random data.
-- The random data is repeatable, for the good compression.
procedure Compare_Streams
(Left, Right : in out Root_Stream_Type'Class);
-- The procedure comparing data in 2 streams.
-- The procedure compearing data in 2 streams.
-- It is for compare data before and after compression/decompression.
procedure Compare_Files (Left, Right : String);
+1 -1
View File
@@ -62,7 +62,7 @@ package ZLib.Streams is
:= Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size);
-- Create the Compression/Decompression stream.
-- Create the Comression/Decompression stream.
-- If mode is In_Stream then Write operation is disabled.
-- If mode is Out_Stream then Read operation is disabled.
+1 -1
View File
@@ -204,7 +204,7 @@ package body ZLib is
end if;
-- We allow ZLib to make header only in case of default header type.
-- Otherwise we would either do header by ourselves, or do not do
-- Otherwise we would either do header by ourselfs, or do not do
-- header at all.
if Header = None or else Header = GZip then
+1 -1
View File
@@ -114,7 +114,7 @@ package ZLib is
-- Compression strategy constants --
------------------------------------
-- RLE strategy could be used only in version 1.2.0 and later.
-- RLE stategy could be used only in version 1.2.0 and later.
Filtered : constant Strategy_Type;
Huffman_Only : constant Strategy_Type;
+1 -1
View File
@@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
const OutBuf: Pointer; BufSize: Integer);
const
zlib_version = '1.3.0';
zlib_version = '1.2.13';
type
EZlibError = class(Exception);
@@ -1,5 +1,5 @@
//
// © Copyright Henrik Ravn 2004
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -61,7 +61,7 @@ namespace DotZLib
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
/// <remarks>All the other <c>Update</c> methods are implemented in terms of this one.
/// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one.
/// This is therefore the only method a derived class has to implement</remarks>
public abstract void Update(byte[] data, int offset, int count);
@@ -1,5 +1,5 @@
//
// © Copyright Henrik Ravn 2004
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -1,5 +1,5 @@
//
// © Copyright Henrik Ravn 2004
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -139,7 +139,7 @@ namespace DotZLib
/// <remarks>This must be implemented by a derived class</remarks>
protected abstract void CleanUp();
// performs the release of the handles and calls the derived CleanUp()
// performs the release of the handles and calls the dereived CleanUp()
private void CleanUp(bool isDisposing)
{
if (!_isDisposed)
@@ -160,7 +160,7 @@ namespace DotZLib
#region Helper methods
/// <summary>
/// Copies a number of bytes to the internal codec buffer - ready for processing
/// Copies a number of bytes to the internal codec buffer - ready for proccesing
/// </summary>
/// <param name="data">The byte array that contains the data to copy</param>
/// <param name="startIndex">The index of the first byte to copy</param>
@@ -1,5 +1,5 @@
//
// © Copyright Henrik Ravn 2004
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -1,5 +1,5 @@
//
// © Copyright Henrik Ravn 2004
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -1,5 +1,5 @@
//
// © Copyright Henrik Ravn 2004
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -246,7 +246,7 @@ namespace DotZLib
}
/// <summary>
/// Not supported.
/// Not suppported.
/// </summary>
/// <param name="offset"></param>
/// <param name="origin"></param>
@@ -268,7 +268,7 @@ namespace DotZLib
}
/// <summary>
/// Gets/sets the current position in the <c>GZipStream</c>. Not supported.
/// Gets/sets the current position in the <c>GZipStream</c>. Not suppported.
/// </summary>
/// <remarks>In this implementation this property is not supported</remarks>
/// <exception cref="NotSupportedException">Always thrown</exception>
@@ -285,7 +285,7 @@ namespace DotZLib
}
/// <summary>
/// Gets the size of the stream. Not supported.
/// Gets the size of the stream. Not suppported.
/// </summary>
/// <remarks>In this implementation this property is not supported</remarks>
/// <exception cref="NotSupportedException">Always thrown</exception>
@@ -1,5 +1,5 @@
//
// © Copyright Henrik Ravn 2004
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -156,7 +156,7 @@ namespace DotZLibTests
public void Info_Version()
{
Info info = new Info();
Assert.AreEqual("1.3.0", Info.Version);
Assert.AreEqual("1.2.13", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer);
+1 -1
View File
@@ -36,7 +36,7 @@ Build instructions:
in the same directory as the DotZLib.build file.
You can define 2 properties on the nant command-line to control the build:
debug={true|false} to toggle between release/debug builds (default=true).
nunit={true|false} to include or exclude unit tests (default=true).
nunit={true|false} to include or esclude unit tests (default=true).
Also the target clean will remove binaries.
Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release
or ./DotZLib/bin/debug, depending on whether you are building the release
+18 -6
View File
@@ -16,8 +16,12 @@
window is a user-supplied window and output buffer that is 64K bytes.
*/
int ZEXPORT inflateBack9Init_(z_stream FAR *strm, unsigned char FAR *window,
const char *version, int stream_size) {
int ZEXPORT inflateBack9Init_(strm, window, version, stream_size)
z_stream FAR *strm;
unsigned char FAR *window;
const char *version;
int stream_size;
{
struct inflate_state FAR *state;
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
@@ -47,7 +51,8 @@ int ZEXPORT inflateBack9Init_(z_stream FAR *strm, unsigned char FAR *window,
#ifdef MAKEFIXED
#include <stdio.h>
void makefixed9(void) {
void makefixed9(void)
{
unsigned sym, bits, low, size;
code *next, *lenfix, *distfix;
struct inflate_state state;
@@ -209,8 +214,13 @@ void makefixed9(void) {
inflateBack() can also return Z_STREAM_ERROR if the input parameters
are not correct, i.e. strm is Z_NULL or the state was not initialized.
*/
int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
out_func out, void FAR *out_desc) {
int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc)
z_stream FAR *strm;
in_func in;
void FAR *in_desc;
out_func out;
void FAR *out_desc;
{
struct inflate_state FAR *state;
z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */
@@ -593,7 +603,9 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
return ret;
}
int ZEXPORT inflateBack9End(z_stream FAR *strm) {
int ZEXPORT inflateBack9End(strm)
z_stream FAR *strm;
{
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
return Z_STREAM_ERROR;
ZFREE(strm, strm->state);
+8 -8
View File
@@ -20,14 +20,14 @@
extern "C" {
#endif
ZEXTERN int ZEXPORT inflateBack9(z_stream FAR *strm,
in_func in, void FAR *in_desc,
out_func out, void FAR *out_desc);
ZEXTERN int ZEXPORT inflateBack9End(z_stream FAR *strm);
ZEXTERN int ZEXPORT inflateBack9Init_(z_stream FAR *strm,
unsigned char FAR *window,
const char *version,
int stream_size);
ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm,
in_func in, void FAR *in_desc,
out_func out, void FAR *out_desc));
ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm));
ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm,
unsigned char FAR *window,
const char *version,
int stream_size));
#define inflateBack9Init(strm, window) \
inflateBack9Init_((strm), (window), \
ZLIB_VERSION, sizeof(z_stream))
+11 -6
View File
@@ -1,5 +1,5 @@
/* inftree9.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2023 Mark Adler
* Copyright (C) 1995-2022 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate9_copyright[] =
" inflate9 1.3 Copyright 1995-2023 Mark Adler ";
" inflate9 1.2.13 Copyright 1995-2022 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -29,9 +29,14 @@ const char inflate9_copyright[] =
table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code.
*/
int inflate_table9(codetype type, unsigned short FAR *lens, unsigned codes,
code FAR * FAR *table, unsigned FAR *bits,
unsigned short FAR *work) {
int inflate_table9(type, lens, codes, table, bits, work)
codetype type;
unsigned short FAR *lens;
unsigned codes;
code FAR * FAR *table;
unsigned FAR *bits;
unsigned short FAR *work;
{
unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */
unsigned min, max; /* minimum and maximum code lengths */
@@ -59,7 +64,7 @@ int inflate_table9(codetype type, unsigned short FAR *lens, unsigned codes,
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
133, 133, 133, 133, 144, 198, 203};
133, 133, 133, 133, 144, 194, 65};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
+3 -3
View File
@@ -56,6 +56,6 @@ typedef enum {
DISTS
} codetype;
extern int inflate_table9(codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work);
extern int inflate_table9 OF((codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work));
@@ -1,5 +1,5 @@
MiniZip 1.1 was derived from MiniZip at version 1.01f
MiniZip 1.1 was derrived from MiniZip at version 1.01f
Change in 1.0 (Okt 2009)
- **TODO - Add history**
+1 -1
View File
@@ -1,7 +1,7 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_INIT([minizip], [1.3.0], [bugzilla.redhat.com])
AC_INIT([minizip], [1.2.13], [bugzilla.redhat.com])
AC_CONFIG_SRCDIR([minizip.c])
AM_INIT_AUTOMAKE([foreign])
LT_INIT
+8 -4
View File
@@ -32,7 +32,8 @@
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
@@ -45,7 +46,8 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
{
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
@@ -61,7 +63,8 @@ static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c)
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
{
*(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L;
@@ -90,7 +93,8 @@ static unsigned crypthead(const char* passwd, /* password string */
int bufSize,
unsigned long* pkeys,
const z_crc_t* pcrc_32_tab,
unsigned long crcForCrypting) {
unsigned long crcForCrypting)
{
unsigned n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
+44 -18
View File
@@ -18,7 +18,7 @@
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) _ftelli64(stream)
#define FSEEKO_FUNC(stream, offset, origin) _fseeki64(stream, offset, origin)
#elif defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
#elif defined(__APPLE__) || defined(IOAPI_NO_64)
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
@@ -32,7 +32,8 @@
#include "ioapi.h"
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) {
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
{
if (pfilefunc->zfile_func64.zopen64_file != NULL)
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
else
@@ -41,7 +42,8 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filenam
}
}
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) {
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
{
if (pfilefunc->zfile_func64.zseek64_file != NULL)
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
else
@@ -54,7 +56,8 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
}
}
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) {
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
{
if (pfilefunc->zfile_func64.zseek64_file != NULL)
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
else
@@ -67,9 +70,11 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestrea
}
}
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) {
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
{
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
@@ -83,7 +88,16 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) {
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
{
FILE* file = NULL;
const char* mode_fopen = NULL;
(void)opaque;
@@ -101,7 +115,8 @@ static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int
return file;
}
static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) {
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
{
FILE* file = NULL;
const char* mode_fopen = NULL;
(void)opaque;
@@ -120,21 +135,24 @@ static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, i
}
static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) {
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
{
uLong ret;
(void)opaque;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}
static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
{
uLong ret;
(void)opaque;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}
static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) {
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
{
long ret;
(void)opaque;
ret = ftell((FILE *)stream);
@@ -142,14 +160,16 @@ static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) {
}
static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) {
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
{
ZPOS64_T ret;
(void)opaque;
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
return ret;
}
static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
{
int fseek_origin=0;
long ret;
(void)opaque;
@@ -172,7 +192,8 @@ static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset
return ret;
}
static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
{
int fseek_origin=0;
long ret;
(void)opaque;
@@ -191,28 +212,32 @@ static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T o
}
ret = 0;
if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0)
if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0)
ret = -1;
return ret;
}
static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) {
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
{
int ret;
(void)opaque;
ret = fclose((FILE *)stream);
return ret;
}
static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) {
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
{
int ret;
(void)opaque;
ret = ferror((FILE *)stream);
return ret;
}
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
void fill_fopen_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def;
{
pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
@@ -223,7 +248,8 @@ void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
pzlib_filefunc_def->opaque = NULL;
}
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) {
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
+18 -18
View File
@@ -50,7 +50,7 @@
#define ftello64 ftell
#define fseeko64 fseek
#else
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define fopen64 fopen
#define ftello64 ftello
#define fseeko64 fseeko
@@ -82,7 +82,7 @@
#include "mz64conf.h"
#endif
/* a type chosen by DEFINE */
/* a type choosen by DEFINE */
#ifdef HAVE_64BIT_INT_CUSTOM
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
#else
@@ -134,14 +134,14 @@ extern "C" {
typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
/* here is the "old" 32 bits structure structure */
@@ -157,9 +157,9 @@ typedef struct zlib_filefunc_def_s
voidpf opaque;
} zlib_filefunc_def;
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode);
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
typedef struct zlib_filefunc64_def_s
{
@@ -173,8 +173,8 @@ typedef struct zlib_filefunc64_def_s
voidpf opaque;
} zlib_filefunc64_def;
void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def);
void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
/* now internal definition, only for zip.c and unzip.h */
typedef struct zlib_filefunc64_32_def_s
@@ -193,11 +193,11 @@ typedef struct zlib_filefunc64_32_def_s
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
+46 -19
View File
@@ -38,6 +38,14 @@
#endif
#endif
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream));
long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
typedef struct
{
HANDLE hf;
@@ -49,7 +57,8 @@ static void win32_translate_open_mode(int mode,
DWORD* lpdwDesiredAccess,
DWORD* lpdwCreationDisposition,
DWORD* lpdwShareMode,
DWORD* lpdwFlagsAndAttributes) {
DWORD* lpdwFlagsAndAttributes)
{
*lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
@@ -70,7 +79,8 @@ static void win32_translate_open_mode(int mode,
}
}
static voidpf win32_build_iowin(HANDLE hFile) {
static voidpf win32_build_iowin(HANDLE hFile)
{
voidpf ret=NULL;
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
@@ -88,7 +98,8 @@ static voidpf win32_build_iowin(HANDLE hFile) {
return ret;
}
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
{
const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
@@ -116,7 +127,8 @@ voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int
}
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
{
const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
@@ -139,7 +151,8 @@ voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, in
}
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
{
const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
@@ -158,7 +171,8 @@ voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, in
}
voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
{
const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
@@ -186,7 +200,8 @@ voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int m
}
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
{
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
@@ -207,7 +222,8 @@ uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLo
}
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
{
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
@@ -227,7 +243,8 @@ uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void*
return ret;
}
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) {
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
{
#ifdef IOWIN32_USING_WINRT_API
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
#else
@@ -246,7 +263,8 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
#endif
}
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
{
long ret=-1;
HANDLE hFile = NULL;
if (stream!=NULL)
@@ -268,7 +286,8 @@ long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
return ret;
}
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
{
ZPOS64_T ret= (ZPOS64_T)-1;
HANDLE hFile = NULL;
if (stream!=NULL)
@@ -292,7 +311,8 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
}
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
{
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
@@ -329,7 +349,8 @@ long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset,
return ret;
}
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
{
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
@@ -367,7 +388,8 @@ long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T off
return ret;
}
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
{
int ret=-1;
if (stream!=NULL)
@@ -384,7 +406,8 @@ int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
return ret;
}
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
{
int ret=-1;
if (stream!=NULL)
{
@@ -393,7 +416,8 @@ int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
return ret;
}
void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen_file = win32_open_file_func;
pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
@@ -404,7 +428,8 @@ void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
pzlib_filefunc_def->opaque = NULL;
}
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) {
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
@@ -416,7 +441,8 @@ void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) {
}
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) {
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
@@ -428,7 +454,8 @@ void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) {
}
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) {
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
+4 -4
View File
@@ -18,10 +18,10 @@
extern "C" {
#endif
void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def);
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def);
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def);
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
#ifdef __cplusplus
}
+48 -22
View File
@@ -27,7 +27,7 @@
#endif
#endif
#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
#ifdef __APPLE__
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
@@ -81,7 +81,11 @@
filename : the filename of the file where date/time must be modified
dosdate : the new date at the MSDos format (4 bytes)
tmu_date : the SAME new date at the tm_unz format */
static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
static void change_file_date(filename,dosdate,tmu_date)
const char *filename;
uLong dosdate;
tm_unz tmu_date;
{
#ifdef _WIN32
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
@@ -111,10 +115,6 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat
ut.actime=ut.modtime=mktime(&newdate);
utime(filename,&ut);
#else
(void)filename;
(void)dosdate;
(void)tmu_date;
#endif
#endif
}
@@ -123,7 +123,9 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat
/* mymkdir and change_file_date are not 100 % portable
As I don't know well Unix, I wait feedback for the unix portion */
static int mymkdir(const char* dirname) {
static int mymkdir(dirname)
const char* dirname;
{
int ret=0;
#ifdef _WIN32
ret = _mkdir(dirname);
@@ -131,13 +133,13 @@ static int mymkdir(const char* dirname) {
ret = mkdir (dirname,0775);
#elif __APPLE__
ret = mkdir (dirname,0775);
#else
(void)dirname;
#endif
return ret;
}
static int makedir(const char *newdir) {
static int makedir (newdir)
const char *newdir;
{
char *buffer ;
char *p;
size_t len = strlen(newdir);
@@ -185,12 +187,14 @@ static int makedir(const char *newdir) {
return 1;
}
static void do_banner(void) {
static void do_banner()
{
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
}
static void do_help(void) {
static void do_help()
{
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
" -e Extract without pathname (junk paths)\n" \
" -x Extract with pathname\n" \
@@ -198,10 +202,11 @@ static void do_help(void) {
" -l list files\n" \
" -d directory to extract into\n" \
" -o overwrite files without prompting\n" \
" -p extract encrypted file using password\n\n");
" -p extract crypted file using password\n\n");
}
static void Display64BitsSize(ZPOS64_T n, int size_char) {
static void Display64BitsSize(ZPOS64_T n, int size_char)
{
/* to avoid compatibility problem , we do here the conversion */
char number[21];
int offset=19;
@@ -228,7 +233,9 @@ static void Display64BitsSize(ZPOS64_T n, int size_char) {
printf("%s",&number[pos_string]);
}
static int do_list(unzFile uf) {
static int do_list(uf)
unzFile uf;
{
uLong i;
unz_global_info64 gi;
int err;
@@ -243,7 +250,7 @@ static int do_list(unzFile uf) {
char filename_inzip[256];
unz_file_info64 file_info;
uLong ratio=0;
const char *string_method = "";
const char *string_method;
char charCrypt=' ';
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
@@ -254,7 +261,7 @@ static int do_list(unzFile uf) {
if (file_info.uncompressed_size>0)
ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size);
/* display a '*' if the file is encrypted */
/* display a '*' if the file is crypted */
if ((file_info.flag & 1) != 0)
charCrypt='*';
@@ -304,7 +311,12 @@ static int do_list(unzFile uf) {
}
static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
unzFile uf;
const int* popt_extract_without_path;
int* popt_overwrite;
const char* password;
{
char filename_inzip[256];
char* filename_withoutpath;
char* p;
@@ -461,7 +473,12 @@ static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_pa
}
static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
static int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
unzFile uf;
int opt_extract_without_path;
int opt_overwrite;
const char* password;
{
uLong i;
unz_global_info64 gi;
int err;
@@ -491,7 +508,13 @@ static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrit
return 0;
}
static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
unzFile uf;
const char* filename;
int opt_extract_without_path;
int opt_overwrite;
const char* password;
{
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
{
printf("file %s not found in the zipfile\n",filename);
@@ -507,7 +530,10 @@ static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_
}
int main(int argc, char *argv[]) {
int main(argc,argv)
int argc;
char *argv[];
{
const char *zipfilename=NULL;
const char *filename_to_extract=NULL;
const char *password=NULL;
@@ -580,7 +606,7 @@ int main(int argc, char *argv[]) {
# endif
strncpy(filename_try, zipfilename,MAXFILENAME-1);
/* strncpy doesn't append the trailing NULL, of the string is too long. */
/* strncpy doesnt append the trailing NULL, of the string is too long. */
filename_try[ MAXFILENAME ] = '\0';
# ifdef USEWIN32IOAPI
+37 -25
View File
@@ -77,9 +77,11 @@
#define MAXFILENAME (256)
#ifdef _WIN32
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
static int filetime(f, tmzip, dt)
const char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
uLong *dt; /* dostime */
{
int ret = 0;
{
FILETIME ftLocal;
@@ -99,9 +101,11 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
}
#else
#if defined(unix) || defined(__APPLE__)
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
static int filetime(f, tmzip, dt)
const char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
uLong *dt; /* dostime */
{
(void)dt;
int ret=0;
struct stat s; /* results of stat() */
@@ -116,7 +120,7 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
len = MAXFILENAME;
strncpy(name, f,MAXFILENAME-1);
/* strncpy doesn't append the trailing NULL, of the string is too long. */
/* strncpy doesnt append the trailing NULL, of the string is too long. */
name[ MAXFILENAME ] = '\0';
if (name[len - 1] == '/')
@@ -140,12 +144,11 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
return ret;
}
#else
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
(void)f;
(void)tmzip;
(void)dt;
static int filetime(f, tmzip, dt)
const char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
uLong *dt; /* dostime */
{
return 0;
}
#endif
@@ -154,7 +157,9 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
static int check_exist_file(const char* filename) {
static int check_exist_file(filename)
const char* filename;
{
FILE* ftestexist;
int ret = 1;
ftestexist = FOPEN_FUNC(filename,"rb");
@@ -165,12 +170,14 @@ static int check_exist_file(const char* filename) {
return ret;
}
static void do_banner(void) {
static void do_banner()
{
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
}
static void do_help(void) {
static void do_help()
{
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
" -r Scan directories recursively\n" \
" -o Overwrite existing file.zip\n" \
@@ -183,13 +190,14 @@ static void do_help(void) {
/* calculate the CRC32 of a file,
because to encrypt a file, we need known the CRC32 of the file before */
static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) {
static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
{
unsigned long calculate_crc=0;
int err=ZIP_OK;
FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
unsigned long size_read = 0;
/* unsigned long total_read = 0; */
unsigned long total_read = 0;
if (fin==NULL)
{
err = ZIP_ERRNO;
@@ -209,7 +217,7 @@ static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_b
if (size_read>0)
calculate_crc = crc32_z(calculate_crc,buf,size_read);
/* total_read += size_read; */
total_read += size_read;
} while ((err == ZIP_OK) && (size_read>0));
@@ -221,7 +229,8 @@ static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_b
return err;
}
static int isLargeFile(const char* filename) {
static int isLargeFile(const char* filename)
{
int largeFile = 0;
ZPOS64_T pos = 0;
FILE* pFile = FOPEN_FUNC(filename, "rb");
@@ -231,7 +240,7 @@ static int isLargeFile(const char* filename) {
FSEEKO_FUNC(pFile, 0, SEEK_END);
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
printf("File : %s is %llu bytes\n", filename, pos);
printf("File : %s is %lld bytes\n", filename, pos);
if(pos >= 0xffffffff)
largeFile = 1;
@@ -382,10 +391,13 @@ void addPathToZip(zipFile zf, const char *filenameinzip, const char *password, i
}
int main(int argc, char *argv[]) {
int main(argc,argv)
int argc;
char *argv[];
{
int i;
int opt_recursive=0;
int opt_overwrite=0;
int opt_overwrite=1;
int opt_compress_level=Z_DEFAULT_COMPRESSION;
int opt_exclude_path=0;
int zipfilenamearg = 0;
@@ -413,7 +425,7 @@ int main(int argc, char *argv[]) {
while ((*p)!='\0')
{
char c=*(p++);
char c=*(p++);;
if ((c=='o') || (c=='O'))
opt_overwrite = 1;
if ((c=='a') || (c=='A'))
@@ -461,7 +473,7 @@ int main(int argc, char *argv[]) {
zipok = 1 ;
strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
/* strncpy doesn't append the trailing NULL, of the string is too long. */
/* strncpy doesnt append the trailing NULL, of the string is too long. */
filename_try[ MAXFILENAME ] = '\0';
len=(int)strlen(filename_try);
+7 -1
View File
@@ -27,7 +27,13 @@
WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
} while(0)
extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) {
extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
const char* file;
const char* fileOut;
const char* fileOutTmp;
uLong* nRecovered;
uLong* bytesRecovered;
{
int err = Z_OK;
FILE* fpZip = fopen(file, "rb");
FILE* fpOut = fopen(fileOut, "wb");
+337 -192
View File
@@ -49,12 +49,12 @@
Copyright (C) 2007-2008 Even Rouault
Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G
should only read the compressed/uncompressed size from the Zip64 format if
the size from normal header was 0xFFFFFFFF
Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant
Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required)
Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant
Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required)
Patch created by Daniel Borca
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
@@ -77,6 +77,8 @@
#ifdef STDC
# include <stddef.h>
# include <string.h>
# include <stdlib.h>
#endif
#ifdef NO_ERRNO_H
extern int errno;
@@ -109,6 +111,9 @@
#ifndef ALLOC
# define ALLOC(size) (malloc(size))
#endif
#ifndef TRYFREE
# define TRYFREE(p) { free(p);}
#endif
#define SIZECENTRALDIRITEM (0x2e)
#define SIZEZIPLOCALHEADER (0x1e)
@@ -148,7 +153,7 @@ typedef struct
ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
zlib_filefunc64_32_def z_filefunc;
voidpf filestream; /* io structure of the zipfile */
voidpf filestream; /* io structore of the zipfile */
uLong compression_method; /* compression method (0==store) */
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
int raw;
@@ -161,7 +166,7 @@ typedef struct
{
zlib_filefunc64_32_def z_filefunc;
int is64bitOpenFunction;
voidpf filestream; /* io structure of the zipfile */
voidpf filestream; /* io structore of the zipfile */
unz_global_info64 gi; /* public global information */
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
ZPOS64_T num_file; /* number of the current file in the zipfile*/
@@ -192,75 +197,157 @@ typedef struct
#include "crypt.h"
#endif
/* ===========================================================================
Read a byte from a gz_stream; update next_in and avail_in. Return EOF
for end of file.
IN assertion: the stream s has been successfully opened for reading.
*/
local int unz64local_getByte OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
int *pi));
local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
{
unsigned char c;
int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
if (err==1)
{
*pi = (int)c;
return UNZ_OK;
}
else
{
if (ZERROR64(*pzlib_filefunc_def,filestream))
return UNZ_ERRNO;
else
return UNZ_EOF;
}
}
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets
*/
local int unz64local_getShort OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX));
local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX) {
unsigned char c[2];
int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,2);
if (err==2)
{
*pX = c[0] | ((uLong)c[1] << 8);
return UNZ_OK;
}
else
{
*pX = 0;
if (ZERROR64(*pzlib_filefunc_def,filestream))
return UNZ_ERRNO;
else
return UNZ_EOF;
}
}
local int unz64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def,
local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX) {
unsigned char c[4];
int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,4);
if (err==4)
{
*pX = c[0] | ((uLong)c[1] << 8) | ((uLong)c[2] << 16) | ((uLong)c[3] << 24);
return UNZ_OK;
}
uLong *pX)
{
uLong x ;
int i = 0;
int err;
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x = (uLong)i;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((uLong)i)<<8;
if (err==UNZ_OK)
*pX = x;
else
{
*pX = 0;
if (ZERROR64(*pzlib_filefunc_def,filestream))
return UNZ_ERRNO;
else
return UNZ_EOF;
}
return err;
}
local int unz64local_getLong OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX));
local int unz64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
ZPOS64_T *pX) {
unsigned char c[8];
int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,8);
if (err==8)
{
*pX = c[0] | ((ZPOS64_T)c[1] << 8) | ((ZPOS64_T)c[2] << 16) | ((ZPOS64_T)c[3] << 24)
| ((ZPOS64_T)c[4] << 32) | ((ZPOS64_T)c[5] << 40) | ((ZPOS64_T)c[6] << 48) | ((ZPOS64_T)c[7] << 56);
return UNZ_OK;
}
local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX)
{
uLong x ;
int i = 0;
int err;
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x = (uLong)i;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((uLong)i)<<8;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((uLong)i)<<16;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x += ((uLong)i)<<24;
if (err==UNZ_OK)
*pX = x;
else
{
*pX = 0;
if (ZERROR64(*pzlib_filefunc_def,filestream))
return UNZ_ERRNO;
else
return UNZ_EOF;
}
return err;
}
local int unz64local_getLong64 OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
ZPOS64_T *pX));
local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
ZPOS64_T *pX)
{
ZPOS64_T x ;
int i = 0;
int err;
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x = (ZPOS64_T)i;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<8;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<16;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<24;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<32;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<40;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<48;
if (err==UNZ_OK)
err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
x |= ((ZPOS64_T)i)<<56;
if (err==UNZ_OK)
*pX = x;
else
*pX = 0;
return err;
}
/* My own strcmpi / strcasecmp */
local int strcmpcasenosensitive_internal(const char* fileName1, const char* fileName2) {
local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
{
for (;;)
{
char c1=*(fileName1++);
@@ -292,17 +379,19 @@ local int strcmpcasenosensitive_internal(const char* fileName1, const char* file
#endif
/*
Compare two filenames (fileName1,fileName2).
If iCaseSensitivity = 1, comparison is case sensitive (like strcmp)
If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
or strcasecmp)
If iCaseSensitivity = 0, case sensitivity is default of your operating system
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
(like 1 on Unix, 2 on Windows)
*/
extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
const char* fileName2,
int iCaseSensitivity) {
const char* fileName2,
int iCaseSensitivity)
{
if (iCaseSensitivity==0)
iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
@@ -316,23 +405,21 @@ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
#define BUFREADCOMMENT (0x400)
#endif
#ifndef CENTRALDIRINVALID
#define CENTRALDIRINVALID ((ZPOS64_T)(-1))
#endif
/*
Locate the Central directory of a zipfile (at the end, just before
the global comment)
*/
local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf;
ZPOS64_T uSizeFile;
ZPOS64_T uBackRead;
ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
ZPOS64_T uPosFound=CENTRALDIRINVALID;
ZPOS64_T uPosFound=0;
if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
return CENTRALDIRINVALID;
return 0;
uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
@@ -342,7 +429,7 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
if (buf==NULL)
return CENTRALDIRINVALID;
return 0;
uBackRead = 4;
while (uBackRead<uMaxBack)
@@ -372,10 +459,10 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
break;
}
if (uPosFound!=CENTRALDIRINVALID)
if (uPosFound!=0)
break;
}
free(buf);
TRYFREE(buf);
return uPosFound;
}
@@ -384,18 +471,23 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
Locate the Central directory 64 of a zipfile (at the end, just before
the global comment)
*/
local ZPOS64_T unz64local_SearchCentralDir64 OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream));
local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream) {
voidpf filestream)
{
unsigned char* buf;
ZPOS64_T uSizeFile;
ZPOS64_T uBackRead;
ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
ZPOS64_T uPosFound=CENTRALDIRINVALID;
ZPOS64_T uPosFound=0;
uLong uL;
ZPOS64_T relativeOffset;
if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
return CENTRALDIRINVALID;
return 0;
uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
@@ -405,7 +497,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
if (buf==NULL)
return CENTRALDIRINVALID;
return 0;
uBackRead = 4;
while (uBackRead<uMaxBack)
@@ -435,47 +527,47 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
break;
}
if (uPosFound!=CENTRALDIRINVALID)
if (uPosFound!=0)
break;
}
free(buf);
if (uPosFound == CENTRALDIRINVALID)
return CENTRALDIRINVALID;
TRYFREE(buf);
if (uPosFound == 0)
return 0;
/* Zip64 end of central directory locator */
if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
return CENTRALDIRINVALID;
return 0;
/* the signature, already checked */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return CENTRALDIRINVALID;
return 0;
/* number of the disk with the start of the zip64 end of central directory */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return CENTRALDIRINVALID;
return 0;
if (uL != 0)
return CENTRALDIRINVALID;
return 0;
/* relative offset of the zip64 end of central directory record */
if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
return CENTRALDIRINVALID;
return 0;
/* total number of disks */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return CENTRALDIRINVALID;
return 0;
if (uL != 1)
return CENTRALDIRINVALID;
return 0;
/* Goto end of central directory record */
if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
return CENTRALDIRINVALID;
return 0;
/* the signature */
if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
return CENTRALDIRINVALID;
return 0;
if (uL != 0x06064b50)
return CENTRALDIRINVALID;
return 0;
return relativeOffset;
}
@@ -489,18 +581,19 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
Else, the return value is a unzFile Handle, usable with other function
of this unzip package.
*/
local unzFile unzOpenInternal(const void *path,
zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
int is64bitOpenFunction) {
local unzFile unzOpenInternal (const void *path,
zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
int is64bitOpenFunction)
{
unz64_s us;
unz64_s *s;
ZPOS64_T central_pos;
uLong uL;
uLong number_disk; /* number of the current dist, used for
spanning ZIP, unsupported, always 0*/
spaning ZIP, unsupported, always 0*/
uLong number_disk_with_CD; /* number the the disk with central dir, used
for spanning ZIP, unsupported, always 0*/
for spaning ZIP, unsupported, always 0*/
ZPOS64_T number_entry_CD; /* total number of entries in
the central dir
(same than number_entry on nospan) */
@@ -528,7 +621,7 @@ local unzFile unzOpenInternal(const void *path,
return NULL;
central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
if (central_pos!=CENTRALDIRINVALID)
if (central_pos)
{
uLong uS;
ZPOS64_T uL64;
@@ -590,7 +683,7 @@ local unzFile unzOpenInternal(const void *path,
else
{
central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
if (central_pos==CENTRALDIRINVALID)
if (central_pos==0)
err=UNZ_ERRNO;
us.isZip64 = 0;
@@ -669,8 +762,9 @@ local unzFile unzOpenInternal(const void *path,
}
extern unzFile ZEXPORT unzOpen2(const char *path,
zlib_filefunc_def* pzlib_filefunc32_def) {
extern unzFile ZEXPORT unzOpen2 (const char *path,
zlib_filefunc_def* pzlib_filefunc32_def)
{
if (pzlib_filefunc32_def != NULL)
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -681,8 +775,9 @@ extern unzFile ZEXPORT unzOpen2(const char *path,
return unzOpenInternal(path, NULL, 0);
}
extern unzFile ZEXPORT unzOpen2_64(const void *path,
zlib_filefunc64_def* pzlib_filefunc_def) {
extern unzFile ZEXPORT unzOpen2_64 (const void *path,
zlib_filefunc64_def* pzlib_filefunc_def)
{
if (pzlib_filefunc_def != NULL)
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -695,11 +790,13 @@ extern unzFile ZEXPORT unzOpen2_64(const void *path,
return unzOpenInternal(path, NULL, 1);
}
extern unzFile ZEXPORT unzOpen(const char *path) {
extern unzFile ZEXPORT unzOpen (const char *path)
{
return unzOpenInternal(path, NULL, 0);
}
extern unzFile ZEXPORT unzOpen64(const void *path) {
extern unzFile ZEXPORT unzOpen64 (const void *path)
{
return unzOpenInternal(path, NULL, 1);
}
@@ -708,7 +805,8 @@ extern unzFile ZEXPORT unzOpen64(const void *path) {
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
these files MUST be closed with unzCloseCurrentFile before call unzClose.
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzClose(unzFile file) {
extern int ZEXPORT unzClose (unzFile file)
{
unz64_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
@@ -718,7 +816,7 @@ extern int ZEXPORT unzClose(unzFile file) {
unzCloseCurrentFile(file);
ZCLOSE64(s->z_filefunc, s->filestream);
free(s);
TRYFREE(s);
return UNZ_OK;
}
@@ -727,7 +825,8 @@ extern int ZEXPORT unzClose(unzFile file) {
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64* pglobal_info) {
extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
{
unz64_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
@@ -736,7 +835,8 @@ extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64* pglobal_i
return UNZ_OK;
}
extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32) {
extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
{
unz64_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
@@ -747,9 +847,10 @@ extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info3
return UNZ_OK;
}
/*
Translate date/time from Dos format to tm_unz (readable more easily)
Translate date/time from Dos format to tm_unz (readable more easilty)
*/
local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz* ptm) {
local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
{
ZPOS64_T uDate;
uDate = (ZPOS64_T)(ulDosDate>>16);
ptm->tm_mday = (int)(uDate&0x1f) ;
@@ -764,16 +865,28 @@ local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz* ptm) {
/*
Get Info about the current file in the zipfile, with internal only info
*/
local int unz64local_GetCurrentFileInfoInternal(unzFile file,
unz_file_info64 *pfile_info,
unz_file_info64_internal
*pfile_info_internal,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize) {
local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
unz_file_info64 *pfile_info,
unz_file_info64_internal
*pfile_info_internal,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize));
local int unz64local_GetCurrentFileInfoInternal (unzFile file,
unz_file_info64 *pfile_info,
unz_file_info64_internal
*pfile_info_internal,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize)
{
unz64_s* s;
unz_file_info64 file_info;
unz_file_info64_internal file_info_internal;
@@ -925,31 +1038,33 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
/* ZIP64 extra fields */
if (headerId == 0x0001)
{
if(file_info.uncompressed_size == MAXU32)
{
if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
err=UNZ_ERRNO;
}
uLong uL;
if(file_info.compressed_size == MAXU32)
{
if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
err=UNZ_ERRNO;
}
if(file_info.uncompressed_size == MAXU32)
{
if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
err=UNZ_ERRNO;
}
if(file_info_internal.offset_curfile == MAXU32)
{
/* Relative Header offset */
if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
err=UNZ_ERRNO;
}
if(file_info.compressed_size == MAXU32)
{
if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
err=UNZ_ERRNO;
}
if(file_info.disk_num_start == 0xffff)
{
/* Disk Start Number */
if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
err=UNZ_ERRNO;
}
if(file_info_internal.offset_curfile == MAXU32)
{
/* Relative Header offset */
if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
err=UNZ_ERRNO;
}
if(file_info.disk_num_start == MAXU32)
{
/* Disk Start Number */
if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
err=UNZ_ERRNO;
}
}
else
@@ -1006,22 +1121,24 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
No preparation of the structure is needed
return UNZ_OK if there is no problem.
*/
extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file,
unz_file_info64 * pfile_info,
char * szFileName, uLong fileNameBufferSize,
void *extraField, uLong extraFieldBufferSize,
char* szComment, uLong commentBufferSize) {
extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
unz_file_info64 * pfile_info,
char * szFileName, uLong fileNameBufferSize,
void *extraField, uLong extraFieldBufferSize,
char* szComment, uLong commentBufferSize)
{
return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
szFileName,fileNameBufferSize,
extraField,extraFieldBufferSize,
szComment,commentBufferSize);
szFileName,fileNameBufferSize,
extraField,extraFieldBufferSize,
szComment,commentBufferSize);
}
extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
unz_file_info * pfile_info,
char * szFileName, uLong fileNameBufferSize,
void *extraField, uLong extraFieldBufferSize,
char* szComment, uLong commentBufferSize) {
extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
unz_file_info * pfile_info,
char * szFileName, uLong fileNameBufferSize,
void *extraField, uLong extraFieldBufferSize,
char* szComment, uLong commentBufferSize)
{
int err;
unz_file_info64 file_info64;
err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
@@ -1045,7 +1162,7 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
pfile_info->internal_fa = file_info64.internal_fa;
pfile_info->external_fa = file_info64.external_fa;
pfile_info->tmu_date = file_info64.tmu_date;
pfile_info->tmu_date = file_info64.tmu_date,
pfile_info->compressed_size = (uLong)file_info64.compressed_size;
@@ -1058,7 +1175,8 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
Set the current file of the zipfile to the first file.
return UNZ_OK if there is no problem
*/
extern int ZEXPORT unzGoToFirstFile(unzFile file) {
extern int ZEXPORT unzGoToFirstFile (unzFile file)
{
int err=UNZ_OK;
unz64_s* s;
if (file==NULL)
@@ -1078,7 +1196,8 @@ extern int ZEXPORT unzGoToFirstFile(unzFile file) {
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
extern int ZEXPORT unzGoToNextFile(unzFile file) {
extern int ZEXPORT unzGoToNextFile (unzFile file)
{
unz64_s* s;
int err;
@@ -1110,7 +1229,8 @@ extern int ZEXPORT unzGoToNextFile(unzFile file) {
UNZ_OK if the file is found. It becomes the current file.
UNZ_END_OF_LIST_OF_FILE if the file is not found
*/
extern int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity) {
extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
{
unz64_s* s;
int err;
@@ -1185,7 +1305,8 @@ typedef struct unz_file_pos_s
} unz_file_pos;
*/
extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) {
extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos)
{
unz64_s* s;
if (file==NULL || file_pos==NULL)
@@ -1200,7 +1321,10 @@ extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) {
return UNZ_OK;
}
extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos) {
extern int ZEXPORT unzGetFilePos(
unzFile file,
unz_file_pos* file_pos)
{
unz64_file_pos file_pos64;
int err = unzGetFilePos64(file,&file_pos64);
if (err==UNZ_OK)
@@ -1211,7 +1335,8 @@ extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos) {
return err;
}
extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) {
extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
{
unz64_s* s;
int err;
@@ -1232,7 +1357,10 @@ extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos
return err;
}
extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) {
extern int ZEXPORT unzGoToFilePos(
unzFile file,
unz_file_pos* file_pos)
{
unz64_file_pos file_pos64;
if (file_pos == NULL)
return UNZ_PARAMERROR;
@@ -1254,9 +1382,10 @@ extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) {
store in *piSizeVar the size of extra info in local header
(filename and size of extra field data)
*/
local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar,
ZPOS64_T * poffset_local_extrafield,
uInt * psize_local_extrafield) {
local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
ZPOS64_T * poffset_local_extrafield,
uInt * psize_local_extrafield)
{
uLong uMagic,uData,uFlags;
uLong size_filename;
uLong size_extra_field;
@@ -1340,8 +1469,9 @@ local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar
Open for reading data the current file in the zipfile.
If there is no error and the file is opened, the return value is UNZ_OK.
*/
extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
int* level, int raw, const char* password) {
extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
int* level, int raw, const char* password)
{
int err=UNZ_OK;
uInt iSizeVar;
unz64_s* s;
@@ -1379,7 +1509,7 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
if (pfile_in_zip_read_info->read_buffer==NULL)
{
free(pfile_in_zip_read_info);
TRYFREE(pfile_in_zip_read_info);
return UNZ_INTERNALERROR;
}
@@ -1436,8 +1566,8 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
else
{
free(pfile_in_zip_read_info->read_buffer);
free(pfile_in_zip_read_info);
TRYFREE(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info);
return err;
}
#else
@@ -1457,8 +1587,8 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
else
{
free(pfile_in_zip_read_info->read_buffer);
free(pfile_in_zip_read_info);
TRYFREE(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info);
return err;
}
/* windowBits is passed < 0 to tell that there is no zlib header.
@@ -1510,21 +1640,25 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
return UNZ_OK;
}
extern int ZEXPORT unzOpenCurrentFile(unzFile file) {
extern int ZEXPORT unzOpenCurrentFile (unzFile file)
{
return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
}
extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char* password) {
extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password)
{
return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
}
extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int* method, int* level, int raw) {
extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)
{
return unzOpenCurrentFile3(file, method, level, raw, NULL);
}
/** Addition for GDAL : START */
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) {
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
s=(unz64_s*)file;
@@ -1544,12 +1678,13 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) {
buf contain buffer where data must be copied
len the size of buf.
return the number of byte copied if some bytes are copied
return the number of byte copied if somes bytes are copied
return 0 if the end of file was reached
return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
{
int err=UNZ_OK;
uInt iRead = 0;
unz64_s* s;
@@ -1756,7 +1891,8 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
/*
Give the current position in uncompressed data
*/
extern z_off_t ZEXPORT unztell(unzFile file) {
extern z_off_t ZEXPORT unztell (unzFile file)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
@@ -1770,7 +1906,8 @@ extern z_off_t ZEXPORT unztell(unzFile file) {
return (z_off_t)pfile_in_zip_read_info->stream.total_out;
}
extern ZPOS64_T ZEXPORT unztell64(unzFile file) {
extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
@@ -1789,7 +1926,8 @@ extern ZPOS64_T ZEXPORT unztell64(unzFile file) {
/*
return 1 if the end of file was reached, 0 elsewhere
*/
extern int ZEXPORT unzeof(unzFile file) {
extern int ZEXPORT unzeof (unzFile file)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
@@ -1820,7 +1958,8 @@ more info in the local-header version than in the central-header)
the return value is the number of bytes copied in buf, or (if <0)
the error code
*/
extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len) {
extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
{
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
uInt read_now;
@@ -1867,7 +2006,8 @@ extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len)
Close the file in zip opened with unzOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
extern int ZEXPORT unzCloseCurrentFile(unzFile file) {
extern int ZEXPORT unzCloseCurrentFile (unzFile file)
{
int err=UNZ_OK;
unz64_s* s;
@@ -1889,7 +2029,7 @@ extern int ZEXPORT unzCloseCurrentFile(unzFile file) {
}
free(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info->read_buffer);
pfile_in_zip_read_info->read_buffer = NULL;
if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
inflateEnd(&pfile_in_zip_read_info->stream);
@@ -1900,7 +2040,7 @@ extern int ZEXPORT unzCloseCurrentFile(unzFile file) {
pfile_in_zip_read_info->stream_initialised = 0;
free(pfile_in_zip_read_info);
TRYFREE(pfile_in_zip_read_info);
s->pfile_in_zip_read=NULL;
@@ -1913,7 +2053,8 @@ extern int ZEXPORT unzCloseCurrentFile(unzFile file) {
uSizeBuf is the size of the szComment buffer.
return the number of byte copied or an error code <0
*/
extern int ZEXPORT unzGetGlobalComment(unzFile file, char * szComment, uLong uSizeBuf) {
extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
{
unz64_s* s;
uLong uReadThis ;
if (file==NULL)
@@ -1940,7 +2081,8 @@ extern int ZEXPORT unzGetGlobalComment(unzFile file, char * szComment, uLong uSi
}
/* Additions by RX '2004 */
extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) {
extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
{
unz64_s* s;
if (file==NULL)
@@ -1954,7 +2096,8 @@ extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) {
return s->pos_in_central_dir;
}
extern uLong ZEXPORT unzGetOffset(unzFile file) {
extern uLong ZEXPORT unzGetOffset (unzFile file)
{
ZPOS64_T offset64;
if (file==NULL)
@@ -1963,7 +2106,8 @@ extern uLong ZEXPORT unzGetOffset(unzFile file) {
return (uLong)offset64;
}
extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) {
extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
{
unz64_s* s;
int err;
@@ -1980,6 +2124,7 @@ extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) {
return err;
}
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) {
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
{
return unzSetOffset64(file,pos);
}
+67 -67
View File
@@ -150,21 +150,21 @@ typedef struct unz_file_info_s
tm_unz tmu_date;
} unz_file_info;
extern int ZEXPORT unzStringFileNameCompare(const char* fileName1,
const char* fileName2,
int iCaseSensitivity);
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
const char* fileName2,
int iCaseSensitivity));
/*
Compare two filenames (fileName1,fileName2).
If iCaseSensitivity = 1, comparison is case sensitive (like strcmp)
If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
or strcasecmp)
If iCaseSensitivity = 0, case sensitivity is default of your operating system
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
(like 1 on Unix, 2 on Windows)
*/
extern unzFile ZEXPORT unzOpen(const char *path);
extern unzFile ZEXPORT unzOpen64(const void *path);
extern unzFile ZEXPORT unzOpen OF((const char *path));
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
@@ -181,41 +181,41 @@ extern unzFile ZEXPORT unzOpen64(const void *path);
*/
extern unzFile ZEXPORT unzOpen2(const char *path,
zlib_filefunc_def* pzlib_filefunc_def);
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
zlib_filefunc_def* pzlib_filefunc_def));
/*
Open a Zip file, like unzOpen, but provide a set of file low level API
for read/write the zip file (see ioapi.h)
*/
extern unzFile ZEXPORT unzOpen2_64(const void *path,
zlib_filefunc64_def* pzlib_filefunc_def);
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
zlib_filefunc64_def* pzlib_filefunc_def));
/*
Open a Zip file, like unz64Open, but provide a set of file low level API
for read/write the zip file (see ioapi.h)
*/
extern int ZEXPORT unzClose(unzFile file);
extern int ZEXPORT unzClose OF((unzFile file));
/*
Close a ZipFile opened with unzOpen.
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
these files MUST be closed with unzCloseCurrentFile before call unzClose.
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo(unzFile file,
unz_global_info *pglobal_info);
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
unz_global_info *pglobal_info));
extern int ZEXPORT unzGetGlobalInfo64(unzFile file,
unz_global_info64 *pglobal_info);
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
unz_global_info64 *pglobal_info));
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalComment(unzFile file,
char *szComment,
uLong uSizeBuf);
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
char *szComment,
uLong uSizeBuf));
/*
Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer.
@@ -226,22 +226,22 @@ extern int ZEXPORT unzGetGlobalComment(unzFile file,
/***************************************************************************/
/* Unzip package allow you browse the directory of the zipfile */
extern int ZEXPORT unzGoToFirstFile(unzFile file);
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
/*
Set the current file of the zipfile to the first file.
return UNZ_OK if there is no problem
*/
extern int ZEXPORT unzGoToNextFile(unzFile file);
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
/*
Set the current file of the zipfile to the next file.
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
extern int ZEXPORT unzLocateFile(unzFile file,
const char *szFileName,
int iCaseSensitivity);
extern int ZEXPORT unzLocateFile OF((unzFile file,
const char *szFileName,
int iCaseSensitivity));
/*
Try locate the file szFileName in the zipfile.
For the iCaseSensitivity signification, see unzStringFileNameCompare
@@ -285,26 +285,26 @@ extern int ZEXPORT unzGoToFilePos64(
/* ****************************************** */
extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file,
unz_file_info64 *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize);
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
unz_file_info64 *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize));
extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
unz_file_info *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize);
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
unz_file_info *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize));
/*
Get Info about the current file
if pfile_info!=NULL, the *pfile_info structure will contain some info about
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
the current file
if szFileName!=NULL, the filemane string will be copied in szFileName
(fileNameBufferSize is the size of the buffer)
@@ -318,7 +318,7 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
/** Addition for GDAL : START */
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file);
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
/** Addition for GDAL : END */
@@ -328,24 +328,24 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file);
from it, and close it (you can close it before reading all the file)
*/
extern int ZEXPORT unzOpenCurrentFile(unzFile file);
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
/*
Open for reading data the current file in the zipfile.
If there is no error, the return value is UNZ_OK.
*/
extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file,
const char* password);
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
const char* password));
/*
Open for reading data the current file in the zipfile.
password is a crypting password
If there is no error, the return value is UNZ_OK.
*/
extern int ZEXPORT unzOpenCurrentFile2(unzFile file,
int* method,
int* level,
int raw);
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
int* method,
int* level,
int raw));
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
@@ -355,11 +355,11 @@ extern int ZEXPORT unzOpenCurrentFile2(unzFile file,
but you CANNOT set method parameter as NULL
*/
extern int ZEXPORT unzOpenCurrentFile3(unzFile file,
int* method,
int* level,
int raw,
const char* password);
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
int* method,
int* level,
int raw,
const char* password));
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
@@ -370,41 +370,41 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file,
*/
extern int ZEXPORT unzCloseCurrentFile(unzFile file);
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
/*
Close the file in zip opened with unzOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
extern int ZEXPORT unzReadCurrentFile(unzFile file,
voidp buf,
unsigned len);
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
voidp buf,
unsigned len));
/*
Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied
len the size of buf.
return the number of byte copied if some bytes are copied
return the number of byte copied if somes bytes are copied
return 0 if the end of file was reached
return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
extern z_off_t ZEXPORT unztell(unzFile file);
extern z_off_t ZEXPORT unztell OF((unzFile file));
extern ZPOS64_T ZEXPORT unztell64(unzFile file);
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
/*
Give the current position in uncompressed data
*/
extern int ZEXPORT unzeof(unzFile file);
extern int ZEXPORT unzeof OF((unzFile file));
/*
return 1 if the end of file was reached, 0 elsewhere
*/
extern int ZEXPORT unzGetLocalExtrafield(unzFile file,
voidp buf,
unsigned len);
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
voidp buf,
unsigned len));
/*
Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
+186 -129
View File
@@ -14,7 +14,7 @@
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions.
Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data
It is used when recreating zip archive with RAW when deleting items from a zip.
It is used when recreting zip archive with RAW when deleting items from a zip.
ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed.
Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required)
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
@@ -25,13 +25,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <time.h>
#include "zlib.h"
#include "zip.h"
#ifdef STDC
# include <stddef.h>
# include <string.h>
# include <stdlib.h>
#endif
#ifdef NO_ERRNO_H
extern int errno;
@@ -46,7 +47,7 @@
/* compile with -Dlocal if your debugger can't find static symbols */
#ifndef VERSIONMADEBY
# define VERSIONMADEBY (0x0) /* platform dependent */
# define VERSIONMADEBY (0x0) /* platform depedent */
#endif
#ifndef Z_BUFSIZE
@@ -60,6 +61,9 @@
#ifndef ALLOC
# define ALLOC(size) (malloc(size))
#endif
#ifndef TRYFREE
# define TRYFREE(p) {if (p) free(p);}
#endif
/*
#define SIZECENTRALDIRITEM (0x2e)
@@ -134,20 +138,20 @@ typedef struct
uInt pos_in_buffered_data; /* last written byte in buffered_data */
ZPOS64_T pos_local_header; /* offset of the local header of the file
currently writing */
currenty writing */
char* central_header; /* central header data for the current file */
uLong size_centralExtra;
uLong size_centralheader; /* size of the central header for cur file */
uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */
uLong flag; /* flag of the file currently writing */
int method; /* compression method of file currently wr.*/
int method; /* compression method of file currenty wr.*/
int raw; /* 1 for directly writing raw data */
Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
uLong dosDate;
uLong crc32;
int encrypt;
int zip64; /* Add ZIP64 extended information in the extra field */
int zip64; /* Add ZIP64 extened information in the extra field */
ZPOS64_T pos_zip64extrainfo;
ZPOS64_T totalCompressedData;
ZPOS64_T totalUncompressedData;
@@ -161,10 +165,10 @@ typedef struct
typedef struct
{
zlib_filefunc64_32_def z_filefunc;
voidpf filestream; /* io structure of the zipfile */
voidpf filestream; /* io structore of the zipfile */
linkedlist_data central_dir;/* datablock with central dir in construction*/
int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/
curfile64_info ci; /* info on the file currently writing */
curfile64_info ci; /* info on the file curretly writing */
ZPOS64_T begin_pos; /* position of the beginning of the zipfile */
ZPOS64_T add_position_when_writing_offset;
@@ -182,7 +186,8 @@ typedef struct
#include "crypt.h"
#endif
local linkedlist_datablock_internal* allocate_new_datablock(void) {
local linkedlist_datablock_internal* allocate_new_datablock()
{
linkedlist_datablock_internal* ldi;
ldi = (linkedlist_datablock_internal*)
ALLOC(sizeof(linkedlist_datablock_internal));
@@ -195,26 +200,30 @@ local linkedlist_datablock_internal* allocate_new_datablock(void) {
return ldi;
}
local void free_datablock(linkedlist_datablock_internal* ldi) {
local void free_datablock(linkedlist_datablock_internal* ldi)
{
while (ldi!=NULL)
{
linkedlist_datablock_internal* ldinext = ldi->next_datablock;
free(ldi);
TRYFREE(ldi);
ldi = ldinext;
}
}
local void init_linkedlist(linkedlist_data* ll) {
local void init_linkedlist(linkedlist_data* ll)
{
ll->first_block = ll->last_block = NULL;
}
local void free_linkedlist(linkedlist_data* ll) {
local void free_linkedlist(linkedlist_data* ll)
{
free_datablock(ll->first_block);
ll->first_block = ll->last_block = NULL;
}
local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) {
local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
{
linkedlist_datablock_internal* ldi;
const unsigned char* from_copy;
@@ -229,7 +238,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
}
ldi = ll->last_block;
from_copy = (const unsigned char*)buf;
from_copy = (unsigned char*)buf;
while (len>0)
{
@@ -274,7 +283,9 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T)
*/
local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) {
local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte));
local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
{
unsigned char buf[8];
int n;
for (n = 0; n < nbByte; n++)
@@ -296,7 +307,9 @@ local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def,
return ZIP_OK;
}
local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) {
local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte));
local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
{
unsigned char* buf=(unsigned char*)dest;
int n;
for (n = 0; n < nbByte; n++) {
@@ -316,7 +329,8 @@ local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) {
/****************************************************************************/
local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) {
local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)
{
uLong year = (uLong)ptm->tm_year;
if (year>=1980)
year-=1980;
@@ -330,7 +344,10 @@ local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) {
/****************************************************************************/
local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int* pi) {
local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi));
local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi)
{
unsigned char c;
int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
if (err==1)
@@ -351,7 +368,10 @@ local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, v
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets
*/
local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) {
local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));
local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
{
uLong x ;
int i = 0;
int err;
@@ -370,7 +390,10 @@ local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def,
return err;
}
local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) {
local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));
local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
{
uLong x ;
int i = 0;
int err;
@@ -397,8 +420,11 @@ local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, v
return err;
}
local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX));
local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) {
local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
{
ZPOS64_T x;
int i = 0;
int err;
@@ -449,7 +475,10 @@ local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
Locate the Central directory of a zipfile (at the end, just before
the global comment)
*/
local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf;
ZPOS64_T uSizeFile;
ZPOS64_T uBackRead;
@@ -500,7 +529,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
if (uPosFound!=0)
break;
}
free(buf);
TRYFREE(buf);
return uPosFound;
}
@@ -508,7 +537,10 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before
the global comment)
*/
local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) {
local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf;
ZPOS64_T uSizeFile;
ZPOS64_T uBackRead;
@@ -563,7 +595,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
break;
}
free(buf);
TRYFREE(buf);
if (uPosFound == 0)
return 0;
@@ -605,7 +637,8 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
return relativeOffset;
}
local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
local int LoadCentralDirectoryRecord(zip64_internal* pziinit)
{
int err=ZIP_OK;
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
@@ -615,9 +648,9 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
uLong uL;
uLong number_disk; /* number of the current dist, used for
spanning ZIP, unsupported, always 0*/
spaning ZIP, unsupported, always 0*/
uLong number_disk_with_CD; /* number the the disk with central dir, used
for spanning ZIP, unsupported, always 0*/
for spaning ZIP, unsupported, always 0*/
ZPOS64_T number_entry;
ZPOS64_T number_entry_CD; /* total number of entries in
the central dir
@@ -797,7 +830,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
size_central_dir_to_read-=read_this;
}
free(buf_read);
TRYFREE(buf_read);
}
pziinit->begin_pos = byte_before_the_zipfile;
pziinit->number_entry = number_entry_CD;
@@ -813,7 +846,8 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
/************************************************************/
extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) {
extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def)
{
zip64_internal ziinit;
zip64_internal* zi;
int err=ZIP_OK;
@@ -871,9 +905,9 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
if (err != ZIP_OK)
{
# ifndef NO_ADDFILEINEXISTINGZIP
free(ziinit.globalcomment);
TRYFREE(ziinit.globalcomment);
# endif /* !NO_ADDFILEINEXISTINGZIP*/
free(zi);
TRYFREE(zi);
return NULL;
}
else
@@ -883,7 +917,8 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
}
}
extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) {
extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def)
{
if (pzlib_filefunc32_def != NULL)
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -894,7 +929,8 @@ extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* glo
return zipOpen3(pathname, append, globalcomment, NULL);
}
extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) {
extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def)
{
if (pzlib_filefunc_def != NULL)
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
@@ -909,15 +945,18 @@ extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc*
extern zipFile ZEXPORT zipOpen(const char* pathname, int append) {
extern zipFile ZEXPORT zipOpen (const char* pathname, int append)
{
return zipOpen3((const void*)pathname,append,NULL,NULL);
}
extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) {
extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append)
{
return zipOpen3(pathname,append,NULL,NULL);
}
local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) {
local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
{
/* write the local header */
int err;
uInt size_filename = (uInt)strlen(filename);
@@ -1013,13 +1052,14 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize
unnecessary allocations.
*/
extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting,
uLong versionMadeBy, uLong flagBase, int zip64) {
extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting,
uLong versionMadeBy, uLong flagBase, int zip64)
{
zip64_internal* zi;
uInt size_filename;
uInt size_comment;
@@ -1222,33 +1262,35 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
return err;
}
extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting,
uLong versionMadeBy, uLong flagBase) {
return zipOpenNewFileInZip4_64(file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
windowBits, memLevel, strategy,
password, crcForCrypting, versionMadeBy, flagBase, 0);
extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting,
uLong versionMadeBy, uLong flagBase)
{
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
windowBits, memLevel, strategy,
password, crcForCrypting, versionMadeBy, flagBase, 0);
}
extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting) {
return zipOpenNewFileInZip4_64(file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
windowBits, memLevel, strategy,
password, crcForCrypting, VERSIONMADEBY, 0, 0);
extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting)
{
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
windowBits, memLevel, strategy,
password, crcForCrypting, VERSIONMADEBY, 0, 0);
}
extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
@@ -1256,64 +1298,70 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, c
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw,
int windowBits,int memLevel, int strategy,
const char* password, uLong crcForCrypting, int zip64) {
return zipOpenNewFileInZip4_64(file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
windowBits, memLevel, strategy,
password, crcForCrypting, VERSIONMADEBY, 0, zip64);
const char* password, uLong crcForCrypting, int zip64)
{
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
windowBits, memLevel, strategy,
password, crcForCrypting, VERSIONMADEBY, 0, zip64);
}
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw) {
return zipOpenNewFileInZip4_64(file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
NULL, 0, VERSIONMADEBY, 0, 0);
const char* comment, int method, int level, int raw)
{
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
NULL, 0, VERSIONMADEBY, 0, 0);
}
extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw, int zip64) {
return zipOpenNewFileInZip4_64(file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
NULL, 0, VERSIONMADEBY, 0, zip64);
const void* extrafield_local, uInt size_extrafield_local,
const void* extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int raw, int zip64)
{
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
NULL, 0, VERSIONMADEBY, 0, zip64);
}
extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void*extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int zip64) {
return zipOpenNewFileInZip4_64(file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, 0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
NULL, 0, VERSIONMADEBY, 0, zip64);
extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void*extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level, int zip64)
{
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, 0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
NULL, 0, VERSIONMADEBY, 0, zip64);
}
extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void*extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level) {
return zipOpenNewFileInZip4_64(file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, 0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
NULL, 0, VERSIONMADEBY, 0, 0);
extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi,
const void* extrafield_local, uInt size_extrafield_local,
const void*extrafield_global, uInt size_extrafield_global,
const char* comment, int method, int level)
{
return zipOpenNewFileInZip4_64 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, 0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
NULL, 0, VERSIONMADEBY, 0, 0);
}
local int zip64FlushWriteBuffer(zip64_internal* zi) {
local int zip64FlushWriteBuffer(zip64_internal* zi)
{
int err=ZIP_OK;
if (zi->ci.encrypt != 0)
@@ -1351,7 +1399,8 @@ local int zip64FlushWriteBuffer(zip64_internal* zi) {
return err;
}
extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) {
extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len)
{
zip64_internal* zi;
int err=ZIP_OK;
@@ -1401,7 +1450,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
else
#endif
{
zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf;
zi->ci.stream.next_in = (Bytef*)buf;
zi->ci.stream.avail_in = len;
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
@@ -1452,11 +1501,13 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
return err;
}
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) {
extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32)
{
return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32);
}
extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32) {
extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32)
{
zip64_internal* zi;
ZPOS64_T compressed_size;
uLong invalidValue = 0xffffffff;
@@ -1691,11 +1742,13 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
return err;
}
extern int ZEXPORT zipCloseFileInZip(zipFile file) {
extern int ZEXPORT zipCloseFileInZip (zipFile file)
{
return zipCloseFileInZipRaw (file,0,0);
}
local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) {
local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
{
int err = ZIP_OK;
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
@@ -1716,7 +1769,8 @@ local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T z
return err;
}
local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
{
int err = ZIP_OK;
uLong Zip64DataSize = 44;
@@ -1754,8 +1808,8 @@ local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_
}
return err;
}
local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) {
local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
{
int err = ZIP_OK;
/*signature*/
@@ -1802,7 +1856,8 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr
return err;
}
local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) {
local int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
{
int err = ZIP_OK;
uInt size_global_comment = 0;
@@ -1819,7 +1874,8 @@ local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) {
return err;
}
extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
{
zip64_internal* zi;
int err = 0;
uLong size_centraldir = 0;
@@ -1880,14 +1936,15 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
err = ZIP_ERRNO;
#ifndef NO_ADDFILEINEXISTINGZIP
free(zi->globalcomment);
TRYFREE(zi->globalcomment);
#endif
free(zi);
TRYFREE(zi);
return err;
}
extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader) {
extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader)
{
char* p = pData;
int size = 0;
char* pNewHeader;
@@ -1939,7 +1996,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
else
retVal = ZIP_ERRNO;
free(pNewHeader);
TRYFREE(pNewHeader);
return retVal;
}
+144 -141
View File
@@ -113,8 +113,8 @@ typedef const char* zipcharpc;
#define APPEND_STATUS_CREATEAFTER (1)
#define APPEND_STATUS_ADDINZIP (2)
extern zipFile ZEXPORT zipOpen(const char *pathname, int append);
extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
/*
Create a zipfile.
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
@@ -131,46 +131,46 @@ extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
/* Note : there is no delete function into a zipfile.
If you want delete file into a zipfile, you must open a zipfile, and create another
Of course, you can use RAW reading and writing to copy the file you did not want delete
Of couse, you can use RAW reading and writing to copy the file you did not want delte
*/
extern zipFile ZEXPORT zipOpen2(const char *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc_def* pzlib_filefunc_def);
extern zipFile ZEXPORT zipOpen2_64(const void *pathname,
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc64_def* pzlib_filefunc_def);
zlib_filefunc_def* pzlib_filefunc_def));
extern zipFile ZEXPORT zipOpen3(const void *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc64_32_def* pzlib_filefunc64_32_def);
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc64_def* pzlib_filefunc_def));
extern int ZEXPORT zipOpenNewFileInZip(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level);
extern zipFile ZEXPORT zipOpen3 OF((const void *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc64_32_def* pzlib_filefunc64_32_def));
extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int zip64);
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level));
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int zip64));
/*
Open a file in the ZIP for writing.
@@ -189,69 +189,70 @@ extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
*/
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw);
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw));
extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int zip64);
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int zip64));
/*
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
*/
extern int ZEXPORT zipOpenNewFileInZip3(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting);
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting));
extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
int zip64);
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
int zip64
));
/*
Same than zipOpenNewFileInZip2, except
@@ -260,45 +261,47 @@ extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file,
crcForCrypting : crc of file to compress (needed for crypting)
*/
extern int ZEXPORT zipOpenNewFileInZip4(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
uLong versionMadeBy,
uLong flagBase);
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
uLong versionMadeBy,
uLong flagBase
));
extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
uLong versionMadeBy,
uLong flagBase,
int zip64);
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
uLong versionMadeBy,
uLong flagBase,
int zip64
));
/*
Same than zipOpenNewFileInZip4, except
versionMadeBy : value for Version made by field
@@ -306,25 +309,25 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file,
*/
extern int ZEXPORT zipWriteInFileInZip(zipFile file,
const void* buf,
unsigned len);
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
const void* buf,
unsigned len));
/*
Write data in the zipfile
*/
extern int ZEXPORT zipCloseFileInZip(zipFile file);
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
/*
Close the current file in the zipfile
*/
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,
uLong uncompressed_size,
uLong crc32);
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
uLong uncompressed_size,
uLong crc32));
extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
ZPOS64_T uncompressed_size,
uLong crc32);
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
ZPOS64_T uncompressed_size,
uLong crc32));
/*
Close the current file in the zipfile, for file opened with
@@ -332,14 +335,14 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
uncompressed_size and crc32 are value for the uncompressed size
*/
extern int ZEXPORT zipClose(zipFile file,
const char* global_comment);
extern int ZEXPORT zipClose OF((zipFile file,
const char* global_comment));
/*
Close the zipfile
*/
extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader);
extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
/*
zipRemoveExtraInfoBlock - Added by Mathias Svensson
+1 -1
View File
@@ -10,7 +10,7 @@ unit zlibpas;
interface
const
ZLIB_VERSION = '1.3.0';
ZLIB_VERSION = '1.2.13';
ZLIB_VERNUM = $12a0;
type
+1 -1
View File
@@ -169,7 +169,7 @@ int main(int argc, char *argv[])
printf("error reading %s\n",argv[1]);
return 1;
}
else printf("file %s read, %ld bytes\n",argv[1],lFileSize);
else printf("file %s read, %u bytes\n",argv[1],lFileSize);
if (argc>=3)
BlockSizeCompress=atol(argv[2]);
+35 -28
View File
@@ -4,22 +4,6 @@
* written by Pedro A. Aranda Gutierrez <paag@tid.es>
* adaptation to Unix by Jean-loup Gailly <jloup@gzip.org>
* various fixes by Cosmin Truta <cosmint@cs.ubbcluj.ro>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#include <stdio.h>
@@ -30,10 +14,15 @@
#include "zlib.h"
#ifdef _WIN32
#ifdef unix
# include <unistd.h>
#else
# include <direct.h>
# include <io.h>
# include <windows.h>
#endif
#ifdef WIN32
#include <windows.h>
# ifndef F_OK
# define F_OK 0
# endif
@@ -44,8 +33,6 @@
# define strdup(str) _strdup(str)
# endif
#else
# include <sys/stat.h>
# include <unistd.h>
# include <utime.h>
#endif
@@ -115,13 +102,27 @@ struct attr_item
enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID };
char *prog;
char *TGZfname OF((const char *));
void TGZnotfound OF((const char *));
void error(const char *msg)
{
fprintf(stderr, "%s: %s\n", prog, msg);
exit(1);
}
int getoct OF((char *, int));
char *strtime OF((time_t *));
int setfiletime OF((char *, time_t));
void push_attr OF((struct attr_item **, char *, int, time_t));
void restore_attr OF((struct attr_item **));
int ExprMatch OF((char *, char *));
int makedir OF((char *));
int matchname OF((int, int, char **, char *));
void error OF((const char *));
int tar OF((gzFile, int, int, int, char **));
void help OF((int));
int main OF((int, char **));
char *prog;
const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL };
@@ -204,7 +205,7 @@ char *strtime (time_t *t)
int setfiletime (char *fname,time_t ftime)
{
#ifdef _WIN32
#ifdef WIN32
static int isWinNT = -1;
SYSTEMTIME st;
FILETIME locft, modft;
@@ -589,6 +590,12 @@ void help(int exitval)
exit(exitval);
}
void error(const char *msg)
{
fprintf(stderr, "%s: %s\n", prog, msg);
exit(1);
}
/* ============================================================ */
@@ -601,7 +608,7 @@ int main(int argc,char **argv)
int action = TGZ_EXTRACT;
int arg = 1;
char *TGZfile;
gzFile f;
gzFile *f;
prog = strrchr(argv[0],'\\');
if (prog == NULL)
+1 -1
View File
@@ -1,4 +1,4 @@
Building instructions for the DLL versions of Zlib 1.3.0
Building instructions for the DLL versions of Zlib 1.2.13
========================================================
This directory contains projects that build zlib and minizip using
+4 -4
View File
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 3, 0, 0
FILEVERSION 1, 2, 13, 0
PRODUCTVERSION 1, 2, 13, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.0\0"
VALUE "FileVersion", "1.2.13\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
+1 -1
View File
@@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3
VERSION 1.2
EXPORTS
adler32 @1
+4 -4
View File
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 3, 0, 0
FILEVERSION 1, 2, 13, 0
PRODUCTVERSION 1, 2, 13, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.0\0"
VALUE "FileVersion", "1.2.13\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
+1 -1
View File
@@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3
VERSION 1.2
EXPORTS
adler32 @1
+4 -4
View File
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 3, 0, 0
FILEVERSION 1, 2, 13, 0
PRODUCTVERSION 1, 2, 13, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.0\0"
VALUE "FileVersion", "1.2.13\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
+1 -1
View File
@@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3
VERSION 1.2
EXPORTS
adler32 @1
+4 -4
View File
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 3, 0, 0
FILEVERSION 1, 2, 13, 0
PRODUCTVERSION 1, 2, 13, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.0\0"
VALUE "FileVersion", "1.2.13\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
+1 -1
View File
@@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3
VERSION 1.2
EXPORTS
adler32 @1
+4 -4
View File
@@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 3, 0, 0
FILEVERSION 1, 2, 13, 0
PRODUCTVERSION 1, 2, 13, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.0\0"
VALUE "FileVersion", "1.2.13\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0"
END
END
BLOCK "VarFileInfo"
+1 -1
View File
@@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3
VERSION 1.2
EXPORTS
adler32 @1
+162 -86
View File
@@ -103,6 +103,19 @@
# define ARMCRC32
#endif
/* Local functions. */
local z_crc_t multmodp OF((z_crc_t a, z_crc_t b));
local z_crc_t x2nmodp OF((z_off64_t n, unsigned k));
#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
local z_word_t byte_swap OF((z_word_t word));
#endif
#if defined(W) && !defined(ARMCRC32)
local z_crc_t crc_word OF((z_word_t data));
local z_word_t crc_word_big OF((z_word_t data));
#endif
#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
/*
Swap the bytes in a z_word_t to convert between little and big endian. Any
@@ -110,7 +123,9 @@
instruction, if one is available. This assumes that word_t is either 32 bits
or 64 bits.
*/
local z_word_t byte_swap(z_word_t word) {
local z_word_t byte_swap(word)
z_word_t word;
{
# if W == 8
return
(word & 0xff00000000000000) >> 56 |
@@ -131,77 +146,24 @@ local z_word_t byte_swap(z_word_t word) {
}
#endif
#ifdef DYNAMIC_CRC_TABLE
/* =========================================================================
* Table of powers of x for combining CRC-32s, filled in by make_crc_table()
* below.
*/
local z_crc_t FAR x2n_table[32];
#else
/* =========================================================================
* Tables for byte-wise and braided CRC-32 calculations, and a table of powers
* of x for combining CRC-32s, all made by make_crc_table().
*/
# include "crc32.h"
#endif
/* CRC polynomial. */
#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */
/*
Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
reflected. For speed, this requires that a not be zero.
*/
local z_crc_t multmodp(z_crc_t a, z_crc_t b) {
z_crc_t m, p;
m = (z_crc_t)1 << 31;
p = 0;
for (;;) {
if (a & m) {
p ^= b;
if ((a & (m - 1)) == 0)
break;
}
m >>= 1;
b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
}
return p;
}
/*
Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
initialized.
*/
local z_crc_t x2nmodp(z_off64_t n, unsigned k) {
z_crc_t p;
p = (z_crc_t)1 << 31; /* x^0 == 1 */
while (n) {
if (n & 1)
p = multmodp(x2n_table[k & 31], p);
n >>= 1;
k++;
}
return p;
}
#ifdef DYNAMIC_CRC_TABLE
/* =========================================================================
* Build the tables for byte-wise and braided CRC-32 calculations, and a table
* of powers of x for combining CRC-32s.
*/
local z_crc_t FAR crc_table[256];
local z_crc_t FAR x2n_table[32];
local void make_crc_table OF((void));
#ifdef W
local z_word_t FAR crc_big_table[256];
local z_crc_t FAR crc_braid_table[W][256];
local z_word_t FAR crc_braid_big_table[W][256];
local void braid(z_crc_t [][256], z_word_t [][256], int, int);
local void braid OF((z_crc_t [][256], z_word_t [][256], int, int));
#endif
#ifdef MAKECRCH
local void write_table(FILE *, const z_crc_t FAR *, int);
local void write_table32hi(FILE *, const z_word_t FAR *, int);
local void write_table64(FILE *, const z_word_t FAR *, int);
local void write_table OF((FILE *, const z_crc_t FAR *, int));
local void write_table32hi OF((FILE *, const z_word_t FAR *, int));
local void write_table64 OF((FILE *, const z_word_t FAR *, int));
#endif /* MAKECRCH */
/*
@@ -214,6 +176,7 @@ local z_crc_t FAR crc_table[256];
/* Definition of once functionality. */
typedef struct once_s once_t;
local void once OF((once_t *, void (*)(void)));
/* Check for the availability of atomics. */
#if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \
@@ -233,7 +196,10 @@ struct once_s {
invoke once() at the same time. The state must be a once_t initialized with
ONCE_INIT.
*/
local void once(once_t *state, void (*init)(void)) {
local void once(state, init)
once_t *state;
void (*init)(void);
{
if (!atomic_load(&state->done)) {
if (atomic_flag_test_and_set(&state->begun))
while (!atomic_load(&state->done))
@@ -256,7 +222,10 @@ struct once_s {
/* Test and set. Alas, not atomic, but tries to minimize the period of
vulnerability. */
local int test_and_set(int volatile *flag) {
local int test_and_set OF((int volatile *));
local int test_and_set(flag)
int volatile *flag;
{
int was;
was = *flag;
@@ -265,7 +234,10 @@ local int test_and_set(int volatile *flag) {
}
/* Run the provided init() function once. This is not thread-safe. */
local void once(once_t *state, void (*init)(void)) {
local void once(state, init)
once_t *state;
void (*init)(void);
{
if (!state->done) {
if (test_and_set(&state->begun))
while (!state->done)
@@ -307,7 +279,8 @@ local once_t made = ONCE_INIT;
combinations of CRC register values and incoming bytes.
*/
local void make_crc_table(void) {
local void make_crc_table()
{
unsigned i, j, n;
z_crc_t p;
@@ -474,7 +447,11 @@ local void make_crc_table(void) {
Write the 32-bit values in table[0..k-1] to out, five per line in
hexadecimal separated by commas.
*/
local void write_table(FILE *out, const z_crc_t FAR *table, int k) {
local void write_table(out, table, k)
FILE *out;
const z_crc_t FAR *table;
int k;
{
int n;
for (n = 0; n < k; n++)
@@ -487,7 +464,11 @@ local void write_table(FILE *out, const z_crc_t FAR *table, int k) {
Write the high 32-bits of each value in table[0..k-1] to out, five per line
in hexadecimal separated by commas.
*/
local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) {
local void write_table32hi(out, table, k)
FILE *out;
const z_word_t FAR *table;
int k;
{
int n;
for (n = 0; n < k; n++)
@@ -503,7 +484,11 @@ local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) {
bits. If not, then the type cast and format string can be adjusted
accordingly.
*/
local void write_table64(FILE *out, const z_word_t FAR *table, int k) {
local void write_table64(out, table, k)
FILE *out;
const z_word_t FAR *table;
int k;
{
int n;
for (n = 0; n < k; n++)
@@ -513,7 +498,8 @@ local void write_table64(FILE *out, const z_word_t FAR *table, int k) {
}
/* Actually do the deed. */
int main(void) {
int main()
{
make_crc_table();
return 0;
}
@@ -525,7 +511,12 @@ int main(void) {
Generate the little and big-endian braid tables for the given n and z_word_t
size w. Each array must have room for w blocks of 256 elements.
*/
local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) {
local void braid(ltl, big, n, w)
z_crc_t ltl[][256];
z_word_t big[][256];
int n;
int w;
{
int k;
z_crc_t i, p, q;
for (k = 0; k < w; k++) {
@@ -540,13 +531,69 @@ local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) {
}
#endif
#else /* !DYNAMIC_CRC_TABLE */
/* ========================================================================
* Tables for byte-wise and braided CRC-32 calculations, and a table of powers
* of x for combining CRC-32s, all made by make_crc_table().
*/
#include "crc32.h"
#endif /* DYNAMIC_CRC_TABLE */
/* ========================================================================
* Routines used for CRC calculation. Some are also required for the table
* generation above.
*/
/*
Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
reflected. For speed, this requires that a not be zero.
*/
local z_crc_t multmodp(a, b)
z_crc_t a;
z_crc_t b;
{
z_crc_t m, p;
m = (z_crc_t)1 << 31;
p = 0;
for (;;) {
if (a & m) {
p ^= b;
if ((a & (m - 1)) == 0)
break;
}
m >>= 1;
b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
}
return p;
}
/*
Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
initialized.
*/
local z_crc_t x2nmodp(n, k)
z_off64_t n;
unsigned k;
{
z_crc_t p;
p = (z_crc_t)1 << 31; /* x^0 == 1 */
while (n) {
if (n & 1)
p = multmodp(x2n_table[k & 31], p);
n >>= 1;
k++;
}
return p;
}
/* =========================================================================
* This function can be used by asm versions of crc32(), and to force the
* generation of the CRC tables in a threaded application.
*/
const z_crc_t FAR * ZEXPORT get_crc_table(void) {
const z_crc_t FAR * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
once(&made, make_crc_table);
#endif /* DYNAMIC_CRC_TABLE */
@@ -572,8 +619,11 @@ const z_crc_t FAR * ZEXPORT get_crc_table(void) {
#define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */
#define Z_BATCH_MIN 800 /* fewest words in a final batch */
unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
z_size_t len) {
unsigned long ZEXPORT crc32_z(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
z_size_t len;
{
z_crc_t val;
z_word_t crc1, crc2;
const z_word_t *word;
@@ -673,14 +723,18 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
least-significant byte of the word as the first byte of data, without any pre
or post conditioning. This is used to combine the CRCs of each braid.
*/
local z_crc_t crc_word(z_word_t data) {
local z_crc_t crc_word(data)
z_word_t data;
{
int k;
for (k = 0; k < W; k++)
data = (data >> 8) ^ crc_table[data & 0xff];
return (z_crc_t)data;
}
local z_word_t crc_word_big(z_word_t data) {
local z_word_t crc_word_big(data)
z_word_t data;
{
int k;
for (k = 0; k < W; k++)
data = (data << 8) ^
@@ -691,8 +745,11 @@ local z_word_t crc_word_big(z_word_t data) {
#endif
/* ========================================================================= */
unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
z_size_t len) {
unsigned long ZEXPORT crc32_z(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
z_size_t len;
{
/* Return initial CRC, if requested. */
if (buf == Z_NULL) return 0;
@@ -724,8 +781,8 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
words = (z_word_t const *)buf;
/* Do endian check at execution time instead of compile time, since ARM
processors can change the endianness at execution time. If the
compiler knows what the endianness will be, it can optimize out the
processors can change the endianess at execution time. If the
compiler knows what the endianess will be, it can optimize out the
check and the unused branch. */
endian = 1;
if (*(unsigned char *)&endian) {
@@ -1012,13 +1069,20 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
#endif
/* ========================================================================= */
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf,
uInt len) {
unsigned long ZEXPORT crc32(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
uInt len;
{
return crc32_z(crc, buf, len);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) {
uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off64_t len2;
{
#ifdef DYNAMIC_CRC_TABLE
once(&made, make_crc_table);
#endif /* DYNAMIC_CRC_TABLE */
@@ -1026,12 +1090,18 @@ uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) {
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) {
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off_t len2;
{
return crc32_combine64(crc1, crc2, (z_off64_t)len2);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) {
uLong ZEXPORT crc32_combine_gen64(len2)
z_off64_t len2;
{
#ifdef DYNAMIC_CRC_TABLE
once(&made, make_crc_table);
#endif /* DYNAMIC_CRC_TABLE */
@@ -1039,11 +1109,17 @@ uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) {
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine_gen(z_off_t len2) {
uLong ZEXPORT crc32_combine_gen(len2)
z_off_t len2;
{
return crc32_combine_gen64((z_off64_t)len2);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) {
uLong ZEXPORT crc32_combine_op(crc1, crc2, op)
uLong crc1;
uLong crc2;
uLong op;
{
return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
}
+336 -233
View File
@@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
* Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
" deflate 1.3 Copyright 1995-2023 Jean-loup Gailly and Mark Adler ";
" deflate 1.2.13 Copyright 1995-2022 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -60,6 +60,9 @@ const char deflate_copyright[] =
copyright string in the executable of your product.
*/
/* ===========================================================================
* Function prototypes.
*/
typedef enum {
need_more, /* block not completed, need more input or more output */
block_done, /* block flush performed */
@@ -67,16 +70,29 @@ typedef enum {
finish_done /* finish done, accept no more input or output */
} block_state;
typedef block_state (*compress_func)(deflate_state *s, int flush);
typedef block_state (*compress_func) OF((deflate_state *s, int flush));
/* Compression function. Returns the block state after the call. */
local block_state deflate_stored(deflate_state *s, int flush);
local block_state deflate_fast(deflate_state *s, int flush);
local int deflateStateCheck OF((z_streamp strm));
local void slide_hash OF((deflate_state *s));
local void fill_window OF((deflate_state *s));
local block_state deflate_stored OF((deflate_state *s, int flush));
local block_state deflate_fast OF((deflate_state *s, int flush));
#ifndef FASTEST
local block_state deflate_slow(deflate_state *s, int flush);
local block_state deflate_slow OF((deflate_state *s, int flush));
#endif
local block_state deflate_rle OF((deflate_state *s, int flush));
local block_state deflate_huff OF((deflate_state *s, int flush));
local void lm_init OF((deflate_state *s));
local void putShortMSB OF((deflate_state *s, uInt b));
local void flush_pending OF((z_streamp strm));
local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
local uInt longest_match OF((deflate_state *s, IPos cur_match));
#ifdef ZLIB_DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match,
int length));
#endif
local block_state deflate_rle(deflate_state *s, int flush);
local block_state deflate_huff(deflate_state *s, int flush);
/* ===========================================================================
* Local data
@@ -179,12 +195,9 @@ local const config configuration_table[10] = {
* bit values at the expense of memory usage). We slide even when level == 0 to
* keep the hash table consistent if we switch back to level > 0 later.
*/
#if defined(__has_feature)
# if __has_feature(memory_sanitizer)
__attribute__((no_sanitize("memory")))
# endif
#endif
local void slide_hash(deflate_state *s) {
local void slide_hash(s)
deflate_state *s;
{
unsigned n, m;
Posf *p;
uInt wsize = s->w_size;
@@ -208,177 +221,30 @@ local void slide_hash(deflate_state *s) {
#endif
}
/* ===========================================================================
* Read a new buffer from the current input stream, update the adler32
* and total number of bytes read. All deflate() input goes through
* this function so some applications may wish to modify it to avoid
* allocating a large strm->next_in buffer and copying from it.
* (See also flush_pending()).
*/
local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) {
unsigned len = strm->avail_in;
if (len > size) len = size;
if (len == 0) return 0;
strm->avail_in -= len;
zmemcpy(buf, strm->next_in, len);
if (strm->state->wrap == 1) {
strm->adler = adler32(strm->adler, buf, len);
}
#ifdef GZIP
else if (strm->state->wrap == 2) {
strm->adler = crc32(strm->adler, buf, len);
}
#endif
strm->next_in += len;
strm->total_in += len;
return len;
}
/* ===========================================================================
* Fill the window when the lookahead becomes insufficient.
* Updates strstart and lookahead.
*
* IN assertion: lookahead < MIN_LOOKAHEAD
* OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
* At least one byte has been read, or avail_in == 0; reads are
* performed for at least two bytes (required for the zip translate_eol
* option -- not supported here).
*/
local void fill_window(deflate_state *s) {
unsigned n;
unsigned more; /* Amount of free space at the end of the window. */
uInt wsize = s->w_size;
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
do {
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
/* Deal with !@#$% 64K limit: */
if (sizeof(int) <= 2) {
if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
more = wsize;
} else if (more == (unsigned)(-1)) {
/* Very unlikely, but possible on 16 bit machine if
* strstart == 0 && lookahead == 1 (input done a byte at time)
*/
more--;
}
}
/* If the window is almost full and there is insufficient lookahead,
* move the upper half to the lower one to make room in the upper half.
*/
if (s->strstart >= wsize + MAX_DIST(s)) {
zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more);
s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) wsize;
if (s->insert > s->strstart)
s->insert = s->strstart;
slide_hash(s);
more += wsize;
}
if (s->strm->avail_in == 0) break;
/* If there was no sliding:
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
* more == window_size - lookahead - strstart
* => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
* => more >= window_size - 2*WSIZE + 2
* In the BIG_MEM or MMAP case (not yet supported),
* window_size == input_size + MIN_LOOKAHEAD &&
* strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
* Otherwise, window_size == 2*WSIZE so more >= 2.
* If there was sliding, more >= WSIZE. So in all cases, more >= 2.
*/
Assert(more >= 2, "more < 2");
n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
s->lookahead += n;
/* Initialize the hash value now that we have some input: */
if (s->lookahead + s->insert >= MIN_MATCH) {
uInt str = s->strstart - s->insert;
s->ins_h = s->window[str];
UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
#if MIN_MATCH != 3
Call UPDATE_HASH() MIN_MATCH-3 more times
#endif
while (s->insert) {
UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
#ifndef FASTEST
s->prev[str & s->w_mask] = s->head[s->ins_h];
#endif
s->head[s->ins_h] = (Pos)str;
str++;
s->insert--;
if (s->lookahead + s->insert < MIN_MATCH)
break;
}
}
/* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
* but this is not important since only literal bytes will be emitted.
*/
} while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
/* If the WIN_INIT bytes after the end of the current data have never been
* written, then zero those bytes in order to avoid memory check reports of
* the use of uninitialized (or uninitialised as Julian writes) bytes by
* the longest match routines. Update the high water mark for the next
* time through here. WIN_INIT is set to MAX_MATCH since the longest match
* routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
*/
if (s->high_water < s->window_size) {
ulg curr = s->strstart + (ulg)(s->lookahead);
ulg init;
if (s->high_water < curr) {
/* Previous high water mark below current data -- zero WIN_INIT
* bytes or up to end of window, whichever is less.
*/
init = s->window_size - curr;
if (init > WIN_INIT)
init = WIN_INIT;
zmemzero(s->window + curr, (unsigned)init);
s->high_water = curr + init;
}
else if (s->high_water < (ulg)curr + WIN_INIT) {
/* High water mark at or above current data, but below current data
* plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
* to end of window, whichever is less.
*/
init = (ulg)curr + WIN_INIT - s->high_water;
if (init > s->window_size - s->high_water)
init = s->window_size - s->high_water;
zmemzero(s->window + s->high_water, (unsigned)init);
s->high_water += init;
}
}
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
"not enough room for search");
}
/* ========================================================================= */
int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version,
int stream_size) {
int ZEXPORT deflateInit_(strm, level, version, stream_size)
z_streamp strm;
int level;
const char *version;
int stream_size;
{
return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
Z_DEFAULT_STRATEGY, version, stream_size);
/* To do: ignore strm->next_in if we use it as window */
}
/* ========================================================================= */
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
int windowBits, int memLevel, int strategy,
const char *version, int stream_size) {
int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
version, stream_size)
z_streamp strm;
int level;
int method;
int windowBits;
int memLevel;
int strategy;
const char *version;
int stream_size;
{
deflate_state *s;
int wrap = 1;
static const char my_version[] = ZLIB_VERSION;
@@ -520,7 +386,9 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
/* =========================================================================
* Check for a valid deflate stream state. Return 0 if ok, 1 if not.
*/
local int deflateStateCheck(z_streamp strm) {
local int deflateStateCheck(strm)
z_streamp strm;
{
deflate_state *s;
if (strm == Z_NULL ||
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
@@ -541,8 +409,11 @@ local int deflateStateCheck(z_streamp strm) {
}
/* ========================================================================= */
int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary,
uInt dictLength) {
int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength)
z_streamp strm;
const Bytef *dictionary;
uInt dictLength;
{
deflate_state *s;
uInt str, n;
int wrap;
@@ -607,8 +478,11 @@ int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary,
}
/* ========================================================================= */
int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary,
uInt *dictLength) {
int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength)
z_streamp strm;
Bytef *dictionary;
uInt *dictLength;
{
deflate_state *s;
uInt len;
@@ -626,7 +500,9 @@ int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary,
}
/* ========================================================================= */
int ZEXPORT deflateResetKeep(z_streamp strm) {
int ZEXPORT deflateResetKeep(strm)
z_streamp strm;
{
deflate_state *s;
if (deflateStateCheck(strm)) {
@@ -661,32 +537,10 @@ int ZEXPORT deflateResetKeep(z_streamp strm) {
return Z_OK;
}
/* ===========================================================================
* Initialize the "longest match" routines for a new zlib stream
*/
local void lm_init(deflate_state *s) {
s->window_size = (ulg)2L*s->w_size;
CLEAR_HASH(s);
/* Set the default configuration parameters:
*/
s->max_lazy_match = configuration_table[s->level].max_lazy;
s->good_match = configuration_table[s->level].good_length;
s->nice_match = configuration_table[s->level].nice_length;
s->max_chain_length = configuration_table[s->level].max_chain;
s->strstart = 0;
s->block_start = 0L;
s->lookahead = 0;
s->insert = 0;
s->match_length = s->prev_length = MIN_MATCH-1;
s->match_available = 0;
s->ins_h = 0;
}
/* ========================================================================= */
int ZEXPORT deflateReset(z_streamp strm) {
int ZEXPORT deflateReset(strm)
z_streamp strm;
{
int ret;
ret = deflateResetKeep(strm);
@@ -696,7 +550,10 @@ int ZEXPORT deflateReset(z_streamp strm) {
}
/* ========================================================================= */
int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) {
int ZEXPORT deflateSetHeader(strm, head)
z_streamp strm;
gz_headerp head;
{
if (deflateStateCheck(strm) || strm->state->wrap != 2)
return Z_STREAM_ERROR;
strm->state->gzhead = head;
@@ -704,7 +561,11 @@ int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) {
}
/* ========================================================================= */
int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
int ZEXPORT deflatePending(strm, pending, bits)
unsigned *pending;
int *bits;
z_streamp strm;
{
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
if (pending != Z_NULL)
*pending = strm->state->pending;
@@ -714,7 +575,11 @@ int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
}
/* ========================================================================= */
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
int ZEXPORT deflatePrime(strm, bits, value)
z_streamp strm;
int bits;
int value;
{
deflate_state *s;
int put;
@@ -737,7 +602,11 @@ int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
}
/* ========================================================================= */
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) {
int ZEXPORT deflateParams(strm, level, strategy)
z_streamp strm;
int level;
int strategy;
{
deflate_state *s;
compress_func func;
@@ -782,8 +651,13 @@ int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) {
}
/* ========================================================================= */
int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
int nice_length, int max_chain) {
int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
z_streamp strm;
int good_length;
int max_lazy;
int nice_length;
int max_chain;
{
deflate_state *s;
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -819,7 +693,10 @@ int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
*
* Shifts are used to approximate divisions, for speed.
*/
uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
uLong ZEXPORT deflateBound(strm, sourceLen)
z_streamp strm;
uLong sourceLen;
{
deflate_state *s;
uLong fixedlen, storelen, wraplen;
@@ -875,8 +752,7 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
/* if not default parameters, return one of the conservative bounds */
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
wraplen;
return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen;
/* default settings: return tight bound for that case -- ~0.03% overhead
plus a small constant */
@@ -889,7 +765,10 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
* IN assertion: the stream state is correct and there is enough room in
* pending_buf.
*/
local void putShortMSB(deflate_state *s, uInt b) {
local void putShortMSB(s, b)
deflate_state *s;
uInt b;
{
put_byte(s, (Byte)(b >> 8));
put_byte(s, (Byte)(b & 0xff));
}
@@ -900,7 +779,9 @@ local void putShortMSB(deflate_state *s, uInt b) {
* applications may wish to modify it to avoid allocating a large
* strm->next_out buffer and copying into it. (See also read_buf()).
*/
local void flush_pending(z_streamp strm) {
local void flush_pending(strm)
z_streamp strm;
{
unsigned len;
deflate_state *s = strm->state;
@@ -931,7 +812,10 @@ local void flush_pending(z_streamp strm) {
} while (0)
/* ========================================================================= */
int ZEXPORT deflate(z_streamp strm, int flush) {
int ZEXPORT deflate(strm, flush)
z_streamp strm;
int flush;
{
int old_flush; /* value of flush param for previous deflate call */
deflate_state *s;
@@ -1243,7 +1127,9 @@ int ZEXPORT deflate(z_streamp strm, int flush) {
}
/* ========================================================================= */
int ZEXPORT deflateEnd(z_streamp strm) {
int ZEXPORT deflateEnd(strm)
z_streamp strm;
{
int status;
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -1267,10 +1153,11 @@ int ZEXPORT deflateEnd(z_streamp strm) {
* To simplify the source, this is not supported for 16-bit MSDOS (which
* doesn't have enough memory anyway to duplicate compression states).
*/
int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
int ZEXPORT deflateCopy(dest, source)
z_streamp dest;
z_streamp source;
{
#ifdef MAXSEG_64K
(void)dest;
(void)source;
return Z_STREAM_ERROR;
#else
deflate_state *ds;
@@ -1318,6 +1205,66 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
#endif /* MAXSEG_64K */
}
/* ===========================================================================
* Read a new buffer from the current input stream, update the adler32
* and total number of bytes read. All deflate() input goes through
* this function so some applications may wish to modify it to avoid
* allocating a large strm->next_in buffer and copying from it.
* (See also flush_pending()).
*/
local unsigned read_buf(strm, buf, size)
z_streamp strm;
Bytef *buf;
unsigned size;
{
unsigned len = strm->avail_in;
if (len > size) len = size;
if (len == 0) return 0;
strm->avail_in -= len;
zmemcpy(buf, strm->next_in, len);
if (strm->state->wrap == 1) {
strm->adler = adler32(strm->adler, buf, len);
}
#ifdef GZIP
else if (strm->state->wrap == 2) {
strm->adler = crc32(strm->adler, buf, len);
}
#endif
strm->next_in += len;
strm->total_in += len;
return len;
}
/* ===========================================================================
* Initialize the "longest match" routines for a new zlib stream
*/
local void lm_init(s)
deflate_state *s;
{
s->window_size = (ulg)2L*s->w_size;
CLEAR_HASH(s);
/* Set the default configuration parameters:
*/
s->max_lazy_match = configuration_table[s->level].max_lazy;
s->good_match = configuration_table[s->level].good_length;
s->nice_match = configuration_table[s->level].nice_length;
s->max_chain_length = configuration_table[s->level].max_chain;
s->strstart = 0;
s->block_start = 0L;
s->lookahead = 0;
s->insert = 0;
s->match_length = s->prev_length = MIN_MATCH-1;
s->match_available = 0;
s->ins_h = 0;
}
#ifndef FASTEST
/* ===========================================================================
* Set match_start to the longest match starting at the given string and
@@ -1328,7 +1275,10 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
* string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
* OUT assertion: the match length is not greater than s->lookahead.
*/
local uInt longest_match(deflate_state *s, IPos cur_match) {
local uInt longest_match(s, cur_match)
deflate_state *s;
IPos cur_match; /* current match */
{
unsigned chain_length = s->max_chain_length;/* max hash chain length */
register Bytef *scan = s->window + s->strstart; /* current string */
register Bytef *match; /* matched string */
@@ -1476,7 +1426,10 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
/* ---------------------------------------------------------------------------
* Optimized version for FASTEST only
*/
local uInt longest_match(deflate_state *s, IPos cur_match) {
local uInt longest_match(s, cur_match)
deflate_state *s;
IPos cur_match; /* current match */
{
register Bytef *scan = s->window + s->strstart; /* current string */
register Bytef *match; /* matched string */
register int len; /* length of current match */
@@ -1537,7 +1490,11 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
local void check_match(deflate_state *s, IPos start, IPos match, int length) {
local void check_match(s, start, match, length)
deflate_state *s;
IPos start, match;
int length;
{
/* check that the match is indeed a match */
if (zmemcmp(s->window + match,
s->window + start, length) != EQUAL) {
@@ -1557,6 +1514,137 @@ local void check_match(deflate_state *s, IPos start, IPos match, int length) {
# define check_match(s, start, match, length)
#endif /* ZLIB_DEBUG */
/* ===========================================================================
* Fill the window when the lookahead becomes insufficient.
* Updates strstart and lookahead.
*
* IN assertion: lookahead < MIN_LOOKAHEAD
* OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
* At least one byte has been read, or avail_in == 0; reads are
* performed for at least two bytes (required for the zip translate_eol
* option -- not supported here).
*/
local void fill_window(s)
deflate_state *s;
{
unsigned n;
unsigned more; /* Amount of free space at the end of the window. */
uInt wsize = s->w_size;
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
do {
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
/* Deal with !@#$% 64K limit: */
if (sizeof(int) <= 2) {
if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
more = wsize;
} else if (more == (unsigned)(-1)) {
/* Very unlikely, but possible on 16 bit machine if
* strstart == 0 && lookahead == 1 (input done a byte at time)
*/
more--;
}
}
/* If the window is almost full and there is insufficient lookahead,
* move the upper half to the lower one to make room in the upper half.
*/
if (s->strstart >= wsize + MAX_DIST(s)) {
zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more);
s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) wsize;
if (s->insert > s->strstart)
s->insert = s->strstart;
slide_hash(s);
more += wsize;
}
if (s->strm->avail_in == 0) break;
/* If there was no sliding:
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
* more == window_size - lookahead - strstart
* => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
* => more >= window_size - 2*WSIZE + 2
* In the BIG_MEM or MMAP case (not yet supported),
* window_size == input_size + MIN_LOOKAHEAD &&
* strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
* Otherwise, window_size == 2*WSIZE so more >= 2.
* If there was sliding, more >= WSIZE. So in all cases, more >= 2.
*/
Assert(more >= 2, "more < 2");
n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
s->lookahead += n;
/* Initialize the hash value now that we have some input: */
if (s->lookahead + s->insert >= MIN_MATCH) {
uInt str = s->strstart - s->insert;
s->ins_h = s->window[str];
UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
#if MIN_MATCH != 3
Call UPDATE_HASH() MIN_MATCH-3 more times
#endif
while (s->insert) {
UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
#ifndef FASTEST
s->prev[str & s->w_mask] = s->head[s->ins_h];
#endif
s->head[s->ins_h] = (Pos)str;
str++;
s->insert--;
if (s->lookahead + s->insert < MIN_MATCH)
break;
}
}
/* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
* but this is not important since only literal bytes will be emitted.
*/
} while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
/* If the WIN_INIT bytes after the end of the current data have never been
* written, then zero those bytes in order to avoid memory check reports of
* the use of uninitialized (or uninitialised as Julian writes) bytes by
* the longest match routines. Update the high water mark for the next
* time through here. WIN_INIT is set to MAX_MATCH since the longest match
* routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
*/
if (s->high_water < s->window_size) {
ulg curr = s->strstart + (ulg)(s->lookahead);
ulg init;
if (s->high_water < curr) {
/* Previous high water mark below current data -- zero WIN_INIT
* bytes or up to end of window, whichever is less.
*/
init = s->window_size - curr;
if (init > WIN_INIT)
init = WIN_INIT;
zmemzero(s->window + curr, (unsigned)init);
s->high_water = curr + init;
}
else if (s->high_water < (ulg)curr + WIN_INIT) {
/* High water mark at or above current data, but below current data
* plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
* to end of window, whichever is less.
*/
init = (ulg)curr + WIN_INIT - s->high_water;
if (init > s->window_size - s->high_water)
init = s->window_size - s->high_water;
zmemzero(s->window + s->high_water, (unsigned)init);
s->high_water += init;
}
}
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
"not enough room for search");
}
/* ===========================================================================
* Flush the current block, with given end-of-file flag.
* IN assertion: strstart is set to the end of the current match.
@@ -1599,7 +1687,10 @@ local void check_match(deflate_state *s, IPos start, IPos match, int length) {
* copied. It is most efficient with large input and output buffers, which
* maximizes the opportunities to have a single copy from next_in to next_out.
*/
local block_state deflate_stored(deflate_state *s, int flush) {
local block_state deflate_stored(s, flush)
deflate_state *s;
int flush;
{
/* Smallest worthy block size when not flushing or finishing. By default
* this is 32K. This can be as small as 507 bytes for memLevel == 1. For
* large input and output buffers, the stored block size will be larger.
@@ -1783,7 +1874,10 @@ local block_state deflate_stored(deflate_state *s, int flush) {
* new strings in the dictionary only for unmatched strings or for short
* matches. It is used only for the fast compression options.
*/
local block_state deflate_fast(deflate_state *s, int flush) {
local block_state deflate_fast(s, flush)
deflate_state *s;
int flush;
{
IPos hash_head; /* head of the hash chain */
int bflush; /* set if current block must be flushed */
@@ -1882,7 +1976,10 @@ local block_state deflate_fast(deflate_state *s, int flush) {
* evaluation for matches: a match is finally adopted only if there is
* no better match at the next window position.
*/
local block_state deflate_slow(deflate_state *s, int flush) {
local block_state deflate_slow(s, flush)
deflate_state *s;
int flush;
{
IPos hash_head; /* head of hash chain */
int bflush; /* set if current block must be flushed */
@@ -2010,7 +2107,10 @@ local block_state deflate_slow(deflate_state *s, int flush) {
* one. Do not maintain a hash table. (It will be regenerated if this run of
* deflate switches away from Z_RLE.)
*/
local block_state deflate_rle(deflate_state *s, int flush) {
local block_state deflate_rle(s, flush)
deflate_state *s;
int flush;
{
int bflush; /* set if current block must be flushed */
uInt prev; /* byte at distance one to match */
Bytef *scan, *strend; /* scan goes up to strend for length of run */
@@ -2081,7 +2181,10 @@ local block_state deflate_rle(deflate_state *s, int flush) {
* For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
* (It will be regenerated if this run of deflate switches away from Huffman.)
*/
local block_state deflate_huff(deflate_state *s, int flush) {
local block_state deflate_huff(s, flush)
deflate_state *s;
int flush;
{
int bflush; /* set if current block must be flushed */
for (;;) {
+8 -8
View File
@@ -291,14 +291,14 @@ typedef struct internal_state {
memory checker errors from longest match routines */
/* in trees.c */
void ZLIB_INTERNAL _tr_init(deflate_state *s);
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
ulg stored_len, int last);
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
void ZLIB_INTERNAL _tr_align(deflate_state *s);
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
ulg stored_len, int last);
void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
ulg stored_len, int last));
void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
ulg stored_len, int last));
#define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
+1 -1
View File
@@ -198,7 +198,7 @@ int main(int argc, char **argv)
if (ret == Z_MEM_ERROR)
quit("out of memory");
/* set up for next recompression */
/* set up for next reocmpression */
ret = inflateReset(&inf);
assert(ret != Z_STREAM_ERROR);
ret = deflateReset(&def);
+11 -15
View File
@@ -1,10 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>zlib Usage Example</title>
<!-- Copyright (c) 2004-2023 Mark Adler. -->
<!-- Copyright (c) 2004, 2005 Mark Adler. -->
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000">
<h2 align="center"> zlib Usage Example </h2>
@@ -17,7 +17,7 @@ from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()<
annotations are interspersed between lines of the code. So please read between the lines.
We hope this helps explain some of the intricacies of <em>zlib</em>.
<p>
Without further ado, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>:
Without further adieu, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>:
<pre><b>
/* zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain
@@ -155,11 +155,13 @@ before we fall out of the loop at the bottom.
</b></pre>
We start off by reading data from the input file. The number of bytes read is put directly
into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also
check to see if end-of-file on the input has been reached using feof().
If we are at the end of file, then <tt>flush</tt> is set to the
check to see if end-of-file on the input has been reached. If we are at the end of file, then <tt>flush</tt> is set to the
<em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to
indicate that this is the last chunk of input data to compress.
If we are not yet at the end of the input, then the <em>zlib</em>
indicate that this is the last chunk of input data to compress. We need to use <tt>feof()</tt>
to check for end-of-file as opposed to seeing if fewer than <tt>CHUNK</tt> bytes have been read. The
reason is that if the input file length is an exact multiple of <tt>CHUNK</tt>, we will miss
the fact that we got to the end-of-file, and not know to tell <tt>deflate()</tt> to finish
up the compressed stream. If we are not yet at the end of the input, then the <em>zlib</em>
constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still
in the middle of the uncompressed data.
<p>
@@ -538,12 +540,6 @@ int main(int argc, char **argv)
}
</b></pre>
<hr>
<i>Last modified 24 January 2023<br>
Copyright &#169; 2004-2023 Mark Adler</i><br>
<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">
<img alt="Creative Commons License" style="border-width:0"
src="https://i.creativecommons.org/l/by-nd/4.0/88x31.png"></a>
<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">
Creative Commons Attribution-NoDerivatives 4.0 International License</a>.
<i>Copyright (c) 2004, 2005 by Mark Adler<br>Last modified 11 December 2005</i>
</body>
</html>
+355 -409
View File
@@ -1,102 +1,114 @@
/* zran.c -- example of deflate stream indexing and random access
* Copyright (C) 2005, 2012, 2018, 2023 Mark Adler
/* zran.c -- example of zlib/gzip stream indexing and random access
* Copyright (C) 2005, 2012, 2018 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.4 13 Apr 2023 Mark Adler */
* Version 1.2 14 Oct 2018 Mark Adler */
/* Version History:
1.0 29 May 2005 First version
1.1 29 Sep 2012 Fix memory reallocation error
1.2 14 Oct 2018 Handle gzip streams with multiple members
Add a header file to facilitate usage in applications
1.3 18 Feb 2023 Permit raw deflate streams as well as zlib and gzip
Permit crossing gzip member boundaries when extracting
Support a size_t size when extracting (was an int)
Do a binary search over the index for an access point
Expose the access point type to enable save and load
1.4 13 Apr 2023 Add a NOPRIME define to not use inflatePrime()
*/
// Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary()
// for random access of a compressed file. A file containing a raw deflate
// stream is provided on the command line. The compressed stream is decoded in
// its entirety, and an index built with access points about every SPAN bytes
// in the uncompressed output. The compressed file is left open, and can then
// be read randomly, having to decompress on the average SPAN/2 uncompressed
// bytes before getting to the desired block of data.
//
// An access point can be created at the start of any deflate block, by saving
// the starting file offset and bit of that block, and the 32K bytes of
// uncompressed data that precede that block. Also the uncompressed offset of
// that block is saved to provide a reference for locating a desired starting
// point in the uncompressed stream. deflate_index_build() decompresses the
// input raw deflate stream a block at a time, and at the end of each block
// decides if enough uncompressed data has gone by to justify the creation of a
// new access point. If so, that point is saved in a data structure that grows
// as needed to accommodate the points.
//
// To use the index, an offset in the uncompressed data is provided, for which
// the latest access point at or preceding that offset is located in the index.
// The input file is positioned to the specified location in the index, and if
// necessary the first few bits of the compressed data is read from the file.
// inflate is initialized with those bits and the 32K of uncompressed data, and
// decompression then proceeds until the desired offset in the file is reached.
// Then decompression continues to read the requested uncompressed data from
// the file.
//
// There is some fair bit of overhead to starting inflation for the random
// access, mainly copying the 32K byte dictionary. If small pieces of the file
// are being accessed, it would make sense to implement a cache to hold some
// lookahead to avoid many calls to deflate_index_extract() for small lengths.
//
// Another way to build an index would be to use inflateCopy(). That would not
// be constrained to have access points at block boundaries, but would require
// more memory per access point, and could not be saved to a file due to the
// use of pointers in the state. The approach here allows for storage of the
// index in a file.
/* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary()
for random access of a compressed file. A file containing a zlib or gzip
stream is provided on the command line. The compressed stream is decoded in
its entirety, and an index built with access points about every SPAN bytes
in the uncompressed output. The compressed file is left open, and can then
be read randomly, having to decompress on the average SPAN/2 uncompressed
bytes before getting to the desired block of data.
An access point can be created at the start of any deflate block, by saving
the starting file offset and bit of that block, and the 32K bytes of
uncompressed data that precede that block. Also the uncompressed offset of
that block is saved to provide a reference for locating a desired starting
point in the uncompressed stream. deflate_index_build() works by
decompressing the input zlib or gzip stream a block at a time, and at the
end of each block deciding if enough uncompressed data has gone by to
justify the creation of a new access point. If so, that point is saved in a
data structure that grows as needed to accommodate the points.
To use the index, an offset in the uncompressed data is provided, for which
the latest access point at or preceding that offset is located in the index.
The input file is positioned to the specified location in the index, and if
necessary the first few bits of the compressed data is read from the file.
inflate is initialized with those bits and the 32K of uncompressed data, and
the decompression then proceeds until the desired offset in the file is
reached. Then the decompression continues to read the desired uncompressed
data from the file.
Another approach would be to generate the index on demand. In that case,
requests for random access reads from the compressed data would try to use
the index, but if a read far enough past the end of the index is required,
then further index entries would be generated and added.
There is some fair bit of overhead to starting inflation for the random
access, mainly copying the 32K byte dictionary. So if small pieces of the
file are being accessed, it would make sense to implement a cache to hold
some lookahead and avoid many calls to deflate_index_extract() for small
lengths.
Another way to build an index would be to use inflateCopy(). That would
not be constrained to have access points at block boundaries, but requires
more memory per access point, and also cannot be saved to file due to the
use of pointers in the state. The approach here allows for storage of the
index in a file.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "zlib.h"
#include "zran.h"
#define WINSIZE 32768U // sliding window size
#define CHUNK 16384 // file input buffer size
#define WINSIZE 32768U /* sliding window size */
#define CHUNK 16384 /* file input buffer size */
// See comments in zran.h.
void deflate_index_free(struct deflate_index *index) {
/* Access point entry. */
struct point {
off_t out; /* corresponding offset in uncompressed data */
off_t in; /* offset in input file of first full byte */
int bits; /* number of bits (1-7) from byte at in-1, or 0 */
unsigned char window[WINSIZE]; /* preceding 32K of uncompressed data */
};
/* See comments in zran.h. */
void deflate_index_free(struct deflate_index *index)
{
if (index != NULL) {
free(index->list);
free(index);
}
}
// Add an access point to the list. If out of memory, deallocate the existing
// list and return NULL. index->mode is temporarily the allocated number of
// access points, until it is time for deflate_index_build() to return. Then
// index->mode is set to the mode of inflation.
static struct deflate_index *add_point(struct deflate_index *index, int bits,
off_t in, off_t out, unsigned left,
unsigned char *window) {
/* Add an entry to the access point list. If out of memory, deallocate the
existing list and return NULL. index->gzip is the allocated size of the
index in point entries, until it is time for deflate_index_build() to
return, at which point gzip is set to indicate a gzip file or not.
*/
static struct deflate_index *addpoint(struct deflate_index *index, int bits,
off_t in, off_t out, unsigned left,
unsigned char *window)
{
struct point *next;
/* if list is empty, create it (start with eight points) */
if (index == NULL) {
// The list is empty. Create it, starting with eight access points.
index = malloc(sizeof(struct deflate_index));
if (index == NULL)
return NULL;
index->have = 0;
index->mode = 8;
index->list = malloc(sizeof(point_t) * index->mode);
if (index == NULL) return NULL;
index->list = malloc(sizeof(struct point) << 3);
if (index->list == NULL) {
free(index);
return NULL;
}
index->gzip = 8;
index->have = 0;
}
else if (index->have == index->mode) {
// The list is full. Make it bigger.
index->mode <<= 1;
point_t *next = realloc(index->list, sizeof(point_t) * index->mode);
/* if list is full, make it bigger */
else if (index->have == index->gzip) {
index->gzip <<= 1;
next = realloc(index->list, sizeof(struct point) * index->gzip);
if (next == NULL) {
deflate_index_free(index);
return NULL;
@@ -104,379 +116,318 @@ static struct deflate_index *add_point(struct deflate_index *index, int bits,
index->list = next;
}
// Fill in the access point and increment how many we have.
point_t *next = (point_t *)(index->list) + index->have++;
if (index->have < 0) {
// Overflowed the int!
deflate_index_free(index);
return NULL;
}
next->out = out;
next->in = in;
/* fill in entry and increment how many we have */
next = (struct point *)(index->list) + index->have;
next->bits = bits;
next->in = in;
next->out = out;
if (left)
memcpy(next->window, window + WINSIZE - left, left);
if (left < WINSIZE)
memcpy(next->window + left, window, WINSIZE - left);
index->have++;
// Return the index, which may have been newly allocated or destroyed.
/* return list, possibly reallocated */
return index;
}
// Decompression modes. These are the inflateInit2() windowBits parameter.
#define RAW -15
#define ZLIB 15
#define GZIP 31
/* See comments in zran.h. */
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built)
{
int ret;
int gzip = 0; /* true if reading a gzip file */
off_t totin, totout; /* our own total counters to avoid 4GB limit */
off_t last; /* totout value of last access point */
struct deflate_index *index; /* access points being generated */
z_stream strm;
unsigned char input[CHUNK];
unsigned char window[WINSIZE];
// See comments in zran.h.
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
// Set up inflation state.
z_stream strm = {0}; // inflate engine (gets fired up later)
unsigned char buf[CHUNK]; // input buffer
unsigned char win[WINSIZE] = {0}; // output sliding window
off_t totin = 0; // total bytes read from input
off_t totout = 0; // total bytes uncompressed
int mode = 0; // mode: RAW, ZLIB, or GZIP (0 => not set yet)
// Decompress from in, generating access points along the way.
int ret; // the return value from zlib, or Z_ERRNO
off_t last; // last access point uncompressed offset
struct deflate_index *index = NULL; // list of access points
do {
// Assure available input, at least until reaching EOF.
if (strm.avail_in == 0) {
strm.avail_in = fread(buf, 1, sizeof(buf), in);
totin += strm.avail_in;
strm.next_in = buf;
if (strm.avail_in < sizeof(buf) && ferror(in)) {
ret = Z_ERRNO;
break;
}
if (mode == 0) {
// At the start of the input -- determine the type. Assume raw
// if it is neither zlib nor gzip. This could in theory result
// in a false positive for zlib, but in practice the fill bits
// after a stored block are always zeros, so a raw stream won't
// start with an 8 in the low nybble.
mode = strm.avail_in == 0 ? RAW : // empty -- will fail
(strm.next_in[0] & 0xf) == 8 ? ZLIB :
strm.next_in[0] == 0x1f ? GZIP :
/* else */ RAW;
ret = inflateInit2(&strm, mode);
if (ret != Z_OK)
break;
}
}
// Assure available output. This rotates the output through, for use as
// a sliding window on the uncompressed data.
if (strm.avail_out == 0) {
strm.avail_out = sizeof(win);
strm.next_out = win;
}
if (mode == RAW && index == NULL)
// We skip the inflate() call at the start of raw deflate data in
// order generate an access point there. Set data_type to imitate
// the end of a header.
strm.data_type = 0x80;
else {
// Inflate and update the number of uncompressed bytes.
unsigned before = strm.avail_out;
ret = inflate(&strm, Z_BLOCK);
totout += before - strm.avail_out;
}
if ((strm.data_type & 0xc0) == 0x80 &&
(index == NULL || totout - last >= span)) {
// We are at the end of a header or a non-last deflate block, so we
// can add an access point here. Furthermore, we are either at the
// very start for the first access point, or there has been span or
// more uncompressed bytes since the last access point, so we want
// to add an access point here.
index = add_point(index, strm.data_type & 7, totin - strm.avail_in,
totout, strm.avail_out, win);
if (index == NULL) {
ret = Z_MEM_ERROR;
break;
}
last = totout;
}
if (ret == Z_STREAM_END && mode == GZIP &&
(strm.avail_in || ungetc(getc(in), in) != EOF))
// There is more input after the end of a gzip member. Reset the
// inflate state to read another gzip member. On success, this will
// set ret to Z_OK to continue decompressing.
ret = inflateReset2(&strm, GZIP);
// Keep going until Z_STREAM_END or error. If the compressed data ends
// prematurely without a file read error, Z_BUF_ERROR is returned.
} while (ret == Z_OK);
inflateEnd(&strm);
if (ret != Z_STREAM_END) {
// An error was encountered. Discard the index and return a negative
// error code.
deflate_index_free(index);
return ret == Z_NEED_DICT ? Z_DATA_ERROR : ret;
}
// Shrink the index to only the occupied access points and return it.
index->mode = mode;
index->length = totout;
point_t *list = realloc(index->list, sizeof(point_t) * index->have);
if (list == NULL) {
// Seems like a realloc() to make something smaller should always work,
// but just in case.
deflate_index_free(index);
return Z_MEM_ERROR;
}
index->list = list;
*built = index;
return index->have;
}
#ifdef NOPRIME
// Support zlib versions before 1.2.3 (July 2005), or incomplete zlib clones
// that do not have inflatePrime().
# define INFLATEPRIME inflatePreface
// Append the low bits bits of value to in[] at bit position *have, updating
// *have. value must be zero above its low bits bits. bits must be positive.
// This assumes that any bits above the *have bits in the last byte are zeros.
// That assumption is preserved on return, as any bits above *have + bits in
// the last byte written will be set to zeros.
static inline void append_bits(unsigned value, int bits,
unsigned char *in, int *have) {
in += *have >> 3; // where the first bits from value will go
int k = *have & 7; // the number of bits already there
*have += bits;
if (k)
*in |= value << k; // write value above the low k bits
else
*in = value;
k = 8 - k; // the number of bits just appended
while (bits > k) {
value >>= k; // drop the bits appended
bits -= k;
k = 8; // now at a byte boundary
*++in = value;
}
}
// Insert enough bits in the form of empty deflate blocks in front of the the
// low bits bits of value, in order to bring the sequence to a byte boundary.
// Then feed that to inflate(). This does what inflatePrime() does, except that
// a negative value of bits is not supported. bits must be in 0..16. If the
// arguments are invalid, Z_STREAM_ERROR is returned. Otherwise the return
// value from inflate() is returned.
static int inflatePreface(z_stream *strm, int bits, int value) {
// Check input.
if (strm == Z_NULL || bits < 0 || bits > 16)
return Z_STREAM_ERROR;
if (bits == 0)
return Z_OK;
value &= (2 << (bits - 1)) - 1;
// An empty dynamic block with an odd number of bits (95). The high bit of
// the last byte is unused.
static const unsigned char dyn[] = {
4, 0xe0, 0x81, 8, 0, 0, 0, 0, 0x20, 0xa8, 0xab, 0x1f
};
const int dynlen = 95; // number of bits in the block
// Build an input buffer for inflate that is a multiple of eight bits in
// length, and that ends with the low bits bits of value.
unsigned char in[(dynlen + 3 * 10 + 16 + 7) / 8];
int have = 0;
if (bits & 1) {
// Insert an empty dynamic block to get to an odd number of bits, so
// when bits bits from value are appended, we are at an even number of
// bits.
memcpy(in, dyn, sizeof(dyn));
have = dynlen;
}
while ((have + bits) & 7)
// Insert empty fixed blocks until appending bits bits would put us on
// a byte boundary. This will insert at most three fixed blocks.
append_bits(2, 10, in, &have);
// Append the bits bits from value, which takes us to a byte boundary.
append_bits(value, bits, in, &have);
// Deliver the input to inflate(). There is no output space provided, but
// inflate() can't get stuck waiting on output not ingesting all of the
// provided input. The reason is that there will be at most 16 bits of
// input from value after the empty deflate blocks (which themselves
// generate no output). At least ten bits are needed to generate the first
// output byte from a fixed block. The last two bytes of the buffer have to
// be ingested in order to get ten bits, which is the most that value can
// occupy.
strm->avail_in = have >> 3;
strm->next_in = in;
strm->avail_out = 0;
strm->next_out = in; // not used, but can't be NULL
return inflate(strm, Z_NO_FLUSH);
}
#else
# define INFLATEPRIME inflatePrime
#endif
// See comments in zran.h.
ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
off_t offset, unsigned char *buf, size_t len) {
// Do a quick sanity check on the index.
if (index == NULL || index->have < 1 || index->list[0].out != 0)
return Z_STREAM_ERROR;
// If nothing to extract, return zero bytes extracted.
if (len == 0 || offset < 0 || offset >= index->length)
return 0;
// Find the access point closest to but not after offset.
int lo = -1, hi = index->have;
point_t *point = index->list;
while (hi - lo > 1) {
int mid = (lo + hi) >> 1;
if (offset < point[mid].out)
hi = mid;
else
lo = mid;
}
point += lo;
// Initialize the input file and prime the inflate engine to start there.
int ret = fseeko(in, point->in - (point->bits ? 1 : 0), SEEK_SET);
if (ret == -1)
return Z_ERRNO;
int ch = 0;
if (point->bits && (ch = getc(in)) == EOF)
return ferror(in) ? Z_ERRNO : Z_BUF_ERROR;
z_stream strm = {0};
ret = inflateInit2(&strm, RAW);
/* initialize inflate */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit2(&strm, 47); /* automatic zlib or gzip decoding */
if (ret != Z_OK)
return ret;
if (point->bits)
INFLATEPRIME(&strm, point->bits, ch >> (8 - point->bits));
inflateSetDictionary(&strm, point->window, WINSIZE);
// Skip uncompressed bytes until offset reached, then satisfy request.
unsigned char input[CHUNK];
unsigned char discard[WINSIZE];
offset -= point->out; // number of bytes to skip to get to offset
size_t left = len; // number of bytes left to read after offset
/* inflate the input, maintain a sliding window, and build an index -- this
also validates the integrity of the compressed data using the check
information in the gzip or zlib stream */
totin = totout = last = 0;
index = NULL; /* will be allocated by first addpoint() */
strm.avail_out = 0;
do {
if (offset) {
// Discard up to offset uncompressed bytes.
strm.avail_out = offset < WINSIZE ? (unsigned)offset : WINSIZE;
strm.next_out = discard;
/* get some compressed data from input file */
strm.avail_in = fread(input, 1, CHUNK, in);
if (ferror(in)) {
ret = Z_ERRNO;
goto deflate_index_build_error;
}
else {
// Uncompress up to left bytes into buf.
strm.avail_out = left < UINT_MAX ? (unsigned)left : UINT_MAX;
strm.next_out = buf + len - left;
}
// Uncompress, setting got to the number of bytes uncompressed.
if (strm.avail_in == 0) {
// Assure available input.
strm.avail_in = fread(input, 1, CHUNK, in);
if (strm.avail_in < CHUNK && ferror(in)) {
ret = Z_ERRNO;
ret = Z_DATA_ERROR;
goto deflate_index_build_error;
}
strm.next_in = input;
/* check for a gzip stream */
if (totin == 0 && strm.avail_in >= 3 &&
input[0] == 31 && input[1] == 139 && input[2] == 8)
gzip = 1;
/* process all of that, or until end of stream */
do {
/* reset sliding window if necessary */
if (strm.avail_out == 0) {
strm.avail_out = WINSIZE;
strm.next_out = window;
}
/* inflate until out of input, output, or at end of block --
update the total input and output counters */
totin += strm.avail_in;
totout += strm.avail_out;
ret = inflate(&strm, Z_BLOCK); /* return at end of block */
totin -= strm.avail_in;
totout -= strm.avail_out;
if (ret == Z_NEED_DICT)
ret = Z_DATA_ERROR;
if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR)
goto deflate_index_build_error;
if (ret == Z_STREAM_END) {
if (gzip &&
(strm.avail_in || ungetc(getc(in), in) != EOF)) {
ret = inflateReset(&strm);
if (ret != Z_OK)
goto deflate_index_build_error;
continue;
}
break;
}
strm.next_in = input;
/* if at end of block, consider adding an index entry (note that if
data_type indicates an end-of-block, then all of the
uncompressed data from that block has been delivered, and none
of the compressed data after that block has been consumed,
except for up to seven bits) -- the totout == 0 provides an
entry point after the zlib or gzip header, and assures that the
index always has at least one access point; we avoid creating an
access point after the last block by checking bit 6 of data_type
*/
if ((strm.data_type & 128) && !(strm.data_type & 64) &&
(totout == 0 || totout - last > span)) {
index = addpoint(index, strm.data_type & 7, totin,
totout, strm.avail_out, window);
if (index == NULL) {
ret = Z_MEM_ERROR;
goto deflate_index_build_error;
}
last = totout;
}
} while (strm.avail_in != 0);
} while (ret != Z_STREAM_END);
/* clean up and return index (release unused entries in list) */
(void)inflateEnd(&strm);
index->list = realloc(index->list, sizeof(struct point) * index->have);
index->gzip = gzip;
index->length = totout;
*built = index;
return index->have;
/* return error */
deflate_index_build_error:
(void)inflateEnd(&strm);
deflate_index_free(index);
return ret;
}
/* See comments in zran.h. */
int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset,
unsigned char *buf, int len)
{
int ret, skip;
z_stream strm;
struct point *here;
unsigned char input[CHUNK];
unsigned char discard[WINSIZE];
/* proceed only if something reasonable to do */
if (len < 0)
return 0;
/* find where in stream to start */
here = index->list;
ret = index->have;
while (--ret && here[1].out <= offset)
here++;
/* initialize file and inflate state to start there */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit2(&strm, -15); /* raw inflate */
if (ret != Z_OK)
return ret;
ret = fseeko(in, here->in - (here->bits ? 1 : 0), SEEK_SET);
if (ret == -1)
goto deflate_index_extract_ret;
if (here->bits) {
ret = getc(in);
if (ret == -1) {
ret = ferror(in) ? Z_ERRNO : Z_DATA_ERROR;
goto deflate_index_extract_ret;
}
unsigned got = strm.avail_out;
ret = inflate(&strm, Z_NO_FLUSH);
got -= strm.avail_out;
(void)inflatePrime(&strm, here->bits, ret >> (8 - here->bits));
}
(void)inflateSetDictionary(&strm, here->window, WINSIZE);
// Update the appropriate count.
if (offset)
offset -= got;
else
left -= got;
/* skip uncompressed bytes until offset reached, then satisfy request */
offset -= here->out;
strm.avail_in = 0;
skip = 1; /* while skipping to offset */
do {
/* define where to put uncompressed data, and how much */
if (offset > WINSIZE) { /* skip WINSIZE bytes */
strm.avail_out = WINSIZE;
strm.next_out = discard;
offset -= WINSIZE;
}
else if (offset > 0) { /* last skip */
strm.avail_out = (unsigned)offset;
strm.next_out = discard;
offset = 0;
}
else if (skip) { /* at offset now */
strm.avail_out = len;
strm.next_out = buf;
skip = 0; /* only do this once */
}
// If we're at the end of a gzip member and there's more to read,
// continue to the next gzip member.
if (ret == Z_STREAM_END && index->mode == GZIP) {
// Discard the gzip trailer.
unsigned drop = 8; // length of gzip trailer
if (strm.avail_in >= drop) {
strm.avail_in -= drop;
strm.next_in += drop;
}
else {
// Read and discard the remainder of the gzip trailer.
drop -= strm.avail_in;
strm.avail_in = 0;
do {
if (getc(in) == EOF)
// The input does not have a complete trailer.
return ferror(in) ? Z_ERRNO : Z_BUF_ERROR;
} while (--drop);
/* uncompress until avail_out filled, or end of stream */
do {
if (strm.avail_in == 0) {
strm.avail_in = fread(input, 1, CHUNK, in);
if (ferror(in)) {
ret = Z_ERRNO;
goto deflate_index_extract_ret;
}
if (strm.avail_in == 0) {
ret = Z_DATA_ERROR;
goto deflate_index_extract_ret;
}
strm.next_in = input;
}
ret = inflate(&strm, Z_NO_FLUSH); /* normal inflate */
if (ret == Z_NEED_DICT)
ret = Z_DATA_ERROR;
if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR)
goto deflate_index_extract_ret;
if (ret == Z_STREAM_END) {
/* the raw deflate stream has ended */
if (index->gzip == 0)
/* this is a zlib stream that has ended -- done */
break;
if (strm.avail_in || ungetc(getc(in), in) != EOF) {
// There's more after the gzip trailer. Use inflate to skip the
// gzip header and resume the raw inflate there.
inflateReset2(&strm, GZIP);
/* near the end of a gzip member, which might be followed by
another gzip member -- skip the gzip trailer and see if
there is more input after it */
if (strm.avail_in < 8) {
fseeko(in, 8 - strm.avail_in, SEEK_CUR);
strm.avail_in = 0;
}
else {
strm.avail_in -= 8;
strm.next_in += 8;
}
if (strm.avail_in == 0 && ungetc(getc(in), in) == EOF)
/* the input ended after the gzip trailer -- done */
break;
/* there is more input, so another gzip member should follow --
validate and skip the gzip header */
ret = inflateReset2(&strm, 31);
if (ret != Z_OK)
goto deflate_index_extract_ret;
do {
if (strm.avail_in == 0) {
strm.avail_in = fread(input, 1, CHUNK, in);
if (strm.avail_in < CHUNK && ferror(in)) {
if (ferror(in)) {
ret = Z_ERRNO;
break;
goto deflate_index_extract_ret;
}
if (strm.avail_in == 0) {
ret = Z_DATA_ERROR;
goto deflate_index_extract_ret;
}
strm.next_in = input;
}
strm.avail_out = WINSIZE;
strm.next_out = discard;
ret = inflate(&strm, Z_BLOCK); // stop at end of header
} while (ret == Z_OK && (strm.data_type & 0x80) == 0);
ret = inflate(&strm, Z_BLOCK);
if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR)
goto deflate_index_extract_ret;
} while ((strm.data_type & 128) == 0);
/* set up to continue decompression of the raw deflate stream
that follows the gzip header */
ret = inflateReset2(&strm, -15);
if (ret != Z_OK)
break;
inflateReset2(&strm, RAW);
goto deflate_index_extract_ret;
}
}
// Continue until we have the requested data, the deflate data has
// ended, or an error is encountered.
} while (ret == Z_OK && left);
inflateEnd(&strm);
/* continue to process the available input before reading more */
} while (strm.avail_out != 0);
// Return the number of uncompressed bytes read into buf, or the error.
return ret == Z_OK || ret == Z_STREAM_END ? len - left : ret;
if (ret == Z_STREAM_END)
/* reached the end of the compressed data -- return the data that
was available, possibly less than requested */
break;
/* do until offset reached and requested data read */
} while (skip);
/* compute the number of uncompressed bytes read after the offset */
ret = skip ? 0 : len - strm.avail_out;
/* clean up and return the bytes read, or the negative error */
deflate_index_extract_ret:
(void)inflateEnd(&strm);
return ret;
}
#ifdef TEST
#define SPAN 1048576L // desired distance between access points
#define LEN 16384 // number of bytes to extract
#define SPAN 1048576L /* desired distance between access points */
#define LEN 16384 /* number of bytes to extract */
// Demonstrate the use of deflate_index_build() and deflate_index_extract() by
// processing the file provided on the command line, and extracting LEN bytes
// from 2/3rds of the way through the uncompressed output, writing that to
// stdout. An offset can be provided as the second argument, in which case the
// data is extracted from there instead.
int main(int argc, char **argv) {
// Open the input file.
/* Demonstrate the use of deflate_index_build() and deflate_index_extract() by
processing the file provided on the command line, and extracting LEN bytes
from 2/3rds of the way through the uncompressed output, writing that to
stdout. An offset can be provided as the second argument, in which case the
data is extracted from there instead. */
int main(int argc, char **argv)
{
int len;
off_t offset = -1;
FILE *in;
struct deflate_index *index = NULL;
unsigned char buf[LEN];
/* open input file */
if (argc < 2 || argc > 3) {
fprintf(stderr, "usage: zran file.raw [offset]\n");
fprintf(stderr, "usage: zran file.gz [offset]\n");
return 1;
}
FILE *in = fopen(argv[1], "rb");
in = fopen(argv[1], "rb");
if (in == NULL) {
fprintf(stderr, "zran: could not open %s for reading\n", argv[1]);
return 1;
}
// Get optional offset.
off_t offset = -1;
/* get optional offset */
if (argc == 3) {
char *end;
offset = strtoll(argv[2], &end, 10);
@@ -486,18 +437,14 @@ int main(int argc, char **argv) {
}
}
// Build index.
struct deflate_index *index = NULL;
int len = deflate_index_build(in, SPAN, &index);
/* build index */
len = deflate_index_build(in, SPAN, &index);
if (len < 0) {
fclose(in);
switch (len) {
case Z_MEM_ERROR:
fprintf(stderr, "zran: out of memory\n");
break;
case Z_BUF_ERROR:
fprintf(stderr, "zran: %s ended prematurely\n", argv[1]);
break;
case Z_DATA_ERROR:
fprintf(stderr, "zran: compressed data error in %s\n", argv[1]);
break;
@@ -511,20 +458,19 @@ int main(int argc, char **argv) {
}
fprintf(stderr, "zran: built index with %d access points\n", len);
// Use index by reading some bytes from an arbitrary offset.
unsigned char buf[LEN];
/* use index by reading some bytes from an arbitrary offset */
if (offset == -1)
offset = ((index->length + 1) << 1) / 3;
ptrdiff_t got = deflate_index_extract(in, index, offset, buf, LEN);
if (got < 0)
offset = (index->length << 1) / 3;
len = deflate_index_extract(in, index, offset, buf, LEN);
if (len < 0)
fprintf(stderr, "zran: extraction failed: %s error\n",
got == Z_MEM_ERROR ? "out of memory" : "input corrupted");
len == Z_MEM_ERROR ? "out of memory" : "input corrupted");
else {
fwrite(buf, 1, got, stdout);
fprintf(stderr, "zran: extracted %ld bytes at %lld\n", got, offset);
fwrite(buf, 1, len, stdout);
fprintf(stderr, "zran: extracted %d bytes at %llu\n", len, offset);
}
// Clean up and exit.
/* clean up and exit */
deflate_index_free(index);
fclose(in);
return 0;
+29 -40
View File
@@ -1,51 +1,40 @@
/* zran.h -- example of deflated stream indexing and random access
* Copyright (C) 2005, 2012, 2018, 2023 Mark Adler
/* zran.h -- example of zlib/gzip stream indexing and random access
* Copyright (C) 2005, 2012, 2018 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.3 18 Feb 2023 Mark Adler */
* Version 1.2 14 Oct 2018 Mark Adler */
#include <stdio.h>
#include "zlib.h"
// Access point.
typedef struct point {
off_t out; // offset in uncompressed data
off_t in; // offset in compressed file of first full byte
int bits; // 0, or number of bits (1-7) from byte at in-1
unsigned char window[32768]; // preceding 32K of uncompressed data
} point_t;
// Access point list.
/* Access point list. */
struct deflate_index {
int have; // number of access points in list
int mode; // -15 for raw, 15 for zlib, or 31 for gzip
off_t length; // total length of uncompressed data
point_t *list; // allocated list of access points
int have; /* number of list entries */
int gzip; /* 1 if the index is of a gzip file, 0 if it is of a
zlib stream */
off_t length; /* total length of uncompressed data */
void *list; /* allocated list of entries */
};
// Make one pass through a zlib, gzip, or raw deflate compressed stream and
// build an index, with access points about every span bytes of uncompressed
// output. gzip files with multiple members are fully indexed. span should be
// chosen to balance the speed of random access against the memory requirements
// of the list, which is about 32K bytes per access point. The return value is
// the number of access points on success (>= 1), Z_MEM_ERROR for out of
// memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format
// or verification error in the input file, or Z_ERRNO for a file read error.
// On success, *built points to the resulting index.
/* Make one entire pass through a zlib or gzip compressed stream and build an
index, with access points about every span bytes of uncompressed output.
gzip files with multiple members are indexed in their entirety. span should
be chosen to balance the speed of random access against the memory
requirements of the list, about 32K bytes per access point. The return value
is the number of access points on success (>= 1), Z_MEM_ERROR for out of
memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a file
read error. On success, *built points to the resulting index. */
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built);
// Use the index to read len bytes from offset into buf. Return the number of
// bytes read or a negative error code. If data is requested past the end of
// the uncompressed data, then deflate_index_extract() will return a value less
// than len, indicating how much was actually read into buf. If given a valid
// index, this function should not return an error unless the file was modified
// somehow since the index was generated, given that deflate_index_build() had
// validated all of the input. If nevertheless there is a failure, Z_BUF_ERROR
// is returned if the compressed data ends prematurely, Z_DATA_ERROR if the
// deflate compressed data is not valid, Z_MEM_ERROR if out of memory,
// Z_STREAM_ERROR if the index is not valid, or Z_ERRNO if there is an error
// reading or seeking on the input file.
ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
off_t offset, unsigned char *buf, size_t len);
// Deallocate an index built by deflate_index_build().
/* Deallocate an index built by deflate_index_build() */
void deflate_index_free(struct deflate_index *index);
/* Use the index to read len bytes from offset into buf. Return bytes read or
negative for error (Z_DATA_ERROR or Z_MEM_ERROR). If data is requested past
the end of the uncompressed data, then deflate_index_extract() will return a
value less than len, indicating how much was actually read into buf. This
function should not return a data error unless the file was modified since
the index was generated, since deflate_index_build() validated all of the
input. deflate_index_extract() will return Z_ERRNO if there is an error on
reading or seeking the input file. */
int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset,
unsigned char *buf, int len);
+3 -1
View File
@@ -8,7 +8,9 @@
/* gzclose() is in a separate file so that it is linked in only if it is used.
That way the other gzclose functions can be used instead to avoid linking in
unneeded compression or decompression routines. */
int ZEXPORT gzclose(gzFile file) {
int ZEXPORT gzclose(file)
gzFile file;
{
#ifndef NO_GZCOMPRESS
gz_statep state;
+12 -11
View File
@@ -7,8 +7,9 @@
# ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1
# endif
# undef _FILE_OFFSET_BITS
# undef _TIME_BITS
# ifdef _FILE_OFFSET_BITS
# undef _FILE_OFFSET_BITS
# endif
#endif
#ifdef HAVE_HIDDEN
@@ -118,8 +119,8 @@
/* gz* functions always use library allocation functions */
#ifndef STDC
extern voidp malloc(uInt size);
extern void free(voidpf ptr);
extern voidp malloc OF((uInt size));
extern void free OF((voidpf ptr));
#endif
/* get errno and strerror definition */
@@ -137,10 +138,10 @@
/* provide prototypes for these when building zlib without LFS */
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
#endif
/* default memLevel */
@@ -202,9 +203,9 @@ typedef struct {
typedef gz_state FAR *gz_statep;
/* shared functions */
void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
#if defined UNDER_CE
char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
#endif
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
@@ -213,6 +214,6 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
#ifdef INT_MAX
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
#else
unsigned ZLIB_INTERNAL gz_intmax(void);
unsigned ZLIB_INTERNAL gz_intmax OF((void));
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
#endif
+79 -22
View File
@@ -15,6 +15,10 @@
#endif
#endif
/* Local functions */
local void gz_reset OF((gz_statep));
local gzFile gz_open OF((const void *, int, const char *));
#if defined UNDER_CE
/* Map the Windows error number in ERROR to a locale-dependent error message
@@ -26,7 +30,9 @@
The gz_strwinerror function does not change the current setting of
GetLastError. */
char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
char ZLIB_INTERNAL *gz_strwinerror(error)
DWORD error;
{
static char buf[1024];
wchar_t *msgbuf;
@@ -66,7 +72,9 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
#endif /* UNDER_CE */
/* Reset gzip file state */
local void gz_reset(gz_statep state) {
local void gz_reset(state)
gz_statep state;
{
state->x.have = 0; /* no output data available */
if (state->mode == GZ_READ) { /* for reading ... */
state->eof = 0; /* not at end of file */
@@ -82,7 +90,11 @@ local void gz_reset(gz_statep state) {
}
/* Open a gzip file either by name or file descriptor. */
local gzFile gz_open(const void *path, int fd, const char *mode) {
local gzFile gz_open(path, fd, mode)
const void *path;
int fd;
const char *mode;
{
gz_statep state;
z_size_t len;
int oflag;
@@ -257,17 +269,26 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
}
/* -- see zlib.h -- */
gzFile ZEXPORT gzopen(const char *path, const char *mode) {
gzFile ZEXPORT gzopen(path, mode)
const char *path;
const char *mode;
{
return gz_open(path, -1, mode);
}
/* -- see zlib.h -- */
gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
gzFile ZEXPORT gzopen64(path, mode)
const char *path;
const char *mode;
{
return gz_open(path, -1, mode);
}
/* -- see zlib.h -- */
gzFile ZEXPORT gzdopen(int fd, const char *mode) {
gzFile ZEXPORT gzdopen(fd, mode)
int fd;
const char *mode;
{
char *path; /* identifier for error messages */
gzFile gz;
@@ -285,13 +306,19 @@ gzFile ZEXPORT gzdopen(int fd, const char *mode) {
/* -- see zlib.h -- */
#ifdef WIDECHAR
gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
gzFile ZEXPORT gzopen_w(path, mode)
const wchar_t *path;
const char *mode;
{
return gz_open(path, -2, mode);
}
#endif
/* -- see zlib.h -- */
int ZEXPORT gzbuffer(gzFile file, unsigned size) {
int ZEXPORT gzbuffer(file, size)
gzFile file;
unsigned size;
{
gz_statep state;
/* get internal structure and check integrity */
@@ -308,14 +335,16 @@ int ZEXPORT gzbuffer(gzFile file, unsigned size) {
/* check and set requested size */
if ((size << 1) < size)
return -1; /* need to be able to double it */
if (size < 8)
size = 8; /* needed to behave well with flushing */
if (size < 2)
size = 2; /* need two bytes to check magic header */
state->want = size;
return 0;
}
/* -- see zlib.h -- */
int ZEXPORT gzrewind(gzFile file) {
int ZEXPORT gzrewind(file)
gzFile file;
{
gz_statep state;
/* get internal structure */
@@ -336,7 +365,11 @@ int ZEXPORT gzrewind(gzFile file) {
}
/* -- see zlib.h -- */
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
z_off64_t ZEXPORT gzseek64(file, offset, whence)
gzFile file;
z_off64_t offset;
int whence;
{
unsigned n;
z_off64_t ret;
gz_statep state;
@@ -409,7 +442,11 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
}
/* -- see zlib.h -- */
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
z_off_t ZEXPORT gzseek(file, offset, whence)
gzFile file;
z_off_t offset;
int whence;
{
z_off64_t ret;
ret = gzseek64(file, (z_off64_t)offset, whence);
@@ -417,7 +454,9 @@ z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
}
/* -- see zlib.h -- */
z_off64_t ZEXPORT gztell64(gzFile file) {
z_off64_t ZEXPORT gztell64(file)
gzFile file;
{
gz_statep state;
/* get internal structure and check integrity */
@@ -432,7 +471,9 @@ z_off64_t ZEXPORT gztell64(gzFile file) {
}
/* -- see zlib.h -- */
z_off_t ZEXPORT gztell(gzFile file) {
z_off_t ZEXPORT gztell(file)
gzFile file;
{
z_off64_t ret;
ret = gztell64(file);
@@ -440,7 +481,9 @@ z_off_t ZEXPORT gztell(gzFile file) {
}
/* -- see zlib.h -- */
z_off64_t ZEXPORT gzoffset64(gzFile file) {
z_off64_t ZEXPORT gzoffset64(file)
gzFile file;
{
z_off64_t offset;
gz_statep state;
@@ -461,7 +504,9 @@ z_off64_t ZEXPORT gzoffset64(gzFile file) {
}
/* -- see zlib.h -- */
z_off_t ZEXPORT gzoffset(gzFile file) {
z_off_t ZEXPORT gzoffset(file)
gzFile file;
{
z_off64_t ret;
ret = gzoffset64(file);
@@ -469,7 +514,9 @@ z_off_t ZEXPORT gzoffset(gzFile file) {
}
/* -- see zlib.h -- */
int ZEXPORT gzeof(gzFile file) {
int ZEXPORT gzeof(file)
gzFile file;
{
gz_statep state;
/* get internal structure and check integrity */
@@ -484,7 +531,10 @@ int ZEXPORT gzeof(gzFile file) {
}
/* -- see zlib.h -- */
const char * ZEXPORT gzerror(gzFile file, int *errnum) {
const char * ZEXPORT gzerror(file, errnum)
gzFile file;
int *errnum;
{
gz_statep state;
/* get internal structure and check integrity */
@@ -502,7 +552,9 @@ const char * ZEXPORT gzerror(gzFile file, int *errnum) {
}
/* -- see zlib.h -- */
void ZEXPORT gzclearerr(gzFile file) {
void ZEXPORT gzclearerr(file)
gzFile file;
{
gz_statep state;
/* get internal structure and check integrity */
@@ -526,7 +578,11 @@ void ZEXPORT gzclearerr(gzFile file) {
memory). Simply save the error message as a static string. If there is an
allocation failure constructing the error message, then convert the error to
out of memory. */
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
void ZLIB_INTERNAL gz_error(state, err, msg)
gz_statep state;
int err;
const char *msg;
{
/* free previously allocated message and clear */
if (state->msg != NULL) {
if (state->err != Z_MEM_ERROR)
@@ -568,7 +624,8 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
available) -- we need to do this to cover cases where 2's complement not
used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */
unsigned ZLIB_INTERNAL gz_intmax(void) {
unsigned ZLIB_INTERNAL gz_intmax()
{
unsigned p, q;
p = 1;
+68 -20
View File
@@ -5,12 +5,25 @@
#include "gzguts.h"
/* Local functions */
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
local int gz_avail OF((gz_statep));
local int gz_look OF((gz_statep));
local int gz_decomp OF((gz_statep));
local int gz_fetch OF((gz_statep));
local int gz_skip OF((gz_statep, z_off64_t));
local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
state->fd, and update state->eof, state->err, and state->msg as appropriate.
This function needs to loop on read(), since read() is not guaranteed to
read the number of bytes requested, depending on the type of descriptor. */
local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
unsigned *have) {
local int gz_load(state, buf, len, have)
gz_statep state;
unsigned char *buf;
unsigned len;
unsigned *have;
{
int ret;
unsigned get, max = ((unsigned)-1 >> 2) + 1;
@@ -40,7 +53,9 @@ local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
If strm->avail_in != 0, then the current data is moved to the beginning of
the input buffer, and then the remainder of the buffer is loaded with the
available data from the input file. */
local int gz_avail(gz_statep state) {
local int gz_avail(state)
gz_statep state;
{
unsigned got;
z_streamp strm = &(state->strm);
@@ -73,7 +88,9 @@ local int gz_avail(gz_statep state) {
case, all further file reads will be directly to either the output buffer or
a user buffer. If decompressing, the inflate state will be initialized.
gz_look() will return 0 on success or -1 on failure. */
local int gz_look(gz_statep state) {
local int gz_look(state)
gz_statep state;
{
z_streamp strm = &(state->strm);
/* allocate read buffers and inflate memory */
@@ -153,7 +170,9 @@ local int gz_look(gz_statep state) {
data. If the gzip stream completes, state->how is reset to LOOK to look for
the next gzip stream or raw data, once state->x.have is depleted. Returns 0
on success, -1 on failure. */
local int gz_decomp(gz_statep state) {
local int gz_decomp(state)
gz_statep state;
{
int ret = Z_OK;
unsigned had;
z_streamp strm = &(state->strm);
@@ -205,7 +224,9 @@ local int gz_decomp(gz_statep state) {
looked for to determine whether to copy or decompress. Returns -1 on error,
otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
end of the input file has been reached and all data has been processed. */
local int gz_fetch(gz_statep state) {
local int gz_fetch(state)
gz_statep state;
{
z_streamp strm = &(state->strm);
do {
@@ -233,7 +254,10 @@ local int gz_fetch(gz_statep state) {
}
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
local int gz_skip(gz_statep state, z_off64_t len) {
local int gz_skip(state, len)
gz_statep state;
z_off64_t len;
{
unsigned n;
/* skip over len bytes or reach end-of-file, whichever comes first */
@@ -265,7 +289,11 @@ local int gz_skip(gz_statep state, z_off64_t len) {
input. Return the number of bytes read. If zero is returned, either the
end of file was reached, or there was an error. state->err must be
consulted in that case to determine which. */
local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
local z_size_t gz_read(state, buf, len)
gz_statep state;
voidp buf;
z_size_t len;
{
z_size_t got;
unsigned n;
@@ -342,7 +370,11 @@ local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
}
/* -- see zlib.h -- */
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
int ZEXPORT gzread(file, buf, len)
gzFile file;
voidp buf;
unsigned len;
{
gz_statep state;
/* get internal structure */
@@ -374,7 +406,12 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
}
/* -- see zlib.h -- */
z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) {
z_size_t ZEXPORT gzfread(buf, size, nitems, file)
voidp buf;
z_size_t size;
z_size_t nitems;
gzFile file;
{
z_size_t len;
gz_statep state;
@@ -405,7 +442,9 @@ z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file)
#else
# undef gzgetc
#endif
int ZEXPORT gzgetc(gzFile file) {
int ZEXPORT gzgetc(file)
gzFile file;
{
unsigned char buf[1];
gz_statep state;
@@ -430,12 +469,17 @@ int ZEXPORT gzgetc(gzFile file) {
return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
}
int ZEXPORT gzgetc_(gzFile file) {
int ZEXPORT gzgetc_(file)
gzFile file;
{
return gzgetc(file);
}
/* -- see zlib.h -- */
int ZEXPORT gzungetc(int c, gzFile file) {
int ZEXPORT gzungetc(c, file)
int c;
gzFile file;
{
gz_statep state;
/* get internal structure */
@@ -443,10 +487,6 @@ int ZEXPORT gzungetc(int c, gzFile file) {
return -1;
state = (gz_statep)file;
/* in case this was just opened, set up the input buffer */
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
(void)gz_look(state);
/* check that we're reading and that there's no (serious) error */
if (state->mode != GZ_READ ||
(state->err != Z_OK && state->err != Z_BUF_ERROR))
@@ -496,7 +536,11 @@ int ZEXPORT gzungetc(int c, gzFile file) {
}
/* -- see zlib.h -- */
char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
char * ZEXPORT gzgets(file, buf, len)
gzFile file;
char *buf;
int len;
{
unsigned left, n;
char *str;
unsigned char *eol;
@@ -556,7 +600,9 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
}
/* -- see zlib.h -- */
int ZEXPORT gzdirect(gzFile file) {
int ZEXPORT gzdirect(file)
gzFile file;
{
gz_statep state;
/* get internal structure */
@@ -574,7 +620,9 @@ int ZEXPORT gzdirect(gzFile file) {
}
/* -- see zlib.h -- */
int ZEXPORT gzclose_r(gzFile file) {
int ZEXPORT gzclose_r(file)
gzFile file;
{
int ret, err;
gz_statep state;
+65 -19
View File
@@ -5,10 +5,18 @@
#include "gzguts.h"
/* Local functions */
local int gz_init OF((gz_statep));
local int gz_comp OF((gz_statep, int));
local int gz_zero OF((gz_statep, z_off64_t));
local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
/* Initialize state for writing a gzip file. Mark initialization by setting
state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
success. */
local int gz_init(gz_statep state) {
local int gz_init(state)
gz_statep state;
{
int ret;
z_streamp strm = &(state->strm);
@@ -62,7 +70,10 @@ local int gz_init(gz_statep state) {
deflate() flush value. If flush is Z_FINISH, then the deflate() state is
reset to start a new gzip stream. If gz->direct is true, then simply write
to the output file without compressing, and ignore flush. */
local int gz_comp(gz_statep state, int flush) {
local int gz_comp(state, flush)
gz_statep state;
int flush;
{
int ret, writ;
unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
z_streamp strm = &(state->strm);
@@ -140,7 +151,10 @@ local int gz_comp(gz_statep state, int flush) {
/* Compress len zeros to output. Return -1 on a write error or memory
allocation failure by gz_comp(), or 0 on success. */
local int gz_zero(gz_statep state, z_off64_t len) {
local int gz_zero(state, len)
gz_statep state;
z_off64_t len;
{
int first;
unsigned n;
z_streamp strm = &(state->strm);
@@ -170,7 +184,11 @@ local int gz_zero(gz_statep state, z_off64_t len) {
/* Write len bytes from buf to file. Return the number of bytes written. If
the returned value is less than len, then there was an error. */
local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
local z_size_t gz_write(state, buf, len)
gz_statep state;
voidpc buf;
z_size_t len;
{
z_size_t put = len;
/* if len is zero, avoid unnecessary operations */
@@ -234,7 +252,11 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
}
/* -- see zlib.h -- */
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
int ZEXPORT gzwrite(file, buf, len)
gzFile file;
voidpc buf;
unsigned len;
{
gz_statep state;
/* get internal structure */
@@ -258,8 +280,12 @@ int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
}
/* -- see zlib.h -- */
z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
gzFile file) {
z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
voidpc buf;
z_size_t size;
z_size_t nitems;
gzFile file;
{
z_size_t len;
gz_statep state;
@@ -284,7 +310,10 @@ z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
}
/* -- see zlib.h -- */
int ZEXPORT gzputc(gzFile file, int c) {
int ZEXPORT gzputc(file, c)
gzFile file;
int c;
{
unsigned have;
unsigned char buf[1];
gz_statep state;
@@ -329,7 +358,10 @@ int ZEXPORT gzputc(gzFile file, int c) {
}
/* -- see zlib.h -- */
int ZEXPORT gzputs(gzFile file, const char *s) {
int ZEXPORT gzputs(file, s)
gzFile file;
const char *s;
{
z_size_t len, put;
gz_statep state;
@@ -356,7 +388,8 @@ int ZEXPORT gzputs(gzFile file, const char *s) {
#include <stdarg.h>
/* -- see zlib.h -- */
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
{
int len;
unsigned left;
char *next;
@@ -427,7 +460,8 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
return len;
}
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
{
va_list va;
int ret;
@@ -440,10 +474,13 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
#else /* !STDC && !Z_HAVE_STDARG_H */
/* -- see zlib.h -- */
int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
int a4, int a5, int a6, int a7, int a8, int a9, int a10,
int a11, int a12, int a13, int a14, int a15, int a16,
int a17, int a18, int a19, int a20) {
int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
gzFile file;
const char *format;
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
{
unsigned len, left;
char *next;
gz_statep state;
@@ -525,7 +562,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
#endif
/* -- see zlib.h -- */
int ZEXPORT gzflush(gzFile file, int flush) {
int ZEXPORT gzflush(file, flush)
gzFile file;
int flush;
{
gz_statep state;
/* get internal structure */
@@ -554,7 +594,11 @@ int ZEXPORT gzflush(gzFile file, int flush) {
}
/* -- see zlib.h -- */
int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
int ZEXPORT gzsetparams(file, level, strategy)
gzFile file;
int level;
int strategy;
{
gz_statep state;
z_streamp strm;
@@ -565,7 +609,7 @@ int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
strm = &(state->strm);
/* check that we're writing and that there's no error */
if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct)
if (state->mode != GZ_WRITE || state->err != Z_OK)
return Z_STREAM_ERROR;
/* if no change is requested, then do nothing */
@@ -592,7 +636,9 @@ int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
}
/* -- see zlib.h -- */
int ZEXPORT gzclose_w(gzFile file) {
int ZEXPORT gzclose_w(file)
gzFile file;
{
int ret = Z_OK;
gz_statep state;
+23 -7
View File
@@ -15,6 +15,9 @@
#include "inflate.h"
#include "inffast.h"
/* function prototypes */
local void fixedtables OF((struct inflate_state FAR *state));
/*
strm provides memory allocation functions in zalloc and zfree, or
Z_NULL to use the library memory allocation functions.
@@ -22,9 +25,13 @@
windowBits is in the range 8..15, and window is a user-supplied
window and output buffer that is 2**windowBits bytes.
*/
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
unsigned char FAR *window, const char *version,
int stream_size) {
int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
z_streamp strm;
int windowBits;
unsigned char FAR *window;
const char *version;
int stream_size;
{
struct inflate_state FAR *state;
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
@@ -73,7 +80,9 @@ int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe.
*/
local void fixedtables(struct inflate_state FAR *state) {
local void fixedtables(state)
struct inflate_state FAR *state;
{
#ifdef BUILDFIXED
static int virgin = 1;
static code *lenfix, *distfix;
@@ -239,8 +248,13 @@ local void fixedtables(struct inflate_state FAR *state) {
inflateBack() can also return Z_STREAM_ERROR if the input parameters
are not correct, i.e. strm is Z_NULL or the state was not initialized.
*/
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
out_func out, void FAR *out_desc) {
int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
z_streamp strm;
in_func in;
void FAR *in_desc;
out_func out;
void FAR *out_desc;
{
struct inflate_state FAR *state;
z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */
@@ -618,7 +632,9 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
return ret;
}
int ZEXPORT inflateBackEnd(z_streamp strm) {
int ZEXPORT inflateBackEnd(strm)
z_streamp strm;
{
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
return Z_STREAM_ERROR;
ZFREE(strm, strm->state);
+4 -1
View File
@@ -47,7 +47,10 @@
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
void ZLIB_INTERNAL inflate_fast(strm, start)
z_streamp strm;
unsigned start; /* inflate()'s starting value for strm->avail_out */
{
struct inflate_state FAR *state;
z_const unsigned char FAR *in; /* local strm->next_in */
z_const unsigned char FAR *last; /* have enough input while in < last */
+1 -1
View File
@@ -8,4 +8,4 @@
subject to change. Applications should only use zlib.h.
*/
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
+99 -30
View File
@@ -91,7 +91,20 @@
# endif
#endif
local int inflateStateCheck(z_streamp strm) {
/* function prototypes */
local int inflateStateCheck OF((z_streamp strm));
local void fixedtables OF((struct inflate_state FAR *state));
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
unsigned copy));
#ifdef BUILDFIXED
void makefixed OF((void));
#endif
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
unsigned len));
local int inflateStateCheck(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
if (strm == Z_NULL ||
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
@@ -103,7 +116,9 @@ local int inflateStateCheck(z_streamp strm) {
return 0;
}
int ZEXPORT inflateResetKeep(z_streamp strm) {
int ZEXPORT inflateResetKeep(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -127,7 +142,9 @@ int ZEXPORT inflateResetKeep(z_streamp strm) {
return Z_OK;
}
int ZEXPORT inflateReset(z_streamp strm) {
int ZEXPORT inflateReset(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -138,7 +155,10 @@ int ZEXPORT inflateReset(z_streamp strm) {
return inflateResetKeep(strm);
}
int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
int ZEXPORT inflateReset2(strm, windowBits)
z_streamp strm;
int windowBits;
{
int wrap;
struct inflate_state FAR *state;
@@ -175,8 +195,12 @@ int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
return inflateReset(strm);
}
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
const char *version, int stream_size) {
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
z_streamp strm;
int windowBits;
const char *version;
int stream_size;
{
int ret;
struct inflate_state FAR *state;
@@ -215,17 +239,22 @@ int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
return ret;
}
int ZEXPORT inflateInit_(z_streamp strm, const char *version,
int stream_size) {
int ZEXPORT inflateInit_(strm, version, stream_size)
z_streamp strm;
const char *version;
int stream_size;
{
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
}
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
int ZEXPORT inflatePrime(strm, bits, value)
z_streamp strm;
int bits;
int value;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
if (bits == 0)
return Z_OK;
state = (struct inflate_state FAR *)strm->state;
if (bits < 0) {
state->hold = 0;
@@ -249,7 +278,9 @@ int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe.
*/
local void fixedtables(struct inflate_state FAR *state) {
local void fixedtables(state)
struct inflate_state FAR *state;
{
#ifdef BUILDFIXED
static int virgin = 1;
static code *lenfix, *distfix;
@@ -311,7 +342,7 @@ local void fixedtables(struct inflate_state FAR *state) {
a.out > inffixed.h
*/
void makefixed(void)
void makefixed()
{
unsigned low, size;
struct inflate_state state;
@@ -365,7 +396,11 @@ void makefixed(void)
output will fall in the output data, making match copies simpler and faster.
The advantage may be dependent on the size of the processor's data caches.
*/
local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
local int updatewindow(strm, end, copy)
z_streamp strm;
const Bytef *end;
unsigned copy;
{
struct inflate_state FAR *state;
unsigned dist;
@@ -587,7 +622,10 @@ local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
will return Z_BUF_ERROR if it has not reached the end of the stream.
*/
int ZEXPORT inflate(z_streamp strm, int flush) {
int ZEXPORT inflate(strm, flush)
z_streamp strm;
int flush;
{
struct inflate_state FAR *state;
z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */
@@ -1263,7 +1301,9 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
return ret;
}
int ZEXPORT inflateEnd(z_streamp strm) {
int ZEXPORT inflateEnd(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm))
return Z_STREAM_ERROR;
@@ -1275,8 +1315,11 @@ int ZEXPORT inflateEnd(z_streamp strm) {
return Z_OK;
}
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
uInt *dictLength) {
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
z_streamp strm;
Bytef *dictionary;
uInt *dictLength;
{
struct inflate_state FAR *state;
/* check state */
@@ -1295,8 +1338,11 @@ int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
return Z_OK;
}
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
uInt dictLength) {
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
z_streamp strm;
const Bytef *dictionary;
uInt dictLength;
{
struct inflate_state FAR *state;
unsigned long dictid;
int ret;
@@ -1327,7 +1373,10 @@ int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
return Z_OK;
}
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) {
int ZEXPORT inflateGetHeader(strm, head)
z_streamp strm;
gz_headerp head;
{
struct inflate_state FAR *state;
/* check state */
@@ -1352,8 +1401,11 @@ int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) {
called again with more data and the *have state. *have is initialized to
zero for the first call.
*/
local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf,
unsigned len) {
local unsigned syncsearch(have, buf, len)
unsigned FAR *have;
const unsigned char FAR *buf;
unsigned len;
{
unsigned got;
unsigned next;
@@ -1372,7 +1424,9 @@ local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf,
return next;
}
int ZEXPORT inflateSync(z_streamp strm) {
int ZEXPORT inflateSync(strm)
z_streamp strm;
{
unsigned len; /* number of bytes to look at or looked at */
int flags; /* temporary to save header status */
unsigned long in, out; /* temporary to save total_in and total_out */
@@ -1428,7 +1482,9 @@ int ZEXPORT inflateSync(z_streamp strm) {
block. When decompressing, PPP checks that at the end of input packet,
inflate is waiting for these length bytes.
*/
int ZEXPORT inflateSyncPoint(z_streamp strm) {
int ZEXPORT inflateSyncPoint(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -1436,7 +1492,10 @@ int ZEXPORT inflateSyncPoint(z_streamp strm) {
return state->mode == STORED && state->bits == 0;
}
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
int ZEXPORT inflateCopy(dest, source)
z_streamp dest;
z_streamp source;
{
struct inflate_state FAR *state;
struct inflate_state FAR *copy;
unsigned char FAR *window;
@@ -1480,7 +1539,10 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
return Z_OK;
}
int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
int ZEXPORT inflateUndermine(strm, subvert)
z_streamp strm;
int subvert;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -1495,7 +1557,10 @@ int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
#endif
}
int ZEXPORT inflateValidate(z_streamp strm, int check) {
int ZEXPORT inflateValidate(strm, check)
z_streamp strm;
int check;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
@@ -1507,7 +1572,9 @@ int ZEXPORT inflateValidate(z_streamp strm, int check) {
return Z_OK;
}
long ZEXPORT inflateMark(z_streamp strm) {
long ZEXPORT inflateMark(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm))
@@ -1518,7 +1585,9 @@ long ZEXPORT inflateMark(z_streamp strm) {
(state->mode == MATCH ? state->was - state->length : 0));
}
unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) {
unsigned long ZEXPORT inflateCodesUsed(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
if (inflateStateCheck(strm)) return (unsigned long)-1;
state = (struct inflate_state FAR *)strm->state;
+11 -6
View File
@@ -1,5 +1,5 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2023 Mark Adler
* Copyright (C) 1995-2022 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
" inflate 1.3 Copyright 1995-2023 Mark Adler ";
" inflate 1.2.13 Copyright 1995-2022 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -29,9 +29,14 @@ const char inflate_copyright[] =
table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code.
*/
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work) {
int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
codetype type;
unsigned short FAR *lens;
unsigned codes;
code FAR * FAR *table;
unsigned FAR *bits;
unsigned short FAR *work;
{
unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */
unsigned min, max; /* minimum and maximum code lengths */
@@ -57,7 +62,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203};
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 194, 65};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+3 -3
View File
@@ -57,6 +57,6 @@ typedef enum {
DISTS
} codetype;
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work);
int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work));
+1 -1
View File
@@ -1,4 +1,4 @@
ZLIB version 1.3.0 for OS/400 installation instructions
ZLIB version 1.2.13 for OS/400 installation instructions
1) Download and unpack the zlib tarball to some IFS directory.
(i.e.: /path/to/the/zlib/ifs/source/directory)
+4 -4
View File
@@ -1,7 +1,7 @@
* ZLIB.INC - Interface to the general purpose compression library
*
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
* Version 1.3.0
* Version 1.2.13
*
*
* WARNING:
@@ -22,12 +22,12 @@
*
* Versioning information.
*
D ZLIB_VERSION C '1.3.0'
D ZLIB_VERSION C '1.2.13'
D ZLIB_VERNUM C X'12a0'
D ZLIB_VER_MAJOR C 1
D ZLIB_VER_MINOR C 3
D ZLIB_VER_MINOR C 2
D ZLIB_VER_REVISION...
D C 0
D C 13
D ZLIB_VER_SUBREVISION...
D C 0
*
+5 -5
View File
@@ -25,10 +25,10 @@
<QPG:Files>
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../libz.so.1.3.0" install="/opt/lib/" user="root:bin" permission="644"/>
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.3.0"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.3.0"/>
<QPG:Add file="../libz.so.1.3.0" install="/opt/lib/" component="slib"/>
<QPG:Add file="../libz.so.1.2.13" install="/opt/lib/" user="root:bin" permission="644"/>
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.13"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.13"/>
<QPG:Add file="../libz.so.1.2.13" install="/opt/lib/" component="slib"/>
</QPG:Files>
<QPG:PackageFilter>
@@ -63,7 +63,7 @@
</QPM:ProductDescription>
<QPM:ReleaseDescription>
<QPM:ReleaseVersion>1.3.0</QPM:ReleaseVersion>
<QPM:ReleaseVersion>1.2.13</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
+80 -23
View File
@@ -34,14 +34,37 @@ static z_const char hello[] = "hello, hello!";
static const char dictionary[] = "hello";
static uLong dictId; /* Adler32 value of the dictionary */
void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_large_deflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_large_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_flush OF((Byte *compr, uLong *comprLen));
void test_sync OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_dict_deflate OF((Byte *compr, uLong comprLen));
void test_dict_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
int main OF((int argc, char *argv[]));
#ifdef Z_SOLO
void *myalloc(void *q, unsigned n, unsigned m) {
void *myalloc OF((void *, unsigned, unsigned));
void myfree OF((void *, void *));
void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
(void)q;
return calloc(n, m);
}
void myfree(void *q, void *p) {
void myfree(void *q, void *p)
{
(void)q;
free(p);
}
@@ -54,11 +77,18 @@ static free_func zfree = myfree;
static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0;
void test_compress OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_gzio OF((const char *fname,
Byte *uncompr, uLong uncomprLen));
/* ===========================================================================
* Test compress() and uncompress()
*/
void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
void test_compress(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
uLong len = (uLong)strlen(hello)+1;
@@ -81,7 +111,11 @@ void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
/* ===========================================================================
* Test read/write of .gz files
*/
void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
void test_gzio(fname, uncompr, uncomprLen)
const char *fname; /* compressed file name */
Byte *uncompr;
uLong uncomprLen;
{
#ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
#else
@@ -163,7 +197,10 @@ void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
/* ===========================================================================
* Test deflate() with small buffers
*/
void test_deflate(Byte *compr, uLong comprLen) {
void test_deflate(compr, comprLen)
Byte *compr;
uLong comprLen;
{
z_stream c_stream; /* compression stream */
int err;
uLong len = (uLong)strlen(hello)+1;
@@ -198,8 +235,10 @@ void test_deflate(Byte *compr, uLong comprLen) {
/* ===========================================================================
* Test inflate() with small buffers
*/
void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
void test_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
z_stream d_stream; /* decompression stream */
@@ -237,8 +276,10 @@ void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
/* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level
*/
void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
z_stream c_stream; /* compression stream */
int err;
@@ -267,7 +308,7 @@ void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
/* Feed in already compressed data and switch to no compression: */
deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
c_stream.next_in = compr;
c_stream.avail_in = (uInt)uncomprLen/2;
c_stream.avail_in = (uInt)comprLen/2;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
@@ -290,8 +331,10 @@ void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
/* ===========================================================================
* Test inflate() with large buffers
*/
void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
z_stream d_stream; /* decompression stream */
@@ -318,7 +361,7 @@ void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + uncomprLen/2) {
if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
exit(1);
} else {
@@ -329,7 +372,10 @@ void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
/* ===========================================================================
* Test deflate() with full flush
*/
void test_flush(Byte *compr, uLong *comprLen) {
void test_flush(compr, comprLen)
Byte *compr;
uLong *comprLen;
{
z_stream c_stream; /* compression stream */
int err;
uInt len = (uInt)strlen(hello)+1;
@@ -364,7 +410,10 @@ void test_flush(Byte *compr, uLong *comprLen) {
/* ===========================================================================
* Test inflateSync()
*/
void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) {
void test_sync(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
z_stream d_stream; /* decompression stream */
@@ -404,7 +453,10 @@ void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) {
/* ===========================================================================
* Test deflate() with preset dictionary
*/
void test_dict_deflate(Byte *compr, uLong comprLen) {
void test_dict_deflate(compr, comprLen)
Byte *compr;
uLong comprLen;
{
z_stream c_stream; /* compression stream */
int err;
@@ -438,8 +490,10 @@ void test_dict_deflate(Byte *compr, uLong comprLen) {
/* ===========================================================================
* Test inflate() with a preset dictionary
*/
void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
z_stream d_stream; /* decompression stream */
@@ -487,10 +541,13 @@ void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
* Usage: example [output.gz [input.gz]]
*/
int main(int argc, char *argv[]) {
int main(argc, argv)
int argc;
char *argv[];
{
Byte *compr, *uncompr;
uLong uncomprLen = 20000;
uLong comprLen = 3 * uncomprLen;
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0]) {
@@ -533,7 +590,7 @@ int main(int argc, char *argv[]) {
test_flush(compr, &comprLen);
test_sync(compr, comprLen, uncompr, uncomprLen);
comprLen = 3 * uncomprLen;
comprLen = uncomprLen;
test_dict_deflate(compr, comprLen);
test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
+2 -3
View File
@@ -373,7 +373,7 @@ local void cover_support(void)
mem_setup(&strm);
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit_(&strm, "!", (int)sizeof(z_stream));
ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream));
assert(ret == Z_VERSION_ERROR);
mem_done(&strm, "wrong version");
@@ -462,8 +462,7 @@ local unsigned pull(void *desc, unsigned char **buf)
local int push(void *desc, unsigned char *buf, unsigned len)
{
(void)buf;
(void)len;
buf += len;
return desc != Z_NULL; /* force error if desc not null */
}
+122 -50
View File
@@ -59,7 +59,7 @@
#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
extern int unlink(const char *);
extern int unlink OF((const char *));
#endif
#endif
@@ -149,12 +149,20 @@ static void pwinerror (s)
# include <unistd.h> /* for unlink() */
#endif
void *myalloc(void *q, unsigned n, unsigned m) {
void *myalloc OF((void *, unsigned, unsigned));
void myfree OF((void *, void *));
void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
(void)q;
return calloc(n, m);
}
void myfree(void *q, void *p) {
void myfree(q, p)
void *q, *p;
{
(void)q;
free(p);
}
@@ -167,7 +175,29 @@ typedef struct gzFile_s {
z_stream strm;
} *gzFile;
gzFile gz_open(const char *path, int fd, const char *mode) {
gzFile gzopen OF((const char *, const char *));
gzFile gzdopen OF((int, const char *));
gzFile gz_open OF((const char *, int, const char *));
gzFile gzopen(path, mode)
const char *path;
const char *mode;
{
return gz_open(path, -1, mode);
}
gzFile gzdopen(fd, mode)
int fd;
const char *mode;
{
return gz_open(NULL, fd, mode);
}
gzFile gz_open(path, fd, mode)
const char *path;
int fd;
const char *mode;
{
gzFile gz;
int ret;
@@ -201,15 +231,13 @@ gzFile gz_open(const char *path, int fd, const char *mode) {
return gz;
}
gzFile gzopen(const char *path, const char *mode) {
return gz_open(path, -1, mode);
}
int gzwrite OF((gzFile, const void *, unsigned));
gzFile gzdopen(int fd, const char *mode) {
return gz_open(NULL, fd, mode);
}
int gzwrite(gzFile gz, const void *buf, unsigned len) {
int gzwrite(gz, buf, len)
gzFile gz;
const void *buf;
unsigned len;
{
z_stream *strm;
unsigned char out[BUFLEN];
@@ -227,7 +255,13 @@ int gzwrite(gzFile gz, const void *buf, unsigned len) {
return len;
}
int gzread(gzFile gz, void *buf, unsigned len) {
int gzread OF((gzFile, void *, unsigned));
int gzread(gz, buf, len)
gzFile gz;
void *buf;
unsigned len;
{
int ret;
unsigned got;
unsigned char in[1];
@@ -258,7 +292,11 @@ int gzread(gzFile gz, void *buf, unsigned len) {
return len - strm->avail_out;
}
int gzclose(gzFile gz) {
int gzclose OF((gzFile));
int gzclose(gz)
gzFile gz;
{
z_stream *strm;
unsigned char out[BUFLEN];
@@ -283,7 +321,12 @@ int gzclose(gzFile gz) {
return Z_OK;
}
const char *gzerror(gzFile gz, int *err) {
const char *gzerror OF((gzFile, int *));
const char *gzerror(gz, err)
gzFile gz;
int *err;
{
*err = gz->err;
return gz->msg;
}
@@ -292,20 +335,67 @@ const char *gzerror(gzFile gz, int *err) {
static char *prog;
void error OF((const char *msg));
void gz_compress OF((FILE *in, gzFile out));
#ifdef USE_MMAP
int gz_compress_mmap OF((FILE *in, gzFile out));
#endif
void gz_uncompress OF((gzFile in, FILE *out));
void file_compress OF((char *file, char *mode));
void file_uncompress OF((char *file));
int main OF((int argc, char *argv[]));
/* ===========================================================================
* Display error message and exit
*/
void error(const char *msg) {
void error(msg)
const char *msg;
{
fprintf(stderr, "%s: %s\n", prog, msg);
exit(1);
}
/* ===========================================================================
* Compress input to output then close both files.
*/
void gz_compress(in, out)
FILE *in;
gzFile out;
{
local char buf[BUFLEN];
int len;
int err;
#ifdef USE_MMAP
/* Try first compressing with mmap. If mmap fails (minigzip used in a
* pipe), use the normal fread loop.
*/
if (gz_compress_mmap(in, out) == Z_OK) return;
#endif
for (;;) {
len = (int)fread(buf, 1, sizeof(buf), in);
if (ferror(in)) {
perror("fread");
exit(1);
}
if (len == 0) break;
if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
}
fclose(in);
if (gzclose(out) != Z_OK) error("failed gzclose");
}
#ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */
/* Try compressing the input file at once using mmap. Return Z_OK if
* if success, Z_ERRNO otherwise.
*/
int gz_compress_mmap(FILE *in, gzFile out) {
int gz_compress_mmap(in, out)
FILE *in;
gzFile out;
{
int len;
int err;
int ifd = fileno(in);
@@ -334,39 +424,13 @@ int gz_compress_mmap(FILE *in, gzFile out) {
}
#endif /* USE_MMAP */
/* ===========================================================================
* Compress input to output then close both files.
*/
void gz_compress(FILE *in, gzFile out) {
local char buf[BUFLEN];
int len;
int err;
#ifdef USE_MMAP
/* Try first compressing with mmap. If mmap fails (minigzip used in a
* pipe), use the normal fread loop.
*/
if (gz_compress_mmap(in, out) == Z_OK) return;
#endif
for (;;) {
len = (int)fread(buf, 1, sizeof(buf), in);
if (ferror(in)) {
perror("fread");
exit(1);
}
if (len == 0) break;
if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
}
fclose(in);
if (gzclose(out) != Z_OK) error("failed gzclose");
}
/* ===========================================================================
* Uncompress input to output then close both files.
*/
void gz_uncompress(gzFile in, FILE *out) {
void gz_uncompress(in, out)
gzFile in;
FILE *out;
{
local char buf[BUFLEN];
int len;
int err;
@@ -390,7 +454,10 @@ void gz_uncompress(gzFile in, FILE *out) {
* Compress the given file: create a corresponding .gz file and remove the
* original.
*/
void file_compress(char *file, char *mode) {
void file_compress(file, mode)
char *file;
char *mode;
{
local char outfile[MAX_NAME_LEN];
FILE *in;
gzFile out;
@@ -426,7 +493,9 @@ void file_compress(char *file, char *mode) {
/* ===========================================================================
* Uncompress the given file and remove the original.
*/
void file_uncompress(char *file) {
void file_uncompress(file)
char *file;
{
local char buf[MAX_NAME_LEN];
char *infile, *outfile;
FILE *out;
@@ -484,7 +553,10 @@ void file_uncompress(char *file) {
* -1 to -9 : compression level
*/
int main(int argc, char *argv[]) {
int main(argc, argv)
int argc;
char *argv[];
{
int copyout = 0;
int uncompr = 0;
gzFile file;
+2 -2
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" ?>
<package name="zlib" version="1.3">
<library name="zlib" dlversion="1.3" dlname="z">
<package name="zlib" version="1.2.13">
<library name="zlib" dlversion="1.2.13" dlname="z">
<property name="description"> zip compression library </property>
<property name="include-target-dir" value="$(@PACKAGE/install-includedir)" />
+302 -224
View File
@@ -122,116 +122,39 @@ struct static_tree_desc_s {
int max_length; /* max bit length for the codes */
};
#ifdef NO_INIT_GLOBAL_POINTERS
# define TCONST
#else
# define TCONST const
#endif
local TCONST static_tree_desc static_l_desc =
local const static_tree_desc static_l_desc =
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
local TCONST static_tree_desc static_d_desc =
local const static_tree_desc static_d_desc =
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
local TCONST static_tree_desc static_bl_desc =
local const static_tree_desc static_bl_desc =
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
/* ===========================================================================
* Output a short LSB first on the stream.
* IN assertion: there is enough room in pendingBuf.
* Local (static) routines in this file.
*/
#define put_short(s, w) { \
put_byte(s, (uch)((w) & 0xff)); \
put_byte(s, (uch)((ush)(w) >> 8)); \
}
/* ===========================================================================
* Reverse the first len bits of a code, using straightforward code (a faster
* method would use a table)
* IN assertion: 1 <= len <= 15
*/
local unsigned bi_reverse(unsigned code, int len) {
register unsigned res = 0;
do {
res |= code & 1;
code >>= 1, res <<= 1;
} while (--len > 0);
return res >> 1;
}
/* ===========================================================================
* Flush the bit buffer, keeping at most 7 bits in it.
*/
local void bi_flush(deflate_state *s) {
if (s->bi_valid == 16) {
put_short(s, s->bi_buf);
s->bi_buf = 0;
s->bi_valid = 0;
} else if (s->bi_valid >= 8) {
put_byte(s, (Byte)s->bi_buf);
s->bi_buf >>= 8;
s->bi_valid -= 8;
}
}
/* ===========================================================================
* Flush the bit buffer and align the output on a byte boundary
*/
local void bi_windup(deflate_state *s) {
if (s->bi_valid > 8) {
put_short(s, s->bi_buf);
} else if (s->bi_valid > 0) {
put_byte(s, (Byte)s->bi_buf);
}
s->bi_buf = 0;
s->bi_valid = 0;
#ifdef ZLIB_DEBUG
s->bits_sent = (s->bits_sent + 7) & ~7;
#endif
}
/* ===========================================================================
* Generate the codes for a given tree and bit counts (which need not be
* optimal).
* IN assertion: the array bl_count contains the bit length statistics for
* the given tree and the field len is set for all tree elements.
* OUT assertion: the field code is set for all tree elements of non
* zero code length.
*/
local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) {
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
unsigned code = 0; /* running code value */
int bits; /* bit index */
int n; /* code index */
/* The distribution counts are first used to generate the code values
* without bit reversal.
*/
for (bits = 1; bits <= MAX_BITS; bits++) {
code = (code + bl_count[bits - 1]) << 1;
next_code[bits] = (ush)code;
}
/* Check that the bit counts in bl_count are consistent. The last code
* must be all ones.
*/
Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
"inconsistent bit counts");
Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
for (n = 0; n <= max_code; n++) {
int len = tree[n].Len;
if (len == 0) continue;
/* Now reverse the bits */
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
}
}
local void tr_static_init OF((void));
local void init_block OF((deflate_state *s));
local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
local void build_tree OF((deflate_state *s, tree_desc *desc));
local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
local int build_bl_tree OF((deflate_state *s));
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
int blcodes));
local void compress_block OF((deflate_state *s, const ct_data *ltree,
const ct_data *dtree));
local int detect_data_type OF((deflate_state *s));
local unsigned bi_reverse OF((unsigned code, int len));
local void bi_windup OF((deflate_state *s));
local void bi_flush OF((deflate_state *s));
#ifdef GEN_TREES_H
local void gen_trees_header(void);
local void gen_trees_header OF((void));
#endif
#ifndef ZLIB_DEBUG
@@ -244,12 +167,27 @@ local void gen_trees_header(void);
send_bits(s, tree[c].Code, tree[c].Len); }
#endif
/* ===========================================================================
* Output a short LSB first on the stream.
* IN assertion: there is enough room in pendingBuf.
*/
#define put_short(s, w) { \
put_byte(s, (uch)((w) & 0xff)); \
put_byte(s, (uch)((ush)(w) >> 8)); \
}
/* ===========================================================================
* Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits.
*/
#ifdef ZLIB_DEBUG
local void send_bits(deflate_state *s, int value, int length) {
local void send_bits OF((deflate_state *s, int value, int length));
local void send_bits(s, value, length)
deflate_state *s;
int value; /* value to send */
int length; /* number of bits */
{
Tracevv((stderr," l %2d v %4x ", length, value));
Assert(length > 0 && length <= 15, "invalid length");
s->bits_sent += (ulg)length;
@@ -291,7 +229,8 @@ local void send_bits(deflate_state *s, int value, int length) {
/* ===========================================================================
* Initialize the various 'constant' tables.
*/
local void tr_static_init(void) {
local void tr_static_init()
{
#if defined(GEN_TREES_H) || !defined(STDC)
static int static_init_done = 0;
int n; /* iterates over tree elements */
@@ -384,7 +323,8 @@ local void tr_static_init(void) {
((i) == (last)? "\n};\n\n" : \
((i) % (width) == (width) - 1 ? ",\n" : ", "))
void gen_trees_header(void) {
void gen_trees_header()
{
FILE *header = fopen("trees.h", "w");
int i;
@@ -433,26 +373,12 @@ void gen_trees_header(void) {
}
#endif /* GEN_TREES_H */
/* ===========================================================================
* Initialize a new block.
*/
local void init_block(deflate_state *s) {
int n; /* iterates over tree elements */
/* Initialize the trees. */
for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
s->dyn_ltree[END_BLOCK].Freq = 1;
s->opt_len = s->static_len = 0L;
s->sym_next = s->matches = 0;
}
/* ===========================================================================
* Initialize the tree data structures for a new zlib stream.
*/
void ZLIB_INTERNAL _tr_init(deflate_state *s) {
void ZLIB_INTERNAL _tr_init(s)
deflate_state *s;
{
tr_static_init();
s->l_desc.dyn_tree = s->dyn_ltree;
@@ -475,6 +401,24 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {
init_block(s);
}
/* ===========================================================================
* Initialize a new block.
*/
local void init_block(s)
deflate_state *s;
{
int n; /* iterates over tree elements */
/* Initialize the trees. */
for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
s->dyn_ltree[END_BLOCK].Freq = 1;
s->opt_len = s->static_len = 0L;
s->sym_next = s->matches = 0;
}
#define SMALLEST 1
/* Index within the heap array of least frequent node in the Huffman tree */
@@ -504,7 +448,11 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {
* when the heap property is re-established (each father smaller than its
* two sons).
*/
local void pqdownheap(deflate_state *s, ct_data *tree, int k) {
local void pqdownheap(s, tree, k)
deflate_state *s;
ct_data *tree; /* the tree to restore */
int k; /* node to move down */
{
int v = s->heap[k];
int j = k << 1; /* left son of k */
while (j <= s->heap_len) {
@@ -535,7 +483,10 @@ local void pqdownheap(deflate_state *s, ct_data *tree, int k) {
* The length opt_len is updated; static_len is also updated if stree is
* not null.
*/
local void gen_bitlen(deflate_state *s, tree_desc *desc) {
local void gen_bitlen(s, desc)
deflate_state *s;
tree_desc *desc; /* the tree descriptor */
{
ct_data *tree = desc->dyn_tree;
int max_code = desc->max_code;
const ct_data *stree = desc->stat_desc->static_tree;
@@ -610,9 +561,48 @@ local void gen_bitlen(deflate_state *s, tree_desc *desc) {
}
}
#ifdef DUMP_BL_TREE
# include <stdio.h>
#endif
/* ===========================================================================
* Generate the codes for a given tree and bit counts (which need not be
* optimal).
* IN assertion: the array bl_count contains the bit length statistics for
* the given tree and the field len is set for all tree elements.
* OUT assertion: the field code is set for all tree elements of non
* zero code length.
*/
local void gen_codes(tree, max_code, bl_count)
ct_data *tree; /* the tree to decorate */
int max_code; /* largest code with non zero frequency */
ushf *bl_count; /* number of codes at each bit length */
{
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
unsigned code = 0; /* running code value */
int bits; /* bit index */
int n; /* code index */
/* The distribution counts are first used to generate the code values
* without bit reversal.
*/
for (bits = 1; bits <= MAX_BITS; bits++) {
code = (code + bl_count[bits - 1]) << 1;
next_code[bits] = (ush)code;
}
/* Check that the bit counts in bl_count are consistent. The last code
* must be all ones.
*/
Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
"inconsistent bit counts");
Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
for (n = 0; n <= max_code; n++) {
int len = tree[n].Len;
if (len == 0) continue;
/* Now reverse the bits */
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
}
}
/* ===========================================================================
* Construct one Huffman tree and assigns the code bit strings and lengths.
@@ -622,7 +612,10 @@ local void gen_bitlen(deflate_state *s, tree_desc *desc) {
* and corresponding code. The length opt_len is updated; static_len is
* also updated if stree is not null. The field max_code is set.
*/
local void build_tree(deflate_state *s, tree_desc *desc) {
local void build_tree(s, desc)
deflate_state *s;
tree_desc *desc; /* the tree descriptor */
{
ct_data *tree = desc->dyn_tree;
const ct_data *stree = desc->stat_desc->static_tree;
int elems = desc->stat_desc->elems;
@@ -707,7 +700,11 @@ local void build_tree(deflate_state *s, tree_desc *desc) {
* Scan a literal or distance tree to determine the frequencies of the codes
* in the bit length tree.
*/
local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
local void scan_tree(s, tree, max_code)
deflate_state *s;
ct_data *tree; /* the tree to be scanned */
int max_code; /* and its largest code of non zero frequency */
{
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
int curlen; /* length of current code */
@@ -748,7 +745,11 @@ local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
* Send a literal or distance tree in compressed form, using the codes in
* bl_tree.
*/
local void send_tree(deflate_state *s, ct_data *tree, int max_code) {
local void send_tree(s, tree, max_code)
deflate_state *s;
ct_data *tree; /* the tree to be scanned */
int max_code; /* and its largest code of non zero frequency */
{
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
int curlen; /* length of current code */
@@ -795,7 +796,9 @@ local void send_tree(deflate_state *s, ct_data *tree, int max_code) {
* Construct the Huffman tree for the bit lengths and return the index in
* bl_order of the last bit length code to send.
*/
local int build_bl_tree(deflate_state *s) {
local int build_bl_tree(s)
deflate_state *s;
{
int max_blindex; /* index of last bit length code of non zero freq */
/* Determine the bit length frequencies for literal and distance trees */
@@ -828,8 +831,10 @@ local int build_bl_tree(deflate_state *s) {
* lengths of the bit length codes, the literal tree and the distance tree.
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
*/
local void send_all_trees(deflate_state *s, int lcodes, int dcodes,
int blcodes) {
local void send_all_trees(s, lcodes, dcodes, blcodes)
deflate_state *s;
int lcodes, dcodes, blcodes; /* number of codes for each tree */
{
int rank; /* index in bl_order */
Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
@@ -855,8 +860,12 @@ local void send_all_trees(deflate_state *s, int lcodes, int dcodes,
/* ===========================================================================
* Send a stored block
*/
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
ulg stored_len, int last) {
void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
deflate_state *s;
charf *buf; /* input block */
ulg stored_len; /* length of input block */
int last; /* one if this is the last block for a file */
{
send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */
bi_windup(s); /* align on byte boundary */
put_short(s, (ush)stored_len);
@@ -875,7 +884,9 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
/* ===========================================================================
* Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
*/
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) {
void ZLIB_INTERNAL _tr_flush_bits(s)
deflate_state *s;
{
bi_flush(s);
}
@@ -883,7 +894,9 @@ void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) {
* Send one empty static block to give enough lookahead for inflate.
* This takes 10 bits, of which 7 may remain in the bit buffer.
*/
void ZLIB_INTERNAL _tr_align(deflate_state *s) {
void ZLIB_INTERNAL _tr_align(s)
deflate_state *s;
{
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
#ifdef ZLIB_DEBUG
@@ -892,99 +905,16 @@ void ZLIB_INTERNAL _tr_align(deflate_state *s) {
bi_flush(s);
}
/* ===========================================================================
* Send the block data compressed using the given Huffman trees
*/
local void compress_block(deflate_state *s, const ct_data *ltree,
const ct_data *dtree) {
unsigned dist; /* distance of matched string */
int lc; /* match length or unmatched char (if dist == 0) */
unsigned sx = 0; /* running index in sym_buf */
unsigned code; /* the code to send */
int extra; /* number of extra bits to send */
if (s->sym_next != 0) do {
dist = s->sym_buf[sx++] & 0xff;
dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
lc = s->sym_buf[sx++];
if (dist == 0) {
send_code(s, lc, ltree); /* send a literal byte */
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
} else {
/* Here, lc is the match length - MIN_MATCH */
code = _length_code[lc];
send_code(s, code + LITERALS + 1, ltree); /* send length code */
extra = extra_lbits[code];
if (extra != 0) {
lc -= base_length[code];
send_bits(s, lc, extra); /* send the extra length bits */
}
dist--; /* dist is now the match distance - 1 */
code = d_code(dist);
Assert (code < D_CODES, "bad d_code");
send_code(s, code, dtree); /* send the distance code */
extra = extra_dbits[code];
if (extra != 0) {
dist -= (unsigned)base_dist[code];
send_bits(s, dist, extra); /* send the extra distance bits */
}
} /* literal or match pair ? */
/* Check that the overlay between pending_buf and sym_buf is ok: */
Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
} while (sx < s->sym_next);
send_code(s, END_BLOCK, ltree);
}
/* ===========================================================================
* Check if the data type is TEXT or BINARY, using the following algorithm:
* - TEXT if the two conditions below are satisfied:
* a) There are no non-portable control characters belonging to the
* "block list" (0..6, 14..25, 28..31).
* b) There is at least one printable character belonging to the
* "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
* - BINARY otherwise.
* - The following partially-portable control characters form a
* "gray list" that is ignored in this detection algorithm:
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
* IN assertion: the fields Freq of dyn_ltree are set.
*/
local int detect_data_type(deflate_state *s) {
/* block_mask is the bit mask of block-listed bytes
* set bits 0..6, 14..25, and 28..31
* 0xf3ffc07f = binary 11110011111111111100000001111111
*/
unsigned long block_mask = 0xf3ffc07fUL;
int n;
/* Check for non-textual ("block-listed") bytes. */
for (n = 0; n <= 31; n++, block_mask >>= 1)
if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
return Z_BINARY;
/* Check for textual ("allow-listed") bytes. */
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|| s->dyn_ltree[13].Freq != 0)
return Z_TEXT;
for (n = 32; n < LITERALS; n++)
if (s->dyn_ltree[n].Freq != 0)
return Z_TEXT;
/* There are no "block-listed" or "allow-listed" bytes:
* this stream either is empty or has tolerated ("gray-listed") bytes only.
*/
return Z_BINARY;
}
/* ===========================================================================
* Determine the best encoding for the current block: dynamic trees, static
* trees or store, and write out the encoded block.
*/
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
ulg stored_len, int last) {
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
deflate_state *s;
charf *buf; /* input block, or NULL if too old */
ulg stored_len; /* length of input block */
int last; /* one if this is the last block for a file */
{
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
int max_blindex = 0; /* index of last bit length code of non zero freq */
@@ -1081,7 +1011,11 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
* Save the match info and tally the frequency counts. Return true if
* the current block must be flushed.
*/
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
int ZLIB_INTERNAL _tr_tally(s, dist, lc)
deflate_state *s;
unsigned dist; /* distance of matched string */
unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */
{
s->sym_buf[s->sym_next++] = (uch)dist;
s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
s->sym_buf[s->sym_next++] = (uch)lc;
@@ -1101,3 +1035,147 @@ int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
}
return (s->sym_next == s->sym_end);
}
/* ===========================================================================
* Send the block data compressed using the given Huffman trees
*/
local void compress_block(s, ltree, dtree)
deflate_state *s;
const ct_data *ltree; /* literal tree */
const ct_data *dtree; /* distance tree */
{
unsigned dist; /* distance of matched string */
int lc; /* match length or unmatched char (if dist == 0) */
unsigned sx = 0; /* running index in sym_buf */
unsigned code; /* the code to send */
int extra; /* number of extra bits to send */
if (s->sym_next != 0) do {
dist = s->sym_buf[sx++] & 0xff;
dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
lc = s->sym_buf[sx++];
if (dist == 0) {
send_code(s, lc, ltree); /* send a literal byte */
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
} else {
/* Here, lc is the match length - MIN_MATCH */
code = _length_code[lc];
send_code(s, code + LITERALS + 1, ltree); /* send length code */
extra = extra_lbits[code];
if (extra != 0) {
lc -= base_length[code];
send_bits(s, lc, extra); /* send the extra length bits */
}
dist--; /* dist is now the match distance - 1 */
code = d_code(dist);
Assert (code < D_CODES, "bad d_code");
send_code(s, code, dtree); /* send the distance code */
extra = extra_dbits[code];
if (extra != 0) {
dist -= (unsigned)base_dist[code];
send_bits(s, dist, extra); /* send the extra distance bits */
}
} /* literal or match pair ? */
/* Check that the overlay between pending_buf and sym_buf is ok: */
Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
} while (sx < s->sym_next);
send_code(s, END_BLOCK, ltree);
}
/* ===========================================================================
* Check if the data type is TEXT or BINARY, using the following algorithm:
* - TEXT if the two conditions below are satisfied:
* a) There are no non-portable control characters belonging to the
* "block list" (0..6, 14..25, 28..31).
* b) There is at least one printable character belonging to the
* "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
* - BINARY otherwise.
* - The following partially-portable control characters form a
* "gray list" that is ignored in this detection algorithm:
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
* IN assertion: the fields Freq of dyn_ltree are set.
*/
local int detect_data_type(s)
deflate_state *s;
{
/* block_mask is the bit mask of block-listed bytes
* set bits 0..6, 14..25, and 28..31
* 0xf3ffc07f = binary 11110011111111111100000001111111
*/
unsigned long block_mask = 0xf3ffc07fUL;
int n;
/* Check for non-textual ("block-listed") bytes. */
for (n = 0; n <= 31; n++, block_mask >>= 1)
if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
return Z_BINARY;
/* Check for textual ("allow-listed") bytes. */
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|| s->dyn_ltree[13].Freq != 0)
return Z_TEXT;
for (n = 32; n < LITERALS; n++)
if (s->dyn_ltree[n].Freq != 0)
return Z_TEXT;
/* There are no "block-listed" or "allow-listed" bytes:
* this stream either is empty or has tolerated ("gray-listed") bytes only.
*/
return Z_BINARY;
}
/* ===========================================================================
* Reverse the first len bits of a code, using straightforward code (a faster
* method would use a table)
* IN assertion: 1 <= len <= 15
*/
local unsigned bi_reverse(code, len)
unsigned code; /* the value to invert */
int len; /* its bit length */
{
register unsigned res = 0;
do {
res |= code & 1;
code >>= 1, res <<= 1;
} while (--len > 0);
return res >> 1;
}
/* ===========================================================================
* Flush the bit buffer, keeping at most 7 bits in it.
*/
local void bi_flush(s)
deflate_state *s;
{
if (s->bi_valid == 16) {
put_short(s, s->bi_buf);
s->bi_buf = 0;
s->bi_valid = 0;
} else if (s->bi_valid >= 8) {
put_byte(s, (Byte)s->bi_buf);
s->bi_buf >>= 8;
s->bi_valid -= 8;
}
}
/* ===========================================================================
* Flush the bit buffer and align the output on a byte boundary
*/
local void bi_windup(s)
deflate_state *s;
{
if (s->bi_valid > 8) {
put_short(s, s->bi_buf);
} else if (s->bi_valid > 0) {
put_byte(s, (Byte)s->bi_buf);
}
s->bi_buf = 0;
s->bi_valid = 0;
#ifdef ZLIB_DEBUG
s->bits_sent = (s->bits_sent + 7) & ~7;
#endif
}
+12 -4
View File
@@ -24,8 +24,12 @@
Z_DATA_ERROR if the input data was corrupted, including if the input data is
an incomplete zlib stream.
*/
int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong *sourceLen) {
int ZEXPORT uncompress2(dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong *sourceLen;
{
z_stream stream;
int err;
const uInt max = (uInt)-1;
@@ -79,7 +83,11 @@ int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
err;
}
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong sourceLen) {
int ZEXPORT uncompress(dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return uncompress2(dest, destLen, source, &sourceLen);
}
+2 -2
View File
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.3.0 is a general purpose data compression library. All the code is
zlib 1.2.13 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
@@ -22,7 +22,7 @@ before asking for help.
Manifest:
The package zlib-1.3.0-win32-x86.zip will contain the following files:
The package zlib-1.2.13-win32-x86.zip will contain the following files:
README-WIN32.txt This document
ChangeLog Changes since previous zlib packages
+1 -1
View File
@@ -6,7 +6,7 @@ What's here
Source
======
zlib version 1.3.0
zlib version 1.2.11
available at http://www.gzip.org/zlib/
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More