Skip to content

Commit 372f5ee

Browse files
committed
Revert "Comment out bits that fail with zlib 1.1"
This reverts commit 098e174.
1 parent a1d7af6 commit 372f5ee

File tree

6 files changed

+36
-19
lines changed

6 files changed

+36
-19
lines changed

Codec/Compression/GZip.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ module Codec.Compression.GZip (
6363
defaultStrategy,
6464
filteredStrategy,
6565
huffmanOnlyStrategy,
66+
rleStrategy,
67+
fixedStrategy,
6668

6769
) where
6870

Codec/Compression/Zlib.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ module Codec.Compression.Zlib (
5151
defaultStrategy,
5252
filteredStrategy,
5353
huffmanOnlyStrategy,
54+
rleStrategy,
55+
fixedStrategy,
5456

5557
) where
5658

Codec/Compression/Zlib/Internal.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ module Codec.Compression.Zlib.Internal (
7070
Stream.defaultStrategy,
7171
Stream.filteredStrategy,
7272
Stream.huffmanOnlyStrategy,
73+
Stream.rleStrategy,
74+
Stream.fixedStrategy,
7375

7476
) where
7577

Codec/Compression/Zlib/Raw.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ module Codec.Compression.Zlib.Raw (
4747
defaultStrategy,
4848
filteredStrategy,
4949
huffmanOnlyStrategy,
50+
rleStrategy,
51+
fixedStrategy,
5052

5153
) where
5254

Codec/Compression/Zlib/Stream.hsc

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ module Codec.Compression.Zlib.Stream (
5656
defaultStrategy,
5757
filteredStrategy,
5858
huffmanOnlyStrategy,
59+
rleStrategy,
60+
fixedStrategy,
5961

6062
-- * The buisness
6163
deflate,
@@ -586,14 +588,14 @@ data Flush =
586588
| SyncFlush
587589
| FullFlush
588590
| Finish
589-
-- | Block -- only available in zlib 1.2 and later, uncomment if you need it.
591+
| Block
590592

591593
fromFlush :: Flush -> CInt
592594
fromFlush NoFlush = #{const Z_NO_FLUSH}
593595
fromFlush SyncFlush = #{const Z_SYNC_FLUSH}
594596
fromFlush FullFlush = #{const Z_FULL_FLUSH}
595597
fromFlush Finish = #{const Z_FINISH}
596-
-- fromFlush Block = #{const Z_BLOCK}
598+
fromFlush Block = #{const Z_BLOCK}
597599

598600

599601
-- | The format used for compression or decompression. There are three
@@ -855,25 +857,21 @@ data CompressionStrategy =
855857
DefaultStrategy
856858
| Filtered
857859
| HuffmanOnly
860+
| RLE
861+
-- ^ @since 0.7.0.0
862+
| Fixed
863+
-- ^ @since 0.7.0.0
858864
deriving (Eq, Ord, Enum, Bounded, Show, Typeable
859865
#if __GLASGOW_HASKELL__ >= 702
860866
, Generic
861867
#endif
862868
)
863869

864-
{-
865-
-- -- only available in zlib 1.2 and later, uncomment if you need it.
866-
| RLE -- ^ Use 'RLE' to limit match distances to one (run-length
867-
-- encoding). 'RLE' is designed to be almost as fast as
868-
-- 'HuffmanOnly', but give better compression for PNG
869-
-- image data.
870-
| Fixed -- ^ 'Fixed' prevents the use of dynamic Huffman codes,
871-
-- allowing for a simpler decoder for special applications.
872-
-}
873-
874870
{-# DEPRECATED DefaultStrategy "Use defaultStrategy. CompressionStrategy constructors will be hidden in version 0.7" #-}
875871
{-# DEPRECATED Filtered "Use filteredStrategy. CompressionStrategy constructors will be hidden in version 0.7" #-}
876872
{-# DEPRECATED HuffmanOnly "Use huffmanOnlyStrategy. CompressionStrategy constructors will be hidden in version 0.7" #-}
873+
{-# DEPRECATED RLE "Use rleStrategy. CompressionStrategy constructors will be hidden in version 0.7" #-}
874+
{-# DEPRECATED Fixed "Use fixedStrategy. CompressionStrategy constructors will be hidden in version 0.7" #-}
877875

878876
-- | Use this default compression strategy for normal data.
879877
--
@@ -896,14 +894,28 @@ filteredStrategy = Filtered
896894
huffmanOnlyStrategy :: CompressionStrategy
897895
huffmanOnlyStrategy = HuffmanOnly
898896

897+
-- | Use 'rleStrategy' to limit match distances to one (run-length
898+
-- encoding). 'rleStrategy' is designed to be almost as fast as
899+
-- 'huffmanOnlyStrategy', but give better compression for PNG
900+
-- image data.
901+
--
902+
-- @since 0.7.0.0
903+
rleStrategy :: CompressionStrategy
904+
rleStrategy = RLE
905+
906+
-- | 'fixedStrategy' prevents the use of dynamic Huffman codes,
907+
-- allowing for a simpler decoder for special applications.
908+
--
909+
-- @since 0.7.0.0
910+
fixedStrategy :: CompressionStrategy
911+
fixedStrategy = Fixed
899912

900913
fromCompressionStrategy :: CompressionStrategy -> CInt
901914
fromCompressionStrategy DefaultStrategy = #{const Z_DEFAULT_STRATEGY}
902915
fromCompressionStrategy Filtered = #{const Z_FILTERED}
903916
fromCompressionStrategy HuffmanOnly = #{const Z_HUFFMAN_ONLY}
904-
--fromCompressionStrategy RLE = #{const Z_RLE}
905-
--fromCompressionStrategy Fixed = #{const Z_FIXED}
906-
917+
fromCompressionStrategy RLE = #{const Z_RLE}
918+
fromCompressionStrategy Fixed = #{const Z_FIXED}
907919

908920
withStreamPtr :: (Ptr StreamState -> IO a) -> Stream a
909921
withStreamPtr f = do

test/Test/Codec/Compression/Zlib/Stream.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,4 @@ instance Arbitrary MemoryLevel where
3434

3535

3636
instance Arbitrary CompressionStrategy where
37-
arbitrary = elements $ [defaultStrategy, filteredStrategy, huffmanOnlyStrategy]
38-
-- These are disabled by default in the package
39-
-- as they are only available with zlib >=1.2
40-
-- ++ [RLE, Fixed]
37+
arbitrary = elements $ [defaultStrategy, filteredStrategy, huffmanOnlyStrategy, rleStrategy, fixedStrategy]

0 commit comments

Comments
 (0)