Repository navigation
fix(lha): make -lh2- match the LHarc format (re-land of #146) - #148
Closed
MagicalTux wants to merge 1 commit into
Closed
MagicalTux wants to merge 1 commit into
MagicalTux wants to merge 1 commit into
Conversation
Trigger: any non-empty input encoded with Lh2 and stored in a .lzh archive as -lh2-, or a genuine -lh2- member fed to Lh2's decoder. Effect: `lha t` reported a CRC error for every archive we produced. Our encoder and decoder agreed only with each other: they used an invented 510-symbol length alphabet, a 14-symbol bit-length position class, and Okumura's LZHUF tree update, none of which is the -lh2- bitstream, so real -lh2- data could not be decoded either. Fix: implement the format LHA actually uses: a 286-symbol char tree (lengths 3..=31 direct, symbol 285 + 8 raw bits for longer matches), a position tree over pos >> 6 that starts as a single leaf and gains a symbol each time the output count passes a multiple of 64, followed by 6 raw low bits, and LHA's leader/block adaptive-Huffman update and rebuild rules for both trees (their node layout fixes every code bit). New tests have the lha CLI verify and extract our output for every LHA method (skipped when lha is absent), pin the lh2 bitstream with an lha-verified fixture, and check decoder reset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Closing: #146 is on hold over the LHa for UNIX provenance question, so it shouldn't be re-landed on master yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-lands #146, which merged into
fix/pre-0.7.4instead ofmaster.#146 was stacked on #145, so its base branch was
fix/pre-0.7.4. #145 was then rebase-merged into master. GitHub retargets a stacked PR only when its base branch is deleted, so #146 keptfix/pre-0.7.4as its base and merged there. Apart from #146's own commit, that branch's tree is identical to master atb44654d, so this PR cherry-picks just that commit (f0b0e9c) onto current master. It applies cleanly; the lha tests, clippy (-D warnings,--features all) and fmt pass.See #146 for the description.
🤖 Generated with Claude Code