Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add D.BS.B.P.I.boundedPrim to fix typo in "boudedPrim" #246

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Data/ByteString/Builder/Prim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ char8 = (fromIntegral . ord) >$< word8
-- | UTF-8 encode a 'Char'.
{-# INLINE charUtf8 #-}
charUtf8 :: BoundedPrim Char
charUtf8 = boudedPrim 4 (encodeCharUtf8 f1 f2 f3 f4)
charUtf8 = boundedPrim 4 (encodeCharUtf8 f1 f2 f3 f4)
where
pokeN n io op = io op >> return (op `plusPtr` n)

Expand Down
12 changes: 6 additions & 6 deletions Data/ByteString/Builder/Prim/ASCII.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ foreign import ccall unsafe "static _hs_bytestring_long_long_int_dec" c_long_lon

{-# INLINE encodeIntDecimal #-}
encodeIntDecimal :: Integral a => Int -> BoundedPrim a
encodeIntDecimal bound = boudedPrim bound $ c_int_dec . fromIntegral
encodeIntDecimal bound = boundedPrim bound $ c_int_dec . fromIntegral

-- | Decimal encoding of an 'Int8'.
{-# INLINE int8Dec #-}
Expand All @@ -133,7 +133,7 @@ int32Dec = encodeIntDecimal 11
-- | Decimal encoding of an 'Int64'.
{-# INLINE int64Dec #-}
int64Dec :: BoundedPrim Int64
int64Dec = boudedPrim 20 $ c_long_long_int_dec . fromIntegral
int64Dec = boundedPrim 20 $ c_long_long_int_dec . fromIntegral

-- | Decimal encoding of an 'Int'.
{-# INLINE intDec #-}
Expand All @@ -154,7 +154,7 @@ foreign import ccall unsafe "static _hs_bytestring_long_long_uint_dec" c_long_lo

{-# INLINE encodeWordDecimal #-}
encodeWordDecimal :: Integral a => Int -> BoundedPrim a
encodeWordDecimal bound = boudedPrim bound $ c_uint_dec . fromIntegral
encodeWordDecimal bound = boundedPrim bound $ c_uint_dec . fromIntegral

-- | Decimal encoding of a 'Word8'.
{-# INLINE word8Dec #-}
Expand All @@ -174,7 +174,7 @@ word32Dec = encodeWordDecimal 10
-- | Decimal encoding of a 'Word64'.
{-# INLINE word64Dec #-}
word64Dec :: BoundedPrim Word64
word64Dec = boudedPrim 20 $ c_long_long_uint_dec . fromIntegral
word64Dec = boundedPrim 20 $ c_long_long_uint_dec . fromIntegral

-- | Decimal encoding of a 'Word'.
{-# INLINE wordDec #-}
Expand All @@ -199,7 +199,7 @@ foreign import ccall unsafe "static _hs_bytestring_long_long_uint_hex" c_long_lo
{-# INLINE encodeWordHex #-}
encodeWordHex :: forall a. (Storable a, Integral a) => BoundedPrim a
encodeWordHex =
boudedPrim (2 * sizeOf (undefined :: a)) $ c_uint_hex . fromIntegral
boundedPrim (2 * sizeOf (undefined :: a)) $ c_uint_hex . fromIntegral

-- | Hexadecimal encoding of a 'Word8'.
{-# INLINE word8Hex #-}
Expand All @@ -219,7 +219,7 @@ word32Hex = encodeWordHex
-- | Hexadecimal encoding of a 'Word64'.
{-# INLINE word64Hex #-}
word64Hex :: BoundedPrim Word64
word64Hex = boudedPrim 16 $ c_long_long_uint_hex . fromIntegral
word64Hex = boundedPrim 16 $ c_long_long_uint_hex . fromIntegral

-- | Hexadecimal encoding of a 'Word'.
{-# INLINE wordHex #-}
Expand Down
10 changes: 8 additions & 2 deletions Data/ByteString/Builder/Prim/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-- standard encodings of standard Haskell values.
--
-- If you need to write your own builder primitives, then be aware that you are
-- writing code with /all saftey belts off/; i.e.,
-- writing code with /all safety belts off/; i.e.,
-- *this is the code that might make your application vulnerable to buffer-overflow attacks!*
-- The "Data.ByteString.Builder.Prim.Tests" module provides you with
-- utilities for testing your encodings thoroughly.
Expand All @@ -42,7 +42,7 @@ module Data.ByteString.Builder.Prim.Internal (

-- * Bounded-size builder primitives
, BoundedPrim
, boudedPrim
, boundedPrim
, sizeBound
, runB

Expand All @@ -64,6 +64,8 @@ module Data.ByteString.Builder.Prim.Internal (
, (>$<)
, (>*<)

-- * Deprecated
, boudedPrim
) where

import Foreign
Expand Down Expand Up @@ -231,6 +233,10 @@ data BoundedPrim a = BP {-# UNPACK #-} !Int (a -> Ptr Word8 -> IO (Ptr Word8))
sizeBound :: BoundedPrim a -> Int
sizeBound (BP b _) = b

boundedPrim :: Int -> (a -> Ptr Word8 -> IO (Ptr Word8)) -> BoundedPrim a
boundedPrim = BP

{-# DEPRECATED boudedPrim "Use 'boundedPrim' instead" #-}
boudedPrim :: Int -> (a -> Ptr Word8 -> IO (Ptr Word8)) -> BoundedPrim a
boudedPrim = BP

Expand Down