Permalink
Browse files

Merge.hs: use bytestring API for file I/O to avoid crashes on UTF-8 s…

…trings and LANG=C locale

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information...
trofi committed Oct 27, 2012
1 parent f4eac3d commit 24d83da7c81b82355f92f3ceb09c266b9692599e
Showing with 5 additions and 4 deletions.
  1. +5 −4 Merge.hs
View
@@ -6,6 +6,7 @@ module Merge
import Control.Monad.Error
import Control.Exception
+import qualified Data.ByteString.Lazy.Char8 as BL
import Data.Maybe
import Data.List as L
@@ -226,15 +227,15 @@ mergeEbuild verbosity target cat ebuild = do
epath = edir </> elocal
emeta = "metadata.xml"
mpath = edir </> emeta
- default_meta = Portage.makeDefaultMetadata (E.long_desc ebuild)
+ default_meta = BL.pack $ Portage.makeDefaultMetadata (E.long_desc ebuild)
createDirectoryIfMissing True edir
notice verbosity $ "Writing " ++ elocal
- writeFile epath (display ebuild)
+ BL.writeFile epath (BL.pack $ display ebuild)
yet_meta <- doesFileExist mpath
if (not yet_meta) -- TODO: add --force-meta-rewrite to opts
then do notice verbosity $ "Writing " ++ emeta
- writeFile mpath default_meta
- else do current_meta <- readFile mpath
+ BL.writeFile mpath default_meta
+ else do current_meta <- BL.readFile mpath
when (current_meta /= default_meta) $
notice verbosity $ "Default and current " ++ emeta ++ " differ."

0 comments on commit 24d83da

Please sign in to comment.