+{-# OPTIONS -cpp #-}
-----------------------------------------------------------------------------
-- |
-- Module : Text.Regex
-- interface in "Text.Regex.Posix".
--
-----------------------------------------------------------------------------
-
+#include "config.h"
module Text.Regex (
-- * Regular expressions
Regex,
+#if defined(HAVE_REGEX_H)
mkRegex,
mkRegexWithOpts,
matchRegex,
matchRegexAll
+#endif
) where
import Prelude
import Text.Regex.Posix ( Regex )
import System.IO.Unsafe
+#if defined(HAVE_REGEX_H)
-- | Makes a regular expression with the default options (multi-line,
-- case-sensitive). The syntax of regular expressions is
-- otherwise that of @egrep@ (i.e. POSIX \"extended\" regular
matchRegexAll p str = unsafePerformIO (RE.regexec p str)
+#endif
-----------------------------------------------------------------------------
-- ToDo: should have an interface using PackedStrings.
+#include "config.h"
module Text.Regex.Posix (
-- * The @Regex@ type
Regex, -- abstract
+#if defined(HAVE_REGEX_H)
-- * Compiling a regular expression
regcomp, -- :: String -> Int -> IO Regex
-- String, -- everything after match
-- [String])) -- subexpression matches
+#endif
) where
+#if defined(HAVE_REGEX_H)
#include <sys/types.h>
#include "regex.h"
+#endif
import Prelude
import Foreign
import Foreign.C
+type CRegex = ()
+
-- | A compiled regular expression
newtype Regex = Regex (ForeignPtr CRegex)
+#if defined(HAVE_REGEX_H)
+-- to the end
-- -----------------------------------------------------------------------------
-- regcomp
REG_ERANGE, \
REG_ESPACE
-type CRegex = ()
type CRegMatch = ()
foreign import ccall unsafe "regcomp"
foreign import ccall unsafe "regexec"
c_regexec :: Ptr CRegex -> CString -> CSize
-> Ptr CRegMatch -> CInt -> IO CInt
+
+#endif /* HAVE_REGEX_H */