Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
See also http://pvp.haskell.org/faq
For versioning policy, see: http://pvp.haskell.org/faq

## 0.96.0.0 Revision 2
## 0.96.0.1 (2021-07-19)

- Compatibility with `base-4.16` (GHC 9.2)
- Fix stack installation problems on Windows around flag `_regex-posix-clib`
(issues
[#4](https://github.com/haskell-hvr/regex-posix/issues/4) and
[#7](https://github.com/haskell-hvr/regex-posix/issues/7)).

## 0.96.0.0 Revision 2 (2021-02-20)

- Compatibility with `base-4.15` (GHC 9.0)

## 0.96.0.0 Revision 1
## 0.96.0.0 Revision 1 (2020-03-25)

- Compatibility with `base-4.14` (GHC 8.10)

## 0.96.0.0
## 0.96.0.0 (2019-09-30)

- Update to `regex-base-0.94.0.0` API
- Compatibility with `base-4.13.0`
- Remove internal regex C implementation

----
34 changes: 19 additions & 15 deletions regex-posix.cabal
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
cabal-version: 1.12
name: regex-posix
version: 0.96.0.0
x-revision: 2
version: 0.96.0.1

build-type: Simple
license: BSD3
license-file: LICENSE
copyright: Copyright (c) 2007-2010, Christopher Kuklewicz
author: Christopher Kuklewicz
maintainer: hvr@gnu.org
maintainer: hvr@gnu.org, Andreas Abel
bug-reports: https://github.com/hvr/regex-posix
synopsis: POSIX Backend for "Text.Regex" (regex-base)
category: Text
Expand Down Expand Up @@ -46,12 +45,12 @@ source-repository head
source-repository this
type: git
location: https://github.com/hvr/regex-base.git
tag: v0.96.0.0-r2
tag: v0.96.0.1

flag _regex-posix-clib
manual: False
default: False
description: Use <//hackage.haskell.org/package/regex-posix-clib regex-posix-clib> package
description: Use <//hackage.haskell.org/package/regex-posix-clib regex-posix-clib> package (used by default on Windows)

library
hs-source-dirs: src
Expand All @@ -69,13 +68,10 @@ library
c-sources: cbits/myfree.c
include-dirs: cbits

if flag(_regex-posix-clib)
if flag(_regex-posix-clib) || os(windows)
build-depends: regex-posix-clib == 2.7.*
else
-- use POSIX.2 regex implementation from @libc@
-- However, Windows/msys2 doesn't provide a POSIX.2 regex impl in its @libc@
if os(windows)
build-depends: base<0
-- Otherwise, use POSIX.2 regex implementation from @libc@.
-- However, Windows/msys2 doesn't provide a POSIX.2 regex impl in its @libc@.

default-language: Haskell2010
default-extensions:
Expand All @@ -85,16 +81,24 @@ library
GeneralizedNewtypeDeriving
FlexibleContexts
TypeSynonymInstances
-- ^ for ghc 7.0, subsumed under FlexibleInstances later
FlexibleInstances

build-depends: regex-base == 0.94.*
, base >= 4.3 && < 4.16
, base >= 4.3 && < 4.17
, containers >= 0.4 && < 0.7
, bytestring >= 0.9 && < 0.12
, array >= 0.3 && < 0.6

if !impl(ghc >= 8)
if impl(ghc < 8)
build-depends: fail == 4.9.*

ghc-options: -O2
-Wall -fno-warn-unused-imports
-- Warnings

ghc-options:
-Wall
-fno-warn-unused-imports

if impl(ghc >= 8)
ghc-options:
-Wcompat
6 changes: 3 additions & 3 deletions src/Text/Regex/Posix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
--
-- Module : Text.Regex.Posix
-- Copyright : (c) Chris Kuklewicz 2006
-- SPDX-License-Identifier: BSD-3-Clause
-- License : BSD-3-Clause
--
-- Maintainer : hvr@gnu.org
-- Stability : experimental
-- Maintainer : hvr@gnu.org, Andreas Abel
-- Stability : stable
-- Portability : non-portable (regex-base needs MPTC+FD)
--
-- Module that provides the Regex backend that wraps the
Expand Down
14 changes: 7 additions & 7 deletions src/Text/Regex/Posix/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
-- |
-- Module : Text.Regex.Posix.ByteString
-- Copyright : (c) Chris Kuklewicz 2006
-- SPDX-License-Identifier: BSD-3-Clause
--
-- Maintainer : hvr@gnu.org
-- Stability : experimental
-- License : BSD-3-Clause
--
-- Maintainer : hvr@gnu.org, Andreas Abel
-- Stability : stable
-- Portability : non-portable (regex-base needs MPTC+FD)
--
-- This provides 'ByteString' instances for RegexMaker and RegexLike
Expand Down Expand Up @@ -81,7 +81,7 @@ instance RegexMaker Regex CompOption ExecOption ByteString where
instance RegexLike Regex ByteString where
matchTest regex bs = unsafePerformIO $
asCString bs (wrapTest regex) >>= unwrap
matchOnce regex bs = unsafePerformIO $
matchOnce regex bs = unsafePerformIO $
execute regex bs >>= unwrap
matchAll regex bs = unsafePerformIO $
asCString bs (wrapMatchAll regex) >>= unwrap
Expand Down Expand Up @@ -115,7 +115,7 @@ execute regex bs = do
case maybeStartEnd of
Right Nothing -> return (Right Nothing)
-- Right (Just []) -> ...
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)
Expand All @@ -127,7 +127,7 @@ regexec regex bs = do
let getSub (start,stop) | start == unusedRegOffset = B.empty
| otherwise = B.take (fi (stop-start)) . B.drop (fi start) $ bs
matchedParts [] = (B.empty,B.empty,bs,[]) -- no information
matchedParts (matchedStartStop@(start,stop):subStartStop) =
matchedParts (matchedStartStop@(start,stop):subStartStop) =
(B.take (fi start) bs
,getSub matchedStartStop
,B.drop (fi stop) bs
Expand Down
10 changes: 5 additions & 5 deletions src/Text/Regex/Posix/ByteString/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
-- |
-- Module : Text.Regex.Posix.ByteString.Lazy
-- Copyright : (c) Chris Kuklewicz 2007
-- SPDX-License-Identifier: BSD-3-Clause
--
-- Maintainer : hvr@gnu.org
-- Stability : experimental
-- License : BSD-3-Clause
--
-- Maintainer : hvr@gnu.org, Andreas Abel
-- Stability : stable
-- Portability : non-portable (regex-base needs MPTC+FD)
--
-- This provides 'ByteString.Lazy' instances for RegexMaker and RegexLike
Expand Down Expand Up @@ -93,7 +93,7 @@ instance RegexMaker Regex CompOption ExecOption L.ByteString where
instance RegexLike Regex L.ByteString where
matchTest regex bs = unsafePerformIO $
asCString bs (wrapTest regex) >>= unwrap
matchOnce regex bs = unsafePerformIO $
matchOnce regex bs = unsafePerformIO $
execute regex bs >>= unwrap
matchAll regex bs = unsafePerformIO $
asCString bs (wrapMatchAll regex) >>= unwrap
Expand Down
32 changes: 16 additions & 16 deletions src/Text/Regex/Posix/Sequence.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
-- |
-- Module : Text.Regex.Posix.Sequence
-- Copyright : (c) Chris Kuklewicz 2006
-- SPDX-License-Identifier: BSD-3-Clause
--
-- Maintainer : hvr@gnu.org
-- Stability : experimental
-- License : BSD-3-Clause
--
-- Maintainer : hvr@gnu.org, Andreas Abel
-- Stability : stable
-- Portability : non-portable (regex-base needs MPTC+FD)
--
-- This provides 'String' instances for 'RegexMaker' and 'RegexLike' based
Expand Down Expand Up @@ -77,23 +77,23 @@ unwrap x = case x of Left err -> fail ("Text.Regex.Posix.Sequence died: "++ show
instance RegexMaker Regex CompOption ExecOption (Seq Char) where
makeRegexOpts c e pattern = unsafePerformIO $
(compile c e pattern >>= unwrap)
makeRegexOptsM c e pattern = either (fail.show) return $ unsafePerformIO $
makeRegexOptsM c e pattern = either (fail.show) return $ unsafePerformIO $
(compile c e pattern)

instance RegexLike Regex (Seq Char) where
matchTest regex str = unsafePerformIO $ do
withSeq str (wrapTest regex) >>= unwrap
matchOnce regex str = unsafePerformIO $
matchOnce regex str = unsafePerformIO $
execute regex str >>= unwrap
matchAll regex str = unsafePerformIO $
matchAll regex str = unsafePerformIO $
withSeq str (wrapMatchAll regex) >>= unwrap
matchCount regex str = unsafePerformIO $
withSeq str (wrapCount regex) >>= unwrap

-- compile
compile :: CompOption -- ^ Flags (summed together)
-> ExecOption -- ^ Flags (summed together)
-> (Seq Char) -- ^ The regular expression to compile (ASCII only, no null bytes)
-> Seq Char -- ^ The regular expression to compile (ASCII only, no null bytes)
-> IO (Either WrapError Regex) -- ^ Returns: the compiled regular expression
compile flags e pattern = withSeq pattern (wrapCompile flags e)

Expand All @@ -102,7 +102,7 @@ compile flags e pattern = withSeq pattern (wrapCompile flags e)

-- | Matches a regular expression against a string
execute :: Regex -- ^ Compiled regular expression
-> (Seq Char) -- ^ (Seq Char) to match against
-> Seq Char -- ^ Text to match against
-> IO (Either WrapError (Maybe (Array Int (MatchOffset,MatchLength))))
-- ^ Returns: 'Nothing' if the regex did not match the
-- string, or:
Expand All @@ -116,7 +116,7 @@ execute regex str = do
Right Nothing -> return (Right Nothing)
-- Right (Just []) -> fail "got [] back!" -- return wierd array instead
Right (Just parts) ->
return . Right . Just . listArray (0,pred (length parts))
return . Right . Just . listArray (0,pred (length parts))
. map (\(s,e)->(fromIntegral s, fromIntegral (e-s)))
$ parts
Left err -> return (Left err)
Expand All @@ -126,8 +126,8 @@ execute regex str = do

-- | Matches a regular expression against a string
regexec :: Regex -- ^ Compiled regular expression
-> (Seq Char) -- ^ (Seq Char) to match against
-> IO (Either WrapError (Maybe ((Seq Char), (Seq Char), (Seq Char), [(Seq Char)])))
-> Seq Char -- ^ Text to match against
-> IO (Either WrapError (Maybe (Seq Char, Seq Char, Seq Char, [Seq Char])))
-- ^ Returns: 'Nothing' if the regex did not match the
-- string, or:
--
Expand All @@ -138,13 +138,13 @@ regexec :: Regex -- ^ Compiled regular expression
-- subexpression matches)
-- @
regexec regex str = do
let getSub :: (RegOffset,RegOffset) -> (Seq Char)
let getSub :: (RegOffset,RegOffset) -> Seq Char
getSub (start,stop) | start == unusedRegOffset = S.empty
| otherwise =
| otherwise =
extract (fromEnum start,fromEnum $ stop-start) $ str
matchedParts :: [(RegOffset,RegOffset)] -> ((Seq Char), (Seq Char), (Seq Char), [(Seq Char)])
matchedParts :: [(RegOffset,RegOffset)] -> (Seq Char, Seq Char, Seq Char, [Seq Char])
matchedParts [] = (str,S.empty,S.empty,[]) -- no information
matchedParts (matchedStartStop@(start,stop):subStartStop) =
matchedParts (matchedStartStop@(start,stop):subStartStop) =
(before (fromEnum start) str
,getSub matchedStartStop
,after (fromEnum stop) str
Expand Down
20 changes: 10 additions & 10 deletions src/Text/Regex/Posix/String.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
-- |
-- Module : Text.Regex.Posix.String
-- Copyright : (c) Chris Kuklewicz 2006
-- SPDX-License-Identifier: BSD-3-Clause
--
-- Maintainer : hvr@gnu.org
-- Stability : experimental
-- License : BSD-3-Clause
--
-- Maintainer : hvr@gnu.org, Andreas Abel
-- Stability : stable
-- Portability : non-portable (regex-base needs MPTC+FD)
--
-- This provides 'String' instances for 'RegexMaker' and 'RegexLike' based
Expand Down Expand Up @@ -73,15 +73,15 @@ unwrap x = case x of Left err -> fail ("Text.Regex.Posix.String died: "++ show e
instance RegexMaker Regex CompOption ExecOption String where
makeRegexOpts c e pattern = unsafePerformIO $
(compile c e pattern >>= unwrap)
makeRegexOptsM c e pattern = either (fail.show) return $ unsafePerformIO $
makeRegexOptsM c e pattern = either (fail.show) return $ unsafePerformIO $
(compile c e pattern)

instance RegexLike Regex String where
matchTest regex str = unsafePerformIO $ do
withCAString str (wrapTest regex) >>= unwrap
matchOnce regex str = unsafePerformIO $
matchOnce regex str = unsafePerformIO $
execute regex str >>= unwrap
matchAll regex str = unsafePerformIO $
matchAll regex str = unsafePerformIO $
withCAString str (wrapMatchAll regex) >>= unwrap
matchCount regex str = unsafePerformIO $
withCAString str (wrapCount regex) >>= unwrap
Expand Down Expand Up @@ -112,7 +112,7 @@ execute regex str = do
Right Nothing -> return (Right Nothing)
-- Right (Just []) -> fail "got [] back!" -- return wierd array instead
Right (Just parts) ->
return . Right . Just . listArray (0,pred (length parts))
return . Right . Just . listArray (0,pred (length parts))
. map (\(s,e)->(fromIntegral s, fromIntegral (e-s)))
$ parts
Left err -> return (Left err)
Expand All @@ -135,10 +135,10 @@ regexec :: Regex -- ^ Compiled regular expression
-- @
regexec regex str = do
let getSub (start,stop) | start == unusedRegOffset = ""
| otherwise =
| otherwise =
genericTake (stop-start) . genericDrop start $ str
matchedParts [] = (str,"","",[]) -- no information
matchedParts (matchedStartStop@(start,stop):subStartStop) =
matchedParts (matchedStartStop@(start,stop):subStartStop) =
(genericTake start str
,getSub matchedStartStop
,genericDrop stop str
Expand Down
Loading