Changeset 2948
- Timestamp:
- 05/10/05 22:25:13 (4 years ago)
- svk:copy_cache_prev:
- 4498
- Files:
-
- 1 modified
-
src/Pugs/Prim/Match.hs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Prim/Match.hs
r2944 r2948 27 27 return (name, rxRule rule) 28 28 pge <- liftIO $ evalPGE pwd (encodeUTF8 cs) (encodeUTF8 re) subrules 29 rv <- tryIO Nothing $ fmap Just (readIO $ decodeUTF8 pge) 29 rv <- tryIO Nothing $ fmap Just (readIO $ decodeUTF8 pge) 30 30 let matchToVal PGE_Fail = VMatch mkMatchFail 31 31 matchToVal (PGE_Array ms) = VList (map matchToVal ms) … … 43 43 44 44 doMatch cs MkRulePCRE{ rxRegex = re } = do 45 rv <- liftIO $ PCRE.execute re (encodeUTF8 cs)045 rv <- liftIO $ PCRE.execute re csUTF8 0 46 46 if isNothing rv then return mkMatchFail else do 47 let ((from , len):subs) = Array.elems (fromJust rv)48 substr from len = genericTake len (genericDrop from cs) 47 let ((fromBytes, lenBytes):subs) = Array.elems (fromJust rv) 48 substr from len = genericTake len (genericDrop from cs) -- in bytes 49 49 subsMatch = [ VMatch $ mkMatchOk f (f + t) (substr f t) [] Map.empty | (f, t) <- subs ] 50 return $ mkMatchOk from (from + len) (substr from len) subsMatch Map.empty 50 51 leftmatch = decodeUTF8 $ genericTake fromBytes csUTF8 52 fromChars = genericLength leftmatch 53 lenChars = genericLength $ decodeUTF8 $ (substr fromBytes lenBytes) 54 55 return $ mkMatchOk fromChars (fromChars + lenChars) (substr fromBytes lenBytes) subsMatch Map.empty 56 where 57 csUTF8 = encodeUTF8 cs 51 58 52 59 matchFromMR mr = VMatch $ mkMatchOk 0 0 (decodeUTF8 all) subsMatch Map.empty … … 131 138 rxSplit _ [] = return [] 132 139 rxSplit rx str = do 133 match <- str `doMatch` rx 140 match <- str `doMatch` rx 134 141 if not (matchOk match) then return [str] else do 135 142 if matchFrom match == matchTo match
