summaryrefslogtreecommitdiff
path: root/utils/hpc
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2015-03-17 18:09:18 +0100
committerThomas Miedema <thomasmiedema@gmail.com>2015-03-17 18:17:27 +0100
commit801f4b98fa5198ab7e033949dd84aaae00162993 (patch)
tree4efda91a9cf063b614c47bd4cd8be44872f77469 /utils/hpc
parent86eff3d92ffa3c9be29e037c01fd9b3fec8976e7 (diff)
downloadhaskell-801f4b98fa5198ab7e033949dd84aaae00162993.tar.gz
hpc: use System.FilePath.(</>) instead of (++)
Summary: BAD: "." ++ "/" ++ "/absolute/path" == ".//absolute/path" GOOD: "." </> "/absolute/path" == "/absolute path" Also replace `++ ".ext"` with `<.> "ext"`. Although it doesn't fix any bugs in this instance, it might in some other. As a general rule it's better not to use (++) on FilePaths. Reviewed By: austin, hvr Differential Revision: https://phabricator.haskell.org/D703 GHC Trac Issues: #10138
Diffstat (limited to 'utils/hpc')
-rw-r--r--utils/hpc/HpcFlags.hs3
-rw-r--r--utils/hpc/HpcMarkup.hs9
-rw-r--r--utils/hpc/HpcUtils.hs3
-rw-r--r--utils/hpc/hpc-bin.cabal1
4 files changed, 10 insertions, 6 deletions
diff --git a/utils/hpc/HpcFlags.hs b/utils/hpc/HpcFlags.hs
index 017030986a..dd1d9f7260 100644
--- a/utils/hpc/HpcFlags.hs
+++ b/utils/hpc/HpcFlags.hs
@@ -8,6 +8,7 @@ import Data.Char
import Trace.Hpc.Tix
import Trace.Hpc.Mix
import System.Exit
+import System.FilePath
data Flags = Flags
{ outputFile :: String
@@ -154,7 +155,7 @@ unionModuleOpt = noArg "union"
-------------------------------------------------------------------------------
readMixWithFlags :: Flags -> Either String TixModule -> IO Mix
-readMixWithFlags flags modu = readMix [ dir ++ "/" ++ hpcDir
+readMixWithFlags flags modu = readMix [ dir </> hpcDir
| dir <- srcDirs flags
, hpcDir <- hpcDirs flags
] modu
diff --git a/utils/hpc/HpcMarkup.hs b/utils/hpc/HpcMarkup.hs
index 1373bfbee5..31327fc991 100644
--- a/utils/hpc/HpcMarkup.hs
+++ b/utils/hpc/HpcMarkup.hs
@@ -13,6 +13,7 @@ import HpcFlags
import HpcUtils
import System.Directory
+import System.FilePath
import System.IO (localeEncoding)
import Data.List
import Data.Maybe(fromJust)
@@ -78,9 +79,9 @@ markup_main flags (prog:modNames) = do
let mods' = sortBy cmp mods
unless (verbosity flags < Normal) $
- putStrLn $ "Writing: " ++ (filename ++ ".html")
+ putStrLn $ "Writing: " ++ (filename <.> "html")
- writeFileUsing (dest_dir ++ "/" ++ filename ++ ".html") $
+ writeFileUsing (dest_dir </> filename <.> "html") $
"<html>" ++
"<head>" ++
charEncodingTag ++
@@ -224,10 +225,10 @@ genHtmlFromMod dest_dir flags tix theFunTotals invertOutput = do
let content' = markup tabStop info content
let addLine n xs = "<span class=\"lineno\">" ++ padLeft 5 ' ' (show n) ++ " </span>" ++ xs
let addLines = unlines . map (uncurry addLine) . zip [1 :: Int ..] . lines
- let fileName = modName0 ++ ".hs.html"
+ let fileName = modName0 <.> "hs" <.> "html"
unless (verbosity flags < Normal) $
putStrLn $ "Writing: " ++ fileName
- writeFileUsing (dest_dir ++ "/" ++ fileName) $
+ writeFileUsing (dest_dir </> fileName) $
unlines ["<html>",
"<head>",
charEncodingTag,
diff --git a/utils/hpc/HpcUtils.hs b/utils/hpc/HpcUtils.hs
index 4f98556176..6ee44b1ae6 100644
--- a/utils/hpc/HpcUtils.hs
+++ b/utils/hpc/HpcUtils.hs
@@ -2,6 +2,7 @@ module HpcUtils where
import Trace.Hpc.Util
import qualified Data.Map as Map
+import System.FilePath
dropWhileEndLE :: (a -> Bool) -> [a] -> [a]
-- Spec: dropWhileEndLE p = reverse . dropWhile p . reverse
@@ -30,6 +31,6 @@ readFileFromPath err filename path0 = readTheFile path0
readTheFile [] = err $ "could not find " ++ show filename
++ " in path " ++ show path0
readTheFile (dir:dirs) =
- catchIO (do str <- readFile (dir ++ "/" ++ filename)
+ catchIO (do str <- readFile (dir </> filename)
return str)
(\ _ -> readTheFile dirs)
diff --git a/utils/hpc/hpc-bin.cabal b/utils/hpc/hpc-bin.cabal
index 8ec6e5b790..0257fb99c7 100644
--- a/utils/hpc/hpc-bin.cabal
+++ b/utils/hpc/hpc-bin.cabal
@@ -43,6 +43,7 @@ Executable hpc
if flag(base3) || flag(base4)
Build-Depends: directory >= 1 && < 1.3,
+ filepath >= 1 && < 1.5,
containers >= 0.1 && < 0.6,
array >= 0.1 && < 0.6
Build-Depends: hpc