hGetLine and eof
Simon Marlow
simonmar at microsoft.com
Tue Jun 18 09:14:32 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!
That's a real bug, thanks for the report. I've fixed it in CVS and 5.04
will have the fix.
Cheers,
Simon
More information about the Glasgow-haskell-bugs
mailing list