Commit Graph

235 Commits

Author SHA1 Message Date
Andrew Kelley df46ee61c4 std.Io.Writer.Allocating: configurable bump amount 2025-08-08 19:22:08 -07:00
Andrew Kelley 91a81d3846 std.compress.flate.Decompress: fix buffer size in test 2025-08-08 15:03:05 -07:00
Ryan Liptak 23fff3442d flate: Handle invalid block type
Fixes `panic: invalid enum value` when the type bits had the u2 value of 3.

Contributes towards #24741
2025-08-08 12:27:25 -07:00
Igor Anić 6de2310035 flate change bit reader Bits to usize (#24719)
Don't see why byte returned from specialPeek needs to be shifted by
remaining_needed_bits.
I believe that decision in specialPeek should be done on the number of
the remaining bits not of the content of that bits.

Some test result are changed, but they are now consistent with the
original state as found in:
https://github.com/ziglang/zig/blame/5f790464b0d5da3c4c1a7252643e7cdd4c4b605e/lib/std/compress/flate/Decompress.zig

Changing Bits from usize to u32 or u64 now returns same results.

* flate: simplify peekBitsEnding

`peekBits` returns at most asked number of bits. Fails with EndOfStream
when there are no available bits. If there are less bits available than
asked still returns that available bits.
Hopefully this change better reflects intention. On first input stream
peek error we break the loop.
2025-08-07 14:40:08 -07:00
Igor Anić d2149106a6 flate zlib fix end of block reading
`n` is wanted number of bits to toss
`buffered_n` is actual number of bytes in `next_int`
2025-08-05 17:09:41 -07:00
Ian Johnson 96be6f6566 std.compress.flate.Decompress: return correct size for unbuffered decompression
Closes #24686

As a bonus, this commit also makes the `git.zig` "testing `main`" compile again.
2025-08-04 19:32:14 -07:00
Andrew Kelley a6f7927764 std.compress.flate.Decompress: use 64 buffered bits
will have to find out why usize doesn't work for 32 bit targets some
other time
2025-08-01 09:04:27 -07:00
Andrew Kelley 64814dc986 std.compress.flate.Decompress: respect stream limit 2025-07-31 22:10:11 -07:00
Andrew Kelley a7808892f7 std.compress.flate.Decompress: be in indirect or direct mode
depending on whether buffered
2025-07-31 22:10:11 -07:00
Andrew Kelley 6eac56caf7 std.compress.flate.Decompress: allow users to swap out Writer 2025-07-31 22:10:11 -07:00
Andrew Kelley c9ff068391 std.compress: fix discard impl and flate error detection 2025-07-31 22:10:11 -07:00
Andrew Kelley 111305678c std: match readVec fn prototype exactly
this is not necessary according to zig language, but works around a flaw
in the C backend
2025-07-31 22:10:11 -07:00
Andrew Kelley 4c04835a08 std.compress.zstd.Decompress: implement discard and readVec 2025-07-31 22:10:11 -07:00
Andrew Kelley 84e4343b0c fix test failures by adding readVec 2025-07-31 22:10:11 -07:00
Andrew Kelley afe9f3a9ec std.compress.flate.Decompress: implement readVec and discard 2025-07-31 22:10:11 -07:00
Andrew Kelley 6bcced31a0 fix 32-bit compilation 2025-07-31 22:10:11 -07:00
Andrew Kelley 42b10f08cc std.compress.flate.Decompress: delete bad unit tests
if I remove the last input byte from "don't read past deflate stream's
end" (on master branch), the test fails with error.EndOfStream. what,
then, is it supposed to be testing?
2025-07-31 22:10:11 -07:00
Andrew Kelley 5f790464b0 std.compress.flate.Decompress: hashing is out of scope
This API provides the data; applications can verify their own checksums.
2025-07-31 22:10:11 -07:00
Andrew Kelley 4741a16d9a putting stuff back does not require mutation 2025-07-31 22:10:11 -07:00
Andrew Kelley 05ce1f99a6 compiler: update to new flate API 2025-07-31 22:10:11 -07:00
Andrew Kelley 2569f4ff85 simplify tossBitsEnding 2025-07-31 22:10:11 -07:00
Andrew Kelley 5bc63794cc fix takeBitsEnding 2025-07-31 22:10:11 -07:00
Andrew Kelley 63f496c4f9 make takeBits deal with integers only 2025-07-31 22:10:11 -07:00
Andrew Kelley c00fb86db6 fix peekBitsEnding 2025-07-31 22:10:11 -07:00
Andrew Kelley 8ab91a6fe9 error.EndOfStream disambiguation 2025-07-31 22:10:11 -07:00
Andrew Kelley f644f40702 implement tossBitsEnding 2025-07-31 22:10:11 -07:00
Andrew Kelley 2d8d0dd9b0 std.compress.flate.Decompress: unfuck the test suite 2025-07-31 22:10:11 -07:00
Andrew Kelley c684b21b4f simplify test cases 2025-07-31 22:10:11 -07:00
Andrew Kelley ac4fbb427b std.compress.flate.Decompress: don't compute checksums
These have no business being in-bound; simply provide the expected
values to user code for maximum flexibility.
2025-07-31 22:10:11 -07:00
Andrew Kelley 5f571f53d6 refactor gzip test cases
zig newbies love using for loops in unit tests
2025-07-31 22:10:11 -07:00
Andrew Kelley e73ca2444e std.compress.flate.Decompress: implement peekBitsEnding and writeMatch 2025-07-31 22:10:11 -07:00
Andrew Kelley 7bf91d705c fix bit read not at eof 2025-07-31 22:10:11 -07:00
Andrew Kelley 73e5594c78 std.compress.flate.Decompress: fix bit read at eof 2025-07-31 22:10:11 -07:00
Andrew Kelley 9c8cb777d4 std.compress.flate.Decompress: implement more bit reading 2025-07-31 22:10:11 -07:00
Andrew Kelley 6509fa1cf3 std.compress.flate.Decompress: passing basic test case 2025-07-31 22:10:11 -07:00
Andrew Kelley 88ca750209 std.compress.flate.Decompress: add rebase impl 2025-07-31 22:10:11 -07:00
Andrew Kelley 1b43551190 std.Io: remove BitWriter 2025-07-31 22:10:11 -07:00
Andrew Kelley 824c157e0c std.compress.flate: finish reorganizing 2025-07-31 22:10:11 -07:00
Andrew Kelley a4f05a4588 delete flate implementation 2025-07-31 22:10:11 -07:00
Andrew Kelley 83513ade35 std.compress: rework flate to new I/O API 2025-07-31 22:10:11 -07:00
Andrew Kelley cf7a28febb std.Io.Reader: introduce readVec back into the VTable
simplifies and fixes things

addresses a subset of #24608
2025-07-30 09:26:34 -07:00
Andrew Kelley 1fcaf90dd3 std.Io.Reader: make fillUnbuffered respect prexisting buffer
addresses only one usage pattern in #24608
2025-07-29 23:10:50 -07:00
Andrew Kelley bb29846732 std.compress.xz: eliminate dependency on std.Io.bitReader 2025-07-27 22:08:52 -07:00
Andrew Kelley 04614d6ea1 std.Io.Reader: add rebase to the vtable
This eliminates a footgun and special case handling with fixed buffers,
as well as allowing decompression streams to keep a window in the output
buffer.
2025-07-26 20:00:25 -07:00
Andrew Kelley 8752d80c84 std.compress.zstd.Decompress: fix bytes_written tracking 2025-07-25 14:15:33 -07:00
Andrew Kelley 7f43f78b5b std.compress.zstd: keep frame state between blocks 2025-07-25 14:15:33 -07:00
Andrew Kelley 13e08ea6f0 std.compress.zstd: fix endianness issue
instead of manually bitcast, use the handy dandy takeStruct function.
2025-07-25 14:15:33 -07:00
Andrew Kelley ee4f5b3f92 std.compress.zstd: respect the window length 2025-07-25 14:15:33 -07:00
Andrew Kelley 3687eada6a std: rework zstd for new I/O API
This passes tests but it doesn't provide as big a window size as is
required to decompress larger streams.

The next commit in this branch will work towards that, without
introducing an additional buffer.
2025-07-25 14:15:33 -07:00
Andrew Kelley 9f27d770a1 std.io: deprecated Reader/Writer; introduce new API 2025-07-07 22:43:51 -07:00