Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand elem #6556

Merged
merged 1 commit into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Cabal/Distribution/Types/PkgconfigName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ instance Pretty PkgconfigName where
pretty = Disp.text . unPkgconfigName

instance Parsec PkgconfigName where
parsec = mkPkgconfigName <$> P.munch1 (\c -> isAlphaNum c || c `elem` "+-._")
parsec = mkPkgconfigName <$> P.munch1 isNameChar where
-- https://gitlab.haskell.org/ghc/ghc/issues/17752
isNameChar '-' = True
isNameChar '_' = True
isNameChar '.' = True
isNameChar '+' = True
isNameChar c = isAlphaNum c

instance NFData PkgconfigName where
rnf (PkgconfigName pkg) = rnf pkg
10 changes: 9 additions & 1 deletion Cabal/Distribution/Types/PkgconfigVersionRange.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pkgconfigParser = P.spaces >> expr where
factor = parens expr <|> prim

prim = do
op <- P.munch1 (`elem` "<>=^-") P.<?> "operator"
op <- P.munch1 isOpChar P.<?> "operator"
case op of
"-" -> anyPkgconfigVersion <$ (P.string "any" *> P.spaces)

Expand All @@ -98,6 +98,14 @@ pkgconfigParser = P.spaces >> expr where

_ -> P.unexpected $ "Unknown version operator " ++ show op

-- https://gitlab.haskell.org/ghc/ghc/issues/17752
isOpChar '<' = True
isOpChar '=' = True
isOpChar '>' = True
isOpChar '^' = True
isOpChar '-' = True
isOpChar _ = False

afterOp f = do
P.spaces
v <- parsec
Expand Down
8 changes: 7 additions & 1 deletion Cabal/Distribution/Types/UnitId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ instance Pretty UnitId where
-- GHC accepts for @-package-id@.
--
instance Parsec UnitId where
parsec = mkUnitId <$> P.munch1 (\c -> isAlphaNum c || c `elem` "-_.+")
parsec = mkUnitId <$> P.munch1 isUnitChar where
-- https://gitlab.haskell.org/ghc/ghc/issues/17752
isUnitChar '-' = True
isUnitChar '_' = True
isUnitChar '.' = True
isUnitChar '+' = True
isUnitChar c = isAlphaNum c

-- | If you need backwards compatibility, consider using 'display'
-- instead, which is supported by all versions of Cabal.
Expand Down
10 changes: 9 additions & 1 deletion Cabal/Distribution/Types/VersionRange/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ versionRangeParser digitParser = expr
factor = parens expr <|> prim

prim = do
op <- P.munch1 (`elem` "<>=^-") P.<?> "operator"
op <- P.munch1 isOpChar P.<?> "operator"
case op of
"-" -> anyVersion <$ P.string "any" <|> P.string "none" *> noVersion'

Expand Down Expand Up @@ -325,6 +325,14 @@ versionRangeParser digitParser = expr
">" -> pure $ laterVersion v
_ -> fail $ "Unknown version operator " ++ show op

-- https://gitlab.haskell.org/ghc/ghc/issues/17752
isOpChar '<' = True
isOpChar '=' = True
isOpChar '>' = True
isOpChar '^' = True
isOpChar '-' = True
isOpChar _ = False

-- Note: There are other features:
-- && and || since 1.8
-- x.y.* (wildcard) since 1.6
Expand Down