diff options
author | Alexey Kuleshevich <alexey@kuleshevi.ch> | 2019-08-18 03:38:37 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-11-19 20:39:20 -0500 |
commit | ef8a08e0dd4e5b908b7fbce1b3101dc311c4d3e1 (patch) | |
tree | a30180b45f705c3006fb4628b2e6284aab49f065 /utils/hpc/HpcUtils.hs | |
parent | d1f3c63701b7f0fd675f792af7f33c5b11eaff83 (diff) | |
download | haskell-ef8a08e0dd4e5b908b7fbce1b3101dc311c4d3e1.tar.gz |
hpc: Fix encoding issues. Add test for and fix #17073
* Make sure files are being read/written in UTF-8. Set encoding while writing
HTML output. Also set encoding while writing and reading .tix files although
we don't yet have a ticket complaining that this poses problems.
* Set encoding in html header to utf8
* Upgrade to new version of 'hpc' library and reuse `readFileUtf8`
and `writeFileUtf8` functions
* Update git submodule for `hpc`
* Bump up `hpc` executable version
Co-authored-by: Ben Gamari <ben@smart-cactus.org>
Diffstat (limited to 'utils/hpc/HpcUtils.hs')
-rw-r--r-- | utils/hpc/HpcUtils.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/utils/hpc/HpcUtils.hs b/utils/hpc/HpcUtils.hs index 6ee44b1ae6..da62f4a364 100644 --- a/utils/hpc/HpcUtils.hs +++ b/utils/hpc/HpcUtils.hs @@ -1,6 +1,6 @@ module HpcUtils where -import Trace.Hpc.Util +import Trace.Hpc.Util (catchIO, HpcPos, fromHpcPos, readFileUtf8) import qualified Data.Map as Map import System.FilePath @@ -25,12 +25,11 @@ grabHpcPos hsMap srcspan = readFileFromPath :: (String -> IO String) -> String -> [String] -> IO String -readFileFromPath _ filename@('/':_) _ = readFile filename +readFileFromPath _ filename@('/':_) _ = readFileUtf8 filename readFileFromPath err filename path0 = readTheFile path0 where readTheFile [] = err $ "could not find " ++ show filename ++ " in path " ++ show path0 readTheFile (dir:dirs) = - catchIO (do str <- readFile (dir </> filename) - return str) + catchIO (readFileUtf8 (dir </> filename)) (\ _ -> readTheFile dirs) |