}
{ $description "Read the next LZW code." } ;
-HELP: lzw-read*
+HELP: lzw-process-next-code
{ $values
{ "lzw" lzw } { "quot" quotation }
}
-{ $description "Read the next LZW code and call " { $snippet "quot" } " with the lzw object and the LZW code only if the code is neither the Clear Code nor the End of Information Code. If it does read a Clear Code, this combinator will take care of handling the Clear Code for you." } ;
+{ $description "Read the next LZW code and, assuming that the code is neither the Clear Code nor the End of Information Code, conditionally processes it by calling " { $snippet "quot" } " with the lzw object and the LZW code. If it does read a Clear Code, this combinator will take care of handling the Clear Code for you." } ;
HELP: <lzw-uncompress>
{ $values
: clear-code? ( lzw code -- ? ) swap clear-code>> = ;
DEFER: handle-clear-code
-: lzw-read* ( lzw quot: ( lzw code -- ) -- )
+: lzw-process-next-code ( lzw quot: ( lzw code -- ) -- )
[ lzw-read ] dip {
{ [ 3dup drop end-of-information? ] [ 3drop ] }
{ [ 3dup drop clear-code? ] [ 2drop handle-clear-code ] }
[ write-code ]
[ code>old-code ] bi
lzw-uncompress-char
- ] lzw-read* ;
+ ] lzw-process-next-code ;
: handle-uncompress-code ( lzw -- lzw )
dup code-in-table? [
] if ;
: lzw-uncompress-char ( lzw -- )
- [ >>code handle-uncompress-code lzw-uncompress-char ] lzw-read* ;
+ [ >>code handle-uncompress-code lzw-uncompress-char ]
+ lzw-process-next-code ;
: lzw-uncompress ( bitstream code-size class -- byte-array )
<lzw-uncompress>