packages feed

regex-compat 0.90 → 0.91

raw patch · 2 files changed

+66/−56 lines, 2 filesdep ~basedep ~regex-basedep ~regex-posix

Dependency ranges changed: base, regex-base, regex-posix

Files

Text/Regex.hs view
@@ -30,7 +30,7 @@   ) where  import Data.Bits((.|.))-import Text.Regex.Base(RegexMaker(makeRegexOpts),defaultExecOpt,RegexContext(matchM))+import Text.Regex.Base(RegexMaker(makeRegexOpts),defaultExecOpt,RegexLike(matchOnceText),RegexContext(matchM)) import Text.Regex.Posix(Regex,compNewline,compIgnoreCase,compExtended)  -- | Makes a regular expression with the default options (multi-line,@@ -87,7 +87,9 @@ @\"\\2\"@ to the second, etc; and @\"\\0\"@ to the entire match. @\"\\\\\\\\\"@ will insert a literal backslash. -This is unsafe if the regex matches an empty string.+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. -} subRegex :: Regex                          -- ^ Search pattern       -> String                         -- ^ Input string@@ -95,40 +97,42 @@       -> String                         -- ^ Output string subRegex _ "" _ = "" subRegex regexp inp repl =-    let bre = mkRegex "\\\\(\\\\|[0-9]+)"-        lookup _ [] _ = []-        lookup [] _ _ = []-        lookup match repl groups =-            case matchRegexAll bre repl of-                Nothing -> repl-                Just (lead, _, trail, bgroups) ->-                    let newval = if (head bgroups) == "\\"-                                 then "\\"-                                 else let index = (read (head bgroups)) - 1-                                          in-                                          if index == -1-                                             then match-                                             else groups !! index-                        in-                        lead ++ newval ++ lookup match trail groups-        in-        case matchRegexAll regexp inp of-            Nothing -> inp-            Just (lead, match, trail, groups) ->-              lead ++ lookup match repl groups ++ (subRegex regexp trail repl)+  let -- bre matches a backslash then capture either a backslash or some digits+      bre = mkRegex "\\\\(\\\\|[0-9]+)"+      lookup _ [] _ = []+      lookup [] _ _ = []+      lookup match repl groups =+        case matchRegexAll bre repl of+          Nothing -> repl+          Just (lead, _, trail, bgroups) ->+            let newval =+                 if (head bgroups) == "\\"+                   then "\\"+                   else let index :: Int+                            index = (read (head bgroups)) - 1+                        in if index == -1+                             then match+                             else groups !! index+            in lead ++ newval ++ lookup match trail groups+  in case matchRegexAll regexp inp of+       Nothing -> inp+       Just (lead, match, trail, groups) ->+         lead ++ lookup match repl groups ++ (subRegex regexp trail repl)  {- | Splits a string based on a regular expression.  The regular expression should identify one delimiter. -This is unsafe if the regex matches an empty string.+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. -}  splitRegex :: Regex -> String -> [String] splitRegex _ [] = []-splitRegex delim str =-    case matchRegexAll delim str of-       Nothing -> [str]-       Just (firstline, _, remainder, _) ->-           if remainder == ""-              then firstline : [] : []-              else firstline : splitRegex delim remainder+splitRegex delim strIn = loop strIn where+  loop str = case matchOnceText delim str of+                Nothing -> [str]+                Just (firstline, _, remainder) ->+                  if null remainder+                    then [firstline,""]+                    else firstline : loop remainder
regex-compat.cabal view
@@ -1,6 +1,6 @@ Name:                   regex-compat-Version:                0.90--- Cabal-Version:       >=1.1.4+Version:                0.91+Cabal-Version:          >=1.2 License:                BSD3 License-File:           LICENSE Copyright:              Copyright (c) 2006, Christopher Kuklewicz@@ -13,26 +13,32 @@ Description:            One module layer over regex-posix to replace Text.Regex Category:               Text Tested-With:            GHC-Build-Depends:          regex-base >= 0.80 , regex-posix, base >= 2.0--- Data-Files:--- Extra-Source-Files:--- Extra-Tmp-Files:-Exposed-Modules:        Text.Regex-Buildable:              True--- Other-Modules:--- HS-Source-Dirs:         "."-Extensions:             MultiParamTypeClasses, FunctionalDependencies-GHC-Options:            -Wall -Werror -O2--- GHC-Options:            -Wall -Werror--- GHC-Options:            -Wall -ddump-minimal-imports--- GHC-Prog-Options: --- Hugs-Options:--- NHC-Options:--- Includes:--- Include-Dirs:--- C-Sources:--- Extra-Libraries:--- Extra-Lib-Dirs:--- CC-Options:--- LD-Options:--- Frameworks:+flag splitBase+  description: Choose the new smaller, split-up base package.+library+  if flag(splitBase)+    Build-Depends:      base >= 3.0, regex-base >= 0.93, regex-posix >= 0.93+  else+    Build-Depends:      base < 3.0,  regex-base >= 0.93, regex-posix >= 0.93+  -- Data-Files:+  -- Extra-Source-Files:+  -- Extra-Tmp-Files:+  Exposed-Modules:        Text.Regex+  Buildable:              True+  -- Other-Modules:+  -- HS-Source-Dirs:         "."+  Extensions:             MultiParamTypeClasses, FunctionalDependencies+  GHC-Options:            -Wall -O2+  -- GHC-Options:            -Wall -Werror -O2+  -- GHC-Options:            -Wall -ddump-minimal-imports+  -- GHC-Prog-Options: +  -- Hugs-Options:+  -- NHC-Options:+  -- Includes:+  -- Include-Dirs:+  -- C-Sources:+  -- Extra-Libraries:+  -- Extra-Lib-Dirs:+  -- CC-Options:+  -- LD-Options:+  -- Frameworks: