module GiveYouAHead.Build.ExtraCompileOption where
import GiveYouAHead.Common
getOptions :: String
-> String
-> String
-> [String] --fileText
-> String
getOptionsFromFile :: String
-> String
-> String
-> FilePath --fileText
-> IO String
delNoteMark :: String
-> String
-> String
getOptBegin :: String
-> [String]
-> [String]
getOptEnd :: String
-> [String]
-> [String]
getOptionsFromFile nM oB oE fn = do
fSrc <- readF fn
let rt = getOptions nM oB oE $ lines fSrc
return rt
getOptBegin oB inStr = rt
where
rt' = dropWhile (/=oB) inStr
(_:rt) = case length rt' of
0 -> ["", ""]
1 -> ["",""]
_ -> rt'
getOptEnd oE inStr = rt
where
rt = takeWhile (/=oE) inStr
getOptions nM oB oE inStr = delNoteMark nM $ concat items
where
makeItems = getOptEnd (nM ++ oE) . getOptBegin (nM ++ oB)
items = makeItems inStr
delNoteMark [] str = str
delNoteMark _ [] = []
delNoteMark (n:nM) (s:str)
| n == s = delNoteMark nM str
| otherwise = s:str