[project @ 2004-07-01 13:25:09 by malcolm]
[haskell-directory.git] / Text / Regex.hs
index a0d724e..94c5c58 100644 (file)
@@ -1,3 +1,4 @@
+{-# OPTIONS -cpp #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Text.Regex
 -- interface in "Text.Regex.Posix".
 --
 -----------------------------------------------------------------------------
-
+#include "config.h"
 module Text.Regex (
     -- * Regular expressions
     Regex,
+#if !defined(__HUGS__) || 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(__HUGS__) || 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
@@ -38,8 +42,8 @@ mkRegex s = unsafePerformIO (RE.regcomp s RE.regExtended)
 -- case-sensitve options can be changed from the default settings.
 mkRegexWithOpts
    :: String  -- ^ The regular expression to compile
-   -> Bool    -- ^ 'True' @\<=>@ '@^@' and '@$@' match the beginning and 
-             -- end of individual lines respectively, and '.' does /not/
+   -> Bool    -- ^ 'True' @\<=>@ @\'^\'@ and @\'$\'@ match the beginning and 
+             -- end of individual lines respectively, and @\'.\'@ does /not/
              -- match the newline character.
    -> Bool    -- ^ 'True' @\<=>@ matching is case-sensitive
    -> Regex   -- ^ Returns: the compiled regular expression
@@ -47,8 +51,8 @@ mkRegexWithOpts
 mkRegexWithOpts s single_line case_sensitive
    = unsafePerformIO (RE.regcomp s (RE.regExtended + newline + igcase))
    where
-       newline | single_line = 0
-               | otherwise   = RE.regNewline
+       newline | single_line = RE.regNewline
+               | otherwise   = 0
 
        igcase  | case_sensitive = 0 
                | otherwise      = RE.regIgnoreCase
@@ -80,3 +84,4 @@ matchRegexAll
 
 matchRegexAll p str = unsafePerformIO (RE.regexec p str)
 
+#endif