[Pkg-haskell-commits] r1274 - in /packages/haskell-regex-compat/branches/upstream/0.92: Text/Regex.hs regex-compat.cabal
arjan at users.alioth.debian.org
arjan at users.alioth.debian.org
Sat Jan 17 14:49:05 UTC 2009
Author: arjan
Date: Sat Jan 17 14:49:05 2009
New Revision: 1274
URL: http://svn.debian.org/wsvn/pkg-haskell/?sc=1&rev=1274
Log: (empty)
Modified:
packages/haskell-regex-compat/branches/upstream/0.92/Text/Regex.hs
packages/haskell-regex-compat/branches/upstream/0.92/regex-compat.cabal
Modified: packages/haskell-regex-compat/branches/upstream/0.92/Text/Regex.hs
URL: http://svn.debian.org/wsvn/pkg-haskell/packages/haskell-regex-compat/branches/upstream/0.92/Text/Regex.hs?rev=1274&op=diff
==============================================================================
--- packages/haskell-regex-compat/branches/upstream/0.92/Text/Regex.hs (original)
+++ packages/haskell-regex-compat/branches/upstream/0.92/Text/Regex.hs Sat Jan 17 14:49:05 2009
@@ -29,9 +29,8 @@
splitRegex
) where
-import Data.Array((!))
import Data.Bits((.|.))
-import Text.Regex.Base(RegexMaker(makeRegexOpts),defaultExecOpt,RegexLike(matchAll,matchAllText),RegexContext(matchM),MatchText)
+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,
@@ -92,70 +91,6 @@
misfeature is here to match the behavior of the the original
Text.Regex API.
-}
-
-subRegex :: Regex -- ^ Search pattern
- -> String -- ^ Input string
- -> String -- ^ Replacement text
- -> String -- ^ Output string
-subRegex _ "" _ = ""
-subRegex regexp inp repl =
- let compile _i str [] = \ _m -> (str++)
- compile i str (("\\",(off,len)):rest) =
- let i' = off+len
- pre = take (off-i) str
- str' = drop (i'-i) str
- in if null str' then \ _m -> (pre ++) . ('\\':)
- else \ m -> (pre ++) . ('\\' :) . compile i' str' rest m
- compile i str ((xstr,(off,len)):rest) =
- let i' = off+len
- 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
- 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)
- go _i str [] = str
- go i str (m:ms) =
- let (_,(off,len)) = m!0
- i' = off+len
- pre = take (off-i) str
- str' = drop (i'-i) str
- in if null str' then pre ++ (compiled m "")
- else pre ++ (compiled m (go i' str' ms))
- in go 0 inp (matchAllText regexp inp)
-
-{- | 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
-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 strIn =
- let matches = map (!0) (matchAll delim strIn)
- go _i str [] = str : []
- go i str ((off,len):rest) =
- let i' = off+len
- firstline = take (off-i) str
- remainder = drop (i'-i) str
- in seq i' $
- if null remainder then [firstline,""]
- else firstline : go i' remainder rest
- in go 0 strIn matches
-
-{-
-
--- These are the older versions which failed on (correct answer:)
--- let r = mkRegex "^(.)" in subRegex2 r "abc\ndef" "|\\1"
--- "|abc\n|def"
-
subRegex :: Regex -- ^ Search pattern
-> String -- ^ Input string
-> String -- ^ Replacement text
@@ -184,6 +119,14 @@
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 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 strIn = loop strIn where
@@ -193,5 +136,3 @@
if null remainder
then [firstline,""]
else firstline : loop remainder
-
--}
Modified: packages/haskell-regex-compat/branches/upstream/0.92/regex-compat.cabal
URL: http://svn.debian.org/wsvn/pkg-haskell/packages/haskell-regex-compat/branches/upstream/0.92/regex-compat.cabal?rev=1274&op=diff
==============================================================================
--- packages/haskell-regex-compat/branches/upstream/0.92/regex-compat.cabal (original)
+++ packages/haskell-regex-compat/branches/upstream/0.92/regex-compat.cabal Sat Jan 17 14:49:05 2009
@@ -1,7 +1,6 @@
Name: regex-compat
-Version: 0.92
+Version: 0.91
Cabal-Version: >=1.2
-build-type: Simple
License: BSD3
License-File: LICENSE
Copyright: Copyright (c) 2006, Christopher Kuklewicz
@@ -18,7 +17,7 @@
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, array
+ 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:
More information about the Pkg-haskell-commits
mailing list