[commit: unix] encoding: Merge branch 'master' of ssh://darcs.haskell.org/srv/darcs/packages/unix into encoding (e73a32b)

Ian Lynagh igloo at earth.li
Fri Apr 8 13:42:50 CEST 2011


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

On branch  : encoding

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

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

commit e73a32b677fd3d2508cfddb8c9a8ccedc1036e65
Merge: 445eb48... a8d4731...
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date:   Wed Apr 6 15:34:48 2011 +0100

    Merge branch 'master' of ssh://darcs.haskell.org/srv/darcs/packages/unix into encoding

 System/Posix/Env.hsc |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --cc System/Posix/Env.hsc
index 03dfc8d,83bdc2c..799fd6b
--- a/System/Posix/Env.hsc
+++ b/System/Posix/Env.hsc
@@@ -69,12 -55,24 +69,24 @@@ foreign import ccall unsafe "getenv
  
  getEnvironmentPrim :: IO [String]
  getEnvironmentPrim = do
-   c_environ <- peek c_environ_p
+   c_environ <- getCEnviron
    arr <- peekArray0 nullPtr c_environ
 -  mapM peekCString arr
 +  mapM peekFilePath arr
  
+ getCEnviron :: IO (Ptr CString)
+ #if darwin_HOST_OS
+ -- You should not access _environ directly on Darwin in a bundle/shared library.
+ -- See #2458 and http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/environ.7.html
+ getCEnviron = nsGetEnviron >>= peek
+ 
+ foreign import ccall unsafe "_NSGetEnviron"
+    nsGetEnviron :: IO (Ptr (Ptr CString))
+ #else
+ getCEnviron = peek c_environ_p
+ 
  foreign import ccall unsafe "&environ"
     c_environ_p :: Ptr (Ptr CString)
+ #endif
  
  -- |'getEnvironment' retrieves the entire environment as a
  -- list of @(key,value)@ pairs.





More information about the Cvs-libraries mailing list