X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FEnvironment.hs;h=f99df14bebee4327e407374d4730eef4cccbe20a;hb=ac29f3c340fca6b7362e089fd439cb0cf5e092f8;hp=d85a52dd2d1ae61a87c387b336d8ca625bebef1c;hpb=1e1907fb42b74de4feb5ac8af10846db31e56edb;p=ghc-base.git diff --git a/System/Environment.hs b/System/Environment.hs index d85a52d..f99df14 100644 --- a/System/Environment.hs +++ b/System/Environment.hs @@ -1,15 +1,13 @@ ----------------------------------------------------------------------------- --- +-- | -- Module : System.Environment -- Copyright : (c) The University of Glasgow 2001 --- License : BSD-style (see the file libraries/core/LICENSE) +-- License : BSD-style (see the file libraries/base/LICENSE) -- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : portable -- --- $Id: Environment.hs,v 1.4 2002/01/02 14:40:11 simonmar Exp $ --- -- Miscellaneous information about the system environment. -- ----------------------------------------------------------------------------- @@ -47,12 +45,19 @@ getArgs = peekArray (p - 1) (advancePtr argv 1) >>= mapM peekCString -foreign import "getProgArgv" unsafe +foreign import ccall unsafe "getProgArgv" getProgArgv :: Ptr CInt -> Ptr (Ptr CString) -> IO () --- Computation `getProgName' returns the name of the program --- as it was invoked. +{-| +Computation 'getProgName' returns the name of the program as it was +invoked. +However, this is hard-to-impossible to implement on some non-Unix +OSes, so instead, for maximum portability, we just return the leafname +of the program as invoked. Even then there are some differences +between platforms: on Windows, for example, a program invoked as foo +is probably really @FOO.EXE@, and that is what 'getProgName' will return. +-} getProgName :: IO String getProgName = alloca $ \ p_argc -> @@ -97,5 +102,5 @@ getEnv name = else ioException (IOError Nothing NoSuchThing "getEnv" "no environment variable" (Just name)) -foreign import ccall "getenv" unsafe +foreign import ccall unsafe "getenv" c_getenv :: CString -> IO (Ptr CChar)