[project @ 2003-07-23 10:27:49 by wolfgang]
authorwolfgang <unknown>
Wed, 23 Jul 2003 10:27:49 +0000 (10:27 +0000)
committerwolfgang <unknown>
Wed, 23 Jul 2003 10:27:49 +0000 (10:27 +0000)
Fix regular expressions for Mac OS X.

For some reason, Apple uses 64-bit offsets in regmatch_t,
so we have to use (#type regoff_t) instead of CInt.

MERGE TO STABLE.

Text/Regex/Posix.hsc

index 865398d..9cc06f7 100644 (file)
@@ -103,8 +103,8 @@ regexec (Regex regex_fptr) str = do
 
 matched_parts :: String -> Ptr CRegMatch -> IO (String, String, String)
 matched_parts string p_match = do
-  start <- (#peek regmatch_t, rm_so) p_match :: IO CInt
-  end   <- (#peek regmatch_t, rm_eo) p_match :: IO CInt
+  start <- (#peek regmatch_t, rm_so) p_match :: IO (#type regoff_t)
+  end   <- (#peek regmatch_t, rm_eo) p_match :: IO (#type regoff_t)
   let s = fromIntegral start; e = fromIntegral end
   return ( take s string, 
           take (e-s) (drop s string),
@@ -112,8 +112,8 @@ matched_parts string p_match = do
 
 unpack :: String -> Ptr CRegMatch -> IO (String)
 unpack string p_match = do
-  start <- (#peek regmatch_t, rm_so) p_match :: IO CInt
-  end   <- (#peek regmatch_t, rm_eo) p_match :: IO CInt
+  start <- (#peek regmatch_t, rm_so) p_match :: IO (#type regoff_t)
+  end   <- (#peek regmatch_t, rm_eo) p_match :: IO (#type regoff_t)
   -- the subexpression may not have matched at all, perhaps because it
   -- was optional.  In this case, the offsets are set to -1.
   if (start == -1) then return "" else do