Skip to content

add an inflate engine in pith; gzip now reads any deflate stream#277

Merged
kacy merged 1 commit into
mainfrom
deflate
Jul 8, 2026
Merged

add an inflate engine in pith; gzip now reads any deflate stream#277
kacy merged 1 commit into
mainfrom
deflate

Conversation

@kacy

@kacy kacy commented Jul 8, 2026

Copy link
Copy Markdown
Owner

summary

std.compress.inflate: rfc 1951 in ~250 lines of pith — lsb-first bit reader, canonical huffman decoding via the first-code walk (no decode tables), dynamic-tree run-length machinery, lz77 back-reference copies. gzip.decompress routes all three block types through it with crc32 + length trailer verification — files from other tools now read correctly, closing the documented interop gap.

verification

  • system gzip levels 1/6/9: 200KB source decompresses byte-identical
  • random binary (incompressible, stored-heavy) round-trips
  • committed gzip -9 fixture pins interop in the suite
  • logscan's ci golden check now feeds the tool a real system-gzip file on every push

honest remainder

compress() still writes stored blocks (pith-written archives exceed their input) — documented in limitations; the compressor is the other half of the project.

what was tested

full suite green (all four golden checks, logscan now on real gzip), fixed point byte-identical, seed refreshed, fmt + doc gates clean.

std.compress.inflate implements rfc 1951 in about 250 lines of pith:
an lsb-first bit reader, canonical huffman decoding by the first-code
walk (a few comparisons per symbol, no decode tables to build), the
dynamic-tree run-length machinery, and lz77 back-reference copies
from the output window. gzip.decompress routes every block type
through it — stored, fixed huffman, dynamic huffman — and verifies
the crc32 and length trailer, so files produced by other tools now
read correctly.

verified against system gzip at levels 1, 6, and 9: a 200KB source
file decompresses byte-identical, and random binary round-trips. a
committed gzip -9 fixture pins interop in the test suite, and
logscan's golden check now hands the tool a real system-gzip file on
every ci run instead of a pith-written one.

the honest remainder is documented in limitations: compress() still
writes stored blocks, so pith-written archives are larger than their
input. the compressor is the other half of the project.
@kacy kacy merged commit 29b9376 into main Jul 8, 2026
2 checks passed
@kacy kacy deleted the deflate branch July 8, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant