Commit 8bbf522b authored by sof's avatar sof
Browse files

[project @ 2001-05-28 03:17:03 by sof]

Avoid the use of Posix when compiling for target i386-unknown-mingw32
parent b8c0cb8a
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- $Id: InteractiveUI.hs,v 1.68 2001/05/23 10:26:14 simonmar Exp $ -- $Id: InteractiveUI.hs,v 1.69 2001/05/28 03:17:03 sof Exp $
-- --
-- GHC Interactive User Interface -- GHC Interactive User Interface
-- --
...@@ -28,10 +28,10 @@ import CmdLineOpts ( DynFlag(..), dopt_unset ) ...@@ -28,10 +28,10 @@ import CmdLineOpts ( DynFlag(..), dopt_unset )
import Panic ( GhcException(..) ) import Panic ( GhcException(..) )
import Config import Config
import CForeign #ifndef mingw32_TARGET_OS
import Foreign
import Posix import Posix
#endif
import Exception import Exception
import Dynamic import Dynamic
#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS #if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS
...@@ -49,6 +49,8 @@ import Char ...@@ -49,6 +49,8 @@ import Char
import Monad ( when ) import Monad ( when )
import PrelGHC ( unsafeCoerce# ) import PrelGHC ( unsafeCoerce# )
import Foreign ( nullPtr )
import CString ( peekCString )
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
...@@ -132,30 +134,22 @@ interactiveUI cmstate mod cmdline_libs = do ...@@ -132,30 +134,22 @@ interactiveUI cmstate mod cmdline_libs = do
dflags <- getDynFlags dflags <- getDynFlags
(cmstate, maybe_hval) (cmstate, maybe_hval)
<- cmCompileExpr cmstate dflags "IO.hFlush IO.stderr" <- cmCompileExpr cmstate dflags "IO.hFlush PrelHandle.stderr"
case maybe_hval of case maybe_hval of
Just hval -> writeIORef flush_stderr (unsafeCoerce# hval :: IO ()) Just hval -> writeIORef flush_stderr (unsafeCoerce# hval :: IO ())
_ -> panic "interactiveUI:stderr" _ -> panic "interactiveUI:stderr"
(cmstate, maybe_hval) (cmstate, maybe_hval)
<- cmCompileExpr cmstate dflags "IO.hFlush IO.stdout" <- cmCompileExpr cmstate dflags "IO.hFlush PrelHandle.stdout"
case maybe_hval of case maybe_hval of
Just hval -> writeIORef flush_stdout (unsafeCoerce# hval :: IO ()) Just hval -> writeIORef flush_stdout (unsafeCoerce# hval :: IO ())
_ -> panic "interactiveUI:stdout" _ -> panic "interactiveUI:stdout"
-- replace the current argv/argc with ["<interactive>"].
interactive_str <- newCString "<interactive>"
poke prog_argc_label 1 -- sets argc to 1
argv <- peek prog_argv_label
poke argv interactive_str -- sets argv[0] to point to "<interactive>"
(unGHCi runGHCi) GHCiState{ target = mod, (unGHCi runGHCi) GHCiState{ target = mod,
cmstate = cmstate, cmstate = cmstate,
options = [] } options = [] }
return () return ()
foreign label "prog_argv" prog_argv_label :: Ptr (Ptr (Ptr CChar))
foreign label "prog_argc" prog_argc_label :: Ptr CInt
runGHCi :: GHCi () runGHCi :: GHCi ()
runGHCi = do runGHCi = do
...@@ -209,6 +203,9 @@ runGHCi = do ...@@ -209,6 +203,9 @@ runGHCi = do
checkPerms :: String -> IO Bool checkPerms :: String -> IO Bool
checkPerms name = checkPerms name =
handle (\_ -> return False) $ do handle (\_ -> return False) $ do
#ifdef mingw32_TARGET_OS
doesFileExist name
#else
st <- getFileStatus name st <- getFileStatus name
me <- getRealUserID me <- getRealUserID
if fileOwner st /= me then do if fileOwner st /= me then do
...@@ -223,6 +220,7 @@ checkPerms name = ...@@ -223,6 +220,7 @@ checkPerms name =
" is writable by someone else, IGNORING!" " is writable by someone else, IGNORING!"
return False return False
else return True else return True
#endif
fileLoop :: Handle -> Bool -> GHCi () fileLoop :: Handle -> Bool -> GHCi ()
fileLoop hdl prompt = do fileLoop hdl prompt = do
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment