#3534: hSetBinaryMode fails after some input has been read
-----------------------------+----------------------------------------------
Reporter:  judah             |          Owner:                  
    Type:  bug               |         Status:  new             
Priority:  normal            |      Component:  libraries/base  
 Version:  6.11              |       Severity:  normal          
Keywords:                    |       Testcase:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-----------------------------+----------------------------------------------
 For the following program (`BadSeek.hs`), type a couple characters of
 input and press return.  With ghc-6.10.3, it works fine; with ghc-6.11 it
 throws an error.
 {{{
 module Main where

 import System.IO

 main = do
     getChar >>= print
     hSetBinaryMode stdin True
     getChar >>= print
 }}}

 With ghc-6.10:
 {{{
 $ ./BadSeek
 ab
 'a'
 'b'
 }}}

 With ghc-6.11:
 {{{
 $ ./BadSeek
 ab
 'a'
 BadSeek: <stdin>: hSetBinaryMode: illegal operation (cannot flush the read
 buffer of a text-mode handle)
 }}}

 The error goes away if the first 'getChar' is commented out.

 For libraries which are not yet using the Unicode I/O layer, having a way
 to temporarily set stdin to `BinaryMode` would be useful.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3534>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to