diff options
author | Max Bolingbroke <batterseapower@hotmail.com> | 2011-05-14 22:45:27 +0100 |
---|---|---|
committer | Max Bolingbroke <batterseapower@hotmail.com> | 2011-05-14 22:45:27 +0100 |
commit | bb8a27d14a63fcd126a924d32c69b7694ea709d9 (patch) | |
tree | fc8fd365f738a6f77bc31a96efd470fbf2bd51dc /System/Posix/Process.hsc | |
parent | b7b180d23472dca03fb4c809cd86bcd6d3f01ea9 (diff) |
Improved Unicode support in the light of PEP383
Diffstat (limited to 'System/Posix/Process.hsc')
-rw-r--r-- | System/Posix/Process.hsc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/System/Posix/Process.hsc b/System/Posix/Process.hsc index 163c356..248c2e2 100644 --- a/System/Posix/Process.hsc +++ b/System/Posix/Process.hsc @@ -63,7 +63,7 @@ module System.Posix.Process ( #include "HsUnix.h" import Foreign.C.Error -import Foreign.C.String ( CString, withCString ) +import Foreign.C.String import Foreign.C.Types ( CInt, CClock ) import Foreign.Marshal.Alloc ( alloca, allocaBytes ) import Foreign.Marshal.Array ( withArray0 ) @@ -80,6 +80,13 @@ import Control.Monad import GHC.TopHandler ( runIO ) #endif +#if __GLASGOW_HASKELL__ > 611 +import System.Posix.Internals ( withFilePath ) +#else +withFilePath :: FilePath -> (CString -> IO a) -> IO a +withFilePath = withCString +#endif + #ifdef __HUGS__ {-# CFILES cbits/HsUnix.c #-} #endif @@ -275,8 +282,8 @@ executeFile :: FilePath -- ^ Command -> Maybe [(String, String)] -- ^ Environment -> IO a executeFile path search args Nothing = do - withCString path $ \s -> - withMany withCString (path:args) $ \cstrs -> + withFilePath path $ \s -> + withMany withFilePath (path:args) $ \cstrs -> withArray0 nullPtr cstrs $ \arr -> do pPrPr_disableITimers if search @@ -285,11 +292,11 @@ executeFile path search args Nothing = do return undefined -- never reached executeFile path search args (Just env) = do - withCString path $ \s -> - withMany withCString (path:args) $ \cstrs -> + withFilePath path $ \s -> + withMany withFilePath (path:args) $ \cstrs -> withArray0 nullPtr cstrs $ \arg_arr -> let env' = map (\ (name, val) -> name ++ ('=' : val)) env in - withMany withCString env' $ \cenv -> + withMany withFilePath env' $ \cenv -> withArray0 nullPtr cenv $ \env_arr -> do pPrPr_disableITimers if search |