packages feed

pcre-heavy 1.0.0.1 → 1.0.0.2

raw patch · 2 files changed

+16/−6 lines, 2 files

Files

library/Text/Regex/PCRE/Heavy.hs view
@@ -1,7 +1,10 @@ {-# OPTIONS_GHC -fno-warn-orphans -fno-warn-unused-binds #-} {-# LANGUAGE NoImplicitPrelude, UndecidableInstances, FlexibleInstances, FlexibleContexts, BangPatterns #-} {-# LANGUAGE TemplateHaskell, QuasiQuotes, UnicodeSyntax #-}-{-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE ForeignFunctionInterface, CPP #-}+#if __GLASGOW_HASKELL__ < 710+{-# LANGUAGE OverlappingInstances #-}+#endif  -- | A usable regular expressions library on top of pcre-light. module Text.Regex.PCRE.Heavy (@@ -70,7 +73,7 @@ (≈) = (=~)  -- | Does raw PCRE matching (you probably shouldn't use this directly).--- +-- -- >>> :set -XOverloadedStrings -- >>> rawMatch [re|\w{2}|] "a a ab abc ba" 0 [] -- Just [(4,6)]@@ -202,6 +205,9 @@ -- -- >>> gsub [re|bad|] "xxxbad" "this is bad, right? bad" :: String -- "this is xxxbad, right? xxxbad"+--+-- >>> gsub [re|a|] "" "aaa" :: String+-- "" gsub ∷ (ConvertibleStrings SBS a, ConvertibleStrings a SBS, RegexReplacement r) ⇒ Regex → r → a → a gsub r t s = gsubO r [] t s @@ -209,11 +215,15 @@ gsubO ∷ (ConvertibleStrings SBS a, ConvertibleStrings a SBS, RegexReplacement r) ⇒ Regex → [PCREExecOption] → r → a → a gsubO r opts t s = cs $ loop 0 str   where str = toSBS s-        loop offset acc =-          case rawSub r t acc offset opts of+        loop offset acc+          | offset >= l = acc+          | otherwise = case rawSub r t acc offset opts of             Just (result, newOffset) →-              if newOffset == offset then acc else loop newOffset result+              if newOffset == offset && l == BS.length result+              then acc+              else loop newOffset result             _ → acc+          where l = BS.length acc  -- | Splits the string using the given regex. --
pcre-heavy.cabal view
@@ -1,5 +1,5 @@ name:            pcre-heavy-version:         1.0.0.1+version:         1.0.0.2 synopsis:        A regexp library on top of pcre-light you can actually use. description:     A regular expressions library that does not suck.