streaming-commons 0.2.1.0 → 0.2.1.1
raw patch · 6 files changed
+40/−26 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Streaming.Process: instance GHC.Exception.Exception Data.Streaming.Process.ProcessExitedUnsuccessfully
- Data.Streaming.Zlib: instance GHC.Exception.Exception Data.Streaming.Zlib.ZlibException
+ Data.Streaming.Process: instance GHC.Exception.Type.Exception Data.Streaming.Process.ProcessExitedUnsuccessfully
+ Data.Streaming.Zlib: instance GHC.Exception.Type.Exception Data.Streaming.Zlib.ZlibException
- Data.Streaming.ByteString.Builder.Buffer: Buffer :: {-# UNPACK #-} !(ForeignPtr Word8) -> {-# UNPACK #-} !(Ptr Word8) -> {-# UNPACK #-} !(Ptr Word8) -> {-# UNPACK #-} !(Ptr Word8) -> Buffer
+ Data.Streaming.ByteString.Builder.Buffer: Buffer :: {-# UNPACK #-} !ForeignPtr Word8 -> {-# UNPACK #-} !Ptr Word8 -> {-# UNPACK #-} !Ptr Word8 -> {-# UNPACK #-} !Ptr Word8 -> Buffer
- Data.Streaming.Filesystem: data DirStream :: *
+ Data.Streaming.Filesystem: data DirStream
- Data.Streaming.Network: getAfterBind :: HasAfterBind a => a -> (Socket -> IO ())
+ Data.Streaming.Network: getAfterBind :: HasAfterBind a => a -> Socket -> IO ()
- Data.Streaming.Network.Internal: AppData :: !(IO ByteString) -> !(ByteString -> IO ()) -> !SockAddr -> !(Maybe SockAddr) -> !(IO ()) -> Maybe Socket -> AppData
+ Data.Streaming.Network.Internal: AppData :: !IO ByteString -> !ByteString -> IO () -> !SockAddr -> !Maybe SockAddr -> !IO () -> Maybe Socket -> AppData
- Data.Streaming.Network.Internal: AppDataUnix :: !(IO ByteString) -> !(ByteString -> IO ()) -> AppDataUnix
+ Data.Streaming.Network.Internal: AppDataUnix :: !IO ByteString -> !ByteString -> IO () -> AppDataUnix
- Data.Streaming.Network.Internal: ServerSettings :: !Int -> !HostPreference -> !(Maybe Socket) -> !(Socket -> IO ()) -> !Bool -> !Int -> ServerSettings
+ Data.Streaming.Network.Internal: ServerSettings :: !Int -> !HostPreference -> !Maybe Socket -> !Socket -> IO () -> !Bool -> !Int -> ServerSettings
- Data.Streaming.Network.Internal: ServerSettingsUnix :: !FilePath -> !(Socket -> IO ()) -> !Int -> ServerSettingsUnix
+ Data.Streaming.Network.Internal: ServerSettingsUnix :: !FilePath -> !Socket -> IO () -> !Int -> ServerSettingsUnix
- Data.Streaming.Network.Internal: [appCloseConnection'] :: AppData -> !(IO ())
+ Data.Streaming.Network.Internal: [appCloseConnection'] :: AppData -> !IO ()
- Data.Streaming.Network.Internal: [appLocalAddr'] :: AppData -> !(Maybe SockAddr)
+ Data.Streaming.Network.Internal: [appLocalAddr'] :: AppData -> !Maybe SockAddr
- Data.Streaming.Network.Internal: [appRead'] :: AppData -> !(IO ByteString)
+ Data.Streaming.Network.Internal: [appRead'] :: AppData -> !IO ByteString
- Data.Streaming.Network.Internal: [appReadUnix] :: AppDataUnix -> !(IO ByteString)
+ Data.Streaming.Network.Internal: [appReadUnix] :: AppDataUnix -> !IO ByteString
- Data.Streaming.Network.Internal: [appWrite'] :: AppData -> !(ByteString -> IO ())
+ Data.Streaming.Network.Internal: [appWrite'] :: AppData -> !ByteString -> IO ()
- Data.Streaming.Network.Internal: [appWriteUnix] :: AppDataUnix -> !(ByteString -> IO ())
+ Data.Streaming.Network.Internal: [appWriteUnix] :: AppDataUnix -> !ByteString -> IO ()
- Data.Streaming.Network.Internal: [serverAfterBindUnix] :: ServerSettingsUnix -> !(Socket -> IO ())
+ Data.Streaming.Network.Internal: [serverAfterBindUnix] :: ServerSettingsUnix -> !Socket -> IO ()
- Data.Streaming.Network.Internal: [serverAfterBind] :: ServerSettings -> !(Socket -> IO ())
+ Data.Streaming.Network.Internal: [serverAfterBind] :: ServerSettings -> !Socket -> IO ()
- Data.Streaming.Network.Internal: [serverSocket] :: ServerSettings -> !(Maybe Socket)
+ Data.Streaming.Network.Internal: [serverSocket] :: ServerSettings -> !Maybe Socket
- Data.Streaming.Process.Internal: StreamingProcessHandle :: ProcessHandle -> (TMVar ExitCode) -> (IO ()) -> StreamingProcessHandle
+ Data.Streaming.Process.Internal: StreamingProcessHandle :: ProcessHandle -> TMVar ExitCode -> IO () -> StreamingProcessHandle
- Data.Streaming.Text: DecodeResultSuccess :: !Text -> !(ByteString -> DecodeResult) -> DecodeResult
+ Data.Streaming.Text: DecodeResultSuccess :: !Text -> !ByteString -> DecodeResult -> DecodeResult
- Data.Streaming.Zlib: data WindowBits :: *
+ Data.Streaming.Zlib: data WindowBits
Files
- ChangeLog.md +6/−0
- Data/Streaming/Network.hs +0/−3
- cbits/text-helper.c +14/−10
- cbits/zlib-helper.c +7/−7
- streaming-commons.cabal +1/−1
- test/Data/Streaming/ByteString/BuilderSpec.hs +12/−5
ChangeLog.md view
@@ -1,3 +1,9 @@+# ChangeLog for streaming-commons++## 0.2.1.1++* Fix a failing test case (invalid `ByteString` copying), does not affect library itself+ ## 0.2.1.0 * Change `bindRandomPortGen` to use binding to port 0
Data/Streaming/Network.hs view
@@ -200,9 +200,6 @@ -- | Bind to a random port number. Especially useful for writing network tests. ----- This will attempt 30 different port numbers before giving up and throwing an--- exception.--- -- Since 0.1.1 bindRandomPortGen :: SocketType -> HostPreference -> IO (Int, Socket) bindRandomPortGen sockettype s = do
cbits/text-helper.c view
@@ -14,13 +14,17 @@ void _hs_streaming_commons_memcpy(void *dest, size_t doff, const void *src, size_t soff, size_t n) {- memcpy(dest + (doff<<1), src + (soff<<1), n<<1);+ char *cdest = dest;+ const char *csrc = src;+ memcpy(cdest + (doff<<1), csrc + (soff<<1), n<<1); } int _hs_streaming_commons_memcmp(const void *a, size_t aoff, const void *b, size_t boff, size_t n) {- return memcmp(a + (aoff<<1), b + (boff<<1), n<<1);+ const char *ca = a;+ const char *cb = b;+ return memcmp(ca + (aoff<<1), cb + (boff<<1), n<<1); } #define UTF8_ACCEPT 0@@ -68,8 +72,8 @@ * an UTF16 array */ void-_hs_streaming_commons_decode_latin1(uint16_t *dest, const uint8_t const *src,- const uint8_t const *srcend)+_hs_streaming_commons_decode_latin1(uint16_t *dest, const uint8_t *src,+ const uint8_t *srcend) { const uint8_t *p = src; @@ -130,14 +134,14 @@ #if defined(__GNUC__) || defined(__clang__) static inline uint8_t const * _hs_streaming_commons_decode_utf8_int(uint16_t *const dest, size_t *destoff,- const uint8_t const **src, const uint8_t const *srcend,+ const uint8_t **src, const uint8_t *srcend, uint32_t *codepoint0, uint32_t *state0) __attribute((always_inline)); #endif static inline uint8_t const * _hs_streaming_commons_decode_utf8_int(uint16_t *const dest, size_t *destoff,- const uint8_t const **src, const uint8_t const *srcend,+ const uint8_t **src, const uint8_t *srcend, uint32_t *codepoint0, uint32_t *state0) { uint16_t *d = dest + *destoff;@@ -158,7 +162,7 @@ if (state == UTF8_ACCEPT) { while (s < srcend - 4) {- codepoint = *((uint32_t *) s);+ codepoint = *((const uint32_t *) s); if ((codepoint & 0x80808080) != 0) break; s += 4;@@ -202,8 +206,8 @@ uint8_t const * _hs_streaming_commons_decode_utf8_state(uint16_t *const dest, size_t *destoff,- const uint8_t const **src,- const uint8_t const *srcend,+ const uint8_t **src,+ const uint8_t *srcend, uint32_t *codepoint0, uint32_t *state0) { uint8_t const *ret = _hs_streaming_commons_decode_utf8_int(dest, destoff, src, srcend,@@ -243,7 +247,7 @@ ascii: #if defined(__x86_64__) while (srcend - src >= 4) {- uint64_t w = *((uint64_t *) src);+ uint64_t w = *((const uint64_t *) src); if (w & 0xFF80FF80FF80FF80ULL) { if (!(w & 0x000000000000FF80ULL)) {
cbits/zlib-helper.c view
@@ -27,14 +27,14 @@ return deflateInit2(stream, level, Z_DEFLATED, methodBits, memlevel, strategy); } -int streaming_commons_inflate_set_dictionary(z_stream *stream, const char* dictionary, +int streaming_commons_inflate_set_dictionary(z_stream *stream, const char* dictionary, unsigned int dictLength) {- return inflateSetDictionary(stream, dictionary, dictLength);+ return inflateSetDictionary(stream, (const Bytef *)dictionary, dictLength); } -int streaming_commons_deflate_set_dictionary(z_stream *stream, const char* dictionary, +int streaming_commons_deflate_set_dictionary(z_stream *stream, const char* dictionary, unsigned int dictLength) {- return deflateSetDictionary(stream, dictionary, dictLength);+ return deflateSetDictionary(stream, (const Bytef *)dictionary, dictLength); } void streaming_commons_free_z_stream_inflate (z_stream *stream)@@ -45,13 +45,13 @@ void streaming_commons_set_avail_in (z_stream *stream, char *buff, unsigned int avail) {- stream->next_in = buff;+ stream->next_in = (Bytef *)buff; stream->avail_in = avail; } void streaming_commons_set_avail_out (z_stream *stream, char *buff, unsigned int avail) {- stream->next_out = buff;+ stream->next_out = (Bytef *)buff; stream->avail_out = avail; } @@ -72,7 +72,7 @@ char* streaming_commons_get_next_in (z_stream *stream) {- return stream->next_in;+ return (char *)stream->next_in; } void streaming_commons_free_z_stream_deflate (z_stream *stream)
streaming-commons.cabal view
@@ -1,5 +1,5 @@ name: streaming-commons-version: 0.2.1.0+version: 0.2.1.1 synopsis: Common lower-level functions needed by various streaming data libraries description: Provides low-dependency functionality commonly needed by various streaming data libraries, such as conduit and pipes. homepage: https://github.com/fpco/streaming-commons
test/Data/Streaming/ByteString/BuilderSpec.hs view
@@ -7,7 +7,6 @@ import qualified Data.ByteString as S import Data.ByteString.Char8 ()-import qualified Data.ByteString.Unsafe as S import qualified Data.ByteString.Builder as B import Data.ByteString.Builder (Builder) import qualified Data.ByteString.Builder.Internal as B@@ -107,12 +106,20 @@ builderSpec - prop "toByteStringIO idempotent to toLazyByteString" $ \bss' -> do+ let prop_idempotent i bss' = do let bss = mconcat (map (B.byteString . S.pack) bss') ior <- newIORef [] toByteStringIOWith 16- (\s -> do s' <- S.useAsCStringLen s S.unsafePackCStringLen- modifyIORef ior (s' :))+ (\s -> do let s' = S.copy s+ s' `seq` modifyIORef ior (s' :)) bss chunks <- readIORef ior- L.fromChunks (reverse chunks) `shouldBe` B.toLazyByteString bss+ let have = L.unpack (L.fromChunks (reverse chunks))+ want = L.unpack (B.toLazyByteString bss)+ (i, have) `shouldBe` (i, want)++ prop "toByteStringIO idempotent to toLazyByteString" (prop_idempotent (0::Int))++ it "toByteStringIO idempotent to toLazyBytestring, specific case" $ do+ let bss' = replicate 10 [0..255]+ mapM_ (\i -> prop_idempotent i bss') [(1::Int)..100]