X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;fp=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=67c68d3b1667f7b465fb776e98bb0852ddf16f08;hb=c86b512d648e23eed323451d5e2998947a9e68b4;hp=7cd720cd39540aef4fff84552d36f88240b6a902;hpb=3d8a086764395544acbfc522e46eab082a0079c0;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 7cd720c..67c68d3 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -196,17 +196,6 @@ interactiveUI session srcs maybe_expr = do Readline.initialize #endif -#if defined(mingw32_HOST_OS) - -- The win32 Console API mutates the first character of - -- type-ahead when reading from it in a non-buffered manner. Work - -- around this by flushing the input buffer of type-ahead characters, - -- but only if stdin is available. - flushed <- IO.try (GHC.ConsoleHandler.flushConsole stdin) - case flushed of - Left err | isDoesNotExistError err -> return () - | otherwise -> ioError err - Right () -> return () -#endif startGHCi (runGHCi srcs maybe_expr) GHCiState{ progname = "", args = [], @@ -269,6 +258,18 @@ runGHCi paths maybe_expr = do case maybe_expr of Nothing -> +#if defined(mingw32_HOST_OS) + do + -- The win32 Console API mutates the first character of + -- type-ahead when reading from it in a non-buffered manner. Work + -- around this by flushing the input buffer of type-ahead characters, + -- but only if stdin is available. + flushed <- io (IO.try (GHC.ConsoleHandler.flushConsole stdin)) + case flushed of + Left err | isDoesNotExistError err -> return () + | otherwise -> io (ioError err) + Right () -> return () +#endif -- enter the interactive loop interactiveLoop is_tty show_prompt Just expr -> do