fix a bug in inflate -- length table was one entry too short

db4
Doug Coleman 2009-05-17 10:10:14 -05:00
parent 0bdccdb7ac
commit c8e0b049a8
1 changed files with 13 additions and 12 deletions

View File

@ -75,18 +75,20 @@ CONSTANT: length-table
19 23 27 31 19 23 27 31
35 43 51 59 35 43 51 59
67 83 99 115 67 83 99 115
131 163 195 227 131 163 195 227 258
} }
CONSTANT: dist-table CONSTANT: dist-table
{ 1 2 3 4 {
1 2 3 4
5 7 9 13 5 7 9 13
17 25 33 49 17 25 33 49
65 97 129 193 65 97 129 193
257 385 513 769 257 385 513 769
1025 1537 2049 3073 1025 1537 2049 3073
4097 6145 8193 12289 4097 6145 8193 12289
16385 24577 } 16385 24577
}
: nth* ( n seq -- elt ) : nth* ( n seq -- elt )
[ length 1- swap - ] [ nth ] bi ; [ length 1- swap - ] [ nth ] bi ;
@ -156,7 +158,7 @@ CONSTANT: dist-table
[ 1 bitstream bs:read 0 = ] [ 1 bitstream bs:read 0 = ]
[ [
bitstream bitstream
2 bitstream bs:read ! B 2 bitstream bs:read
{ {
{ 0 [ inflate-raw ] } { 0 [ inflate-raw ] }
{ 1 [ inflate-static ] } { 1 [ inflate-static ] }
@ -206,6 +208,5 @@ PRIVATE>
: zlib-inflate ( bytes -- bytes ) : zlib-inflate ( bytes -- bytes )
bs:<lsb0-bit-reader> bs:<lsb0-bit-reader>
[ check-zlib-header ] [ check-zlib-header ] [ inflate-loop ] bi
[ inflate-loop ] bi
inflate-lz77 ; inflate-lz77 ;