bz3 0.1.0.0 → 0.1.0.1
raw patch · 5 files changed
+15/−12 lines, 5 filesbinary-addedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- bz3.cabal +2/−1
- src/Codec/Bz3.hs +8/−10
- src/Codec/Bz3/Binary.hs +1/−1
- test/data/LICENSE.bz3 binary
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.1.0.1++* Fix bug compressing files that are not large+ # 0.1.0.0 * Initial release.
bz3.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.4 name: bz3-version: 0.1.0.0+version: 0.1.0.1 synopsis: High-level bindings to bz3 description: Streaming compression/decompression in bz3 format via lazy bytestrings@@ -14,6 +14,7 @@ extra-source-files: include/common.h include/libsais.h+ test/data/LICENSE.bz3 source-repository head type: darcs
src/Codec/Bz3.hs view
@@ -31,7 +31,7 @@ loop st bs where loop st bs | BSL.null bs = pure []- | otherwise = do {(dc, rest) <- decNext st bs; (dc:) <$> loop st rest}+ | otherwise = do {(dc, rest) <- decN st bs; (dc:) <$> loop st rest} -- will fail if bz3st cannot fit exotic big input compressFile :: BSL.ByteString -> BSL.ByteString@@ -41,14 +41,12 @@ let fileH = runPut (putFileH sz) pure (fileH<>BSL.fromChunks bb) where- loop _ [] = pure (0, [])+ loop _ [] = pure (bSz, []) loop s (b:bs) | BS.length b > feed = let (next,b') = BS.splitAt feed b in loop s (next:b':bs) loop s (b:bs) = do- (csz, e) <- if osz<64- then pure (0xffffffff, b)- else encN s b- let chunk=BSL.toStrict $ runPut (putChunk (Chunk (fromIntegral csz) osz))- bimap (max osz) ((chunk:).(e:)) <$> loop s bs+ (csz, e) <- encN s b+ let ucsz=fromIntegral csz; chunk=BSL.toStrict $ runPut (putChunk (Chunk ucsz osz))+ bimap (max ucsz) ((chunk:).(e:)) <$> loop s bs where osz=fromIntegral (BS.length b) @@ -67,8 +65,8 @@ bz3EncodeBlock st (castPtr bb) (fromIntegral sz) pure (enc, BS.BS (castForeignPtr buf) (fromIntegral enc)) -decNext :: ForeignPtr Bz3St -> BSL.ByteString -> LazyST.ST s (BS.ByteString, BSL.ByteString)-decNext st inp = LazyST.unsafeIOToST $ do+decN :: ForeignPtr Bz3St -> BSL.ByteString -> LazyST.ST s (BS.ByteString, BSL.ByteString)+decN st inp = LazyST.unsafeIOToST $ do let (next, off, Chunk csz osz) = y (runGetOrFail getChunk inp) if osz>=64 then do@@ -84,7 +82,7 @@ Left e | e==Bz3Ok -> pure () | otherwise -> error =<< bz3Strerror st pure (BS.BS (castForeignPtr buf) (fromIntegral osz), next)- else let bb=BSL.toStrict (BSL.drop 8 $ BSL.take off inp) + else let bb=BSL.toStrict (BSL.drop 8 $ BSL.take off inp) in pure (bb, next) where y (Right x) = x; y (Left (_, _, e)) = error e
src/Codec/Bz3/Binary.hs view
@@ -36,7 +36,7 @@ getChunk = do csz <- getWord32le; osz <- getWord32le if osz<64- then getSmallBlock csz+ then getSmallBlock osz else getRegularBlock csz pure $ Chunk csz osz
+ test/data/LICENSE.bz3 view
binary file changed (absent → 10015 bytes)