summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/IO/Buffer.hs
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-04-21 09:16:48 -0400
committerBen Gamari <ben@smart-cactus.org>2017-04-28 22:35:04 -0400
commit945c45ad50ed31e3acb96fdaafb21640c4669f12 (patch)
treeae2e59ba8d3a49bbd3c3dcece39d53aef691ed44 /libraries/base/GHC/IO/Buffer.hs
parente5b3492f23c2296d0d8221e1787ee585331f726e (diff)
downloadhaskell-945c45ad50ed31e3acb96fdaafb21640c4669f12.tar.gz
Prefer #if defined to #ifdef
Our new CPP linter enforces this.
Diffstat (limited to 'libraries/base/GHC/IO/Buffer.hs')
-rw-r--r--libraries/base/GHC/IO/Buffer.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/libraries/base/GHC/IO/Buffer.hs b/libraries/base/GHC/IO/Buffer.hs
index 50de06e97e..33eee6363d 100644
--- a/libraries/base/GHC/IO/Buffer.hs
+++ b/libraries/base/GHC/IO/Buffer.hs
@@ -101,7 +101,7 @@ readWord8Buf arr ix = withForeignPtr arr $ \p -> peekByteOff p ix
writeWord8Buf :: RawBuffer Word8 -> Int -> Word8 -> IO ()
writeWord8Buf arr ix w = withForeignPtr arr $ \p -> pokeByteOff p ix w
-#ifdef CHARBUF_UTF16
+#if defined(CHARBUF_UTF16)
type CharBufElem = Word16
#else
type CharBufElem = Char
@@ -124,7 +124,7 @@ writeCharBuf arr ix c = withForeignPtr arr $ \p -> writeCharBufPtr p ix c
{-# INLINE readCharBufPtr #-}
readCharBufPtr :: Ptr CharBufElem -> Int -> IO (Char, Int)
-#ifdef CHARBUF_UTF16
+#if defined(CHARBUF_UTF16)
readCharBufPtr p ix = do
c1 <- peekElemOff p ix
if (c1 < 0xd800 || c1 > 0xdbff)
@@ -138,7 +138,7 @@ readCharBufPtr p ix = do c <- peekElemOff (castPtr p) ix; return (c, ix+1)
{-# INLINE writeCharBufPtr #-}
writeCharBufPtr :: Ptr CharBufElem -> Int -> Char -> IO Int
-#ifdef CHARBUF_UTF16
+#if defined(CHARBUF_UTF16)
writeCharBufPtr p ix ch
| c < 0x10000 = do pokeElemOff p ix (fromIntegral c)
return (ix+1)
@@ -153,7 +153,7 @@ writeCharBufPtr p ix ch = do pokeElemOff (castPtr p) ix ch; return (ix+1)
#endif
charSize :: Int
-#ifdef CHARBUF_UTF16
+#if defined(CHARBUF_UTF16)
charSize = 2
#else
charSize = 4
@@ -186,7 +186,7 @@ data Buffer e
bufR :: !Int -- offset of last item + 1
}
-#ifdef CHARBUF_UTF16
+#if defined(CHARBUF_UTF16)
type CharBuffer = Buffer Word16
#else
type CharBuffer = Buffer Char
@@ -208,7 +208,7 @@ isFullBuffer Buffer{ bufR=w, bufSize=s } = s == w
-- if a Char buffer does not have room for a surrogate pair, it is "full"
isFullCharBuffer :: Buffer e -> Bool
-#ifdef CHARBUF_UTF16
+#if defined(CHARBUF_UTF16)
isFullCharBuffer buf = bufferAvailable buf < 2
#else
isFullCharBuffer = isFullBuffer