@@ -45,7 +45,19 @@ module Text.Regex.PCRE.Sequence(
4545 execPartial
4646 ) where
4747
48- import Prelude hiding (fail )
48+ import Prelude
49+ ( Bool (False )
50+ , Char
51+ , Either (Left ,Right ), either
52+ , IO , (>>) , (>>=) , return
53+ , Int , (-) , fromIntegral , pred
54+ , Maybe (Nothing ,Just )
55+ , Show (show )
56+ , String
57+ , ($) , (.) , seq , undefined
58+ , (==) , otherwise
59+ , (++) , length , map
60+ )
4961import Control.Monad.Fail (MonadFail (fail ))
5062
5163import Text.Regex.PCRE.Wrap -- all
@@ -54,12 +66,20 @@ import Data.Array(Array,listArray)
5466import System.IO.Unsafe (unsafePerformIO )
5567import Text.Regex.Base.RegexLike (RegexMaker (.. ),RegexLike (.. ),RegexContext (.. ),MatchLength ,MatchOffset ,Extract (.. ))
5668import Text.Regex.Base.Impl (polymatch ,polymatchM )
57- import Data.Sequence as S hiding (length )
69+ import Data.Sequence as S
70+ ( Seq ,
71+ empty ,
72+ singleton ,
73+ viewl ,
74+ viewr ,
75+ (|>) ,
76+ ViewL ((:<) , EmptyL ),
77+ ViewR ((:>) , EmptyR ) )
5878import qualified Data.Sequence as S (length )
59- import Foreign.C.String
60- import Foreign.Marshal.Array
61- import Foreign.Marshal.Alloc
62- import Foreign.Storable
79+ import Foreign.C.String ( castCharToCChar , CString , CStringLen )
80+ import Foreign.Marshal.Array ( advancePtr )
81+ import Foreign.Marshal.Alloc ( allocaBytes )
82+ import Foreign.Storable ( Storable ( poke ) )
6383
6484instance RegexContext Regex (Seq Char ) (Seq Char ) where
6585 match = polymatch
@@ -80,9 +100,9 @@ instance RegexLike Regex (Seq Char) where
80100 withSeq str (wrapTest 0 regex) >>= unwrap
81101 matchOnce regex str = unsafePerformIO $
82102 execute regex str >>= unwrap
83- matchAll regex str = unsafePerformIO $
103+ matchAll regex str = unsafePerformIO $
84104 withSeq str (wrapMatchAll regex) >>= unwrap
85- matchCount regex str = unsafePerformIO $
105+ matchCount regex str = unsafePerformIO $
86106 withSeq str (wrapCount regex) >>= unwrap
87107
88108-- | Compiles a regular expression
@@ -104,7 +124,7 @@ execute regex str = do
104124 case maybeStartEnd of
105125 Right Nothing -> return (Right Nothing )
106126-- Right (Just []) -> fail "got [] back!" -- should never happen
107- Right (Just parts) ->
127+ Right (Just parts) ->
108128 return . Right . Just . listArray (0 ,pred (length parts))
109129 . map (\ (s,e)-> (fromIntegral s, fromIntegral (e- s))) $ parts
110130 Left err -> return (Left err)
@@ -119,7 +139,7 @@ regexec regex str = do
119139 let getSub (start,stop) | start == unusedOffset = S. empty
120140 | otherwise = extract (start,stop- start) str
121141 matchedParts [] = (S. empty,S. empty,str,[] ) -- no information
122- matchedParts (matchedStartStop@ (start,stop): subStartStop) =
142+ matchedParts (matchedStartStop@ (start,stop): subStartStop) =
123143 (before start str
124144 ,getSub matchedStartStop
125145 ,after stop str
0 commit comments