[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:50:48 UTC 2010
The following commit has been merged in the master branch:
commit aca78a497546f8cf007d7a9971c0ae9de75f1f4b
Author: John Goerzen <jgoerzen at complete.org>
Date: Thu Dec 16 03:29:35 2004 +0100
Fixed EOF handling in HVIO code
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.7--patch-74)
diff --git a/ChangeLog b/ChangeLog
index b98a6d5..4bfa169 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
#
+2004-12-15 20:29:35 GMT John Goerzen <jgoerzen at complete.org> patch-74
+
+ Summary:
+ Fixed EOF handling in HVIO code
+ Revision:
+ missingh--head--0.7--patch-74
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/HVIO.hs
+
+
2004-12-15 20:12:52 GMT John Goerzen <jgoerzen at complete.org> patch-73
Summary:
diff --git a/libsrc/MissingH/HVIO.hs b/libsrc/MissingH/HVIO.hs
index 26b7a20..d8ea2a9 100644
--- a/libsrc/MissingH/HVIO.hs
+++ b/libsrc/MissingH/HVIO.hs
@@ -61,7 +61,8 @@ class (Show a) => HVIOGeneric a where
vIsClosed :: a -> IO Bool
-- | Raise an error if the file is not open.
vTestOpen :: a -> IO ()
- -- | Whether or not we're at EOF
+ -- | Whether or not we're at EOF. This may raise on exception
+ -- on some items, most notably write-only Handles such as stdout.
vIsEOF :: a -> IO Bool
-- | Detailed show output.
vShow :: a -> IO String
@@ -113,25 +114,29 @@ class (HVIOGeneric a) => HVIOReader a where
vReady :: a -> IO Bool
vGetLine h =
- let loop accum = do e <- vIsEOF h
- if e then return accum
- else do c <- vGetChar h
- case c of
- '\n' -> return accum
- x -> accum `seq` loop (accum ++ [x])
+ let loop accum =
+ let func = do c <- vGetChar h
+ case c of
+ '\n' -> return accum
+ x -> accum `seq` loop (accum ++ [x])
+ handler e = if isEOFError e then return accum
+ else ioError e
+ in catch func handler
in
- do vTestEOF h
- loop ""
+ do vGetChar h >>= \x -> loop [x]
vGetContents h =
- let loop = do e <- vIsEOF h
- if e then return []
- else do c <- vGetChar h
- next <- loop
- c `seq` return (c : next)
+ let loop =
+ let func = do c <- vGetChar h
+ next <- loop
+ c `seq` return (c : next)
+ handler e = if isEOFError e then return []
+ else ioError e
+ in catch func handler
in
- do vTestEOF h
- loop
+ do firstchar <- vGetChar h
+ rest <- loop
+ return (firstchar : rest)
vReady h = do vTestEOF h
return True
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list