[project @ 2004-01-09 12:09:23 by simonmar]
[ghc-hetmet.git] / ghc / compiler / utils / StringBuffer.lhs
index 16218fd..1a7020b 100644 (file)
@@ -19,7 +19,6 @@ module StringBuffer
        prevChar,          -- :: StringBuffer -> Char -> Char
        lookAhead,         -- :: StringBuffer -> Int  -> Char
        atEnd,             -- :: StringBuffer -> Bool
-       difference,        -- :: StringBuffer -> StringBuffer -> Int
 
        -- * Moving
        stepOn, stepOnBy,
@@ -47,6 +46,11 @@ import GHC.IO                ( slurpFile )
 #endif
 
 import IO                      ( openFile, hFileSize, IOMode(ReadMode) )
+#if __GLASGOW_HASKELL__ >= 601
+import System.IO               ( openBinaryFile )
+#else
+import IOExts                   ( openFileEx, IOModeEx(..) )
+#endif
 
 #if __GLASGOW_HASKELL__ < 503
 import IArray                  ( listArray )
@@ -62,6 +66,9 @@ import Data.Array.IO          ( IOArray, hGetArray )
 
 import Char                    ( ord )
 
+#if __GLASGOW_HASKELL__ < 601
+openBinaryFile fp mode = openFileEx fp (BinaryMode mode)
+#endif
 -- -----------------------------------------------------------------------------
 -- The StringBuffer type
 
@@ -82,7 +89,7 @@ instance Show StringBuffer where
 
 hGetStringBuffer :: FilePath -> IO StringBuffer
 hGetStringBuffer fname = do
-   h <- openFile fname ReadMode
+   h <- openBinaryFile fname ReadMode
    size <- hFileSize h
    let size_i@(I# sz#) = fromIntegral size
 #if __GLASGOW_HASKELL__ < 503
@@ -135,9 +142,6 @@ lookAhead (StringBuffer arr# l# c#) (I# i#) =
  where 
    off = c# +# i#
 
-difference :: StringBuffer -> StringBuffer -> Int
-difference (StringBuffer _ _ c1#) (StringBuffer _ _ c2#) = I# (c2# -# c1#)
-
 -- -----------------------------------------------------------------------------
 -- Moving