diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-03-17 18:09:18 +0100 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2015-03-17 18:17:27 +0100 |
commit | 801f4b98fa5198ab7e033949dd84aaae00162993 (patch) | |
tree | 4efda91a9cf063b614c47bd4cd8be44872f77469 /utils/hpc/HpcMarkup.hs | |
parent | 86eff3d92ffa3c9be29e037c01fd9b3fec8976e7 (diff) | |
download | haskell-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/HpcMarkup.hs')
-rw-r--r-- | utils/hpc/HpcMarkup.hs | 9 |
1 files changed, 5 insertions, 4 deletions
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, |