Lennart Kolmodin 2009 Make GHC 6.10.2 use readline instead of editline diff -rN -u old-ghc-6.10.2/aclocal.m4 new-ghc-6.10.2/aclocal.m4 --- old-ghc-6.10.2/aclocal.m4 2009-04-02 22:56:21.000000000 +0200 +++ new-ghc-6.10.2/aclocal.m4 2009-04-02 22:56:23.000000000 +0200 @@ -900,18 +900,18 @@ fi])# FP_PROG_GHC_PKG -# FP_GHC_HAS_EDITLINE +# FP_GHC_HAS_READLINE # ------------------- -AC_DEFUN([FP_GHC_HAS_EDITLINE], +AC_DEFUN([FP_GHC_HAS_READLINE], [AC_REQUIRE([FP_PROG_GHC_PKG]) -AC_CACHE_CHECK([whether ghc has editline package], [fp_cv_ghc_has_editline], -[if "${GhcPkgCmd-ghc-pkg}" --show-package editline >/dev/null 2>&1; then - fp_cv_ghc_has_editline=yes +AC_CACHE_CHECK([whether ghc has readline package], [fp_cv_ghc_has_readline], +[if "${GhcPkgCmd-ghc-pkg}" describe readline >/dev/null 2>&1; then + fp_cv_ghc_has_readline=yes else - fp_cv_ghc_has_editline=no + fp_cv_ghc_has_readline=no fi]) -AC_SUBST([GhcHasEditline], [`echo $fp_cv_ghc_has_editline | sed 'y/yesno/YESNO/'`]) -])# FP_GHC_HAS_EDITLINE +AC_SUBST([GhcHasReadline], [`echo $fp_cv_ghc_has_readline | sed 'y/yesno/YESNO/'`]) +])# FP_GHC_HAS_READLINE # FP_GCC_EXTRA_FLAGS diff -rN -u old-ghc-6.10.2/compiler/ghc.cabal.in new-ghc-6.10.2/compiler/ghc.cabal.in --- old-ghc-6.10.2/compiler/ghc.cabal.in 2009-04-02 22:56:21.000000000 +0200 +++ new-ghc-6.10.2/compiler/ghc.cabal.in 2009-04-02 22:56:23.000000000 +0200 @@ -28,8 +28,8 @@ Default: False Manual: True -Flag editline - Description: Use editline +Flag readline + Description: Use readline Default: False Manual: True @@ -71,8 +71,8 @@ else Build-Depends: unix - if flag(editline) - Build-Depends: editline + if flag(readline) + Build-Depends: readline CPP-Options: -DUSE_EDITLINE GHC-Options: -Wall -fno-warn-name-shadowing -fno-warn-orphans diff -rN -u old-ghc-6.10.2/compiler/ghci/InteractiveUI.hs new-ghc-6.10.2/compiler/ghci/InteractiveUI.hs --- old-ghc-6.10.2/compiler/ghci/InteractiveUI.hs 2009-04-02 22:56:21.000000000 +0200 +++ new-ghc-6.10.2/compiler/ghci/InteractiveUI.hs 2009-04-02 22:56:23.000000000 +0200 @@ -66,7 +66,7 @@ #ifdef USE_EDITLINE import Control.Concurrent ( yield ) -- Used in readline loop -import System.Console.Editline.Readline as Readline +import System.Console.Readline as Readline #endif --import SystemExts @@ -96,6 +96,10 @@ import Data.IORef ( IORef, readIORef, writeIORef ) +#ifdef USE_EDITLINE +import System.Posix.Internals ( setNonBlockingFD ) +#endif + ----------------------------------------------------------------------------- ghciWelcomeMsg :: String @@ -322,10 +326,6 @@ when is_tty $ withReadline $ do Readline.initialize - withGhcAppData - (\dir -> Readline.readHistory (dir "ghci_history")) - (return True) - Readline.setAttemptedCompletionFunction (Just completeWord) --Readline.parseAndBind "set show-all-if-ambiguous 1" @@ -360,9 +360,6 @@ #ifdef USE_EDITLINE liftIO $ do - Readline.stifleHistory 100 - withGhcAppData (\dir -> Readline.writeHistory (dir "ghci_history")) - (return True) Readline.resetTerminal Nothing #endif @@ -634,11 +631,9 @@ return (Just str) withReadline :: IO a -> IO a -withReadline = bracket_ stopTimer startTimer - -- editline doesn't handle some of its system calls returning - -- EINTR, so our timer signal confuses it, hence we turn off - -- the timer signal when making calls to editline. (#2277) - -- If editline is ever fixed, we can remove this. +withReadline = flip finally (setNonBlockingFD 0) + -- 1. readline sometimes puts stdin into blocking mode, + -- so we need to put it back for the IO library -- These come from the RTS foreign import ccall unsafe startTimer :: IO () diff -rN -u old-ghc-6.10.2/compiler/ghci/Linker.lhs new-ghc-6.10.2/compiler/ghci/Linker.lhs --- old-ghc-6.10.2/compiler/ghci/Linker.lhs 2009-04-02 22:56:21.000000000 +0200 +++ new-ghc-6.10.2/compiler/ghci/Linker.lhs 2009-04-02 22:56:23.000000000 +0200 @@ -953,7 +953,7 @@ partOfGHCi | isWindowsTarget || isDarwinTarget = [] | otherwise = map PackageName - ["base", "haskell98", "template-haskell", "editline"] + ["base", "haskell98", "template-haskell", "readline"] showLS :: LibrarySpec -> String showLS (Object nm) = "(static) " ++ nm diff -rN -u old-ghc-6.10.2/compiler/Makefile new-ghc-6.10.2/compiler/Makefile --- old-ghc-6.10.2/compiler/Makefile 2009-04-02 22:56:21.000000000 +0200 +++ new-ghc-6.10.2/compiler/Makefile 2009-04-02 22:56:23.000000000 +0200 @@ -118,15 +118,15 @@ CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DDEBUGGER endif -# Enable editline if: -# - we're building stage 2/3, and we have built the editline package +# Enable readline if: +# - we're building stage 2/3, and we have built the readline package # -# But we don't enable editline on Windows, as Windows terminals have -# editline-like support builtin. +# But we don't enable readline on Windows, as Windows terminals have +# readline-like support builtin. # ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32" -ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/editline/unbuildable)" "" -CONFIGURE_FLAGS_STAGE2 += --flags=editline +ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/readline/unbuildable)" "" +CONFIGURE_FLAGS_STAGE2 += --flags=readline endif endif endif diff -rN -u old-ghc-6.10.2/configure.ac new-ghc-6.10.2/configure.ac --- old-ghc-6.10.2/configure.ac 2009-04-02 22:56:21.000000000 +0200 +++ new-ghc-6.10.2/configure.ac 2009-04-02 22:56:23.000000000 +0200 @@ -679,8 +679,8 @@ AC_SUBST(ghc_ge_609)dnl fi -# Check whether this GHC has editline installed -FP_GHC_HAS_EDITLINE +# Check whether this GHC has readline installed +FP_GHC_HAS_READLINE # Dummy arguments to print help for --with-editline-* arguments. # Those are actually passed to the editline package's configure script diff -rN -u old-ghc-6.10.2/libraries/ifBuildable.hs new-ghc-6.10.2/libraries/ifBuildable.hs --- old-ghc-6.10.2/libraries/ifBuildable.hs 2009-04-02 22:56:22.000000000 +0200 +++ new-ghc-6.10.2/libraries/ifBuildable.hs 2009-04-02 22:56:23.000000000 +0200 @@ -36,5 +36,5 @@ requiredLines = filter ((3 == ) . length) $ map words nonCommentLines requiredLibraries = [ x | 'l':'i':'b':'r':'a':'r':'i':'e':'s':'/':x <- map head requiredLines ] - return $ filter ("editline" /=) requiredLibraries + return $ filter ("readline" /=) requiredLibraries diff -rN -u old-ghc-6.10.2/libraries/Makefile new-ghc-6.10.2/libraries/Makefile --- old-ghc-6.10.2/libraries/Makefile 2009-04-02 22:56:22.000000000 +0200 +++ new-ghc-6.10.2/libraries/Makefile 2009-04-02 22:56:23.000000000 +0200 @@ -46,7 +46,7 @@ ifeq "$(Windows)" "YES" SUBDIRS += $(wildcard Win32) endif -SUBDIRS += directory process pretty hpc template-haskell editline Cabal random haskell98 +SUBDIRS += directory process pretty hpc template-haskell readline Cabal random haskell98 # Set GhcBootLibs=YES from the command line to work with just the libraries # needed to bootstrap GHC. diff -rN -u old-ghc-6.10.2/Makefile new-ghc-6.10.2/Makefile --- old-ghc-6.10.2/Makefile 2009-04-02 22:56:21.000000000 +0200 +++ new-ghc-6.10.2/Makefile 2009-04-02 22:56:23.000000000 +0200 @@ -393,7 +393,7 @@ echo "HaveLibGmp = $(HaveLibGmp)" >> $(BIN_DIST_VARFILE) echo "GhcLibsWithUnix = $(GhcLibsWithUnix)" >> $(BIN_DIST_VARFILE) echo "GhcWithInterpreter = $(GhcWithInterpreter)" >> $(BIN_DIST_VARFILE) - echo "GhcHasEditline = $(GhcHasEditline)" >> $(BIN_DIST_VARFILE) + echo "GhcHasReadline = $(GhcHasReadline)" >> $(BIN_DIST_VARFILE) echo "BootingFromHc = $(BootingFromHc)" >> $(BIN_DIST_VARFILE) echo "XMLDocWays = $(XMLDocWays)" >> $(BIN_DIST_VARFILE) # We won't actually use xsltproc, but we need to know if it's "" or not diff -rN -u old-ghc-6.10.2/mk/config.mk.in new-ghc-6.10.2/mk/config.mk.in --- old-ghc-6.10.2/mk/config.mk.in 2009-04-02 22:56:22.000000000 +0200 +++ new-ghc-6.10.2/mk/config.mk.in 2009-04-02 22:56:23.000000000 +0200 @@ -891,8 +891,8 @@ GHC = @WithGhc@ GhcDir = $(dir $(GHC)) -# Set to YES if $(GHC) has the editline package installed -GhcHasEditline = @GhcHasEditline@ +# Set to YES if $(GHC) has the readline package installed +GhcHasReadline = @GhcHasReadline@ HBC = @HBC@ NHC = @NHC@