Commit d043ef59 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Add replaceSeparators to Util.hs.

parent 212e91f1
module Util (
module Data.Char,
replaceIf, replaceEq,
replaceIf, replaceEq, replaceSeparators,
postProcessPackageData
) where
......@@ -13,6 +13,9 @@ replaceIf p to = map (\from -> if p from then to else from)
replaceEq :: Eq a => a -> a -> [a] -> [a]
replaceEq from = replaceIf (== from)
replaceSeparators :: String -> String
replaceSeparators = replaceIf isPathSeparator
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$'
-- 2) Replace '/' and '\' with '_' before '='
......@@ -21,6 +24,6 @@ postProcessPackageData file = do
pkgData <- (filter ('$' `notElem`) . lines) <$> liftIO (readFile file)
length pkgData `seq` writeFileLines file $ map processLine pkgData
where
processLine line = replaceIf isPathSeparator '_' prefix ++ suffix
processLine line = replaceSeparators '_' prefix ++ suffix
where
(prefix, suffix) = break (== '=') line
Supports Markdown
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