diff --git a/Distribution/PackageDescription/Parse.hs b/Distribution/PackageDescription/Parse.hs index 21f9cd222b4..97705f0953c 100644 --- a/Distribution/PackageDescription/Parse.hs +++ b/Distribution/PackageDescription/Parse.hs @@ -213,13 +213,13 @@ binfoFieldDescrs = , commaListField "build-tools" disp parseBuildTool buildTools (\xs binfo -> binfo{buildTools=xs}) - , listField "cpp-options" + , spaceListField "cpp-options" showToken parseTokenQ cppOptions (\val binfo -> binfo{cppOptions=val}) - , listField "cc-options" + , spaceListField "cc-options" showToken parseTokenQ ccOptions (\val binfo -> binfo{ccOptions=val}) - , listField "ld-options" + , spaceListField "ld-options" showToken parseTokenQ ldOptions (\val binfo -> binfo{ldOptions=val}) , commaListField "pkgconfig-depends" diff --git a/Distribution/ParseUtils.hs b/Distribution/ParseUtils.hs index 3f7f04a55d8..b58319f9d4a 100644 --- a/Distribution/ParseUtils.hs +++ b/Distribution/ParseUtils.hs @@ -59,8 +59,8 @@ module Distribution.ParseUtils ( parseTestedWithQ, parseLicenseQ, parseExtensionQ, parseSepList, parseCommaList, parseOptCommaList, showFilePath, showToken, showTestedWith, showFreeText, - field, simpleField, listField, commaListField, optsField, liftField, - boolField, parseQuoted, + field, simpleField, listField, spaceListField, commaListField, + optsField, liftField, boolField, parseQuoted, UnrecFieldParser, warnUnrec, ignoreUnrec, ) where @@ -204,6 +204,14 @@ commaListField name showF readF get set = where set' xs b = set (get b ++ xs) b +spaceListField :: String -> (a -> Doc) -> (ReadP [a] a) + -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b +spaceListField name showF readF get set = + liftField get set' $ + field name (fsep . map showF) (parseSpaceList readF) + where + set' xs b = set (get b ++ xs) b + listField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b listField name showF readF get set = @@ -605,6 +613,10 @@ parseSepList :: ReadP r b parseSepList sepr p = sepBy p separator where separator = skipSpaces >> sepr >> skipSpaces +parseSpaceList :: ReadP r a -- ^The parser for the stuff between commas + -> ReadP r [a] +parseSpaceList p = sepBy p skipSpaces + parseCommaList :: ReadP r a -- ^The parser for the stuff between commas -> ReadP r [a] parseCommaList = parseSepList (ReadP.char ',')