From 0305f4e365b5b96be0f5b28d04b424ffb07a4bb1 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Wed, 23 Jul 2003 10:27:49 +0000 Subject: [PATCH] [project @ 2003-07-23 10:27:49 by wolfgang] 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Text/Regex/Posix.hsc b/Text/Regex/Posix.hsc index 865398d..9cc06f7 100644 --- a/Text/Regex/Posix.hsc +++ b/Text/Regex/Posix.hsc @@ -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 -- 1.7.10.4