packages feed

blaze-builder 0.4.2.3 → 0.4.3

raw patch · 8 files changed

+44/−72 lines, 8 filesdep −bytestring-builderdep −semigroupsdep ~basedep ~bytestringdep ~textPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: bytestring-builder, semigroups

Dependency ranges changed: base, bytestring, text

API changes (from Hackage documentation)

- Blaze.ByteString.Builder: toLazyByteString :: Builder -> ByteString
+ Blaze.ByteString.Builder: toLazyByteString :: Builder -> LazyByteString

Files

Blaze/ByteString/Builder.hs view
@@ -92,12 +92,8 @@  import Control.Monad(unless) -#if __GLASGOW_HASKELL__ >= 702 import Foreign import qualified Foreign.ForeignPtr.Unsafe as Unsafe-#else-import Foreign as Unsafe-#endif  import qualified Blaze.ByteString.Builder.Internal.Write as W import           Blaze.ByteString.Builder.ByteString@@ -113,12 +109,7 @@ import qualified Data.ByteString.Lazy          as L import qualified Data.ByteString.Lazy.Internal as L -#if __GLASGOW_HASKELL__ >= 702 import System.IO.Unsafe (unsafeDupablePerformIO)-#else-unsafeDupablePerformIO :: IO a -> a-unsafeDupablePerformIO = unsafePerformIO-#endif  withBS :: S.ByteString -> (ForeignPtr Word8 -> Int -> Int -> a) -> a #if MIN_VERSION_bytestring(0,11,0)
Blaze/ByteString/Builder/HTTP.hs view
@@ -40,11 +40,6 @@  import qualified Blaze.ByteString.Builder.Char8 as Char8 -#if !MIN_VERSION_base(4,8,0)-import Data.Monoid-#endif-- {-# INLINE shiftr_w32 #-} shiftr_w32 :: Word32 -> Int -> Word32 @@ -103,9 +98,14 @@ word32HexLength = max 1 . iterationsUntilZero (`shiftr_w32` 4) {-# INLINE word32HexLength #-} +-- | Maximum length of a hex string encoding any 'Word32'.+--   Same as @word32HexLength maxBound@.+maxWord32HexLength :: Int+maxWord32HexLength = 8+ writeWord32Hex :: Word32 -> Write writeWord32Hex w =-    boundedWrite (2 * sizeOf w) (pokeN len $ pokeWord32HexN len w)+    boundedWrite maxWord32HexLength (pokeN len $ pokeWord32HexN len w)   where     len = word32HexLength w {-# INLINE writeWord32Hex #-}@@ -129,8 +129,8 @@               return $ bufferFull minimalBufferSize op (go innerStep)           | otherwise = do               let !brInner@(BufferRange opInner _) = BufferRange-                     (op  `plusPtr` (chunkSizeLength + 2))     -- leave space for chunk header-                     (ope `plusPtr` (-maxAfterBufferOverhead)) -- leave space at end of data+                     (op  `plusPtr` (chunkSizeLength + crlfLength)) -- leave space for chunk header+                     (ope `plusPtr` (-maxAfterBufferOverhead))      -- leave space at end of data                    -- wraps the chunk, if it is non-empty, and returns the                   -- signal constructed with the correct end-of-data pointer@@ -143,9 +143,9 @@                         pokeWord32HexN chunkSizeLength                             (fromIntegral $ opInner' `minusPtr` opInner)                             op-                        execWrite writeCRLF (opInner `plusPtr` (-2))+                        execWrite writeCRLF (opInner `plusPtr` (-crlfLength))                         execWrite writeCRLF opInner'-                        mkSignal (opInner' `plusPtr` 2)+                        mkSignal (opInner' `plusPtr` crlfLength)                    -- prepare handlers                   doneH opInner' _ = wrapChunk opInner' $ \op' -> do@@ -186,10 +186,14 @@             -- builders.             minimalChunkSize  = 1 -            -- overhead computation-            maxBeforeBufferOverhead = sizeOf (undefined :: Int) + 2 -- max chunk size and CRLF after header-            maxAfterBufferOverhead  = 2 +                           -- CRLF after data-                                      sizeOf (undefined :: Int) + 2 -- max bytestring size, CRLF after header+            -- overhead computation which is when (re)sizing the output buffer.+            -- We make sure we have enough space+            -- - at the beginning of the chunk for the chunk length followed by CRLF+            -- - at the end of the chunk for the terminating CRLF and+            --   the chunk header (see above) of the next chunk.+            crlfLength = 2+            maxBeforeBufferOverhead = maxWord32HexLength + crlfLength+            maxAfterBufferOverhead  = crlfLength + maxWord32HexLength + crlfLength              maxEncodingOverhead = maxBeforeBufferOverhead + maxAfterBufferOverhead 
Blaze/ByteString/Builder/Html/Utf8.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704+ {-# OPTIONS_GHC -fsimpl-tick-factor=40000 #-}-#endif  ------------------------------------------------------------------------------ -- |@@ -104,17 +103,9 @@ -- UTF-8 encoding. -- fromHtmlEscapedText :: TS.Text -> B.Builder-#if MIN_VERSION_text(1,1,2) && MIN_VERSION_bytestring(0,10,4) fromHtmlEscapedText = TE.encodeUtf8BuilderEscaped wordHtmlEscaped-#else-fromHtmlEscapedText = fromHtmlEscapedString . TS.unpack-#endif  -- | /O(n)/. Serialize a HTML escaped Unicode 'TL.Text' using the UTF-8 encoding. -- fromHtmlEscapedLazyText :: TL.Text -> B.Builder-#if MIN_VERSION_text(1,1,2) && MIN_VERSION_bytestring(0,10,4) fromHtmlEscapedLazyText = TLE.encodeUtf8BuilderEscaped wordHtmlEscaped-#else-fromHtmlEscapedLazyText = fromHtmlEscapedString . TL.unpack-#endif
Blaze/ByteString/Builder/Html/Word.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704+ {-# OPTIONS_GHC -fsimpl-tick-factor=40000 #-}-#endif  ------------------------------------------------------------------------------ -- |
Blaze/ByteString/Builder/Internal/Write.hs view
@@ -53,10 +53,6 @@ import Control.Monad  import Data.ByteString.Builder.Internal--#if !MIN_VERSION_base(4,8,0)-import Data.Monoid (Monoid(..))-#endif import Data.Semigroup (Semigroup(..))  ------------------------------------------------------------------------------
CHANGES view
@@ -1,3 +1,9 @@+* 0.4.3 2025-05-15+  - Fix computation of max buffer overhead on 32 bit platforms+    (sternenseemann, PR #8 https://github.com/blaze-builder/blaze-builder/pull/8)+  - Drop support for GHC 7, bytestring < 0.10.4 and text < 1.1.2+  - Tested with GHC 8.0 - 9.12.2+ * 0.4.2.3 2023-08-27   - Fix compilation warnings concerning non-canonical mappend   - Support bytestring-0.12
blaze-builder.cabal view
@@ -1,5 +1,5 @@ Name:                blaze-builder-Version:             0.4.2.3+Version:             0.4.3 Synopsis:            Efficient buffered output.  Description:@@ -33,9 +33,11 @@ Cabal-version:       >= 1.10  Tested-with:-  GHC == 9.8.0-  GHC == 9.6.2-  GHC == 9.4.7+  GHC == 9.12.2+  GHC == 9.10.2+  GHC == 9.8.4+  GHC == 9.6.7+  GHC == 9.4.8   GHC == 9.2.8   GHC == 9.0.2   GHC == 8.10.7@@ -44,11 +46,6 @@   GHC == 8.4.4   GHC == 8.2.2   GHC == 8.0.2-  GHC == 7.10.3-  GHC == 7.8.4-  GHC == 7.6.3-  GHC == 7.4.2-  GHC == 7.0.4  Extra-source-files:                      Makefile@@ -84,32 +81,25 @@                      Blaze.ByteString.Builder.Internal.Write    build-depends:-      base       >= 4.3  && < 5-    , bytestring >= 0.9  && < 1+      base       >= 4.9    && < 5+    , bytestring >= 0.10.4 && < 1     , deepseq     , ghc-prim-    , text       >= 0.10 && < 3--  if impl(ghc < 7.8)-     build-depends:  bytestring-builder-  else-     build-depends:  bytestring >= 0.10.4--  if impl(ghc < 8.0)-     build-depends:  semigroups >= 0.16 && < 0.20+    , text       >= 1.1.2  && < 3 -  ghc-options:       -Wall-  if impl(ghc >= 8.0)-    ghc-options:     -Wcompat+  ghc-options:+    -Wall+    -Wcompat  test-suite test   type:             exitcode-stdio-1.0   hs-source-dirs:   tests   main-is:          Tests.hs   default-language: Haskell98-  ghc-options:      -Wall -fno-warn-orphans-  if impl(ghc >= 8.0)-    ghc-options:     -Wcompat+  ghc-options:+    -Wall+    -Wno-orphans+    -Wcompat    build-depends: base                , blaze-builder
tests/Tests.hs view
@@ -1,15 +1,10 @@ {-# LANGUAGE CPP, OverloadedStrings #-}-#if __GLASGOW_HASKELL__ >= 704+ {-# OPTIONS_GHC -fsimpl-tick-factor=40000 #-}-#endif+ -- | Tests for the Blaze builder -- module Main where--#if !MIN_VERSION_base(4,8,0)-import Control.Applicative ((<$>))-import Data.Monoid (mempty, mappend, mconcat)-#endif  import qualified Data.Text as T import qualified Data.ByteString.Lazy as LB