regex-compat 0.95.2.0 → 0.95.2.1
raw patch · 3 files changed
+61/−27 lines, 3 filesdep ~basenew-uploader
Dependency ranges changed: base
Files
- ChangeLog.md +8/−1
- Text/Regex.hs +19/−19
- regex-compat.cabal +34/−7
ChangeLog.md view
@@ -1,6 +1,13 @@ See also http://pvp.haskell.org/faq +## 0.95.2.1++- Allow `base-4.15` (GHC 9.0)++- Workaround for `{-# LANGUAGE Haskell2010 #-}` parser regression introduced in GHC 9.0++- Optimization flag `-O2` has been removed+ ## 0.95.2.0 - Declare `Text.Regex` module `Trustworthy` under SafeHaskell-
Text/Regex.hs view
@@ -45,12 +45,12 @@ -- | Makes a regular expression, where the multi-line and -- case-sensitive options can be changed from the default settings. mkRegexWithOpts- :: String -- ^ The regular expression to compile- -> Bool -- ^ 'True' @\<=>@ @\'^\'@ and @\'$\'@ match the beginning and+ :: String -- ^ The regular expression to compile.+ -> Bool -- ^ 'True' iff @\'^\'@ and @\'$\'@ match the beginning and -- end of individual lines respectively, and @\'.\'@ does /not/ -- match the newline character.- -> Bool -- ^ 'True' @\<=>@ matching is case-sensitive- -> Regex -- ^ Returns: the compiled regular expression+ -> Bool -- ^ 'True' iff matching is case-sensitive.+ -> Regex -- ^ Returns: the compiled regular expression. mkRegexWithOpts s single_line case_sensitive = let opt = (if single_line then (compNewline .|.) else id) .@@ -58,10 +58,10 @@ compExtended in makeRegexOpts opt defaultExecOpt s --- | Match a regular expression against a string+-- | Match a regular expression against a string. matchRegex- :: Regex -- ^ The regular expression- -> String -- ^ The string to match against+ :: Regex -- ^ The regular expression.+ -> String -- ^ The string to match against. -> Maybe [String] -- ^ Returns: @'Just' strs@ if the match succeeded -- (and @strs@ is the list of subexpression matches), -- or 'Nothing' otherwise.@@ -70,8 +70,8 @@ -- | Match a regular expression against a string, returning more information -- about the match. matchRegexAll- :: Regex -- ^ The regular expression- -> String -- ^ The string to match against+ :: Regex -- ^ The regular expression.+ -> String -- ^ The string to match against. -> Maybe ( String, String, String, [String] ) -- ^ Returns: 'Nothing' if the match failed, or: --@@ -82,15 +82,15 @@ matchRegexAll p str = matchM p str -{- | Replaces every occurance of the given regexp with the replacement string.+{- | Replaces every occurrence of the given regexp with the replacement string. In the replacement string, @\"\\1\"@ refers to the first substring; @\"\\2\"@ to the second, etc; and @\"\\0\"@ to the entire match. @\"\\\\\\\\\"@ will insert a literal backslash. This does not advance if the regex matches an empty string. This-misfeature is here to match the behavior of the the original-Text.Regex API.+misfeature is here to match the behavior of the original+@Text.Regex@ API. -} subRegex :: Regex -- ^ Search pattern@@ -111,16 +111,16 @@ pre = take (off-i) str str' = drop (i'-i) str x = read xstr- in if null str' then \ m -> (pre++) . ((fst (m!x))++)- else \ m -> (pre++) . ((fst (m!x))++) . compile i' str' rest m+ in if null str' then \ m -> (pre ++) . (fst (m ! x) ++)+ else \ m -> (pre ++) . (fst (m ! x) ++) . compile i' str' rest m compiled :: MatchText String -> String -> String compiled = compile 0 repl findrefs where -- bre matches a backslash then capture either a backslash or some digits bre = mkRegex "\\\\(\\\\|[0-9]+)"- findrefs = map (\m -> (fst (m!1),snd (m!0))) (matchAllText bre repl)+ findrefs = map (\m -> (fst (m ! 1), snd (m ! 0))) (matchAllText bre repl) go _i str [] = str go i str (m:ms) =- let (_,(off,len)) = m!0+ let (_, (off, len)) = m ! 0 i' = off+len pre = take (off-i) str str' = drop (i'-i) str@@ -131,15 +131,15 @@ {- | Splits a string based on a regular expression. The regular expression should identify one delimiter. -This does not advance and produces an infinite list of [] if the regex+This does not advance and produces an infinite list of @[]@ if the regex matches an empty string. This misfeature is here to match the-behavior of the the original Text.Regex API.+behavior of the original @Text.Regex@ API. -} splitRegex :: Regex -> String -> [String] splitRegex _ [] = [] splitRegex delim strIn =- let matches = map (!0) (matchAll delim strIn)+ let matches = map (! 0) (matchAll delim strIn) go _i str [] = str : [] go i str ((off,len):rest) = let i' = off+len
regex-compat.cabal view
@@ -1,31 +1,58 @@ cabal-version: 1.12 name: regex-compat-version: 0.95.2.0+version: 0.95.2.1 -build-type: Simple+build-type: Simple license: BSD3 license-file: LICENSE copyright: Copyright (c) 2006, Christopher Kuklewicz author: Christopher Kuklewicz-maintainer: hvr@gnu.org+maintainer:+ Herbert Valerio Riedel <hvr@gnu.org>,+ Andreas Abel+homepage: https://wiki.haskell.org/Regular_expressions bug-reports: https://github.com/hvr/regex-compat/issues-synopsis: Replaces/Enhances "Text.Regex"+synopsis: Replaces/enhances "Text.Regex" category: Text description: One module compat layer over <//hackage.haskell.org/package/regex-posix regex-posix> to replace "Text.Regex". . See also <https://wiki.haskell.org/Regular_expressions> for more information. -extra-source-files: ChangeLog.md+extra-source-files:+ ChangeLog.md +tested-with:+ -- Haskell CI:+ GHC == 7.0.4+ GHC == 7.2.2+ GHC == 7.4.2+ GHC == 7.6.3+ GHC == 7.8.4+ GHC == 7.10.3+ GHC == 8.0.2+ GHC == 8.2.2+ GHC == 8.4.4+ GHC == 8.6.5+ GHC == 8.8.4+ GHC == 8.10.3+ -- manually (AA, 2021-02-17):+ -- GHC == 8.10.4+ -- GHC == 9.0.1+ source-repository head type: git location: https://github.com/hvr/regex-compat.git +source-repository this+ type: git+ location: https://github.com/hvr/regex-compat.git+ tag: v0.95.2.1+ library exposed-modules: Text.Regex - build-depends: base >= 4.3 && < 4.14+ build-depends: base >= 4.3 && < 4.16 , regex-base == 0.94.* , regex-posix == 0.96.* , array >= 0.3 && < 0.6@@ -36,4 +63,4 @@ if impl(ghc >= 7.2) default-extensions: Trustworthy - ghc-options: -Wall+ ghc-options: -Wall