[library cleanups
John Meacham <john@repetae.net>**20120130063455
 Ignore-this: ca8a77608e6ca9828366dc9d20af4375
] hunk ./lib/base/System/Environment.hs 34
-
hunk ./lib/base/System/Environment.hs 37
-
hunk ./lib/base/System/Environment.hs 53
-
hunk ./lib/base/System/Environment.hs 64
-
-
hunk ./lib/base/System/Exit.hs 7
-import Foreign.C.String
-import Foreign.Ptr
-import Foreign.Storable
-import Foreign.Marshal.Alloc
-import Foreign.C.Types
hunk ./lib/base/System/Exit.hs 8
-import qualified Jhc.Options
hunk ./lib/base/System/Exit.hs 12
-getArgs     :: IO [String]
-getProgName :: IO String
-getEnv      :: String -> IO String
-system      :: String -> IO ExitCode
-exitWith    :: ExitCode -> IO a
-exitFailure :: IO a
+-- exitFailure :: IO a
hunk ./lib/base/System/Exit.hs 14
-
hunk ./lib/base/System/Exit.hs 16
+exitWith    :: ExitCode -> IO a
hunk ./lib/base/System/Exit.hs 24
-
-getProgName = case Jhc.Options.target of
-    Jhc.Options.GhcHs -> ghc_getProgName
-    _ -> peek jhc_progname >>= peekCString
-
-getArgs = case Jhc.Options.target of
-    Jhc.Options.GhcHs -> ghc_getArgs
-    _ -> do
-        argc <- peek jhc_argc
-        argv <- peek jhc_argv
-        let f n = peekElemOff argv n >>= peekCString
-        mapM f [0 .. fromIntegral argc - 1]
-
-
-getEnv s = withCString s c_getenv >>= \p ->
-    if p == nullPtr then fail ("getEnv: " ++ show s)  else peekCString p
-
-
-system s = withCString s c_system >>= \r -> case r of
-    0 -> return ExitSuccess
-    _ -> return $ ExitFailure (fromIntegral r)
-
hunk ./lib/base/System/Exit.hs 25
-foreign import unsafe ccall "system" c_system :: CString -> IO CInt
-foreign import unsafe ccall "stdlib.h getenv" c_getenv :: Ptr CChar -> IO (Ptr CChar)
-
-foreign import ccall "&jhc_progname" jhc_progname :: Ptr CString
-foreign import ccall "&jhc_argc" jhc_argc :: Ptr CInt
-foreign import ccall "&jhc_argv" jhc_argv :: Ptr (Ptr CString)
-
-ghc_getArgs :: IO [String]
-ghc_getArgs =
-    alloca $ \ p_argc ->
-    alloca $ \ p_argv -> do
-        getProgArgv p_argc p_argv
-        p    <- peek p_argc
-        argv <- peek p_argv
-        let f n = peekElemOff argv n >>= peekCString
-        mapM f [1 .. fromIntegral p - 1]
-
-
-foreign import unsafe ccall "getProgArgv"
-  getProgArgv :: Ptr CInt -> Ptr (Ptr CString) -> IO ()
-
-ghc_getProgName :: IO String
-ghc_getProgName =
-  alloca $ \ p_argc ->
-  alloca $ \ p_argv -> do
-     getProgArgv p_argc p_argv
-     argv <- peek p_argv
-     peekElemOff argv 0 >>= peekCString
-