Commit c971406c authored by Duncan Coutts's avatar Duncan Coutts
Browse files

GHC's package db files are actually ascii, not UTF8

Because they're in Haskell Read/Show format which escapes non-ascii chars
in Strings.
parent cf7baddf
...@@ -309,7 +309,7 @@ getInstalledPackages' verbosity packagedbs conf = do ...@@ -309,7 +309,7 @@ getInstalledPackages' verbosity packagedbs conf = do
(UserPackageDB, _global:_) -> Nothing (UserPackageDB, _global:_) -> Nothing
(SpecificPackageDB specific, _) -> Just specific (SpecificPackageDB specific, _) -> Just specific
_ -> error "cannot read ghc-pkg global package file" _ -> error "cannot read ghc-pkg global package file"
sequence [ readTextFile file >>= \content -> return (db, read content) sequence [ readAsciiFile file >>= \content -> return (db, read content)
| (db , Just file) <- zip packagedbs (map dbFile packagedbs) ] | (db , Just file) <- zip packagedbs (map dbFile packagedbs) ]
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
......
...@@ -91,6 +91,7 @@ module Distribution.Simple.Utils ( ...@@ -91,6 +91,7 @@ module Distribution.Simple.Utils (
fromUTF8, fromUTF8,
toUTF8, toUTF8,
readTextFile, readTextFile,
readAsciiFile,
writeTextFile, writeTextFile,
-- * generic utils -- * generic utils
...@@ -647,6 +648,13 @@ toUTF8 (c:cs) ...@@ -647,6 +648,13 @@ toUTF8 (c:cs)
readTextFile :: FilePath -> IO String readTextFile :: FilePath -> IO String
readTextFile = fmap fromUTF8 . readFile readTextFile = fmap fromUTF8 . readFile
-- | Reads an ASCII encoded text file as a String
--
-- Reads lazily using ordinary 'readFile'.
--
readAsciiFile :: FilePath -> IO String
readAsciiFile = readFile
-- | Writes a Unicode String as a UTF8 encoded text file. -- | Writes a Unicode String as a UTF8 encoded text file.
-- --
-- Uses 'writeFileAtomic', so provides the same guarantees. -- Uses 'writeFileAtomic', so provides the same guarantees.
......
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