[commit: ghc] master: utils: detabify/dewhitespace BufWrite (fb9bc40)

git at git.haskell.org git at git.haskell.org
Wed Aug 20 08:48:08 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/fb9bc40af7ced7ede22e91f12b66dc8035f94ff5/ghc

>---------------------------------------------------------------

commit fb9bc40af7ced7ede22e91f12b66dc8035f94ff5
Author: Austin Seipp <austin at well-typed.com>
Date:   Wed Aug 20 03:33:02 2014 -0500

    utils: detabify/dewhitespace BufWrite
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


>---------------------------------------------------------------

fb9bc40af7ced7ede22e91f12b66dc8035f94ff5
 compiler/utils/BufWrite.hs | 73 +++++++++++++++++++++-------------------------
 1 file changed, 33 insertions(+), 40 deletions(-)

diff --git a/compiler/utils/BufWrite.hs b/compiler/utils/BufWrite.hs
index 7eba075..482e9ee 100644
--- a/compiler/utils/BufWrite.hs
+++ b/compiler/utils/BufWrite.hs
@@ -12,22 +12,15 @@
 --
 -----------------------------------------------------------------------------
 
-{-# OPTIONS_GHC -fno-warn-tabs #-}
--- The above warning supression flag is a temporary kludge.
--- While working on this module you are encouraged to remove it and
--- detab the module (please do the detabbing in a separate patch). See
---     http://ghc.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
--- for details
-
 module BufWrite (
-	BufHandle(..),
-	newBufHandle,
-	bPutChar,
-	bPutStr,
-	bPutFS,
-	bPutFZS,
-	bPutLitString,
-	bFlush,
+        BufHandle(..),
+        newBufHandle,
+        bPutChar,
+        bPutStr,
+        bPutFS,
+        bPutFZS,
+        bPutLitString,
+        bFlush,
   ) where
 
 #include "HsVersions.h"
@@ -36,10 +29,10 @@ import FastString
 import FastTypes
 import FastMutInt
 
-import Control.Monad	( when )
+import Control.Monad    ( when )
 import Data.ByteString (ByteString)
 import qualified Data.ByteString.Unsafe as BS
-import Data.Char	( ord )
+import Data.Char        ( ord )
 import Foreign
 import Foreign.C.String
 import System.IO
@@ -47,8 +40,8 @@ import System.IO
 -- -----------------------------------------------------------------------------
 
 data BufHandle = BufHandle {-#UNPACK#-}!(Ptr Word8)
-			   {-#UNPACK#-}!FastMutInt
-			   Handle
+                           {-#UNPACK#-}!FastMutInt
+                           Handle
 
 newBufHandle :: Handle -> IO BufHandle
 newBufHandle hdl = do
@@ -68,11 +61,11 @@ STRICT2(bPutChar)
 bPutChar b@(BufHandle buf r hdl) c = do
   i <- readFastMutInt r
   if (i >= buf_size)
-	then do hPutBuf hdl buf buf_size
-		writeFastMutInt r 0
-		bPutChar b c
-	else do pokeElemOff buf i (fromIntegral (ord c) :: Word8)
-		writeFastMutInt r (i+1)
+        then do hPutBuf hdl buf buf_size
+                writeFastMutInt r 0
+                bPutChar b c
+        else do pokeElemOff buf i (fromIntegral (ord c) :: Word8)
+                writeFastMutInt r (i+1)
 
 bPutStr :: BufHandle -> String -> IO ()
 STRICT2(bPutStr)
@@ -80,14 +73,14 @@ bPutStr (BufHandle buf r hdl) str = do
   i <- readFastMutInt r
   loop str i
   where loop _ i | i `seq` False = undefined
-	loop "" i = do writeFastMutInt r i; return ()
-	loop (c:cs) i
-	   | i >= buf_size = do
-		hPutBuf hdl buf buf_size
-		loop (c:cs) 0
-	   | otherwise = do
-		pokeElemOff buf i (fromIntegral (ord c))
-		loop cs (i+1)
+        loop "" i = do writeFastMutInt r i; return ()
+        loop (c:cs) i
+           | i >= buf_size = do
+                hPutBuf hdl buf buf_size
+                loop (c:cs) 0
+           | otherwise = do
+                pokeElemOff buf i (fromIntegral (ord c))
+                loop cs (i+1)
 
 bPutFS :: BufHandle -> FastString -> IO ()
 bPutFS b fs = bPutBS b $ fastStringToByteString fs
@@ -116,14 +109,14 @@ bPutLitString b@(BufHandle buf r hdl) a len_ = a `seq` do
   let len = iBox len_
   i <- readFastMutInt r
   if (i+len) >= buf_size
-	then do hPutBuf hdl buf i
-		writeFastMutInt r 0
-		if (len >= buf_size) 
-		    then hPutBuf hdl a len
-		    else bPutLitString b a len_
-	else do
-		copyBytes (buf `plusPtr` i) a len
-		writeFastMutInt r (i+len)
+        then do hPutBuf hdl buf i
+                writeFastMutInt r 0
+                if (len >= buf_size)
+                    then hPutBuf hdl a len
+                    else bPutLitString b a len_
+        else do
+                copyBytes (buf `plusPtr` i) a len
+                writeFastMutInt r (i+len)
 
 bFlush :: BufHandle -> IO ()
 bFlush (BufHandle buf r hdl) = do



More information about the ghc-commits mailing list