hGetLine and eof
Jon Fairbairn
Jon.Fairbairn at cl.cam.ac.uk
Mon Jun 17 12:52:12 EDT 2002
This doesn't seem right:
echo -n "no-newline" > /tmp/no-newline
so /tmp/no-newline has no newline before the end of file.
let f h = do p <- hIsEOF h
if p then putStrLn "done"
else do l <- hGetLine h
f h
and then
do h <- openFile "/tmp/no-newline" ReadMode
f h
with ghc 5.02.2
outputs "no-newline" over and over. Surely when the first
hGetLine is done the file pointer is at end of file so
hIsEOF should return True? Furthermore, even if there's
some reason why that isn't the case, the next hGetline
shouldn't return the same string!
It's not obvious to me how to write around this either!
Cheers,
Jón
--
Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk
31 Chalmers Road jf at cl.cam.ac.uk
Cambridge CB1 3SZ +44 1223 570179 (after 14:00 only, please!)
More information about the Glasgow-haskell-bugs
mailing list