packages feed

zlib 0.6.1.2 → 0.6.2

raw patch · 5 files changed

+62/−31 lines, 5 files

Files

Codec/Compression/Zlib/Stream.hsc view
@@ -2,6 +2,9 @@ #if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE DeriveGeneric #-} #endif+#if __GLASGOW_HASKELL__ >= 706+{-# LANGUAGE CApiFFI #-}+#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (c) 2006-2015 Duncan Coutts@@ -709,8 +712,8 @@ -- usage. -- -- The compression window size is the value of the the window bits raised to--- the power 2. The window bits must be in the range @8..15@ which corresponds--- to compression window sizes of 256b to 32Kb. The default is 15 which is also+-- the power 2. The window bits must be in the range @9..15@ which corresponds+-- to compression window sizes of 512b to 32Kb. The default is 15 which is also -- the maximum size. -- -- The total amount of memory used depends on the window bits and the@@ -737,19 +740,19 @@ defaultWindowBits :: WindowBits defaultWindowBits = WindowBits 15 --- | A specific compression window size, specified in bits in the range @8..15@+-- | A specific compression window size, specified in bits in the range @9..15@ -- windowBits :: Int -> WindowBits windowBits n-  | n >= 8 && n <= 15 = WindowBits n-  | otherwise         = error "WindowBits must be in the range 8..15"+  | n >= 9 && n <= 15 = WindowBits n+  | otherwise         = error "WindowBits must be in the range 9..15"  fromWindowBits :: Format -> WindowBits-> CInt fromWindowBits format bits = (formatModifier format) (checkWindowBits bits)   where checkWindowBits DefaultWindowBits = 15         checkWindowBits (WindowBits n)-          | n >= 8 && n <= 15 = fromIntegral n-          | otherwise         = error "WindowBits must be in the range 8..15"+          | n >= 9 && n <= 15 = fromIntegral n+          | otherwise         = error "WindowBits must be in the range 9..15"         formatModifier Zlib       = id         formatModifier GZip       = (+16)         formatModifier GZipOrZlib = (+32)@@ -1008,6 +1011,10 @@ -- -- So we define c_inflateInit2 and c_deflateInit2 here as wrappers around -- their _ counterparts and pass the extra args.+--+-- As of GHC 7.6, we can import macros directly using the CApiFFI extension.+-- This avoids the need for the hsc2hs #{const_str} construct, which means+-- hsc2hs can run in cross-compilation mode.  ##ifdef NON_BLOCKING_FFI ##define SAFTY safe@@ -1015,6 +1022,14 @@ ##define SAFTY unsafe ##endif +#if __GLASGOW_HASKELL__ >= 706+foreign import capi unsafe "zlib.h inflateInit2"+  c_inflateInit2 :: StreamState -> CInt -> IO CInt+ +foreign import capi unsafe "zlib.h deflateInit2"+  c_deflateInit2 :: StreamState+                 -> CInt -> CInt -> CInt -> CInt -> CInt -> IO CInt+#else foreign import ccall unsafe "zlib.h inflateInit2_"   c_inflateInit2_ :: StreamState -> CInt -> Ptr CChar -> CInt -> IO CInt @@ -1023,15 +1038,6 @@   withCAString #{const_str ZLIB_VERSION} $ \versionStr ->     c_inflateInit2_ z n versionStr (#{const sizeof(z_stream)} :: CInt) -foreign import ccall SAFTY "zlib.h inflate"-  c_inflate :: StreamState -> CInt -> IO CInt--foreign import ccall unsafe "zlib.h &inflateEnd"-  c_inflateEnd :: FinalizerPtr StreamState--foreign import ccall unsafe "zlib.h inflateReset"-  c_inflateReset :: StreamState -> IO CInt- foreign import ccall unsafe "zlib.h deflateInit2_"   c_deflateInit2_ :: StreamState                   -> CInt -> CInt -> CInt -> CInt -> CInt@@ -1043,6 +1049,16 @@ c_deflateInit2 z a b c d e =   withCAString #{const_str ZLIB_VERSION} $ \versionStr ->     c_deflateInit2_ z a b c d e versionStr (#{const sizeof(z_stream)} :: CInt)+#endif++foreign import ccall SAFTY "zlib.h inflate"+  c_inflate :: StreamState -> CInt -> IO CInt++foreign import ccall unsafe "zlib.h &inflateEnd"+  c_inflateEnd :: FinalizerPtr StreamState++foreign import ccall unsafe "zlib.h inflateReset"+  c_inflateReset :: StreamState -> IO CInt  foreign import ccall unsafe "zlib.h deflateSetDictionary"   c_deflateSetDictionary :: StreamState
changelog view
@@ -1,3 +1,9 @@+0.6.2 Herbert Valerio Riedel <hvr@gnu.org> March 2018++ * New cabal flag 'pkg-config' for discovering 'zlib` via pkg-config(1) (#16)+ * Use CApiFFI where available for cross-compile friendliness (#14)+ * Change the window bits range from 8..15 to 9..15 (#11)+ 0.6.1.2 Herbert Valerio Riedel <hvr@gnu.org> October 2016   * Fix a segfault when reading the stream multithreaded, #7
test/Test.hs view
@@ -61,10 +61,7 @@                                -> Property prop_decompress_after_compress w cp dp =    (w /= zlibFormat || decompressWindowBits dp >= compressWindowBits cp) &&-   -- Zlib decompression has been observed to fail with both compress and decompress-   -- window bits = 8. This seems to be contrary to the docs and to a quick reading-   -- of the zlib source code.-   (decompressWindowBits dp > compressWindowBits cp || decompressWindowBits dp > WindowBits 8) &&+   (decompressWindowBits dp > compressWindowBits cp) &&    decompressBufferSize dp > 0 && compressBufferSize cp > 0 ==>    liftM2 (==) (decompress w dp . compress w cp) id 
test/Test/Codec/Compression/Zlib/Stream.hs view
@@ -24,7 +24,7 @@   instance Arbitrary WindowBits where-  arbitrary = elements $ defaultWindowBits:map windowBits [8..15]+  arbitrary = elements $ defaultWindowBits:map windowBits [9..15]   instance Arbitrary MemoryLevel where
zlib.cabal view
@@ -1,5 +1,5 @@ name:            zlib-version:         0.6.1.2+version:         0.6.2 copyright:       (c) 2006-2016 Duncan Coutts license:         BSD3 license-file:    LICENSE@@ -20,7 +20,7 @@                  provides access to the full zlib feature set. build-type:      Simple cabal-version:   >= 1.10-tested-with:     GHC ==7.0.4, GHC ==7.2.2, GHC ==7.4.2, GHC ==7.6.3, GHC ==7.8.4, GHC ==7.10.3, GHC ==8.0.1, GHC==8.0.2, GHC ==8.1.*+tested-with:     GHC ==7.0.4, GHC ==7.2.2, GHC ==7.4.2, GHC ==7.6.3, GHC ==7.8.4, GHC ==7.10.3, GHC ==8.0.1, GHC==8.0.2, GHC ==8.2.2, GHC ==8.4.1  extra-source-files: changelog                     -- zlib C sources (for Windows)@@ -45,6 +45,11 @@                prevents other Haskell threads running. Enabling this flag                avoids this unfairness, but with greater overall cost. +flag pkg-config+  default:     False+  manual:      True+  description: Use @pkg-config(1)@ to locate foreign @zlib@ library.+ library   exposed-modules: Codec.Compression.GZip,                    Codec.Compression.Zlib,@@ -60,6 +65,8 @@                     DeriveDataTypeable   if impl(ghc >= 7.2)     other-extensions: DeriveGeneric+  if impl(ghc >= 7.6)+    other-extensions: CApiFFI   build-depends:   base >= 4 && < 5,                    bytestring >= 0.9 && < 0.12   if impl(ghc >= 7.2 && < 7.6)@@ -68,18 +75,23 @@   ghc-options:     -Wall -fwarn-tabs   if flag(non-blocking-ffi)     cpp-options:   -DNON_BLOCKING_FFI-  if !os(windows)-    -- Normally we use the the standard system zlib:-    extra-libraries: z+  if flag(pkg-config)+    -- NB: pkg-config is available on windows as well when using msys2+    pkgconfig-depends: zlib   else-    -- However for the benefit of users of Windows (which does not have zlib-    -- by default) we bundle a complete copy of the C sources of zlib-1.2.8-    c-sources:     cbits/adler32.c cbits/compress.c cbits/crc32.c+    -- don't use pkg-config+    if !os(windows)+      -- Normally we use the the standard system zlib.+      extra-libraries: z+    else+      -- However for the benefit of users of Windows (which does not have zlib+      -- by default) we bundle a complete copy of the C sources of zlib-1.2.8+      c-sources:   cbits/adler32.c cbits/compress.c cbits/crc32.c                    cbits/deflate.c cbits/infback.c                    cbits/inffast.c cbits/inflate.c cbits/inftrees.c                    cbits/trees.c cbits/uncompr.c cbits/zutil.c-    include-dirs:  cbits-    install-includes: zlib.h zconf.h+      include-dirs:  cbits+      install-includes: zlib.h zconf.h  test-suite tests   type: exitcode-stdio-1.0