pcre-light 0.3.1.1 → 0.4
raw patch · 3 files changed
+18/−10 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.Regex.PCRE.Light: captureCount :: Regex -> Int
Files
- Text/Regex/PCRE/Light.hs +12/−7
- pcre-light.cabal +1/−1
- tests/Unit.hs +5/−2
Text/Regex/PCRE/Light.hs view
@@ -23,6 +23,7 @@ -- * ByteString interface , compile, compileM , match+ , captureCount -- * Regex types and constructors externally visible @@ -264,7 +265,7 @@ match :: Regex -> S.ByteString -> [PCREExecOption] -> Maybe [S.ByteString] match (Regex pcre_fp _) subject os = unsafePerformIO $ do withForeignPtr pcre_fp $ \pcre_ptr -> do- n_capt <- capturedCount pcre_ptr+ n_capt <- captureCount' pcre_ptr -- The smallest size for ovector that will allow for n captured -- substrings, in addition to the offsets of the substring@@ -321,9 +322,13 @@ start = S.unsafeDrop (fromIntegral a) s end = S.unsafeTake (fromIntegral (b-a)) start - -- use pcre_info to work out how many substrings to reserve space for- capturedCount :: Ptr PCRE -> IO Int- capturedCount regex_ptr =- alloca $ \n_ptr -> do -- (st :: Ptr CInt)- c_pcre_fullinfo regex_ptr nullPtr info_capturecount n_ptr- return . fromIntegral =<< peek (n_ptr :: Ptr CInt)++captureCount :: Regex -> Int+captureCount (Regex pcre_fp _) = unsafePerformIO $ do+ withForeignPtr pcre_fp $ \pcre_ptr -> do+ captureCount' pcre_ptr++captureCount' pcre_fp =+ alloca $ \n_ptr -> do -- (st :: Ptr CInt)+ c_pcre_fullinfo pcre_fp nullPtr info_capturecount n_ptr+ return . fromIntegral =<< peek (n_ptr :: Ptr CInt)
pcre-light.cabal view
@@ -1,5 +1,5 @@ name: pcre-light-version: 0.3.1.1+version: 0.4 homepage: http://code.haskell.org/~dons/code/pcre-light synopsis: A small, efficient and portable regex library for Perl 5 compatible regular expressions description:
tests/Unit.hs view
@@ -15,7 +15,7 @@ import qualified Data.Map as M import System.IO.Unsafe-import Control.Exception+import Control.OldException import Control.Monad.Error assertBool' s = assertBool (S.unpack s)@@ -1530,6 +1530,7 @@ Nothing, Nothing] +{- , testRegex "^(a\\1?){4}$" [] ["a", "aa",@@ -1561,6 +1562,7 @@ Nothing, Nothing, Nothing]+-} , testRegex "abc" [] ["abc",@@ -3588,7 +3590,7 @@ [Just ["b", "b"]] , -+{- testRegex "(?(1)a|b)" [] [] []@@ -3600,6 +3602,7 @@ [Just ["a"]] , +-} testRegex "(x)?(?(1)a|b)" [] ["*** Failers",