Skip to content
Snippets Groups Projects
Commit dcfe9a1f authored by sof's avatar sof
Browse files

[project @ 1998-02-09 13:02:15 by sof]

Remove IO exception compat. cruft
parent 7cd31df2
No related branches found
No related tags found
No related merge requests found
...@@ -105,7 +105,6 @@ instance Text StringBuffer where ...@@ -105,7 +105,6 @@ instance Text StringBuffer where
\begin{code} \begin{code}
hGetStringBuffer :: FilePath -> IO StringBuffer hGetStringBuffer :: FilePath -> IO StringBuffer
hGetStringBuffer fname = hGetStringBuffer fname =
-- trace ("Renamer: opening " ++ fname) $
openFile fname ReadMode >>= \ hndl -> openFile fname ReadMode >>= \ hndl ->
hFileSize hndl >>= \ len@(J# _ _ d#) -> hFileSize hndl >>= \ len@(J# _ _ d#) ->
let len_i = fromInteger len in let len_i = fromInteger len in
...@@ -114,7 +113,7 @@ hGetStringBuffer fname = ...@@ -114,7 +113,7 @@ hGetStringBuffer fname =
-- trace (show ((len_i::Int)+1)) $ -- trace (show ((len_i::Int)+1)) $
_casm_ `` %r=(char *)malloc(sizeof(char)*(int)%0); '' (len_i::Int) >>= \ arr@(A# a#) -> _casm_ `` %r=(char *)malloc(sizeof(char)*(int)%0); '' (len_i::Int) >>= \ arr@(A# a#) ->
if addr2Int# a# ==# 0# then if addr2Int# a# ==# 0# then
failWith MkIOError(hndl,UserError,("hGetStringBuffer: Could not allocate "++show len_i ++ " bytes")) fail (userError ("hGetStringBuffer: Could not allocate "++show len_i ++ " bytes"))
else else
-- _casm_ `` %r=NULL; '' >>= \ free_p -> -- _casm_ `` %r=NULL; '' >>= \ free_p ->
...@@ -123,10 +122,9 @@ hGetStringBuffer fname = ...@@ -123,10 +122,9 @@ hGetStringBuffer fname =
writeHandle hndl hndl_ >> writeHandle hndl hndl_ >>
let ptr = filePtr hndl_ in let ptr = filePtr hndl_ in
_ccall_ fread arr (1::Int) len_i ptr >>= \ (I# read#) -> _ccall_ fread arr (1::Int) len_i ptr >>= \ (I# read#) ->
-- trace ("DEBUG: opened " ++ fname ++ show (I# read#)) $
hClose hndl >> hClose hndl >>
if read# ==# 0# then -- EOF or other error if read# ==# 0# then -- EOF or some other error
failWith MkIOError(hndl,UserError,"hGetStringBuffer: EOF reached or some other error") fail (userError ("hGetStringBuffer: failed to slurp in interface file "++fname))
else else
-- Add a sentinel NUL -- Add a sentinel NUL
_casm_ `` ((char *)%0)[(int)%1]=(char)0; '' arr (I# (read# -# 1#)) >>= \ () -> _casm_ `` ((char *)%0)[(int)%1]=(char)0; '' arr (I# (read# -# 1#)) >>= \ () ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment