     ] if zlib-failed ;
 
 : zlib-error ( n -- )
-    dup compression.zlib.ffi:Z_OK = [ drop ] [ dup zlib-error-message zlib-failed ] if ;
+    dup {
+        { compression.zlib.ffi:Z_OK [ drop ] }
+        { compression.zlib.ffi:Z_STREAM_END [ drop ] }
+        [ dup zlib-error-message zlib-failed ]
+    } case ;
 
 : compressed-size ( byte-array -- n )
     length 1001/1000 * ceiling 12 + ;

: uncompress ( byte-array -- byte-array' )
    [ length 5 [0,b) [ 2^ * ] with map ] keep
    '[ _ (uncompress) ] attempt-all ;

! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types alien.data alien.syntax
byte-arrays byte-vectors classes.struct combinators
compression.zlib.ffi continuations destructors fry kernel libc
math math.functions math.ranges sequences system ;
QUALIFIED: compression.zlib.ffi
IN: compression.zlib

