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

Doug Coleman 2009-05-17 10:10:14 -05:00
parent cab57f5547
commit 6ac69d74c4
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 {
5 7 9 13 1 2 3 4
17 25 33 49 5 7 9 13
65 97 129 193 17 25 33 49
257 385 513 769 65 97 129 193
1025 1537 2049 3073 257 385 513 769
4097 6145 8193 12289 1025 1537 2049 3073
16385 24577 } 4097 6145 8193 12289
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 ;