Repository : ssh://darcs.haskell.org//srv/darcs/packages/process

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/ccd64e56749f85a4839b839515548f07929c231e

>---------------------------------------------------------------

commit ccd64e56749f85a4839b839515548f07929c231e
Author: Max Bolingbroke <[email protected]>
Date:   Sat May 14 22:44:05 2011 +0100

    Improved Unicode support (PEP383, Unicode env on Windows)

>---------------------------------------------------------------

 System/Process/Internals.hs |   13 ++++++-------
 cbits/runProcess.c          |    8 +++++---
 include/runProcess.h        |    2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/System/Process/Internals.hs b/System/Process/Internals.hs
index 2c984ad..b68f268 100644
--- a/System/Process/Internals.hs
+++ b/System/Process/Internals.hs
@@ -236,8 +236,8 @@ runGenProcess_ fun CreateProcess{ cmdspec = cmdsp,
    alloca $ \ pfdStdOutput ->
    alloca $ \ pfdStdError  ->
    maybeWith withCEnvironment mb_env $ \pEnv ->
-   maybeWith withCString mb_cwd $ \pWorkDir ->
-   withMany withCString (cmd:args) $ \cstrs ->
+   maybeWith withFilePath mb_cwd $ \pWorkDir ->
+   withMany withFilePath (cmd:args) $ \cstrs ->
    withArray0 nullPtr cstrs $ \pargs -> do
      
      fdin  <- mbFd fun fd_stdin  mb_stdin
@@ -361,7 +361,7 @@ foreign import ccall unsafe "runInteractiveProcess"
   c_runInteractiveProcess
         :: CWString
         -> CWString
-        -> Ptr ()
+        -> Ptr CWString
         -> FD
         -> FD
         -> FD
@@ -370,11 +370,10 @@ foreign import ccall unsafe "runInteractiveProcess"
         -> Ptr FD
         -> CInt                         -- flags
         -> IO PHANDLE
+#endif
 
 #endif /* __GLASGOW_HASKELL__ */
 
-#endif
-
 fd_stdin, fd_stdout, fd_stderr :: FD
 fd_stdin  = 0
 fd_stdout = 1
@@ -602,9 +601,9 @@ withCEnvironment envir act =
   let env' = map (\(name, val) -> name ++ ('=':val)) envir 
   in withMany withCString env' (\pEnv -> withArray0 nullPtr pEnv act)
 #else
-withCEnvironment :: [(String,String)] -> (Ptr () -> IO a) -> IO a
+withCEnvironment :: [(String,String)] -> (Ptr CWString -> IO a) -> IO a
 withCEnvironment envir act =
   let env' = foldr (\(name, val) env -> name ++ ('=':val)++'\0':env) "\0" envir
-  in withCString env' (act . castPtr)
+  in withCWString env' (act . castPtr)
 #endif
 
diff --git a/cbits/runProcess.c b/cbits/runProcess.c
index 2c1028f..6154d1d 100644
--- a/cbits/runProcess.c
+++ b/cbits/runProcess.c
@@ -107,6 +107,7 @@ runInteractiveProcess (char *const args[],
         if ((flags & RUN_PROCESS_IN_NEW_GROUP) != 0) {
             setpgid(0, 0);
         }
+
         unblockUserSignals();
 
        if (workingDirectory) {
@@ -356,7 +357,7 @@ mkAnonPipe (HANDLE* pHandleIn, BOOL isInheritableIn,
 
 ProcHandle
 runInteractiveProcess (wchar_t *cmd, wchar_t *workingDirectory, 
-                       void *environment,
+                       wchar_t *environment,
                        int fdStdIn, int fdStdOut, int fdStdErr,
                       int *pfdStdInput, int *pfdStdOutput, int *pfdStdError,
                        int flags)
@@ -370,7 +371,8 @@ runInteractiveProcess (wchar_t *cmd, wchar_t 
*workingDirectory,
        HANDLE hStdErrorRead   = INVALID_HANDLE_VALUE;
         HANDLE hStdErrorWrite  = INVALID_HANDLE_VALUE;
     BOOL close_fds = ((flags & RUN_PROCESS_IN_CLOSE_FDS) != 0);
-       DWORD dwFlags = 0;
+       // We always pass a wide environment block, so we MUST set this flag 
+        DWORD dwFlags = CREATE_UNICODE_ENVIRONMENT;
        BOOL status;
         BOOL inherit;
 
@@ -438,7 +440,7 @@ runInteractiveProcess (wchar_t *cmd, wchar_t 
*workingDirectory,
             sInfo.hStdError = hStdErrorWrite;
         }
 
-       if (sInfo.hStdInput  != GetStdHandle(STD_INPUT_HANDLE)  &&
+        if (sInfo.hStdInput  != GetStdHandle(STD_INPUT_HANDLE)  &&
            sInfo.hStdOutput != GetStdHandle(STD_OUTPUT_HANDLE) &&
            sInfo.hStdError  != GetStdHandle(STD_ERROR_HANDLE)  &&
            (flags & RUN_PROCESS_IN_NEW_GROUP) == 0)
diff --git a/include/runProcess.h b/include/runProcess.h
index 818a96f..7eb5c75 100644
--- a/include/runProcess.h
+++ b/include/runProcess.h
@@ -63,7 +63,7 @@ extern ProcHandle runInteractiveProcess( char *const args[],
 
 extern ProcHandle runInteractiveProcess( wchar_t *cmd,
                                         wchar_t *workingDirectory,
-                                        void *environment,
+                                        wchar_t *environment,
                                          int fdStdIn, int fdStdOut, int 
fdStdErr,
                                         int *pfdStdInput,
                                         int *pfdStdOutput,



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to