import Foreign
import IO
-#if __GLASGOW_HASKELL__ < 503
-import PrelIOBase ( IO(..) )
-import IOExts ( hPutBufFull )
-#else
import GHC.IOBase ( IO(..) )
import System.IO ( hPutBuf )
-#endif
-
-import GLAEXTS ( touch#, byteArrayContents#, Int(..), Int#, Addr# )
+import GHC.Ptr ( Ptr(..) )
-import PrimPacked ( Ptr(..) )
+import GLAEXTS ( Int(..), Int#, Addr# )
-- -----------------------------------------------------------------------------
loop cs (i+1)
bPutFS :: BufHandle -> FastString -> IO ()
-bPutFS b@(BufHandle buf r hdl) fs@(FastString _ len# arr#) = do
- let len = I# len#
+bPutFS b@(BufHandle buf r hdl) fs@(FastString _ len _ fp _) =
+ withForeignPtr fp $ \ptr -> do
i <- readFastMutInt r
if (i + len) >= buf_size
then do hPutBuf hdl buf i
writeFastMutInt r 0
if (len >= buf_size)
- then do
- let a# = byteArrayContents# arr#
- hPutBuf hdl (Ptr a#) len
- touch fs
+ then hPutBuf hdl ptr len
else bPutFS b fs
else do
- let a# = byteArrayContents# arr#
- copyBytes (buf `plusPtr` i) (Ptr a#) len
- touch fs
+ copyBytes (buf `plusPtr` i) ptr len
writeFastMutInt r (i+len)
bPutFS _ _ = panic "bPutFS"
free buf
return ()
-touch r = IO $ \s -> case touch# r s of s -> (# s, () #)
-
#if 0
myPutBuf s hdl buf i =
modifyIOError (\e -> ioeSetErrorString e (ioeGetErrorString e ++ ':':s ++ " (" ++ show buf ++ "," ++ show i ++ ")")) $