From b47555c3c6e7d9b6cbe17714fee9fd22d1779928 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 29 Apr 2008 22:24:09 +0000 Subject: [PATCH] don't turn off stdin/stdout buffering after loading a module with ghc -e (#2228) --- compiler/ghci/GhciMonad.hs | 10 ++++++---- compiler/ghci/InteractiveUI.hs | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/compiler/ghci/GhciMonad.hs b/compiler/ghci/GhciMonad.hs index dc16f25..7720b84 100644 --- a/compiler/ghci/GhciMonad.hs +++ b/compiler/ghci/GhciMonad.hs @@ -77,7 +77,8 @@ data GHCiState = GHCiState -- were supposed to be in the context but currently had errors, -- but this was complicated. Just replaying the :module commands -- seems to be the right thing. - virtual_path :: FilePath + virtual_path :: FilePath, + ghc_e :: Bool -- True if this is 'ghc -e' (or runghc) } data CtxtCmd @@ -251,10 +252,11 @@ printTimes allocs psecs ----------------------------------------------------------------------------- -- reverting CAFs -revertCAFs :: IO () +revertCAFs :: GHCi () revertCAFs = do - rts_revertCAFs - turnOffBuffering + io $ rts_revertCAFs + s <- getGHCiState + when (not (ghc_e s)) $ io turnOffBuffering -- Have to turn off buffering again, because we just -- reverted stdout, stderr & stdin to their defaults. diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index ca4a20e..db7844d 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -356,7 +356,8 @@ interactiveUI session srcs maybe_exprs = do last_command = Nothing, cmdqueue = [], remembered_ctx = [], - virtual_path = cwd + virtual_path = cwd, + ghc_e = isJust maybe_exprs } #ifdef USE_EDITLINE @@ -729,7 +730,7 @@ afterRunStmt step_here run_result = do flushInterpBuffers io installSignalHandlers b <- isOptionSet RevertCAFs - io (when b revertCAFs) + when b revertCAFs return (case run_result of GHC.RunOk _ -> True; _ -> False) @@ -899,7 +900,7 @@ doWithArgs args cmd = enqueueCommands ["System.Environment.withArgs " ++ addModule :: [FilePath] -> GHCi () addModule files = do - io (revertCAFs) -- always revert CAFs on load/add. + revertCAFs -- always revert CAFs on load/add. files <- mapM expandPath files targets <- mapM (\m -> io (GHC.guessTarget m Nothing)) files session <- getSession @@ -1098,7 +1099,7 @@ doLoad session retain_context prev_context howmuch = do afterLoad :: SuccessFlag -> Session -> Bool -> ([Module],[Module]) -> GHCi () afterLoad ok session retain_context prev_context = do - io (revertCAFs) -- always revert CAFs on load. + revertCAFs -- always revert CAFs on load. discardTickArrays loaded_mod_summaries <- getLoadedModules session let loaded_mods = map GHC.ms_mod loaded_mod_summaries -- 1.7.10.4