Skip to content

Commit

Permalink
Do not use ',' as a list separator for the cpp/cc/ld-options fields
Browse files Browse the repository at this point in the history
It breaks for some options like "ld-options: -Wl,-z,now"
No existing .cabal files on hackage were using ',' as a
list separator so this should not break anything.
  • Loading branch information
dcoutts committed Jul 29, 2008
1 parent 8a4b73c commit c1f3d40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Distribution/PackageDescription/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 14 additions & 2 deletions Distribution/ParseUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 ',')
Expand Down

0 comments on commit c1f3d40

Please sign in to comment.