[project @ 2000-10-27 14:04:21 by simonmar]
[ghc-hetmet.git] / ghc / compiler / utils / StringBuffer.lhs
index b6b728f..f84311b 100644 (file)
@@ -37,6 +37,7 @@ module StringBuffer
         stepOnBy#,        -- :: StringBuffer -> Int# -> StringBuffer
         stepOnTo#,        -- :: StringBuffer -> Int# -> StringBuffer
         stepOnUntil,      -- :: (Char -> Bool) -> StringBuffer -> StringBuffer
+       stepOnUntilChar#, -- :: StringBuffer -> Char# -> StringBuffer
         stepOverLexeme,   -- :: StringBuffer   -> StringBuffer
        scanNumLit,       -- :: Int -> StringBuffer -> (Int, StringBuffer)
        squeezeLexeme,    -- :: StringBuffer -> Int# -> StringBuffer
@@ -51,7 +52,6 @@ module StringBuffer
         -- matching
         prefixMatch,       -- :: StringBuffer -> String -> Bool
        untilEndOfString#, -- :: StringBuffer -> Int#
-       untilChar#,        -- :: StringBuffer -> Char# -> Int#
 
          -- conversion
         lexemeToString,     -- :: StringBuffer -> String
@@ -66,7 +66,7 @@ module StringBuffer
 #include "HsVersions.h"
 
 import GlaExts
-import Addr            ( Addr(..) )
+import PrelAddr        ( Addr(..) )
 import Foreign
 import ST
 import Char            ( chr )
@@ -75,7 +75,11 @@ import Char          ( chr )
 #include "../lib/std/cbits/stgerror.h"
 
 #if __GLASGOW_HASKELL__ >= 303
-import IO              ( openFile, slurpFile )
+import IO              ( openFile
+#if __GLASGOW_HASKELL__ < 407
+                        , slurpFile   -- comes from PrelHandle or IOExts now
+#endif
+                        )
 import PrelIOBase
 import PrelHandle
 import Addr
@@ -119,7 +123,7 @@ data StringBuffer
 \end{code}
 
 \begin{code}
-instance Text StringBuffer where
+instance Show StringBuffer where
        showsPrec _ s = showString ""
 \end{code}
 
@@ -482,13 +486,13 @@ untilEndOfString# (StringBuffer fo l# s# c#) =
     _ -> loop (c# +# 1#)
 
 
-untilChar# :: StringBuffer -> Char# -> StringBuffer
-untilChar# (StringBuffer fo l# s# c#) x# = 
+stepOnUntilChar# :: StringBuffer -> Char# -> StringBuffer
+stepOnUntilChar# (StringBuffer fo l# s# c#) x# = 
  loop c# 
  where
   loop c#
    | c# >=# l# || indexCharOffAddr# fo c# `eqChar#` x#
-   = StringBuffer fo l# s# c#
+   = StringBuffer fo l# c# c#
    | otherwise
    = loop (c# +# 1#)
 
@@ -500,7 +504,7 @@ lexemeToString (StringBuffer fo _ start_pos# current#) =
  else
     unpackCStringBA (copySubStr (A# fo) (I# start_pos#) (I# (current# -# start_pos#)))
     
-lexemeToByteArray :: StringBuffer -> _ByteArray Int
+lexemeToByteArray :: StringBuffer -> ByteArray Int
 lexemeToByteArray (StringBuffer fo _ start_pos# current#) = 
  if start_pos# ==# current# then
     error "lexemeToByteArray"