Permalink
Browse files

Remove trailing whitespace.

  • Loading branch information...
1 parent e4f9285 commit e8b11e54ce889141941d95f0507cc3616c2ed127 @meiersi committed Mar 11, 2013
@@ -3,7 +3,7 @@
-- Module : Blaze.ByteString.Builder
-- Copyright : (c) 2010 Jasper Van der Jeugt & Simon Meier
-- License : BSD3-style (see LICENSE)
---
+--
-- Maintainer : Simon Meier <iridcode@gmail.com>
-- Stability : experimental
-- Portability : tested on GHC only
@@ -12,7 +12,7 @@
-- of the @blaze-builder@ library.
--
-- > import Blaze.ByteString.Builder
---
+--
-- It provides you with a type 'Builder' that allows to efficiently construct
-- lazy bytestrings with a large average chunk size.
--
@@ -57,7 +57,7 @@
-----------------------------------------------------------------------------
module Blaze.ByteString.Builder
- (
+ (
-- * The 'Builder' type
Builder
@@ -4,7 +4,7 @@
-- Module : Blaze.ByteString.Builder.ByteString
-- Copyright : (c) 2010 Jasper Van der Jeugt & Simon Meier
-- License : BSD3-style (see LICENSE)
---
+--
-- Maintainer : Simon Meier <iridcode@gmail.com>
-- Stability : experimental
-- Portability : tested on GHC only
@@ -18,7 +18,7 @@
-- > import qualified Data.ByteString.Lazy as L
--
module Blaze.ByteString.Builder.ByteString
- (
+ (
-- * Strict bytestrings
writeByteString
, fromByteString
@@ -76,7 +76,7 @@ writeByteString bs = exactWrite l io
--
-- If you statically know that copying or inserting the strict bytestring is
-- always the best choice, then you can use the 'copyByteString' or
--- 'insertByteString' functions.
+-- 'insertByteString' functions.
--
fromByteString :: S.ByteString -> Builder
fromByteString = fromByteStringWith defaultMaximalCopySize
@@ -97,7 +97,7 @@ fromByteString = fromByteStringWith defaultMaximalCopySize
fromByteStringWith :: Int -- ^ Maximal number of bytes to copy.
-> S.ByteString -- ^ Strict 'S.ByteString' to serialize.
-> Builder -- ^ Resulting 'Builder'.
-fromByteStringWith maxCopySize =
+fromByteStringWith maxCopySize =
\bs -> fromBuildStepCont $ step bs
where
step !bs !k br@(BufRange !op _)
@@ -106,7 +106,7 @@ fromByteStringWith maxCopySize =
{-# INLINE fromByteStringWith #-}
-- | @copyByteString bs@ serialize the strict bytestring @bs@ by copying it to
--- the output buffer.
+-- the output buffer.
--
-- Use this function to serialize strict bytestrings that are statically known
-- to be smallish (@<= 4kb@).
@@ -115,10 +115,10 @@ copyByteString :: S.ByteString -> Builder
copyByteString = \bs -> fromBuildStepCont $ copyByteStringStep bs
{-# INLINE copyByteString #-}
-copyByteStringStep :: S.ByteString
+copyByteStringStep :: S.ByteString
-> (BufRange -> IO (BuildSignal a))
-> (BufRange -> IO (BuildSignal a))
-copyByteStringStep (S.PS ifp ioff isize) !k =
+copyByteStringStep (S.PS ifp ioff isize) !k =
goBS (unsafeForeignPtrToPtr ifp `plusPtr` ioff)
where
!ipe = unsafeForeignPtrToPtr ifp `plusPtr` (ioff + isize)
@@ -138,15 +138,15 @@ copyByteStringStep (S.PS ifp ioff isize) !k =
{-# INLINE copyByteStringStep #-}
-- | @insertByteString bs@ serializes the strict bytestring @bs@ by inserting
--- it directly as a chunk of the output stream.
+-- it directly as a chunk of the output stream.
--
-- Note that this implies flushing the output buffer; even if it contains just
-- a single byte. Hence, you should use this operation only for large (@> 8kb@)
-- bytestrings, as otherwise the resulting output stream may be too fragmented
-- to be processed efficiently.
--
insertByteString :: S.ByteString -> Builder
-insertByteString =
+insertByteString =
\bs -> fromBuildStepCont $ step bs
where
step !bs !k !(BufRange op _) = return $ I.insertByteString op bs k
@@ -167,7 +167,7 @@ insertByteString =
--
-- If you statically know that copying or inserting /all/ chunks of the lazy
-- bytestring is always the best choice, then you can use the
--- 'copyLazyByteString' or 'insertLazyByteString' functions.
+-- 'copyLazyByteString' or 'insertLazyByteString' functions.
--
fromLazyByteString :: L.ByteString -> Builder
fromLazyByteString = fromLazyByteStringWith defaultMaximalCopySize
@@ -188,7 +188,7 @@ fromLazyByteString = fromLazyByteStringWith defaultMaximalCopySize
fromLazyByteStringWith :: Int -- ^ Maximal number of bytes to copy.
-> L.ByteString -- ^ Lazy 'L.ByteString' to serialize.
-> Builder -- ^ Resulting 'Builder'.
-fromLazyByteStringWith maxCopySize =
+fromLazyByteStringWith maxCopySize =
L.foldrChunks (\bs b -> fromByteStringWith maxCopySize bs `mappend` b) mempty
{-# INLINE fromLazyByteStringWith #-}
@@ -199,7 +199,7 @@ fromLazyByteStringWith maxCopySize =
-- See 'copyByteString' for usage considerations.
--
copyLazyByteString :: L.ByteString -> Builder
-copyLazyByteString =
+copyLazyByteString =
L.foldrChunks (\bs b -> copyByteString bs `mappend` b) mempty
{-# INLINE copyLazyByteString #-}
@@ -1,20 +1,20 @@
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- ignore warning from 'import Data.Text.Encoding'
-- |
-- Module : Blaze.ByteString.Builder.Char.Utf8
-- Copyright : (c) 2010 Jasper Van der Jeugt & Simon Meier
-- License : BSD3-style (see LICENSE)
---
+--
-- Maintainer : Simon Meier <iridcode@gmail.com>
-- Stability : experimental
-- Portability : tested on GHC only
--
-- 'Write's and 'Builder's for serializing Unicode characters using the UTF-8
--- encoding.
+-- encoding.
--
module Blaze.ByteString.Builder.Char.Utf8
- (
+ (
-- * Writing UTF-8 encoded characters to a buffer
writeChar
@@ -46,7 +46,7 @@ writeChar c = boundedWrite 4 (encodeCharUtf8 f1 f2 f3 f4 c)
f2 x1 x2 = pokeN 2 $ \op -> do pokeByteOff op 0 x1
pokeByteOff op 1 x2
-
+
f3 x1 x2 x3 = pokeN 3 $ \op -> do pokeByteOff op 0 x1
pokeByteOff op 1 x2
pokeByteOff op 2 x3
@@ -1,18 +1,18 @@
-{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE MonoPatBinds #-}
-- ignore warning from 'import Data.Text.Encoding'
-- |
-- Module : Blaze.ByteString.Builder.Char8
-- Copyright : (c) 2010 Simon Meier
-- License : BSD3-style (see LICENSE)
---
+--
-- Maintainer : Simon Meier <iridcode@gmail.com>
-- Stability : experimental
-- Portability : tested on GHC only
--
-- //Note:// This package is intended for low-level use like implementing
--- protocols. If you need to //serialize// Unicode characters use one of the
+-- protocols. If you need to //serialize// Unicode characters use one of the
-- UTF encodings (e.g. 'Blaze.ByteString.Builder.Char.UTF-8').
--
-- 'Write's and 'Builder's for serializing the lower 8-bits of characters.
@@ -21,7 +21,7 @@
-- 'Data.ByteString.Char8'.
--
module Blaze.ByteString.Builder.Char8
- (
+ (
-- * Writing Latin-1 (ISO 8859-1) encodable characters to a buffer
writeChar
@@ -67,7 +67,7 @@ writeWord16Hex = exactWrite 4 . pokeWord16Hex
-}
pokeWord32HexN :: Int -> Word32 -> Ptr Word8 -> IO ()
-pokeWord32HexN n0 w0 op0 =
+pokeWord32HexN n0 w0 op0 =
go w0 (op0 `plusPtr` (n0 - 1))
where
go !w !op
@@ -94,7 +94,7 @@ word32HexLength = max 1 . iterationsUntilZero (`shiftr_w32` 4)
{-# INLINE word32HexLength #-}
writeWord32Hex :: Word32 -> Write
-writeWord32Hex w =
+writeWord32Hex w =
boundedWrite (2 * sizeOf w) (pokeN len $ pokeWord32HexN len w)
where
len = word32HexLength w
@@ -108,7 +108,7 @@ test = flip (toLazyByteStringWith 32 32 32) L.empty
map oneLine [0,1] ++
[B.insertByteString ""] ++
map oneLine [0..16]
-
+
where
oneLine x = fromWriteSingleton writeWord32Hex x `mappend` Char8.fromChar ' '
@@ -133,22 +133,22 @@ chunkedTransferEncoding (Builder b) =
where
go innerStep !(BufRange op ope)
-- FIXME: Assert that outRemaining < maxBound :: Word32
- | outRemaining < minimalBufferSize =
+ | outRemaining < minimalBufferSize =
return $ bufferFull minimalBufferSize op (go innerStep)
| otherwise = do
- let !brInner@(BufRange opInner _) = BufRange
+ let !brInner@(BufRange opInner _) = BufRange
(op `plusPtr` (chunkSizeLength + 2)) -- 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
{-# INLINE wrapChunk #-}
- wrapChunk :: Ptr Word8 -> (Ptr Word8 -> IO (BuildSignal a))
+ wrapChunk :: Ptr Word8 -> (Ptr Word8 -> IO (BuildSignal a))
-> IO (BuildSignal a)
- wrapChunk !opInner' mkSignal
+ wrapChunk !opInner' mkSignal
| opInner' == opInner = mkSignal op
| otherwise = do
- pokeWord32HexN chunkSizeLength
+ pokeWord32HexN chunkSizeLength
(fromIntegral $ opInner' `minusPtr` opInner)
op
execWrite writeCRLF (opInner `plusPtr` (-2))
@@ -165,38 +165,38 @@ chunkedTransferEncoding (Builder b) =
BufferFull minRequiredSize opInner' nextInnerStep ->
wrapChunk opInner' $ \op' ->
- return $! bufferFull
- (minRequiredSize + maxEncodingOverhead)
+ return $! bufferFull
+ (minRequiredSize + maxEncodingOverhead)
op'
- (go nextInnerStep)
+ (go nextInnerStep)
- InsertByteString opInner' bs nextInnerStep
+ InsertByteString opInner' bs nextInnerStep
| S.null bs -> -- flush
wrapChunk opInner' $ \op' ->
- return $! insertByteString
- op' S.empty
+ return $! insertByteString
+ op' S.empty
(go nextInnerStep)
| otherwise -> -- insert non-empty bytestring
wrapChunk opInner' $ \op' -> do
-- add header for inserted bytestring
-- FIXME: assert(S.length bs < maxBound :: Word32)
!op'' <- (`runPoke` op') $ getPoke $
- writeWord32Hex (fromIntegral $ S.length bs)
+ writeWord32Hex (fromIntegral $ S.length bs)
`mappend` writeCRLF
-- insert bytestring and write CRLF in next buildstep
return $! InsertByteString
op'' bs
- (unBuilder (fromWrite writeCRLF) $
+ (unBuilder (fromWrite writeCRLF) $
buildStep $ go nextInnerStep)
-
+
where
-- minimal size guaranteed for actual data no need to require more
-- than 1 byte to guarantee progress the larger sizes will be
-- hopefully provided by the driver or requested by the wrapped
-- builders.
- minimalChunkSize = 1
-
+ minimalChunkSize = 1
+
-- overhead computation
maxBeforeBufferOverhead = sizeOf (undefined :: Int) + 2 -- max chunk size and CRLF after header
maxAfterBufferOverhead = 2 + -- CRLF after data
@@ -210,7 +210,7 @@ chunkedTransferEncoding (Builder b) =
outRemaining :: Int
outRemaining = ope `minusPtr` op
chunkSizeLength = word32HexLength $ fromIntegral outRemaining
-
+
-- | The zero-length chunk '0\r\n\r\n' signaling the termination of the data transfer.
chunkedTransferTerminator :: Builder
@@ -3,7 +3,7 @@
-- Module : Blaze.ByteString.Builder.Html.Utf8
-- Copyright : (c) 2010 Jasper Van der Jeugt & Simon Meier
-- License : BSD3-style (see LICENSE)
---
+--
-- Maintainer : Simon Meier <iridcode@gmail.com>
-- Stability : experimental
-- Portability : tested on GHC only
@@ -16,7 +16,7 @@
-- 'Data.Binary.Builder' implementation, this module will most likely keep its
-- place, as it provides a set of very specialized functions.
module Blaze.ByteString.Builder.Html.Utf8
- (
+ (
module Blaze.ByteString.Builder.Char.Utf8
-- * Writing HTML escaped and UTF-8 encoded characters to a buffer
@@ -42,7 +42,7 @@ import Blaze.ByteString.Builder.Char.Utf8
-- | Write a HTML escaped and UTF-8 encoded Unicode character to a bufffer.
--
writeHtmlEscapedChar :: Char -> Write
-writeHtmlEscapedChar c0 =
+writeHtmlEscapedChar c0 =
boundedWrite 6 (io c0)
-- WARNING: Don't forget to change the bound if you change the bytestrings.
where
Oops, something went wrong.

0 comments on commit e8b11e5

Please sign in to comment.