From b23d75aa7253aee1bb3bfc685cbae352bf5fbe0d Mon Sep 17 00:00:00 2001 From: sof Date: Mon, 13 Oct 2003 03:21:20 +0000 Subject: [PATCH] [project @ 2003-10-13 03:21:20 by sof] cope if regex.h isn't supported by target --- Text/Regex.hs | 7 ++++++- Text/Regex/Posix.hsc | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Text/Regex.hs b/Text/Regex.hs index 15aecb8..8ba4eae 100644 --- a/Text/Regex.hs +++ b/Text/Regex.hs @@ -1,3 +1,4 @@ +{-# OPTIONS -cpp #-} ----------------------------------------------------------------------------- -- | -- Module : Text.Regex @@ -12,14 +13,16 @@ -- 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 @@ -27,6 +30,7 @@ import qualified Text.Regex.Posix as RE 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 @@ -80,3 +84,4 @@ matchRegexAll matchRegexAll p str = unsafePerformIO (RE.regexec p str) +#endif diff --git a/Text/Regex/Posix.hsc b/Text/Regex/Posix.hsc index 65ab13d..9b4d706 100644 --- a/Text/Regex/Posix.hsc +++ b/Text/Regex/Posix.hsc @@ -13,11 +13,13 @@ ----------------------------------------------------------------------------- -- 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 @@ -34,19 +36,26 @@ module Text.Regex.Posix ( -- String, -- everything after match -- [String])) -- subexpression matches +#endif ) where +#if defined(HAVE_REGEX_H) #include #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 @@ -154,7 +163,6 @@ unpack string p_match = do REG_ERANGE, \ REG_ESPACE -type CRegex = () type CRegMatch = () foreign import ccall unsafe "regcomp" @@ -166,3 +174,5 @@ foreign import ccall unsafe "®free" foreign import ccall unsafe "regexec" c_regexec :: Ptr CRegex -> CString -> CSize -> Ptr CRegMatch -> CInt -> IO CInt + +#endif /* HAVE_REGEX_H */ -- 1.7.10.4