[commit: base] encoding: streamEncode was obviously wrong (33d015b)
Max Bolingbroke
batterseapower at hotmail.com
Mon Apr 11 18:47:41 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : encoding
http://hackage.haskell.org/trac/ghc/changeset/33d015b72c6a3c86f0e2396c06b66cf63c478c5d
>---------------------------------------------------------------
commit 33d015b72c6a3c86f0e2396c06b66cf63c478c5d
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date: Mon Apr 11 17:47:07 2011 +0100
streamEncode was obviously wrong
>---------------------------------------------------------------
GHC/IO/Handle/Internals.hs | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/GHC/IO/Handle/Internals.hs b/GHC/IO/Handle/Internals.hs
index e37902b..a2b644f 100644
--- a/GHC/IO/Handle/Internals.hs
+++ b/GHC/IO/Handle/Internals.hs
@@ -380,11 +380,12 @@ streamEncode codec from to = go (from, to)
where
go (from, to) = do
(why, from', to') <- encode codec from to
- -- When we are dealing with Streams
+ -- When we are dealing with Handles, we don't care about input/output
+ -- underflow particularly, and we want to delay errors about invalid
+ -- sequences as far as possible.
case why of
- Encoding.InvalidSequence -> recover codec from to >>= go
- Encoding.OutputUnderflow -> return (from', to')
- Encoding.InputUnderflow -> return (from', to')
+ Encoding.InvalidSequence | bufL from == bufL from' -> recover codec from' to' >>= go
+ _ -> return (from', to')
-- -----------------------------------------------------------------------------
-- Handle Finalizers
More information about the Cvs-libraries
mailing list