Fix a lzw_decoder bug.

This commit is contained in:
Nigel Tao committed 2017-06-10 18:08:16 +10:00
1 parent f403d0faa8
commit 2fd08e0cf8
3 files changed
+2 -5

No files matched your search

+1 -1
View File
@@ -298,7 +298,7 @@ label_0_continue:;
sizeof(self->f_stack) - v_s);
a_dst->wi += sizeof(self->f_stack) - v_s;
if (v_use_save_code) {
self->f_suffixes[v_save_code] = self->f_stack[4095];
self->f_suffixes[v_save_code] = ((uint8_t)(v_c));
self->f_prefixes[v_save_code] = ((uint16_t)(v_prev_code));
}
} else {
+1 -1
View File
@@ -94,7 +94,7 @@ pub func lzw_decoder.decode?(dst ptr buf1, src ptr buf1, src_final bool)() {
in.dst.write?(x:s)
if use_save_code {
this.suffixes[save_code] = this.stack[4095]
this.suffixes[save_code] = c as u8
this.prefixes[save_code] = prev_code as u16
}
-3
View File
@@ -64,12 +64,9 @@ void test_lzw_decode() {
goto cleanup1;
}
/*
TODO: fix the bug and uncomment this test.
if (!buf1s_equal(&got, &want)) {
goto cleanup1;
}
*/
// As a sanity check, the first decoded byte should be 0xDC.
if (got.ptr[0] != 0xDC) {
FAIL("first decoded byte: got 0x%02x, want 0x%02x", (int)(got.ptr[0]),