ngx-export 1.7.7.1 → 1.7.8
raw patch · 3 files changed
+29/−27 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Changelog.md +5/−0
- NgxExport.hs +20/−20
- ngx-export.cabal +4/−7
Changelog.md view
@@ -1,3 +1,8 @@+### 1.7.8++- Refactored to avoid using *head* and *tail* as it triggers *x-partial*+ warnings in GHC *9.8.1*.+ ### 1.7.7.1 - Added a minimal example of using exporters.
NgxExport.hs view
@@ -91,6 +91,7 @@ import qualified Data.ByteString as B import qualified Data.ByteString.Unsafe as B import qualified Data.ByteString.Lazy as L+import qualified Data.ByteString.Lazy.Internal as L import qualified Data.ByteString.Lazy.Char8 as C8L import Data.Binary.Put import Data.Bits@@ -370,6 +371,9 @@ -- > toUpper hello = HELLO -- > reverse world = dlrow -- > 1 `isInList` [10, 1, ] = 1+--+-- See documentation with more examples at+-- <https://nginx-haskell-module.readthedocs.io>. -- | Exports a function of type --@@ -693,28 +697,24 @@ CString -> CSize -> Ptr CString -> Ptr CSize -> IO () #-} toBuffers :: L.ByteString -> Ptr NgxStrType -> IO (Ptr NgxStrType, Int)-toBuffers (L.null -> True) _ =+toBuffers L.Empty _ = return (nullPtr, 0)-toBuffers s p = do+toBuffers (L.Chunk s L.Empty) p | p /= nullPtr = do+ B.unsafeUseAsCStringLen s $ \(x, I l) -> poke p $ NgxStrType l x+ return (p, 1)+toBuffers s _ = do let n = L.foldlChunks (const . succ) 0 s- if n == 1 && p /= nullPtr- then do- B.unsafeUseAsCStringLen (head $ L.toChunks s) $- \(x, I l) -> poke p $ NgxStrType l x- return (p, 1)- else do- t <- safeMallocBytes $ n * sizeOf (undefined :: NgxStrType)- if t == nullPtr- then return (nullPtr, -1)- else (t, ) <$>- L.foldlChunks- (\a c -> do- off <- a- B.unsafeUseAsCStringLen c $- \(x, I l) ->- pokeElemOff t off $ NgxStrType l x- return $ off + 1- ) (return 0) s+ t <- safeMallocBytes $ n * sizeOf (undefined :: NgxStrType)+ if t == nullPtr+ then return (nullPtr, -1)+ else (t, ) <$>+ L.foldlChunks+ (\a c -> do+ off <- a+ B.unsafeUseAsCStringLen c $ \(x, I l) ->+ pokeElemOff t off $ NgxStrType l x+ return $ off + 1+ ) (return 0) s pokeLazyByteString :: L.ByteString -> Ptr (Ptr NgxStrType) -> Ptr CInt -> Ptr (StablePtr L.ByteString) -> IO ()
ngx-export.cabal view
@@ -1,12 +1,12 @@ name: ngx-export-version: 1.7.7.1+version: 1.7.8 synopsis: Helper module for Nginx haskell module description: Helper module for <https://github.com/lyokha/nginx-haskell-module Nginx haskell module>. homepage: https://github.com/lyokha/nginx-haskell-module license: BSD3 license-file: LICENSE-extra-source-files: Changelog.md+extra-doc-files: Changelog.md author: Alexey Radkov <alexey.radkov@gmail.com> maintainer: Alexey Radkov <alexey.radkov@gmail.com> stability: stable@@ -31,9 +31,6 @@ Paths_ngx_export ghc-options: -Wall- if impl(ghc < 8.0)- ghc-options: -fno-warn-incomplete-patterns- else- if impl(ghc < 8.2)- ghc-options: -Wno-incomplete-patterns+ if impl(ghc < 8.2)+ ghc-options: -Wno-incomplete-patterns