packages feed

regex-pcre 0.92 → 0.93

raw patch · 5 files changed

+27/−16 lines, 5 filessetup-changed

Files

Setup.hs view
@@ -6,6 +6,6 @@ main = do putStrLn msg           defaultMain -msg = "regex-pcre needs to compile against the libpcre libary from http://www.pcre.org/\n\+msg = "\nregex-pcre needs to compile against the libpcre libary from http://www.pcre.org/\n\       \You might also need to edit the end of the regex-pcre.cabal file to point at\n\       \the directories where libpcre 'include' and 'lib' have been installed.\n"
Text/Regex/PCRE.hs view
@@ -65,6 +65,6 @@  getVersion_Text_Regex_PCRE :: Version getVersion_Text_Regex_PCRE =-  Version { versionBranch = [0,92]+  Version { versionBranch = [0,93]           , versionTags = ["unstable"]           }
Text/Regex/PCRE/ByteString.hs view
@@ -48,12 +48,13 @@ import Text.Regex.PCRE.Wrap -- all import Data.Array(Array,listArray) import Data.ByteString(ByteString)-import qualified Data.ByteString as B(empty,useAsCString,last,take,drop,null)+import qualified Data.ByteString as B(empty,useAsCString,last,take,drop,null,pack) import qualified Data.ByteString.Base as B(unsafeUseAsCString,unsafeUseAsCStringLen) import System.IO.Unsafe(unsafePerformIO) import Text.Regex.Base.RegexLike(RegexContext(..),RegexMaker(..),RegexLike(..),MatchOffset,MatchLength) import Text.Regex.Base.Impl(polymatch,polymatchM) import Foreign.C.String(CStringLen)+import Foreign(nullPtr)  instance RegexContext Regex ByteString ByteString where   match = polymatch@@ -63,8 +64,13 @@ unwrap x = case x of Left err -> fail ("Text.Regex.PCRE.ByteString died: "++ show err)                      Right v -> return v +{-# INLINE asCStringLen #-} asCStringLen :: ByteString -> (CStringLen -> IO a) -> IO a-asCStringLen = B.unsafeUseAsCStringLen+asCStringLen s op = B.unsafeUseAsCStringLen s checked+  where checked cs@(ptr,_) | ptr == nullPtr = B.unsafeUseAsCStringLen myEmpty (op . trim)+                           | otherwise = op cs+        myEmpty = B.pack [0]+        trim (ptr,_) = (ptr,0)  instance RegexMaker Regex CompOption ExecOption ByteString where   makeRegexOpts c e pattern = unsafePerformIO $@@ -77,9 +83,9 @@     asCStringLen bs (wrapTest 0 regex) >>= unwrap   matchOnce regex bs = unsafePerformIO $     execute regex bs >>= unwrap-  matchAll regex bs = unsafePerformIO $ +  matchAll regex bs = unsafePerformIO $     asCStringLen bs (wrapMatchAll regex) >>= unwrap-  matchCount regex bs = unsafePerformIO $ +  matchCount regex bs = unsafePerformIO $     asCStringLen bs (wrapCount regex) >>= unwrap  -- ---------------------------------------------------------------------@@ -111,7 +117,7 @@   maybeStartEnd <- asCStringLen bs (wrapMatch 0 regex)   case maybeStartEnd of     Right Nothing -> return (Right Nothing)-    Right (Just parts) -> +    Right (Just parts) ->       return . Right . Just . listArray (0,pred (length parts))       . map (\(s,e)->(fromIntegral s, fromIntegral (e-s))) $ parts     Left err -> return (Left err)@@ -123,7 +129,7 @@   let getSub (start,stop) | start == unusedOffset = B.empty                           | otherwise = B.take (stop-start) . B.drop start $ bs       matchedParts [] = (B.empty,B.empty,bs,[]) -- no information-      matchedParts (matchedStartStop@(start,stop):subStartStop) = +      matchedParts (matchedStartStop@(start,stop):subStartStop) =         (B.take start bs         ,getSub matchedStartStop         ,B.drop stop bs
Text/Regex/PCRE/ByteString/Lazy.hs view
@@ -48,13 +48,14 @@ import Text.Regex.PCRE.Wrap -- all import Data.Array(Array) import qualified Data.ByteString.Lazy as L(ByteString,toChunks,fromChunks,last,null,snoc)-import qualified Data.ByteString as B(ByteString,concat)+import qualified Data.ByteString as B(ByteString,concat,pack) import qualified Data.ByteString.Base as B(unsafeUseAsCString,unsafeUseAsCStringLen) import System.IO.Unsafe(unsafePerformIO) import Text.Regex.Base.RegexLike(RegexContext(..),RegexMaker(..),RegexLike(..),MatchOffset,MatchLength) import Text.Regex.Base.Impl(polymatch,polymatchM) import qualified Text.Regex.PCRE.ByteString as BS(execute,regexec) import Foreign.C.String(CString,CStringLen)+import Foreign(nullPtr)  instance RegexContext Regex L.ByteString L.ByteString where   match = polymatch@@ -80,7 +81,11 @@  {-# INLINE asCStringLen #-} asCStringLen :: L.ByteString -> (CStringLen -> IO a) -> IO a-asCStringLen s = B.unsafeUseAsCStringLen (fromLazy s)+asCStringLen ls op = B.unsafeUseAsCStringLen (fromLazy ls) checked+  where checked cs@(ptr,_) | ptr == nullPtr = B.unsafeUseAsCStringLen myEmpty (op . trim)+                           | otherwise = op cs+        myEmpty = B.pack [0]+        trim (ptr,_) = (ptr,0)  instance RegexMaker Regex CompOption ExecOption L.ByteString where   makeRegexOpts c e pattern = unsafePerformIO $@@ -93,9 +98,9 @@     asCStringLen bs (wrapTest 0 regex) >>= unwrap   matchOnce regex bs = unsafePerformIO $     execute regex bs >>= unwrap-  matchAll regex bs = unsafePerformIO $ +  matchAll regex bs = unsafePerformIO $     asCStringLen bs (wrapMatchAll regex) >>= unwrap-  matchCount regex bs = unsafePerformIO $ +  matchCount regex bs = unsafePerformIO $     asCStringLen bs (wrapCount regex) >>= unwrap  -- ---------------------------------------------------------------------
regex-pcre.cabal view
@@ -1,5 +1,5 @@ Name:                   regex-pcre-Version:                0.92+Version:                0.93 -- Cabal-Version:       >=1.1.4 License:                BSD3 License-File:           LICENSE@@ -30,7 +30,7 @@ -- GHC-Options:            -Wall -Werror GHC-Options:            -Wall -Werror -O2 -- GHC-Options:            -Wall -ddump-minimal-imports--- GHC-Prof-Options: +-- GHC-Prof-Options: -- Hugs-Options: -- NHC-Options: -- C-Sources:@@ -39,5 +39,5 @@ -- Frameworks: CC-Options:             -DHAVE_PCRE_H Extra-Libraries:        pcre--- Include-Dirs:           /opt/local/include--- Extra-Lib-Dirs:         /opt/local/lib+--Include-Dirs:           /opt/local/include+--Extra-Lib-Dirs:         /opt/local/lib