summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Foreign.hs
diff options
context:
space:
mode:
authorMax Bolingbroke <batterseapower@hotmail.com>2011-11-18 17:45:34 +0000
committerMax Bolingbroke <batterseapower@hotmail.com>2011-11-18 17:45:34 +0000
commit8019a64224d72647e8fc8cb99b4477fc9e90b3d6 (patch)
tree66ec16bdf6d968e4ffd87e2699207041f5904896 /libraries/base/GHC/Foreign.hs
parentb55007757210c1a7dfc06dcea956f4b8d9204783 (diff)
downloadhaskell-8019a64224d72647e8fc8cb99b4477fc9e90b3d6.tar.gz
Go back to using private-use characters in roundtripping
Diffstat (limited to 'libraries/base/GHC/Foreign.hs')
-rw-r--r--libraries/base/GHC/Foreign.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/libraries/base/GHC/Foreign.hs b/libraries/base/GHC/Foreign.hs
index f6f0272164..4eef2ebc2f 100644
--- a/libraries/base/GHC/Foreign.hs
+++ b/libraries/base/GHC/Foreign.hs
@@ -63,7 +63,6 @@ import GHC.Base
import GHC.IO
import GHC.IO.Exception
import GHC.IO.Buffer
-import GHC.IO.Encoding.Failure (surrogatifyRoundtripCharacter, desurrogatifyRoundtripCharacter)
import GHC.IO.Encoding.Types
@@ -173,7 +172,7 @@ peekEncodedCString (TextEncoding { mkTextDecoder = mk_decoder }) (p, sz_bytes)
if isEmptyBuffer from'
then
-- No input remaining: @why@ will be InputUnderflow, but we don't care
- fmap (map desurrogatifyRoundtripCharacter) $ withBuffer to' $ peekArray (bufferElems to')
+ withBuffer to' $ peekArray (bufferElems to')
else do
-- Input remaining: what went wrong?
putDebugMsg ("peekEncodedCString: " ++ show iteration ++ " " ++ show why)
@@ -183,7 +182,7 @@ peekEncodedCString (TextEncoding { mkTextDecoder = mk_decoder }) (p, sz_bytes)
putDebugMsg ("peekEncodedCString: from " ++ summaryBuffer from ++ " " ++ summaryBuffer from' ++ " " ++ summaryBuffer from'')
putDebugMsg ("peekEncodedCString: to " ++ summaryBuffer to ++ " " ++ summaryBuffer to' ++ " " ++ summaryBuffer to'')
to_chars <- withBuffer to'' $ peekArray (bufferElems to'')
- fmap (map desurrogatifyRoundtripCharacter to_chars++) $ go (iteration + 1) from''
+ fmap (to_chars++) $ go (iteration + 1) from''
go (0 :: Int) from0
@@ -194,7 +193,7 @@ withEncodedCString :: TextEncoding -- ^ Encoding of CString to create
-> (CStringLen -> IO a) -- ^ Worker that can safely use the allocated memory
-> IO a
withEncodedCString (TextEncoding { mkTextEncoder = mk_encoder }) null_terminate s act
- = bracket mk_encoder close $ \encoder -> withArrayLen (map surrogatifyRoundtripCharacter s) $ \sz p -> do
+ = bracket mk_encoder close $ \encoder -> withArrayLen s $ \sz p -> do
from <- fmap (\fp -> bufferAdd sz (emptyBuffer fp sz ReadBuffer)) $ newForeignPtr_ p
let go iteration to_sz_bytes = do
@@ -214,7 +213,7 @@ newEncodedCString :: TextEncoding -- ^ Encoding of CString to create
-> String -- ^ String to encode
-> IO CStringLen
newEncodedCString (TextEncoding { mkTextEncoder = mk_encoder }) null_terminate s
- = bracket mk_encoder close $ \encoder -> withArrayLen (map surrogatifyRoundtripCharacter s) $ \sz p -> do
+ = bracket mk_encoder close $ \encoder -> withArrayLen s $ \sz p -> do
from <- fmap (\fp -> bufferAdd sz (emptyBuffer fp sz ReadBuffer)) $ newForeignPtr_ p
let go iteration to_p to_sz_bytes = do