1539 Commits

Author SHA1 Message Date
Timofey Solomko d9bb44001d Merge branch 'hotfix-4.9.1' into develop 2026-06-13 16:21:33 +08:00
Timofey Solomko 56267f0e14 Prepare for 4.9.1 release 2026-06-13 16:18:50 +08:00
Timofey Solomko e75d4bb167 [ZIP] Decode CP437 manually on non-Darwin platforms with Swift earlier than 6.2
Fixes #65.
2026-06-13 16:11:11 +08:00
Timofey Solomko 8b10dd5c0c [GZip] Add null terminator as a zero byte instead of character
Fixes #66.
2026-06-13 16:10:08 +08:00
Timofey Solomko 934ea37acd [Zlib] Mark ZlibHeader as Sendable 2026-05-27 12:09:24 +08:00
Timofey Solomko 3f07b0d571 [TAR] Define autoreleasepool on Android and Wasm
Apparently, Swift Package Index is trying to build SWC on these two platforms as well. While we do not currently support them, we can try to at least fix some issues.
2026-05-26 20:33:47 +08:00
Timofey Solomko 1b2c9ccc0a [ZIP] Mark extra field-related types as Sendable 2026-05-26 11:56:54 +08:00
Timofey Solomko 8dc5cb575c [GZip] Mark some structs as Sendable 2026-05-26 11:56:33 +08:00
Timofey Solomko e95c1e3e6e [Common] Mark several enums as Sendable 2026-05-26 11:56:15 +08:00
Timofey Solomko c01d42ff7c [Common] Mark container protocols as Sendable 2026-05-26 11:55:49 +08:00
Timofey Solomko 0359b943ea [ZIP] Mark customExtraFields as nonisolated(unsafe)
This is a temporary measure to "fix" compilation errors in Swift 6 language mode. Ultimately, this is a global variable which is not really concurrency-safe, so the entire custom extra field management system should be rethought.
2026-05-26 11:19:28 +08:00
Timofey Solomko 57186f13af [Common] Add Sendable conformance to OptionSet types 2026-05-26 11:17:37 +08:00
Timofey Solomko b2178ac126 Prepare for 4.9.0 release 2026-05-22 19:44:49 +08:00
Timofey Solomko 26dd6f5b5e Merge branch 'hotfix-4.8.7' into develop 2026-05-22 19:40:59 +08:00
Timofey Solomko 8ca3c18c61 Prepare for 4.8.7 release 2026-05-22 19:32:37 +08:00
Timofey Solomko e3c41ca9a0 [BZip2] Fix grammar in comments 2026-05-22 17:16:29 +08:00
Timofey Solomko a41fe89076 [Tests] Add a test for 7-zip container with large LZMA dictionary size 2026-05-14 21:33:33 +08:00
nekonya 735795a7e1 [7-Zip] Fix LZMA dictionary size parsing
The LZMA dictionary size was being read from only 3 bytes (indices 1-3)
instead of the full 4 bytes (indices 1-4) specified in the LZMA format.

This caused decompression to fail with LZMAError.notEnoughToRepeat for
archives using dictionary sizes >= 16MB (e.g., LZMA:24 = 2^24 = 16MB),
because the high byte was not read and the dictionary size defaulted
to the minimum 4096 bytes.

