Add a suitable Show instance for TextEncoding (#4273)
[ghc-base.git] / GHC / IO / Encoding / Latin1.hs
index 99b2af3..5bdf608 100644 (file)
@@ -1,4 +1,4 @@
-{-# OPTIONS_GHC -fno-implicit-prelude -funbox-strict-fields #-}
+{-# OPTIONS_GHC  -XNoImplicitPrelude -funbox-strict-fields #-}
 {-# LANGUAGE BangPatterns #-}
 -----------------------------------------------------------------------------
 -- |
@@ -39,7 +39,8 @@ import Data.Maybe
 -- Latin1
 
 latin1 :: TextEncoding
-latin1 = TextEncoding { mkTextDecoder = latin1_DF,
+latin1 = TextEncoding { textEncodingName = "ISO8859-1",
+                        mkTextDecoder = latin1_DF,
                         mkTextEncoder = latin1_EF }
 
 latin1_DF :: IO (TextDecoder ())
@@ -61,7 +62,8 @@ latin1_EF =
           })
 
 latin1_checked :: TextEncoding
-latin1_checked = TextEncoding { mkTextDecoder = latin1_DF,
+latin1_checked = TextEncoding { textEncodingName = "ISO8859-1(checked)",
+                                mkTextDecoder = latin1_DF,
                                 mkTextEncoder = latin1_checked_EF }
 
 latin1_checked_EF :: IO (TextEncoder ())
@@ -83,8 +85,8 @@ latin1_decode
          | ow >= os || ir >= iw =  done ir ow
          | otherwise = do
               c0 <- readWord8Buf iraw ir
-              writeCharBuf oraw ow (unsafeChr (fromIntegral c0))
-              loop (ir+1) (ow+1)
+              ow' <- writeCharBuf oraw ow (unsafeChr (fromIntegral c0))
+              loop (ir+1) ow'
 
        -- lambda-lifted, to avoid thunks being built in the inner-loop:
        done !ir !ow = return (if ir == iw then input{ bufL=0, bufR=0 }