-----------------------------------------------------------------------------
-- ToDo: should have an interface using PackedStrings.
+#include "config.h"
module Text.Regex.Posix (
-- * The @Regex@ type
) where
#include <sys/types.h>
+
+#if HAVE_REGEX_H && HAVE_REGCOMP
#include "regex.h"
+#else
+#include "regex/regex.h"
+{-# CBITS regex/reallocf.c #-}
+{-# CBITS regex/regcomp.c #-}
+{-# CBITS regex/regerror.c #-}
+{-# CBITS regex/regexec.c #-}
+{-# CBITS regex/regfree.c #-}
+#endif
import Prelude
import Foreign
import Foreign.C
+type CRegex = ()
+
-- | A compiled regular expression
newtype Regex = Regex (ForeignPtr CRegex)
r <- withCString pattern $ \cstr ->
withForeignPtr regex_fptr $ \p ->
c_regcomp p cstr (fromIntegral flags)
- addForeignPtrFinalizer regex_fptr ptr_regfree
if (r == 0)
- then return (Regex regex_fptr)
+ then do addForeignPtrFinalizer ptr_regfree regex_fptr
+ return (Regex regex_fptr)
else error "Text.Regex.Posix.regcomp: error in pattern" -- ToDo
-- -----------------------------------------------------------------------------
REG_ERANGE, \
REG_ESPACE
-type CRegex = ()
type CRegMatch = ()
foreign import ccall unsafe "regcomp"