Change: `for i in 1..<4` → `for i in 1..<5`
2026-05-14 21:31:30 +08:00
Timofey Solomko 85c8fd60aa [docs] Update BZip2 docs for multiDecompress functionality 2026-05-14 12:42:02 +08:00
Timofey Solomko cf044550f1 [swcomp] Add --multi-decompress option to bz2 command
This option allows to decompress multiple BZip2 archives concatenated together.
2026-05-14 12:42:02 +08:00
Timofey Solomko 75cc406d47 [BZip2] Add multiDecompress public function
This should help with inputs consisting of multiple BZip2 archives concatenated together which were brought up in #59.
2026-05-12 16:06:19 +08:00
Timofey Solomko e32887084c [Huffman] Change Decoding/Encoding tree to structs
This seems to have a positive impact on the performance of Deflate and BZip2 decompression and compression. It is unclear to me why these two were declared as classes in the first place.
2026-03-01 20:35:22 +08:00
Timofey Solomko 567a5473d1 [GZip] Move bytes left check out of the loop when reading extra fields 2026-03-01 20:35:22 +08:00
Timofey Solomko 5d4b4d2493 [TAR] Fix code comment to refer to TarParser instead of Provider 2026-03-01 20:35:22 +08:00
Timofey Solomko 93e2eef38d [BZip2] Remove redundant check for zero code lengths
Such code lengths are now filtered out during Huffman code construction.
2026-03-01 20:35:22 +08:00
Timofey Solomko d8c22c55da [Deflate][Huffman] Filter out zero code lengths only during code construction
This should prevent crashes described in issue #57.
2026-03-01 20:35:21 +08:00
Timofey Solomko 7e6a9fd42c [Deflate] Add a check for correct number of literal/length codes 2026-03-01 20:35:21 +08:00
Timofey Solomko a39011a00b [Deflate] Fix potential crashes in cases of too large copy amount
In a dynamic Huffman block if either previous or zero code length is copied too many times, it could cause a crash or lead to inconsistent state. These situations are checked now.
2026-03-01 20:35:21 +08:00
Timofey Solomko 7f547c20a1 [Huffman] Optimize DecodingTree leaf count 2026-03-01 20:35:21 +08:00
Timofey Solomko ccf97c995b [Deflate] Check that 16 is not the first code length symbol
This symbol in the dynamic Huffman block encodes copy of the previous code length. If this symbol is the first, then there is nothing to copy. Previously, this could cause a crash.
2026-02-28 01:26:43 +08:00
Timofey Solomko b743b0b7ed [Deflate] Optimize decoding of code lengths for dynamic trees 2026-02-26 00:53:17 +08:00
Timofey Solomko 52efeef2b8 [Zlib] Improve handling of truncated inputs during decompression 2026-02-24 00:58:49 +08:00
Timofey Solomko f307a7fb0b [BZip2] Improve handling of truncated inputs during decompression 2026-02-23 18:08:27 +08:00
Timofey Solomko ad73d82367 [BZip2] Slightly rewrite Huffman+RUNA/B+MTF decoding
This piece of the code is now more logical, with less branching, and mirrors encoding counterpart.
2026-02-23 18:08:26 +08:00
Timofey Solomko a0c64f7f9c [Deflate] Optimize creation of uncompressed blocks 2026-02-23 18:08:26 +08:00
Timofey Solomko 51734eb8d3 [swcomp] Remove empty warmupIteration function from comp-ratio benchmarks
These functions weren't called anyway since 5e8f568f64 commit where Benchmark protocol requirement for this function acquired Double return type. In any event, skipping of warmup iteration is better controlled by the corresponding option of "benchmark run" command.
2026-02-23 18:08:26 +08:00
Timofey Solomko 3686067e54 [LZMA] Remove LZMARangeDecoder.isCorrupted property
According to LZMA specification this property is ignored by the reference implementation. In addition, specification suggests that other LZMA decoders should also ignore it. We weren't using this property for anything anyway, so its removal does not really change anything, except for better compliance with LZMA specification.

In addition, range decoder initialization error is now thrown in accordance with reference implementation.
2026-02-23 18:08:26 +08:00
Timofey Solomko 609eb29791 [BZip2] Change a couple of guard/if-checks to assertions 2026-02-23 18:08:26 +08:00
Timofey Solomko 1e7154474b [BZip2] Use better versions of bit writer functions
First, write(unsignedNumber:) is better than write(number:) when the argument is already UInt, since it does one fewer precondition check and does not do additional integer conversion. Secondly, using write(number:) to write one bit was very inefficient.
2026-02-23 18:08:25 +08:00
Timofey Solomko 7af76764d7 [BZip2] Use UInt8 arrays instead of Data 2026-02-23 18:08:25 +08:00
Timofey Solomko bff411d511 [BZip2] Improve encoding performance of code lengths deltas 2026-02-23 18:08:25 +08:00
Timofey Solomko 273b6ed9e9 Remove redundant imports 2026-02-18 12:21:57 +08:00
Timofey Solomko 5b5b20f582 [Huffman] Remove codes argument label from EncodingTree.init 2026-02-18 00:12:55 +08:00
Timofey Solomko ce1736a2b0 [Huffman] Add HuffmanCodes typealias for clarity 2026-02-18 00:10:29 +08:00
Timofey Solomko d76351caa0 [swcomp] Update benchmark run command to use new format 2026-02-12 21:44:42 +08:00
Timofey Solomko 52961ea60d [swcomp] Update benchmark show command to use new format
This allowed to rewrite implementation in a much clearer way. One user-visible change, however, is that NEW/BASE is now always printed with an index even if there is only one (implementation complexity to accommodate empty index is not worth it).
2026-02-12 21:44:42 +08:00
Timofey Solomko 515c11fd0e [swcomp] Support new format in benchmark remove-run command 2026-02-12 21:44:42 +08:00
Timofey Solomko 8847fe92ce [swcomp] SaveFile.load now auto-converts from old format 2026-02-12 21:44:41 +08:00
Timofey Solomko 4ec437e912 [swcomp] Add benchmark convert command
This command converts save file from old format to the new one.
2026-02-12 21:44:35 +08:00
Timofey Solomko 20d33b0966 [swcomp] Add a new benchmark save file format
Ultimately, it turned out that the approach of the old save file format of separating runs metadatas and results only leads to super complicated code. Unfortunately, it didn't help with append-updates to save files (they are still loaded fully, their content is modified in memory, and the actual file is then overwritten).
2026-02-12 21:44:35 +08:00