prevChar, -- :: StringBuffer -> Char -> Char
lookAhead, -- :: StringBuffer -> Int -> Char
atEnd, -- :: StringBuffer -> Bool
- difference, -- :: StringBuffer -> StringBuffer -> Int
-- * Moving
stepOn, stepOnBy,
#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 )
import Char ( ord )
+#if __GLASGOW_HASKELL__ < 601
+openBinaryFile fp mode = openFileEx fp (BinaryMode mode)
+#endif
-- -----------------------------------------------------------------------------
-- The StringBuffer type
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
where
off = c# +# i#
-difference :: StringBuffer -> StringBuffer -> Int
-difference (StringBuffer _ _ c1#) (StringBuffer _ _ c2#) = I# (c2# -# c1#)
-
-- -----------------------------------------------------------------------------
-- Moving