Commit 0a9c183a authored by batterseapower's avatar batterseapower
Browse files

Fix #5436 by using 'recover' on handle EOF

parent 0224b809
...@@ -126,6 +126,7 @@ test('4855', normal, compile_and_run, ['']) ...@@ -126,6 +126,7 @@ test('4855', normal, compile_and_run, [''])
test('hSetEncoding001',extra_run_opts('hSetEncoding001.in'), compile_and_run, ['']) test('hSetEncoding001',extra_run_opts('hSetEncoding001.in'), compile_and_run, [''])
test('decodingerror001',normal, compile_and_run, ['']) test('decodingerror001',normal, compile_and_run, [''])
test('decodingerror002',normal, compile_and_run, [''])
encoding001Encodings = ["utf8", "utf8_bom", "utf16", "utf16le", encoding001Encodings = ["utf8", "utf8_bom", "utf16", "utf16le",
"utf16be", "utf32", "utf32le", "utf32be"] "utf16be", "utf32", "utf32le", "utf32be"]
......
...@@ -3,8 +3,8 @@ UTF8 error:Left decodingerror001.in1: hGetChar: invalid argument (invalid byte s ...@@ -3,8 +3,8 @@ UTF8 error:Left decodingerror001.in1: hGetChar: invalid argument (invalid byte s
UTF8 error:Left decodingerror001.in1: hGetChar: invalid argument (invalid byte sequence) UTF8 error:Left decodingerror001.in1: hGetChar: invalid argument (invalid byte sequence)
UTF8 error:Left decodingerror001.in1: hGetChar: invalid argument (invalid byte sequence) UTF8 error:Left decodingerror001.in1: hGetChar: invalid argument (invalid byte sequence)
UTF8 error:Left decodingerror001.in1: hGetChar: invalid argument (invalid byte sequence) UTF8 error:Left decodingerror001.in1: hGetChar: invalid argument (invalid byte sequence)
UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence for this encoding) UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence)
UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence for this encoding) UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence)
UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence for this encoding) UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence)
UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence for this encoding) UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence)
UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence for this encoding) UTF8 incomplete sequence at end:Left decodingerror001.in2: hGetChar: invalid argument (invalid byte sequence)
import Control.Monad
import System.IO
import System.IO.Error
import GHC.IO.Handle (hSetEncoding)
main = alltests "decodingerror002.in"
alltests file = mapM (test file) ["UTF8",
"UTF8//IGNORE",
"UTF8//TRANSLIT",
"UTF8//ROUNDTRIP"]
test file enc_name = do
h <- openFile file ReadMode
enc <- mkTextEncoding enc_name
hSetEncoding h enc
e <- try $ forever $ hGetChar h >>= putChar
print (e :: Either IOError ())
Left decodingerror002.in: hGetChar: invalid argument (invalid byte sequence)
Left decodingerror002.in: hGetChar: end of file
�Left decodingerror002.in: hGetChar: end of file
Left <stdout>: hPutChar: invalid argument (invalid character)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment