[binutils-gdb] Import readline 7.0 (patch 5)

Tom Tromey tromey@sourceware.org
Mon Aug 12 16:59:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=775e241e9c5f2b2ff2b59972ab70e5f20763fae6

commit 775e241e9c5f2b2ff2b59972ab70e5f20763fae6
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Oct 7 12:52:13 2018 -0600

    Import readline 7.0 (patch 5)
    
    This imports readline 7.0 (up to patch 5) while preserving all
    gdb-local changes.
    
    This was done by checking out the readline git repository, making a
    branch based on the gdb baseline revision, applying the gdb changes to
    that branch, and then merging from readline 7.
    
    readline/ChangeLog.gdb
    2019-08-12  Tom Tromey  <tom@tromey.com>
    
    	* Imported readline 7.0 patch 5.

Diff:
---
 readline/.gitignore                     |   37 +
 readline/CHANGELOG                      |  211 +++
 readline/CHANGES                        |  324 +++++
 readline/ChangeLog.gdb                  |    4 +
 readline/INSTALL                        |    2 +-
 readline/MANIFEST                       |   11 +-
 readline/Makefile.in                    |   60 +-
 readline/NEWS                           |  302 +++-
 readline/README                         |   11 +-
 readline/aclocal.m4                     |   40 +-
 readline/bind.c                         |  424 ++++--
 readline/callback.c                     |  113 +-
 readline/chardefs.h                     |   20 +-
 readline/colors.c                       |  279 ++++
 readline/colors.h                       |  126 ++
 readline/complete.c                     |  519 +++++--
 readline/config.h.in                    |   50 +-
 readline/configure                      |  344 ++++-
 readline/{configure.in => configure.ac} |   35 +-
 readline/display.c                      |  703 +++++++---
 readline/doc/Makefile.in                |   21 +-
 readline/doc/history.3                  |   33 +-
 readline/doc/history.texi               |   26 +-
 readline/doc/hstech.texi                |   17 +-
 readline/doc/hsuser.texi                |   41 +-
 readline/doc/readline.3                 |  182 ++-
 readline/doc/rlman.texi                 |   27 +-
 readline/doc/rltech.texi                |  309 +++-
 readline/doc/rluser.texi                |  345 ++++-
 readline/doc/rluserman.texi             |   27 +-
 readline/doc/texi2dvi                   | 2336 ++++++++++++++++++++++++-------
 readline/doc/texi2html                  |    6 +-
 readline/doc/version.texi               |   12 +-
 readline/examples/Makefile.in           |   56 +-
 readline/examples/excallback.c          |    7 +-
 readline/examples/fileman.c             |   18 +
 readline/examples/hist_erasedups.c      |  119 ++
 readline/examples/hist_purgecmd.c       |  149 ++
 readline/examples/readlinebuf.h         |    6 +-
 readline/examples/rl-callbacktest.c     |  115 ++
 readline/examples/rl.c                  |    1 +
 readline/examples/rlbasic.c             |   29 +
 readline/examples/rlfe/config.h.in      |    6 +-
 readline/examples/rlfe/configure        |   15 +-
 readline/examples/rlfe/configure.in     |    4 +-
 readline/examples/rlfe/extern.h         |    2 +-
 readline/examples/rlfe/os.h             |    8 +-
 readline/examples/rlfe/rlfe.c           |    9 +-
 readline/examples/rlptytest.c           |   14 +-
 readline/examples/rlversion.c           |    1 +
 readline/funmap.c                       |   14 +-
 readline/histexpand.c                   |  116 +-
 readline/histfile.c                     |  306 +++-
 readline/histlib.h                      |    3 -
 readline/history.c                      |   72 +-
 readline/history.h                      |   20 +-
 readline/input.c                        |  115 +-
 readline/isearch.c                      |  151 +-
 readline/kill.c                         |  104 +-
 readline/macro.c                        |   42 +-
 readline/mbutil.c                       |   15 +-
 readline/misc.c                         |   43 +-
 readline/nls.c                          |   35 +-
 readline/parens.c                       |   28 +-
 readline/parse-colors.c                 |  440 ++++++
 readline/parse-colors.h                 |   46 +
 readline/patchlevel                     |    2 +-
 readline/posixdir.h                     |   14 +-
 readline/posixjmp.h                     |   20 +-
 readline/readline.c                     |  266 +++-
 readline/readline.h                     |   78 +-
 readline/readline.pc.in                 |   12 +
 readline/rlconf.h                       |   22 +-
 readline/rldefs.h                       |   10 +-
 readline/rlmbutil.h                     |   51 +-
 readline/rlprivate.h                    |   68 +-
 readline/rlstdc.h                       |   12 +
 readline/rltty.c                        |   67 +-
 readline/rltypedefs.h                   |   11 +-
 readline/search.c                       |  100 +-
 readline/shell.c                        |   48 +-
 readline/shlib/Makefile.in              |   85 +-
 readline/signals.c                      |  157 ++-
 readline/support/config.guess           |   42 +-
 readline/support/config.sub             |    5 +-
 readline/support/mkdist                 |   15 +-
 readline/support/shlib-install          |    9 +-
 readline/support/shobj-conf             |   71 +-
 readline/tcap.h                         |    2 +-
 readline/terminal.c                     |   66 +-
 readline/text.c                         |   92 +-
 readline/tilde.c                        |   10 +-
 readline/undo.c                         |   48 +-
 readline/util.c                         |   80 +-
 readline/vi_keymap.c                    |    7 +-
 readline/vi_mode.c                      |  291 +++-
 96 files changed, 9072 insertions(+), 1795 deletions(-)

diff --git a/readline/.gitignore b/readline/.gitignore
new file mode 100644
index 0000000..be107bb
--- /dev/null
+++ b/readline/.gitignore
@@ -0,0 +1,37 @@
+Makefile
+
+*.o
+*.a
+*.so
+*.sl
+*.dll
+
+config.cache
+config.h
+config.log
+config.status
+
+doc/Makefile
+examples/Makefile
+shlib/Makefile
+
+examples/fileman
+examples/hist_erasedups
+examples/hist_purgecmd
+examples/histexamp
+examples/rl
+examples/rl-callbacktest
+examples/rlbasic
+examples/rlcat
+examples/rlevent
+examples/rltest
+examples/rlversion
+
+libhistory.so.*
+libreadline.so.*
+
+*.dylib
+
+readline.pc
+
+stamp-h
diff --git a/readline/CHANGELOG b/readline/CHANGELOG
index 5513f12..6794591 100644
--- a/readline/CHANGELOG
+++ b/readline/CHANGELOG
@@ -1093,3 +1093,214 @@ xfree.c
 				   -----
 {examples,shlib}/Makefile.in
 	- Cygwin-based changes from Eric Blake <eblake@redhat.com>
+
+				 3/26/2011
+				 ---------
+Makefile.in
+	- don't ignore failures when building, installing, or cleaning in
+	  the shlib subdirectory.  Sample patch from Mike Frysinger
+	  <vapier@gentoo.org>
+
+shlib/Makefile.in
+	- split the install and uninstall targets into install-supported and
+	  install-unsupported targets that depend on the value of
+	  SHLIB_STATUS
+
+				    4/2
+				    ---
+{,shlib}/Makefile.in
+	- add dependency for callback.o/callback.so on xmalloc.h.  From
+	  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+{,doc,examples,shlib}/Makefile.in
+	- fix typo: htm target should be html.  From Jan Kratochvil
+	  <jan.kratochvil@redhat.com>
+	- remove `.' from VPATH.  From Jan Kratochvil
+	   <jan.kratochvil@redhat.com>
+
+examples/rlfe/configure.in
+	- quote AC_PROGRAM_SOURCE.  From Jan Kratochvil
+	   <jan.kratochvil@redhat.com>
+
+				   5/17
+				   ----
+config.h.in
+	- WCWIDTH_BROKEN: new define, picked up from bash, defined on systems
+	  where wcwidth returns 1 for Unicode combining characters
+
+				   11/28
+				   -----
+support/shlib-install
+	- make sure solaris2 systems make the installed shared library
+	  executable.  ldd warns about it otherwise.  Bug and fix from
+	  Tim Mooney <tim.mooney@ndsu.edu>
+
+examples/hist_erasedups.c
+	- new example program, shows how to erase duplicates from the history
+	  list
+
+examples/hist_purgecmd.c
+	- new example program, shows how to remove all entries matching a
+	  string or pattern from the history list
+
+				 1/12/2012
+				 ---------
+colors.[ch],parse-colors.[ch]}
+	- new files, part of color infrastructure support
+
+Makefile.in,shlib/Makefile.in
+	- arrange to have colors.o and parse-colors.o added to library
+	  (static and shared versions)
+
+{configure,config.h}.in
+	- check for stdbool.h, define HAVE_STDBOOL_H if found
+
+rldefs.h
+	- COLOR_SUPPORT: if defined, compile in colors.c and parse-colors.c
+	  for color support
+
+				   1/18
+				   ----
+
+{configure,config.h}.in
+        - new check: check for AUDIT_USER_TTY defined in <linux/audit.h>,
+          define HAVE_DECL_AUDIT_USER_TTY if both are found
+
+				    8/7
+				    ---
+configure.in
+	- AC_CANONICAL_BUILD: call to set the build_xxx variables
+	- use $build_os instead of $host_os to decide when DJGPP should run
+	  `pwd.exe' to figure out the build directory.  Report and fix from
+	  Yao Qi <yao@codesourcery.com>
+
+				   8/29
+				   ----
+configure.ac
+	- new name for configure.in
+
+MANIFEST,Makefile.in
+	- configure.in -> configure.ac
+
+				 1/5/2013
+				 --------
+configure.ac
+	- move version number up to 6.3
+
+				   1/31
+				   ----
+configure.ac
+	- use AC_CHECK_TOOL instead of AC_CHECK_PROG to check for ar, since it
+	  will find $host-prefixed versions of utilities.  Report and fix from
+	  Mike Frysinger <vapier@gentoo.org>
+
+				    3/4
+				    ---
+Makefile.in
+        - PACKAGE_TARNAME, docdir: new variables substituted by autoconf
+        - OTHER_DOCS,OTHER_INSTALLED_DOCS: new variables with auxiliary
+	  documentation files to be installed into $(docdir)
+        - install: add new rule to install $(OTHER_DOCS)
+        - uninstall: add new rule to uninstall $(docdir)/$(OTHER_INSTALLED_DOCS)
+
+				   4/29
+				   ----
+Makefile.in
+	- installdirs: make sure to create $(DESTDIR)$(docdir).  Report from
+	  <hiroo.hayashi@computer.org>
+
+				 1/27/2014
+				 ---------
+Makefile.in
+	- install-examples: should not depend on `shared', since the examples
+	  themselves are not built using shared libraries.  Report from
+	  <hiroo.hayashi@computer.org>
+
+support/shobj-conf
+	- [from bash] darwin: changed the install_name embedded into the
+	  shared library to contain only the major version number, not the
+	  minor one. The idea is that the minor versions should all be API/ABI
+	  compatible, and it is better to link automatically with the latest
+	  one.  Idea from Max Horn <max@quendi.de>
+
+				 2/26/2014
+				 ---------
+[readline-6.3 released]
+
+				   3/14
+				   ----
+shlib/Makefile.in
+	- fix typo in dependency list for vi_mode.so: it should not depend on
+	  just $(topdir). Report and fix from Natanael Copa
+	  <ncopa@alpinelinux.org>
+
+				   4/15
+				   ----
+{.,shlib,examples}/Makefile.in
+	- make sure $(INCLUDES) appears before $(CPPFLAGS) in the various
+	  CFLAGS assignments so readline looks in its own source and build
+	  directories (INCLUDES) before some directories specified by the
+	  user or builder (CPPFLAGS).  Report and fix from Max Horn
+	  <max@quendi.de>
+
+				    6/2
+				    ---
+config.h.in
+	- use correct symbols: HAVE_STRUCT_DIRENT_D_INO, HAVE_STRUCT_DIRENT_D_FILENO
+	  HAVE_STRUCT_DIRENT_D_NAMLEN.  They don't really matter, but they are
+	  what posixdir.h looks for.  Report from Ross Burton <ross.burton@intel.com>
+
+				   6/11
+				   ----
+readline.pc.in
+	- new file, config file for pkgconfig. Patch to add from Jirka Klimes
+	  <jklimes@redhat.com>
+
+{MANIFEST,configure.ac,Makefile.in}
+	- readline.pc: changes to create file for pkgconfig
+
+				   10/13
+				   -----
+doc/Makefile.in
+	- readline.pdf, history.pdf, rluserman.pdf: use texi2dvi --pdf to generate
+	  these.  Suggestion from Siep Kroonenberg <siepo@cybercomm.nl>
+
+				   11/29
+				   -----
+config.h.in
+        - HAVE_PSELECT: define if pselect(2) available
+
+configure.ac
+        - check for pselect(2), define HAVE_PSELECT if found
+
+				   12/29
+				   -----
+configure.ac
+	- bump version number up to 6.4
+
+				 1/6/2015
+				 --------
+configure.ac,config.h.in
+	- look for ncurses/termcap.h, define HAVE_NCURSES_TERMCAP_H
+
+				   4/20
+				   ----
+configure.ac
+	- add template definitions set by AC_USE_SYSTEM_EXTENSIONS from a report
+	  from Andreas Schwab <schwab@linux-m68k.org>
+
+				   4/24
+				   ----
+configure.ac,config.h.in
+	- add check for sys/ioctl.h to AC_CHECK_HEADERS, define HAVE_SYS_IOCTL_H
+	  if found
+
+				   5/29
+				   ----
+configure.ac
+	- bump library version to 7.0 because of addition of rl_callback_sigcleanup
+
+				   8/26
+				   ----
+configure.ac,Makefile.in,examples/Makefile.in
+	- remove references to purify
diff --git a/readline/CHANGES b/readline/CHANGES
index 9d58988..b5e16b7 100644
--- a/readline/CHANGES
+++ b/readline/CHANGES
@@ -1,3 +1,327 @@
+This document details the changes between this version, readline-7.0, and the
+previous version, readline-6.3.
+
+1.  Changes to Readline
+
+a.  A bug that caused vi-mode `.' to be unable to redo `c', `d', and `y'
+    commands with modifiers was fixed.
+
+b.  Fixed a bug that caused callback mode to dump core when reading a
+    multiple-key sequence (e.g., arrow keys).
+
+c.  Fixed a bug that caused the redisplay code to erase some of the line when
+    using horizontal scrolling with incremental search.
+
+d.  Readline's input handler now performs signal processing if read(2) is
+    interrupted by SIGALRM or SIGVTALRM.
+
+e.  Fixed a problem with revert-all-at-newline freeing freed memory.
+
+f.  Clarified the documentation for the history_quotes_inhibit_expansion
+    variable to note that it inhibits scanning for the history comment
+    character and that it only affects double-quoted strings.
+
+g.  Fixed an off-by-one error in the prompt printed when performing searches.
+
+h.  Use pselect(2), if available, to wait for input before calling read(2), so
+    a SIGWINCH can interrupt it, since it doesn't interrupt read(2).
+
+i.  Some memory leaks caused by signals interrupting filename completion have
+    been fixed.
+
+j.  Reading EOF twice on a non-empty line causes EOF to be returned, rather
+    than the partial line.  This can cause partial lines to be executed on
+    SIGHUP, for example.
+
+k.  Fixed a bug concerning deleting multibyte characters from the search
+    string while performing an incremental search.
+
+l.  Fixed a bug with tilde expanding directory names in filename completion.
+
+m.  Fixed a bug that did not allow binding sequences beginning with a `\'.
+
+n.  Fixed a redisplay bug involving incorrect line wrapping when the prompt
+    contains a multibyte character in the last screen column.
+
+o.  Fixed a bug that caused history expansion to disregard characters that are
+    documented to delimit a history event specifier without requiring `:'.
+
+p.  Fixed a bug that could cause reading past the end of a string when reading
+    the value when binding the set of isearch terminators.
+
+q.  Fixed a bug that caused readline commands that depend on knowing which  
+    key invoked them to misbehave when dispatching key sequences that are
+    prefixes of other key bindings. 
+
+r.  Paren matching now works in vi insert mode.
+
+s.  Colored completion prefixes are now displayed using a different color, less
+    likely to collide with files.
+
+t.  Fixed a bug that caused vi-mode character search to misbehave when
+    running in callback mode.
+
+u.  Fixed a bug that caused output to be delayed when input is coming from a
+    macro in vi-mode.
+
+v.  Fixed a bug that caused the vi-mode `.' command to misbehave when redoing
+    a multi-key key sequence via a macro.
+
+w.  Fixed a bug that caused problems with applications that supply their own
+    input function when performing completion.
+
+x.  When read returns -1/EIO when attempting to read a key, return an error
+    instead of line termination back to the caller.
+
+y.  Updated tty auditing feature based on patch from Red Hat.
+
+z.  Fixed a bug that could cause the history library to crash on overflows
+    introduced by malicious editing of timestamps in the history file.
+
+aa. The history file writing functions only attempt to create and use a backup
+    history file if the history file exists and is a regular file.
+
+bb. Fixed an out-of-bounds read in readline's internal tilde expansion interface.
+
+cc. Fixed several redisplay bugs with prompt strings containing multibyte
+    and non-visible characters whose physical length is longer than the screen
+    width.
+
+dd. Fixed a redisplay bug with prompt strings containing invisible characters
+    whose physical length exceeds the screen width and using incremental search.
+
+ee. Readline prints more descriptive error messages when it encounters errors
+    while reading an inputrc file.
+
+ff. Fixed a bug in the character insertion code that attempts to optimize
+    typeahead when it reads a character that is not bound to self-insert and
+    resets the key sequence state.
+
+gg.  When refreshing the line as the result of a key sequence, Readline attempts
+     to redraw only the last line of a multiline prompt.
+
+hh.  Fixed an issue that caused completion of git commands to display
+     incorrectly when using colored-completion-prefix.
+
+ii.  Fixed several redisplay bugs having to do with multibyte characters and
+     invisible characters in prompt strings.
+
+jj. Fixed a bug that caused mode strings to be displayed incorrectly if the
+    prompt was shorter than the mode string.
+
+2.  New Features in Readline
+
+a.  The history truncation code now uses the same error recovery mechansim as
+    the history writing code, and restores the old version of the history file
+    on error.  The error recovery mechanism handles symlinked history files.
+
+b.  There is a new bindable variable, `enable-bracketed-paste', which enables
+    support for a terminal's bracketed paste mode.
+
+c.  The editing mode indicators can now be strings and are user-settable
+    (new `emacs-mode-string', `vi-cmd-mode-string' and `vi-ins-mode-string'
+    variables).  Mode strings can contain invisible character sequences.
+    Setting mode strings to null strings restores the defaults.
+
+d.  Prompt expansion adds the mode string to the last line of a multi-line
+    prompt (one with embedded newlines).
+
+e.  There is a new bindable variable, `colored-completion-prefix', which, if
+    set, causes the common prefix of a set of possible completions to be
+    displayed in color.
+
+f.  There is a new bindable command `vi-yank-pop', a vi-mode version of emacs-
+    mode yank-pop.
+
+g.  The redisplay code underwent several efficiency improvements for multibyte
+    locales.
+
+h.  The insert-char function attempts to batch-insert all pending typeahead
+    that maps to self-insert, as long as it is coming from the terminal.
+
+i.  rl_callback_sigcleanup: a new application function that can clean up and
+    unset any state set by readline's callback mode.  Intended to be used
+    after a signal.
+
+j.  If an incremental search string has its last character removed with DEL, the
+    resulting empty search string no longer matches the previous line.
+
+k.  If readline reads a history file that begins with `#' (or the value of
+    the history comment character) and has enabled history timestamps, the history
+    entries are assumed to be delimited by timestamps.  This allows multi-line
+    history entries.
+
+l.  Readline now throws an error if it parses a key binding without a terminating
+    `:' or whitespace.
+
+m.  The default binding for ^W in vi mode now uses word boundaries specified
+    by Posix (vi-unix-word-rubout is bindable command name).
+
+n.  rl_clear_visible_line: new application-callable function; clears all
+    screen lines occupied by the current visible readline line.
+
+o.  rl_tty_set_echoing: application-callable function that controls whether
+    or not readline thinks it is echoing terminal output.
+
+p.  Handle >| and strings of digits preceding and following redirection
+    specifications as single tokens when tokenizing the line for history
+    expansion.
+
+q.  Fixed a bug with displaying completions when the prefix display length
+    is greater than the length of the completions to be displayed.
+
+r.  The :p history modifier now applies to the entire line, so any expansion
+    specifying :p causes the line to be printed instead of expanded.
+
+s.  New application-callable function: rl_pending_signal(): returns the signal
+    number of any signal readline has caught but not yet handled.
+    
+t.  New application-settable variable: rl_persistent_signal_handlers: if set
+    to a non-zero value, readline will enable the readline-6.2 signal handler
+    behavior in callback mode: handlers are installed when
+    rl_callback_handler_install is called and removed removed when a complete
+    line has been read.
+
+-------------------------------------------------------------------------------
+This document details the changes between this version, readline-6.3, and the
+previous version, readline-6.2.
+
+1.  Changes to Readline
+
+a.  Fixed a bug that did not allow the `dd', `cc', or `yy' vi editing mode
+    commands to work on the entire line.
+
+b.  Fixed a bug that caused redisplay problems with prompts longer than 128
+    characters and history searches.
+
+c.  Fixed a bug that caused readline to try and run code to modify its idea
+    of the screen size in a signal handler context upon receiving a SIGWINCH.
+
+d.  Fixed a bug that caused the `meta' key to be enabled beyond the duration
+    of an individual call top readline().
+    
+e.  Added a workaround for a wcwidth bug in Mac OS X that caused readline's
+    redisplay to mishandle zero-width combining characters.
+
+f.  Fixed a bug that caused readline to `forget' part of a key sequence when
+    a multiple-key sequence caused it to break out of an incremental search.
+
+g.  Fixed bugs that caused readline to execute code in a signal handler
+    context if interrupted while reading from the file system during completion.
+
+h.  Fixed a bug that caused readline to `forget' part of a key sequence when
+    reading an unbound multi-character key sequence.
+
+i.  Fixed a bug that caused Readline's signal handlers to be installed beyond
+    the bounds of a single call to readline().
+
+j.  Fixed a bug that caused the `.' command to not redo the most recent `R'
+    command in vi mode.
+
+k.  Fixed a bug that caused ignoring case in completion matches to result in
+    readline using the wrong match.
+
+l.  Paren matching now works in vi insert mode.
+
+m.  Fix menu-completion to make show-all-if-ambiguous and menu-complete-display-prefix
+    work together.
+
+n.  Fixed a bug that didn't allow the `cc', `dd', or `yy' commands to be redone
+    in vi editing mode.
+
+o.  Fixed a bug that caused the filename comparison code to not compare
+    multibyte characters correctly when using case-sensitive or case-mapping
+    comparisons.
+
+p.  Fixed the input reading loop to call the input hook function only when there
+    is no terminal input available.
+
+q.  Fixed a bug that caused binding a macro to a multi-character key sequence
+    where the sequence and macro value share a common prefix to not perform
+    the macro replacement.
+
+r.  Fixed several redisplay errors with multibyte characters and prompts
+    containing invisible characters when using horizontal scrolling.
+
+s.  Fixed a bug that caused redisplay errors when trying to overwrite
+    existing characters using multibyte characters.
+
+t.  Fixed a bug in vi mode that caused the arrow keys to set the saved last
+    vi-mode command to the wrong value.
+
+u.  Fixed a bug that caused double-quoted strings to be scanned incorrectly
+    when being used as the value of a readline variable assignment.
+
+v.  Fixed a bug with vi mode that prevented `.' from repeating a command
+    entered on a previous line (command).
+
+w.  Fixed a bug that could cause completion to core dump if it was interrupted
+    by a signal.
+
+x. Fixed a bug that could cause readline to crash and seg fault attempting to
+   expand an empty history entry.
+
+y. Fixed a bug that caused display problems with multi-line prompts containing
+   invisible characters on multiple lines.
+   
+z. Fixed a bug that caused effects made by undoing changes to a history line to
+   be discarded.
+
+2.  New Features in Readline
+
+a.  Readline is now more responsive to SIGHUP and other fatal signals when
+    reading input from the terminal or performing word completion but no
+    longer attempts to run any not-allowable functions from a signal handler
+    context.
+
+b.  There are new bindable commands to search the history for the string of
+    characters between the beginning of the line and the point
+    (history-substring-search-forward, history-substring-search-backward)
+
+c.  Readline allows quoted strings as the values of variables when setting
+    them with `set'.  As a side effect, trailing spaces and tabs are ignored
+    when setting a string variable's value.
+
+d.  The history library creates a backup of the history file when writing it
+    and restores the backup on a write error.
+
+e.  New application-settable variable: rl_filename_stat_hook: a function called
+    with a filename before using it in a call to stat(2).  Bash uses it to
+    expand shell variables so things like $HOME/Downloads have a slash
+    appended.
+
+f.  New bindable function `print-last-kbd-macro', prints the most-recently-
+    defined keyboard macro in a reusable format.
+
+g.  New user-settable variable `colored-stats', enables use of colored text
+    to denote file types when displaying possible completions (colored analog
+    of visible-stats).
+
+h.  New user-settable variable `keyseq-timout', acts as an inter-character
+    timeout when reading input or incremental search strings.
+
+i.  New application-callable function: rl_clear_history. Clears the history list
+    and frees all readline-associated private data.
+
+j.  New user-settable variable, show-mode-in-prompt, adds a characters to the
+    beginning of the prompt indicating the current editing mode.
+
+k.  New application-settable variable: rl_input_available_hook; function to be
+    called when readline needs to check whether there is data available on its
+    input source.  The default hook checks rl_instream.
+
+l.  Readline calls an application-set event hook (rl_signal_event_hook) after
+    it gets a signal while reading input (read returns -1/EINTR but readline    
+    does not handle the signal immediately) to allow the application to handle
+    or otherwise note it.  Not currently called for SIGHUP or SIGTERM.
+    
+m.  If the user-settable variable `history-size' is set to a value less than
+    0, the history list size is unlimited.
+
+n.  When creating shared libraries on Mac OS X, the pathname written into the
+    library (install_name) no longer includes the minor version number.
+
+-------------------------------------------------------------------------------
 This document details the changes between this version, readline-6.2,
 and the previous version, readline-6.1.
 
diff --git a/readline/ChangeLog.gdb b/readline/ChangeLog.gdb
index e71ee96..fb53dc6 100644
--- a/readline/ChangeLog.gdb
+++ b/readline/ChangeLog.gdb
@@ -1,3 +1,7 @@
+2019-08-12  Tom Tromey  <tom@tromey.com>
+
+	* Imported readline 7.0 patch 5.
+
 2019-07-12  Tom de Vries  <tdevries@suse.de>
 	    Chet Ramey  <chet.ramey@case.edu>
 
diff --git a/readline/INSTALL b/readline/INSTALL
index a0b0976..e1a92d3 100644
--- a/readline/INSTALL
+++ b/readline/INSTALL
@@ -1,7 +1,7 @@
 Basic Installation
 ==================
 
-These are installation instructions for Readline-6.2.
+These are installation instructions for Readline-7.0.
 
 The simplest way to compile readline is:
 
diff --git a/readline/MANIFEST b/readline/MANIFEST
index 8972bdd..bfd0547 100644
--- a/readline/MANIFEST
+++ b/readline/MANIFEST
@@ -18,13 +18,16 @@ USAGE		f
 aclocal.m4	f
 config.h.in	f
 configure	f
-configure.in	f
+configure.ac	f
 Makefile.in	f
+readline.pc.in	f
 ansi_stdlib.h	f
 chardefs.h	f
+colors.h	f
 history.h	f
 histlib.h	f
 keymaps.h	f
+parse-colors.h	f
 posixdir.h	f
 posixjmp.h	f
 posixselect.h	f
@@ -44,6 +47,7 @@ tilde.h		f
 xmalloc.h	f
 bind.c		f
 callback.c	f
+colors.c	f
 compat.c	f
 complete.c	f
 display.c	f
@@ -58,6 +62,7 @@ mbutil.c	f
 misc.c		f
 nls.c		f
 parens.c	f
+parse-colors.c	f
 readline.c	f
 rltty.c		f
 savestring.c	f
@@ -110,13 +115,17 @@ examples/fileman.c	f
 examples/manexamp.c	f
 examples/readlinebuf.h	f
 examples/rl-fgets.c	f
+examples/rlbasic.c	f
 examples/rlcat.c	f
 examples/rlevent.c	f
 examples/rltest.c	f
+examples/rl-callbacktest.c	f
 examples/rl.c		f
 examples/rlptytest.c	f
 examples/rlversion.c	f
 examples/histexamp.c	f
+examples/hist_erasedups.c	f
+examples/hist_purgecmd.c	f
 examples/Inputrc	f
 examples/autoconf/BASH_CHECK_LIB_TERMCAP	f
 examples/autoconf/RL_LIB_READLINE_VERSION	f
diff --git a/readline/Makefile.in b/readline/Makefile.in
index f4ed811..0916d33 100644
--- a/readline/Makefile.in
+++ b/readline/Makefile.in
@@ -26,6 +26,8 @@ PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+
 srcdir = @srcdir@
 VPATH = @srcdir@
 top_srcdir = @top_srcdir@
@@ -43,8 +45,6 @@ RM = rm -f
 CP = cp
 MV = mv
 
-PURIFY = @PURIFY@
-
 @SET_MAKE@
 SHELL = @MAKE_SHELL@
 
@@ -62,6 +62,8 @@ localedir = @localedir@
 
 infodir = @infodir@
 
+docdir = @docdir@
+
 man3dir = $(mandir)/man3
 
 # Support an alternate destination root directory for package building
@@ -83,7 +85,7 @@ TERMCAP_LIB = @TERMCAP_LIB@
 # For libraries which include headers from other libraries.
 INCLUDES = -I. -I$(srcdir)
 
-XCCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES)
+XCCFLAGS = $(DEFS) $(LOCAL_DEFS) $(INCLUDES) $(CPPFLAGS)
 CCFLAGS = $(XCCFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
 
 # could add -Werror here
@@ -121,14 +123,17 @@ HSOURCES = $(srcdir)/readline.h $(srcdir)/rldefs.h $(srcdir)/chardefs.h \
 	   $(srcdir)/tilde.h $(srcdir)/rlconf.h $(srcdir)/rltty.h \
 	   $(srcdir)/ansi_stdlib.h $(srcdir)/tcap.h $(srcdir)/rlstdc.h \
 	   $(srcdir)/xmalloc.h $(srcdir)/rlprivate.h $(srcdir)/rlshell.h \
-	   $(srcdir)/rltypedefs.h $(srcdir)/rlmbutil.h
+	   $(srcdir)/rltypedefs.h $(srcdir)/rlmbutil.h \
+	   $(srcdir)/colors.h $(srcdir)/parse-colors.h
 
 HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o mbutil.o
 TILDEOBJ = tilde.o
+COLORSOBJ = colors.o parse-colors.o
 OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
 	  rltty.o complete.o bind.o isearch.o display.o signals.o \
 	  util.o kill.o undo.o macro.o input.o callback.o terminal.o \
-	  text.o nls.o misc.o compat.o xfree.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)
+	  text.o nls.o misc.o $(HISTOBJ) $(TILDEOBJ) $(COLORSOBJ) \
+	  xmalloc.o xfree.o compat.o
 
 # The texinfo files which document this library.
 DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
@@ -138,12 +143,15 @@ DOCUMENTATION = $(DOCSOURCE) $(DOCOBJECT) $(DOCSUPPORT)
 
 CREATED_MAKEFILES = Makefile doc/Makefile examples/Makefile shlib/Makefile
 CREATED_CONFIGURE = config.status config.h config.cache config.log \
-		    stamp-config stamp-h
+		    stamp-config stamp-h readline.pc
 CREATED_TAGS = TAGS tags
 
 INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h \
 		    rlstdc.h rlconf.h rltypedefs.h
 
+OTHER_DOCS = $(srcdir)/CHANGES $(srcdir)/INSTALL $(srcdir)/README
+OTHER_INSTALLED_DOCS = CHANGES INSTALL README
+
 ##########################################################################
 TARGETS = @STATIC_TARGET@ @SHARED_TARGET@
 INSTALL_TARGETS = @STATIC_INSTALL_TARGET@ @SHARED_INSTALL_TARGET@
@@ -193,13 +201,13 @@ stamp-h: config.status $(srcdir)/config.h.in
 	CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status
 	echo > $@
 
-#$(srcdir)/configure: $(srcdir)/configure.in	## Comment-me-out in distribution
+#$(srcdir)/configure: $(srcdir)/configure.ac	## Comment-me-out in distribution
 #	cd $(srcdir) && autoconf	## Comment-me-out in distribution
 
 
 shared:	force
 	-test -d shlib || mkdir shlib
-	-( cd shlib ; ${MAKE} ${MFLAGS} all )
+	( cd shlib ; ${MAKE} ${MFLAGS} all )
 
 documentation: force
 	-test -d doc || mkdir doc
@@ -245,7 +253,7 @@ install-static: installdirs $(STATIC_LIBS) install-headers install-doc install-e
 installdirs: $(srcdir)/support/mkinstalldirs
 	-$(SHELL) $(srcdir)/support/mkinstalldirs $(DESTDIR)$(includedir) \
 		$(DESTDIR)$(includedir)/readline $(DESTDIR)$(libdir) \
-		$(DESTDIR)$(infodir) $(DESTDIR)$(man3dir)
+		$(DESTDIR)$(infodir) $(DESTDIR)$(man3dir) $(DESTDIR)$(docdir)
 
 uninstall: uninstall-headers uninstall-doc uninstall-examples
 	-test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \
@@ -253,24 +261,26 @@ uninstall: uninstall-headers uninstall-doc uninstall-examples
 	-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
 
 install-shared: installdirs install-headers shared install-doc
-	-( cd shlib ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
+	( cd shlib ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
 	
 uninstall-shared: maybe-uninstall-headers
 	-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
 
-install-examples: installdirs install-headers shared
+install-examples: installdirs install-headers
 	-( cd examples ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
 	
 uninstall-examples: maybe-uninstall-headers
 	-( cd examples; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
 
 install-doc:	installdirs
+	$(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir)
 	-( if test -d doc ; then \
 		cd doc && \
 		${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} install; \
 	  fi )
 
 uninstall-doc:
+	-( cd $(DESTDIR)$(docdir) && ${RM} ${OTHER_INSTALLED_DOCS} )
 	-( if test -d doc ; then \
 		cd doc && \
 		${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} uninstall; \
@@ -285,23 +295,26 @@ tags:	force
 clean:	force
 	$(RM) $(OBJECTS) $(STATIC_LIBS)
 	$(RM) readline readline.exe
-	-( cd shlib && $(MAKE) $(MFLAGS) $@ )
+	( cd shlib && $(MAKE) $(MFLAGS) $@ )
 	-( cd doc && $(MAKE) $(MFLAGS) $@ )
 	-( cd examples && $(MAKE) $(MFLAGS) $@ )
 
 mostlyclean: clean
-	-( cd shlib && $(MAKE) $(MFLAGS) $@ )
+	( cd shlib && $(MAKE) $(MFLAGS) $@ )
 	-( cd doc && $(MAKE) $(MFLAGS) $@ )
 	-( cd examples && $(MAKE) $(MFLAGS) $@ )
 
 distclean maintainer-clean: clean
-	-( cd shlib && $(MAKE) $(MFLAGS) $@ )
+	( cd shlib && $(MAKE) $(MFLAGS) $@ )
 	-( cd doc && $(MAKE) $(MFLAGS) $@ )
 	-( cd examples && $(MAKE) $(MFLAGS) $@ )
 	$(RM) Makefile
 	$(RM) $(CREATED_CONFIGURE)
 	$(RM) $(CREATED_TAGS)
 
+readline.pc:	config.status $(srcdir)/readline.pc.in
+	$(SHELL) config.status
+
 info dvi html pdf ps:
 	-( cd doc && $(MAKE) $(MFLAGS) $@ )
 
@@ -332,7 +345,8 @@ bind.o: history.h
 callback.o: rlconf.h
 callback.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
 callback.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
-compat.o: rlstdc.h
+compat.o: ${BUILD_DIR}/config.h
+compat.o: rlstdc.h rltypedefs.h
 complete.o: ansi_stdlib.h posixdir.h posixstat.h
 complete.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
 complete.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
@@ -393,6 +407,7 @@ readline.o: posixstat.h ansi_stdlib.h posixjmp.h
 rltty.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
 rltty.o: rltty.h
 rltty.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
+savestring.o: ${BUILD_DIR}/config.h
 search.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
 search.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
 search.o: ansi_stdlib.h history.h rlstdc.h
@@ -426,6 +441,14 @@ xfree.o: ansi_stdlib.h readline.h
 xmalloc.o: ${BUILD_DIR}/config.h
 xmalloc.o: ansi_stdlib.h
 
+colors.o: ${BUILD_DIR}/config.h colors.h
+colors.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
+colors.o: rlconf.h  
+colors.o: ansi_stdlib.h posixstat.h
+parse-colors.o: ${BUILD_DIR}/config.h colors.h parse-colors.h
+parse-colors.o: rldefs.h rlconf.h
+parse-colors.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
+
 bind.o: rlshell.h
 histfile.o: rlshell.h
 nls.o: rlshell.h
@@ -455,6 +478,8 @@ text.o: rlprivate.h
 undo.o: rlprivate.h
 util.o: rlprivate.h
 vi_mode.o: rlprivate.h
+colors.o: rlprivate.h
+parse-colors.o: rlprivate.h
 
 bind.o: xmalloc.h
 callback.o: xmalloc.h
@@ -483,6 +508,8 @@ util.o: xmalloc.h
 vi_mode.o: xmalloc.h
 xfree.o: xmalloc.h
 xmalloc.o: xmalloc.h
+colors.o: xmalloc.h
+parse-colors.o: xmalloc.h
 
 complete.o: rlmbutil.h
 display.o: rlmbutil.h
@@ -526,6 +553,9 @@ vi_mode.o: $(srcdir)/vi_mode.c
 xfree.o: $(srcdir)/xfree.c
 xmalloc.o: $(srcdir)/xmalloc.c
 
+colors.o: $(srcdir)/parse-colors.c
+parse-colors.o: $(srcdir)/parse-colors.c
+
 histexpand.o: $(srcdir)/histexpand.c
 histfile.o: $(srcdir)/histfile.c
 history.o: $(srcdir)/history.c
diff --git a/readline/NEWS b/readline/NEWS
index 0ec6e09..cf7107e 100644
--- a/readline/NEWS
+++ b/readline/NEWS
@@ -1,19 +1,293 @@
-This is a terse description of the new features added to readline-6.2 since
-the release of readline-6.1.
+This is a terse description of the new features added to readline-7.0 since
+the release of readline-6.3.
 
-a.  The history library does not try to write the history filename in the
-    current directory if $HOME is unset.  This closes a potential security
-    problem if the application does not specify a history filename.
+New Features in Readline
 
-b.  New bindable variable `completion-display-width' to set the number of
-    columns used when displaying completions.
+a.  The history truncation code now uses the same error recovery mechansim as
+    the history writing code, and restores the old version of the history file
+    on error.  The error recovery mechanism handles symlinked history files.
 
-c.  New bindable variable `completion-case-map' to cause case-insensitive
-    completion to treat `-' and `_' as identical.
+b.  There is a new bindable variable, `enable-bracketed-paste', which enables
+    support for a terminal's bracketed paste mode.
 
-d.  There are new bindable vi-mode command names to avoid readline's case-
-    insensitive matching not allowing them to be bound separately.
+c.  The editing mode indicators can now be strings and are user-settable
+    (new `emacs-mode-string', `vi-cmd-mode-string' and `vi-ins-mode-string'
+    variables).  Mode strings can contain invisible character sequences.
+    Setting mode strings to null strings restores the defaults.
 
-e.  New bindable variable `menu-complete-display-prefix' causes the menu
-    completion code to display the common prefix of the possible completions
-    before cycling through the list, instead of after.
+d.  Prompt expansion adds the mode string to the last line of a multi-line
+    prompt (one with embedded newlines).
+
+e.  There is a new bindable variable, `colored-completion-prefix', which, if
+    set, causes the common prefix of a set of possible completions to be
+    displayed in color.
+
+f.  There is a new bindable command `vi-yank-pop', a vi-mode version of emacs-
+    mode yank-pop.
+
+g.  The redisplay code underwent several efficiency improvements for multibyte
+    locales.
+
+h.  The insert-char function attempts to batch-insert all pending typeahead
+    that maps to self-insert, as long as it is coming from the terminal.
+
+i.  rl_callback_sigcleanup: a new application function that can clean up and
+    unset any state set by readline's callback mode.  Intended to be used
+    after a signal.
+
+j.  If an incremental search string has its last character removed with DEL, the
+    resulting empty search string no longer matches the previous line.
+
+k.  If readline reads a history file that begins with `#' (or the value of
+    the history comment character) and has enabled history timestamps, the history
+    entries are assumed to be delimited by timestamps.  This allows multi-line
+    history entries.
+
+l.  Readline now throws an error if it parses a key binding without a terminating
+    `:' or whitespace.
+
+-------------------------------------------------------------------------------
+This is a terse description of the new features added to readline-6.3 since
+the release of readline-6.2.
+
+New Features in Readline
+
+a.  Readline is now more responsive to SIGHUP and other fatal signals when
+    reading input from the terminal or performing word completion but no
+    longer attempts to run any not-allowable functions from a signal handler
+    context.
+
+b.  There are new bindable commands to search the history for the string of
+    characters between the beginning of the line and the point
+    (history-substring-search-forward, history-substring-search-backward)
+
+c.  Readline allows quoted strings as the values of variables when setting
+    them with `set'.  As a side effect, trailing spaces and tabs are ignored
+    when setting a string variable's value.
+
+d.  The history library creates a backup of the history file when writing it
+    and restores the backup on a write error.
+
+e.  New application-settable variable: rl_filename_stat_hook: a function called
+    with a filename before using it in a call to stat(2).  Bash uses it to
+    expand shell variables so things like $HOME/Downloads have a slash
+    appended.
+
+f.  New bindable function `print-last-kbd-macro', prints the most-recently-
+    defined keyboard macro in a reusable format.
+
+g.  New user-settable variable `colored-stats', enables use of colored text
+    to denote file types when displaying possible completions (colored analog
+    of visible-stats).
+
+h.  New user-settable variable `keyseq-timout', acts as an inter-character
+    timeout when reading input or incremental search strings.
+
+i.  New application-callable function: rl_clear_history. Clears the history list
+    and frees all readline-associated private data.
+
+j.  New user-settable variable, show-mode-in-prompt, adds a characters to the
+    beginning of the prompt indicating the current editing mode.
+
+k.  New application-settable variable: rl_input_available_hook; function to be
+    called when readline detects there is data available on its input file
+    descriptor.
+
+l.  Readline calls an application-set event hook (rl_event_hook) after it gets
+    a signal while reading input (read returns -1/EINTR but readline does not
+    handle the signal immediately) to allow the application to handle or
+    otherwise note it.
+
+m.  If the user-settable variable `history-size' is set to a value less than
+    0, the history list size is unlimited.
+
+n.  New application-settable variable: rl_signal_event_hook; function that is
+    called when readline is reading terminal input and read(2) is interrupted
+    by a signal.  Currently not called for SIGHUP or SIGTERM.
+
+-------------------------------------------------------------------------------
+This is a terse description of the new features added to readline-6.1 since
+the release of readline-6.0.
+
+New Features in Readline
+
+a.  New bindable function: menu-complete-backward.
+
+b.  In the vi insertion keymap, C-n is now bound to menu-complete by default,
+    and C-p to menu-complete-backward.
+
+c.  When in vi command mode, repeatedly hitting ESC now does nothing, even
+    when ESC introduces a bound key sequence.  This is closer to how
+    historical vi behaves.
+
+d.  New bindable function: skip-csi-sequence.  Can be used as a default to
+    consume key sequences generated by keys like Home and End without having
+    to bind all keys.
+
+e.  New application-settable function: rl_filename_rewrite_hook.  Can be used
+    to rewite or modify filenames read from the file system before they are
+    compared to the word to be completed.
+
+f.  New bindable variable: skip-completed-text, active when completing in the
+    middle of a word.  If enabled, it means that characters in the completion
+    that match characters in the remainder of the word are "skipped" rather
+    than inserted into the line.
+
+g.  The pre-readline-6.0 version of menu completion is available as
+    "old-menu-complete" for users who do not like the readline-6.0 version.
+
+h.  New bindable variable: echo-control-characters.  If enabled, and the
+    tty ECHOCTL bit is set, controls the echoing of characters corresponding
+    to keyboard-generated signals.
+
+i.  New bindable variable: enable-meta-key.  Controls whether or not readline
+    sends the smm/rmm sequences if the terminal indicates it has a meta key
+    that enables eight-bit characters.
+
+-------------------------------------------------------------------------------
+This is a terse description of the new features added to readline-6.0 since
+the release of readline-5.2.
+
+New Features in Readline
+
+a.  A new variable, rl_sort_completion_matches; allows applications to inhibit
+    match list sorting (but beware: some things don't work right if
+    applications do this).
+
+b.  A new variable, rl_completion_invoking_key; allows applications to discover
+    the key that invoked rl_complete or rl_menu_complete.
+
+c.  The functions rl_block_sigint and rl_release_sigint are now public and
+    available to calling applications who want to protect critical sections
+    (like redisplay).
+
+d.  The functions rl_save_state and rl_restore_state are now public and
+    available to calling applications; documented rest of readline's state
+    flag values.
+
+e.  A new user-settable variable, `history-size', allows setting the maximum
+    number of entries in the history list.
+
+f.  There is a new implementation of menu completion, with several improvements
+    over the old; the most notable improvement is a better `completions
+    browsing' mode.
+
+g.  The menu completion code now uses the rl_menu_completion_entry_function
+    variable, allowing applications to provide their own menu completion
+    generators.
+
+h.  There is support for replacing a prefix  of a pathname with a `...' when
+    displaying possible completions.  This is controllable by setting the
+    `completion-prefix-display-length' variable.  Matches with a common prefix
+    longer than this value have the common prefix replaced with `...'.
+
+i.  There is a new `revert-all-at-newline' variable.  If enabled, readline will
+    undo all outstanding changes to all history lines when `accept-line' is
+    executed.
+
+-------------------------------------------------------------------------------
+This is a terse description of the new features added to readline-5.2 since
+the release of readline-5.1.
+
+New Features in Readline
+
+a.  Calling applications can now set the keyboard timeout to 0, allowing
+    poll-like behavior.
+
+b.  The value of SYS_INPUTRC (configurable at compilation time) is now used as
+    the default last-ditch startup file.
+
+c.  The history file reading functions now allow windows-like \r\n line
+    terminators.
+
+-------------------------------------------------------------------------------
+This is a terse description of the new features added to readline-5.1 since
+the release of readline-5.0.
+
+New Features in Readline
+
+a.  The key sequence sent by the keypad `delete' key is now automatically   
+    bound to delete-char.
+
+b.  A negative argument to menu-complete now cycles backward through the
+    completion list.
+
+c.  A new bindable readline variable:  bind-tty-special-chars.  If non-zero,
+    readline will bind the terminal special characters to their readline
+    equivalents when it's called (on by default).
+
+d.  New bindable command: vi-rubout.  Saves deleted text for possible  
+    reinsertion, as with any vi-mode `text modification' command; `X' is bound
+    to this in vi command mode.
+
+e.  If the rl_completion_query_items is set to a value < 0, readline never
+    asks the user whether or not to view the possible completions.
+
+f.  New application-callable auxiliary function, rl_variable_value, returns
+    a string corresponding to a readline variable's value.
+
+g.  When parsing inputrc files and variable binding commands, the parser
+    strips trailing whitespace from values assigned to boolean variables
+    before checking them.
+
+h.  A new external application-controllable variable that allows the LINES
+    and COLUMNS environment variables to set the window size regardless of
+    what the kernel returns.
+
+
+-------------------------------------------------------------------------------
+This is a terse description of the new features added to readline-5.0 since
+the release of readline-4.3.
+
+New Features in Readline
+
+a.  History expansion has a new `a' modifier equivalent to the `g' modifier
+    for compatibility with the BSD csh.
+
+b.  History expansion has a new `G' modifier equivalent to the BSD csh `g'
+    modifier, which performs a substitution once per word.
+
+c.  All non-incremental search operations may now undo the operation of
+    replacing the current line with the history line.
+
+d.  The text inserted by an `a' command in vi mode can be reinserted with
+    `.'.
+
+e.  New bindable variable, `show-all-if-unmodified'.  If set, the readline
+    completer will list possible completions immediately if there is more
+    than one completion and partial completion cannot be performed.
+
+f.  There is a new application-callable `free_history_entry()' function.
+
+g.  History list entries now contain timestamp information; the history file
+    functions know how to read and write timestamp information associated
+    with each entry.
+
+h.  Four new key binding functions have been added:
+
+	rl_bind_key_if_unbound()
+	rl_bind_key_if_unbound_in_map()
+	rl_bind_keyseq_if_unbound()
+	rl_bind_keyseq_if_unbound_in_map()
+
+i.  New application variable, rl_completion_quote_character, set to any
+    quote character readline finds before it calls the application completion
+    function.
+
+j.  New application variable, rl_completion_suppress_quote, settable by an   
+    application completion function.  If set to non-zero, readline does not
+    attempt to append a closing quote to a completed word.
+    
+k.  New application variable, rl_completion_found_quote, set to a non-zero
+    value if readline determines that the word to be completed is quoted.
+    Set before readline calls any application completion function.
+
+l.  New function hook, rl_completion_word_break_hook, called when readline
+    needs to break a line into words when completion is attempted.  Allows
+    the word break characters to vary based on position in the line.
+
+m.  New bindable command: unix-filename-rubout.  Does the same thing as
+    unix-word-rubout, but adds `/' to the set of word delimiters.
+
+n.  When listing completions, directories have a `/' appended if the
+    `mark-directories' option has been enabled.
diff --git a/readline/README b/readline/README
index bc89f46..6a9c2b9 100644
--- a/readline/README
+++ b/readline/README
@@ -1,7 +1,7 @@
 Introduction
 ============
 
-This is the Gnu Readline library, version 6.2.
+This is the Gnu Readline library, version 7.0.
 
 The Readline library provides a set of functions for use by applications
 that allow users to edit command lines as they are typed in.  Both
@@ -159,6 +159,15 @@ Readline library.  The texinfo files include both user and
 programmer's manuals.  HTML versions of the manuals appear in the
 `doc' subdirectory as well. 
 
+Usage
+=====
+
+Our position on the use of Readline through a shared-library linking
+mechanism is that there is no legal difference between shared-library
+linking and static linking--either kind of linking combines various
+modules into a single larger work.  The conditions for using Readline
+in a larger work are stated in section 3 of the GNU GPL.
+
 Reporting Bugs
 ==============
 
diff --git a/readline/aclocal.m4 b/readline/aclocal.m4
index 716a043..d3bac07 100644
--- a/readline/aclocal.m4
+++ b/readline/aclocal.m4
@@ -1692,13 +1692,14 @@ AC_CHECK_HEADERS(wctype.h)
 AC_CHECK_HEADERS(wchar.h)
 AC_CHECK_HEADERS(langinfo.h)
 
+AC_CHECK_HEADERS(mbstr.h)
+
 AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN))
 AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCMP))
 AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP))
 AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS))
 AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))
 
-
 AC_REPLACE_FUNCS(mbschr)
 
 AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB))
@@ -1763,9 +1764,36 @@ if test $bash_cv_type_wint_t = yes; then
         AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])
 fi
 
+dnl check for broken wcwidth
+AC_CACHE_CHECK([for wcwidth broken with unicode combining characters],
+bash_cv_wcwidth_broken,
+[AC_TRY_RUN([
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <locale.h>
+#include <wchar.h>
+
+main(c, v)
+int     c;
+char    **v;
+{
+        int     w;
+
+        setlocale(LC_ALL, "en_US.UTF-8");
+        w = wcwidth (0x0301);
+        exit (w == 0);  /* exit 0 if wcwidth broken */
+}
+],
+bash_cv_wcwidth_broken=yes, bash_cv_wcwidth_broken=no, bash_cv_wcwidth_broken=no)])
+if test "$bash_cv_wcwidth_broken" = yes; then
+        AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken])
+fi
+
 if test "$am_cv_func_iconv" = yes; then
 	OLDLIBS="$LIBS"
-	LIBS="$LIBS $LIBICONV"
+	LIBS="$LIBS $LIBINTL $LIBICONV"
 	AC_CHECK_FUNCS(locale_charset)
 	LIBS="$OLDLIBS"
 fi
@@ -1828,7 +1856,7 @@ main()
 ],
 ac_cv_rl_version=`cat conftest.rlv`,
 ac_cv_rl_version='0.0',
-ac_cv_rl_version='4.2')])
+ac_cv_rl_version='6.3')])
 
 CFLAGS="$_save_CFLAGS"
 LDFLAGS="$_save_LDFLAGS"
@@ -3098,7 +3126,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
           found_so=
           found_a=
           if test $use_additional = yes; then
-            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+            if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
               found_dir="$additional_libdir"
               found_so="$additional_libdir/lib$name.$shlibext"
               if test -f "$additional_libdir/lib$name.la"; then
@@ -3120,7 +3148,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
               case "$x" in
                 -L*)
                   dir=`echo "X$x" | sed -e 's/^X-L//'`
-                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                  if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
                     found_dir="$dir"
                     found_so="$dir/lib$name.$shlibext"
                     if test -f "$dir/lib$name.la"; then
@@ -4123,7 +4151,7 @@ main()
 AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET,
 [AC_MSG_CHECKING(for offset of exit status in return status from wait)
 AC_CACHE_VAL(bash_cv_wexitstatus_offset,
-[AC_RUN_IFELSE([
+[AC_TRY_RUN([
 #include <stdlib.h>
 #include <unistd.h>
 
diff --git a/readline/bind.c b/readline/bind.c
index a939528..f1098c4 100644
--- a/readline/bind.c
+++ b/readline/bind.c
@@ -1,6 +1,6 @@
 /* bind.c -- key binding and startup file support for the readline library. */
 
-/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -72,11 +72,20 @@ extern char *strchr (), *strrchr ();
 /* Variables exported by this file. */
 Keymap rl_binding_keymap;
 
+static int _rl_skip_to_delim PARAMS((char *, int, int));
+
+#if defined (USE_VARARGS) && defined (PREFER_STDARG)
+static void _rl_init_file_error (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
+#else
+static void _rl_init_file_error ();
+#endif
+
 static char *_rl_read_file PARAMS((char *, size_t *));
-static void _rl_init_file_error PARAMS((const char *));
 static int _rl_read_init_file PARAMS((const char *, int));
 static int glean_key_from_name PARAMS((char *));
+
 static int find_boolean_var PARAMS((const char *));
+static int find_string_var PARAMS((const char *));
 
 static char *_rl_get_string_variable_value PARAMS((const char *));
 static int substring_member_of_array PARAMS((const char *, const char * const *));
@@ -113,6 +122,9 @@ rl_bind_key (key, function)
      int key;
      rl_command_func_t *function;
 {
+  char keyseq[3];
+  int l;
+
   if (key < 0)
     return (key);
 
@@ -131,8 +143,24 @@ rl_bind_key (key, function)
       return (key);
     }
 
-  _rl_keymap[key].type = ISFUNC;
-  _rl_keymap[key].function = function;
+  /* If it's bound to a function or macro, just overwrite.  Otherwise we have
+     to treat it as a key sequence so rl_generic_bind handles shadow keymaps
+     for us.  If we are binding '\' make sure to escape it so it makes it
+     through the call to rl_translate_keyseq. */
+  if (_rl_keymap[key].type != ISKMAP)
+    {
+      _rl_keymap[key].type = ISFUNC;
+      _rl_keymap[key].function = function;
+    }
+  else
+    {
+      l = 0;
+      if (key == '\\')
+	keyseq[l++] = '\\';
+      keyseq[l++] = key;
+      keyseq[l] = '\0';
+      rl_bind_keyseq (keyseq, function);
+    }
   rl_binding_keymap = _rl_keymap;
   return (0);
 }
@@ -538,7 +566,7 @@ rl_translate_keyseq (seq, array, len)
 	    case '0': case '1': case '2': case '3':
 	    case '4': case '5': case '6': case '7':
 	      i++;
-	      for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++)
+	      for (temp = 2, c -= '0'; ISOCTAL ((unsigned char)seq[i]) && temp--; i++)
 	        c = (c * 8) + OCTVALUE (seq[i]);
 	      i--;	/* auto-increment in for loop */
 	      array[l++] = c & largest_char;
@@ -567,6 +595,40 @@ rl_translate_keyseq (seq, array, len)
   return (0);
 }
 
+static int
+_rl_isescape (c)
+     int c;
+{
+  switch (c)
+    {
+    case '\007':
+    case '\b':
+    case '\f':
+    case '\n':
+    case '\r':
+    case TAB:
+    case 0x0b:  return (1);
+    default: return (0);
+    }
+}
+
+static int
+_rl_escchar (c)
+     int c;
+{
+  switch (c)
+    {
+    case '\007':  return ('a');
+    case '\b':  return ('b');
+    case '\f':  return ('f');
+    case '\n':  return ('n');
+    case '\r':  return ('r');
+    case TAB:  return ('t');
+    case 0x0b:  return ('v');
+    default: return (c);
+    }
+}
+
 char *
 rl_untranslate_keyseq (seq)
      int seq;
@@ -618,9 +680,10 @@ rl_untranslate_keyseq (seq)
   return kseq;
 }
 
-static char *
-_rl_untranslate_macro_value (seq)
+char *
+_rl_untranslate_macro_value (seq, use_escapes)
      char *seq;
+     int use_escapes;
 {
   char *ret, *r, *s;
   int c;
@@ -644,9 +707,14 @@ _rl_untranslate_macro_value (seq)
       else if (CTRL_CHAR (c))
 	{
 	  *r++ = '\\';
-	  *r++ = 'C';
-	  *r++ = '-';
-	  c = _rl_to_lower (UNCTRL (c));
+	  if (use_escapes && _rl_isescape (c))
+	    c = _rl_escchar (c);
+	  else
+	    {
+	      *r++ = 'C';
+	      *r++ = '-';
+	      c = _rl_to_lower (UNCTRL (c));
+	    }
 	}
       else if (c == RUBOUT)
  	{
@@ -926,14 +994,35 @@ _rl_read_init_file (filename, include_level)
 }
 
 static void
-_rl_init_file_error (msg)
-     const char *msg;
+#if defined (PREFER_STDARG)
+_rl_init_file_error (const char *format, ...)
+#else
+_rl_init_file_error (va_alist)
+     va_dcl
+#endif
 {
+  va_list args;
+#if defined (PREFER_VARARGS)
+  char *format;
+#endif
+
+#if defined (PREFER_STDARG)
+  va_start (args, format);
+#else
+  va_start (args);
+  format = va_arg (args, char *);
+#endif
+
+  fprintf (stderr, "readline: ");
   if (currently_reading_init_file)
-    _rl_errmsg ("%s: line %d: %s\n", current_readline_init_file,
-		     current_readline_init_lineno, msg);
-  else
-    _rl_errmsg ("%s", msg);
+    fprintf (stderr, "%s: line %d: ", current_readline_init_file,
+		     current_readline_init_lineno);
+
+  vfprintf (stderr, format, args);
+  fprintf (stderr, "\n");
+  fflush (stderr);
+
+  va_end (args);
 }
 
 /* **************************************************************** */
@@ -1153,10 +1242,42 @@ handle_parser_directive (statement)
       }
 
   /* display an error message about the unknown parser directive */
-  _rl_init_file_error ("unknown parser directive");
+  _rl_init_file_error ("%s: unknown parser directive", directive);
   return (1);
 }
 
+/* Start at STRING[START] and look for DELIM.  Return I where STRING[I] ==
+   DELIM or STRING[I] == 0.  DELIM is usually a double quote. */
+static int
+_rl_skip_to_delim (string, start, delim)
+     char *string;
+     int start, delim;
+{
+  int i, c, passc;
+
+  for (i = start,passc = 0; c = string[i]; i++)
+    {
+      if (passc)
+	{
+	  passc = 0;
+	  if (c == 0)
+	    break;
+	  continue;
+	}
+
+      if (c == '\\')
+	{
+	  passc = 1;
+	  continue;
+	}
+
+      if (c == delim)
+	break;
+    }
+
+  return i;
+}
+
 /* Read the binding command from STRING and perform it.
    A key binding command looks like: Keyname: function-name\0,
    a variable binding command looks like: set variable value.
@@ -1167,12 +1288,12 @@ rl_parse_and_bind (string)
 {
   char *funname, *kname;
   register int c, i;
-  int key, equivalency;
+  int key, equivalency, foundmod, foundsep;
 
   while (string && whitespace (*string))
     string++;
 
-  if (!string || !*string || *string == '#')
+  if (string == 0 || *string == 0 || *string == '#')
     return 0;
 
   /* If this is a parser directive, act on it. */
@@ -1192,31 +1313,16 @@ rl_parse_and_bind (string)
      backslash to quote characters in the key expression. */
   if (*string == '"')
     {
-      int passc = 0;
-
-      for (i = 1; c = string[i]; i++)
-	{
-	  if (passc)
-	    {
-	      passc = 0;
-	      continue;
-	    }
-
-	  if (c == '\\')
-	    {
-	      passc++;
-	      continue;
-	    }
+      i = _rl_skip_to_delim (string, 1, '"');
 
-	  if (c == '"')
-	    break;
-	}
       /* If we didn't find a closing quote, abort the line. */
       if (string[i] == '\0')
         {
-          _rl_init_file_error ("no closing `\"' in key binding");
+          _rl_init_file_error ("%s: no closing `\"' in key binding", string);
           return 1;
         }
+      else
+        i++;	/* skip past closing double quote */
     }
 
   /* Advance to the colon (:) or whitespace which separates the two objects. */
@@ -1224,6 +1330,8 @@ rl_parse_and_bind (string)
 
   equivalency = (c == ':' && string[i + 1] == '=');
 
+  foundsep = c != 0;
+
   /* Mark the end of the command (or keyname). */
   if (string[i])
     string[i++] = '\0';
@@ -1236,6 +1344,7 @@ rl_parse_and_bind (string)
   if (_rl_stricmp (string, "set") == 0)
     {
       char *var, *value, *e;
+      int s;
 
       var = string + i;
       /* Make VAR point to start of variable name. */
@@ -1243,25 +1352,37 @@ rl_parse_and_bind (string)
 
       /* Make VALUE point to start of value string. */
       value = var;
-      while (*value && !whitespace (*value)) value++;
+      while (*value && whitespace (*value) == 0) value++;
       if (*value)
 	*value++ = '\0';
       while (*value && whitespace (*value)) value++;
 
-      /* Strip trailing whitespace from values to boolean variables.  Temp
-	 fix until I get a real quoted-string parser here. */
-      i = find_boolean_var (var);
-      if (i >= 0)
+      /* Strip trailing whitespace from values of boolean variables. */
+      if (find_boolean_var (var) >= 0)
 	{
 	  /* remove trailing whitespace */
+remove_trailing:
 	  e = value + strlen (value) - 1;
 	  while (e >= value && whitespace (*e))
 	    e--;
 	  e++;		/* skip back to whitespace or EOS */
+	  
 	  if (*e && e >= value)
 	    *e = '\0';
 	}
-
+      else if ((i = find_string_var (var)) >= 0)
+	{
+	  /* Allow quoted strings in variable values */
+	  if (*value == '"')
+	    {
+	      i = _rl_skip_to_delim (value, 1, *value);
+	      value[i] = '\0';
+	      value++;	/* skip past the quote */
+	    }
+	  else
+	    goto remove_trailing;
+	}
+	
       rl_variable_bind (var, value);
       return 0;
     }
@@ -1282,32 +1403,13 @@ rl_parse_and_bind (string)
      the quoted string delimiter, like the shell. */
   if (*funname == '\'' || *funname == '"')
     {
-      int delimiter, passc;
-
-      delimiter = string[i++];
-      for (passc = 0; c = string[i]; i++)
-	{
-	  if (passc)
-	    {
-	      passc = 0;
-	      continue;
-	    }
-
-	  if (c == '\\')
-	    {
-	      passc = 1;
-	      continue;
-	    }
-
-	  if (c == delimiter)
-	    break;
-	}
-      if (c)
+      i = _rl_skip_to_delim (string, i+1, *funname);
+      if (string[i])
 	i++;
     }
 
   /* Advance to the end of the string.  */
-  for (; string[i] && !whitespace (string[i]); i++);
+  for (; string[i] && whitespace (string[i]) == 0; i++);
 
   /* No extra whitespace at the end of the string. */
   string[i] = '\0';
@@ -1319,6 +1421,12 @@ rl_parse_and_bind (string)
       return 0;
     }
 
+  if (foundsep == 0)
+    {
+      _rl_init_file_error ("%s: no key sequence terminator", string);
+      return 1;
+    }
+
   /* If this is a new-style key-binding, then do the binding with
      rl_bind_keyseq ().  Otherwise, let the older code deal with it. */
   if (*string == '"')
@@ -1367,7 +1475,7 @@ rl_parse_and_bind (string)
 
   /* Get the actual character we want to deal with. */
   kname = strrchr (string, '-');
-  if (!kname)
+  if (kname == 0)
     kname = string;
   else
     kname++;
@@ -1375,11 +1483,24 @@ rl_parse_and_bind (string)
   key = glean_key_from_name (kname);
 
   /* Add in control and meta bits. */
+  foundmod = 0;
   if (substring_member_of_array (string, _rl_possible_control_prefixes))
-    key = CTRL (_rl_to_upper (key));
+    {
+      key = CTRL (_rl_to_upper (key));
+      foundmod = 1;
+    }
 
   if (substring_member_of_array (string, _rl_possible_meta_prefixes))
-    key = META (key);
+    {
+      key = META (key);
+      foundmod = 1;
+    }
+
+  if (foundmod == 0 && kname != string)
+    {
+      _rl_init_file_error ("%s: unknown key modifier", string);
+      return 1;
+    }
 
   /* Temporary.  Handle old-style keyname with macro-binding. */
   if (*funname == '\'' || *funname == '"')
@@ -1406,6 +1527,7 @@ rl_parse_and_bind (string)
 #endif /* PREFIX_META_HACK */
   else
     rl_bind_key (key, rl_named_function (funname));
+
   return 0;
 }
 
@@ -1423,11 +1545,16 @@ static const struct {
   { "bind-tty-special-chars",	&_rl_bind_stty_chars,		0 },
   { "blink-matching-paren",	&rl_blink_matching_paren,	V_SPECIAL },
   { "byte-oriented",		&rl_byte_oriented,		0 },
+#if defined (COLOR_SUPPORT)
+  { "colored-completion-prefix",&_rl_colored_completion_prefix,	0 },
+  { "colored-stats",		&_rl_colored_stats,		0 },
+#endif
   { "completion-ignore-case",	&_rl_completion_case_fold,	0 },
   { "completion-map-case",	&_rl_completion_case_map,	0 },
   { "convert-meta",		&_rl_convert_meta_chars_to_ascii, 0 },
   { "disable-completion",	&rl_inhibit_completion,		0 },
   { "echo-control-characters",	&_rl_echo_control_chars,	0 },
+  { "enable-bracketed-paste",	&_rl_enable_bracketed_paste,	0 },
   { "enable-keypad",		&_rl_enable_keypad,		0 },
   { "enable-meta-key",		&_rl_enable_meta,		0 },
   { "expand-tilde",		&rl_complete_with_tilde_expansion, 0 },
@@ -1447,6 +1574,7 @@ static const struct {
   { "revert-all-at-newline",	&_rl_revert_all_at_newline,	0 },
   { "show-all-if-ambiguous",	&_rl_complete_show_all,		0 },
   { "show-all-if-unmodified",	&_rl_complete_show_unmodified,	0 },
+  { "show-mode-in-prompt",	&_rl_show_mode_in_prompt,	0 },
   { "skip-completed-text",	&_rl_skip_completed_text,	0 },
 #if defined (VISIBLE_STATS)
   { "visible-stats",		&rl_visible_stats,		0 },
@@ -1486,6 +1614,8 @@ hack_special_boolean_var (i)
       else
 	_rl_bell_preference = AUDIBLE_BELL;
     }
+  else if (_rl_stricmp (name, "show-mode-in-prompt") == 0)
+    _rl_reset_prompt ();
 }
 
 typedef int _rl_sv_func_t PARAMS((const char *));
@@ -1508,9 +1638,13 @@ static int sv_dispprefix PARAMS((const char *));
 static int sv_compquery PARAMS((const char *));
 static int sv_compwidth PARAMS((const char *));
 static int sv_editmode PARAMS((const char *));
+static int sv_emacs_modestr PARAMS((const char *));
 static int sv_histsize PARAMS((const char *));
 static int sv_isrchterm PARAMS((const char *));
 static int sv_keymap PARAMS((const char *));
+static int sv_seqtimeout PARAMS((const char *));
+static int sv_viins_modestr PARAMS((const char *));
+static int sv_vicmd_modestr PARAMS((const char *));
 
 static const struct {
   const char * const name;
@@ -1523,9 +1657,13 @@ static const struct {
   { "completion-prefix-display-length", V_INT,	sv_dispprefix },
   { "completion-query-items", V_INT,	sv_compquery },
   { "editing-mode",	V_STRING,	sv_editmode },
+  { "emacs-mode-string", V_STRING,	sv_emacs_modestr },  
   { "history-size",	V_INT,		sv_histsize },
   { "isearch-terminators", V_STRING,	sv_isrchterm },
   { "keymap",		V_STRING,	sv_keymap },
+  { "keyseq-timeout",	V_INT,		sv_seqtimeout },
+  { "vi-cmd-mode-string", V_STRING,	sv_vicmd_modestr }, 
+  { "vi-ins-mode-string", V_STRING,	sv_viins_modestr }, 
   { (char *)NULL,	0, (_rl_sv_func_t *)0 }
 };
 
@@ -1542,7 +1680,7 @@ find_string_var (name)
 }
 
 /* A boolean value that can appear in a `set variable' command is true if
-   the value is null or empty, `on' (case-insenstive), or "1".  Any other
+   the value is null or empty, `on' (case-insensitive), or "1".  Any other
    values result in 0 (false). */
 static int
 bool_to_int (value)
@@ -1591,10 +1729,14 @@ rl_variable_bind (name, value)
 
   i = find_string_var (name);
 
-  /* For the time being, unknown variable names or string names without a
-     handler function are simply ignored. */
+  /* For the time being, string names without a handler function are simply
+     ignored. */
   if (i < 0 || string_varlist[i].set_func == 0)
-    return 0;
+    {
+      if (i < 0)
+	_rl_init_file_error ("%s: unknown variable name", name);
+      return 0;
+    }
 
   v = (*string_varlist[i].set_func) (value);
   return v;
@@ -1683,13 +1825,17 @@ static int
 sv_histsize (value)
      const char *value;
 {
-  int nval = 500;
+  int nval;
 
+  nval = 500;
   if (value && *value)
     {
       nval = atoi (value);
       if (nval < 0)
-	return 1;
+	{
+	  unstifle_history ();
+	  return 0;
+	}
     }
   stifle_history (nval);
   return 0;
@@ -1711,6 +1857,23 @@ sv_keymap (value)
 }
 
 static int
+sv_seqtimeout (value)
+     const char *value;
+{
+  int nval;
+
+  nval = 0;
+  if (value && *value)
+    {
+      nval = atoi (value);
+      if (nval < 0)
+	nval = 0;
+    }
+  _rl_keyseq_timeout = nval;
+  return 0;
+}
+
+static int
 sv_bell_style (value)
      const char *value;
 {
@@ -1748,7 +1911,7 @@ sv_isrchterm (value)
     }
   else
     {
-      for (beg = end = 0; whitespace (v[end]) == 0; end++)
+      for (beg = end = 0; v[end] && whitespace (v[end]) == 0; end++)
 	;
     }
 
@@ -1762,7 +1925,96 @@ sv_isrchterm (value)
   xfree (v);
   return 0;
 }
-      
+
+extern char *_rl_emacs_mode_str;
+
+static int
+sv_emacs_modestr (value)
+     const char *value;
+{
+  if (value && *value)
+    {
+      FREE (_rl_emacs_mode_str);
+      _rl_emacs_mode_str = (char *)xmalloc (2 * strlen (value) + 1);
+      rl_translate_keyseq (value, _rl_emacs_mode_str, &_rl_emacs_modestr_len);
+      _rl_emacs_mode_str[_rl_emacs_modestr_len] = '\0';
+      return 0;
+    }
+  else if (value)
+    {
+      FREE (_rl_emacs_mode_str);
+      _rl_emacs_mode_str = (char *)xmalloc (1);
+      _rl_emacs_mode_str[_rl_emacs_modestr_len = 0] = '\0';
+      return 0;
+    }
+  else if (value == 0)
+    {
+      FREE (_rl_emacs_mode_str);
+      _rl_emacs_mode_str = 0;	/* prompt_modestr does the right thing */
+      _rl_emacs_modestr_len = 0;
+      return 0;
+    }
+  return 1;
+}
+
+static int
+sv_viins_modestr (value)
+     const char *value;
+{
+  if (value && *value)
+    {
+      FREE (_rl_vi_ins_mode_str);
+      _rl_vi_ins_mode_str = (char *)xmalloc (2 * strlen (value) + 1);
+      rl_translate_keyseq (value, _rl_vi_ins_mode_str, &_rl_vi_ins_modestr_len);
+      _rl_vi_ins_mode_str[_rl_vi_ins_modestr_len] = '\0';
+      return 0;
+    }
+  else if (value)
+    {
+      FREE (_rl_vi_ins_mode_str);
+      _rl_vi_ins_mode_str = (char *)xmalloc (1);
+      _rl_vi_ins_mode_str[_rl_vi_ins_modestr_len = 0] = '\0';
+      return 0;
+    }
+  else if (value == 0)
+    {
+      FREE (_rl_vi_ins_mode_str);
+      _rl_vi_ins_mode_str = 0;	/* prompt_modestr does the right thing */
+      _rl_vi_ins_modestr_len = 0;
+      return 0;
+    }
+  return 1;
+}
+
+static int
+sv_vicmd_modestr (value)
+     const char *value;
+{
+  if (value && *value)
+    {
+      FREE (_rl_vi_cmd_mode_str);
+      _rl_vi_cmd_mode_str = (char *)xmalloc (2 * strlen (value) + 1);
+      rl_translate_keyseq (value, _rl_vi_cmd_mode_str, &_rl_vi_cmd_modestr_len);
+      _rl_vi_cmd_mode_str[_rl_vi_cmd_modestr_len] = '\0';
+      return 0;
+    }
+  else if (value)
+    {
+      FREE (_rl_vi_cmd_mode_str);
+      _rl_vi_cmd_mode_str = (char *)xmalloc (1);
+      _rl_vi_cmd_mode_str[_rl_vi_cmd_modestr_len = 0] = '\0';
+      return 0;
+    }
+  else if (value == 0)
+    {
+      FREE (_rl_vi_cmd_mode_str);
+      _rl_vi_cmd_mode_str = 0;	/* prompt_modestr does the right thing */
+      _rl_vi_cmd_modestr_len = 0;
+      return 0;
+    }
+  return 1;
+}
+
 /* Return the character which matches NAME.
    For example, `Space' returns ' '. */
 
@@ -2167,7 +2419,8 @@ rl_function_dumper (print_readably)
 	    }
 	}
     }
-  free (names);
+
+  xfree (names);
 }
 
 /* Print all of the current functions and their bindings to
@@ -2200,7 +2453,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
 	{
 	case ISMACR:
 	  keyname = _rl_get_keyname (key);
-	  out = _rl_untranslate_macro_value ((char *)map[key].function);
+	  out = _rl_untranslate_macro_value ((char *)map[key].function, 0);
 
 	  if (print_readably)
 	    fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "",
@@ -2312,7 +2565,7 @@ _rl_get_string_variable_value (name)
     {
       if (_rl_isearch_terminators == 0)
 	return 0;
-      ret = _rl_untranslate_macro_value (_rl_isearch_terminators);
+      ret = _rl_untranslate_macro_value (_rl_isearch_terminators, 0);
       if (ret)
 	{
 	  strncpy (numbuf, ret, sizeof (numbuf) - 1);
@@ -2330,6 +2583,17 @@ _rl_get_string_variable_value (name)
 	ret = rl_get_keymap_name_from_edit_mode ();
       return (ret ? ret : "none");
     }
+  else if (_rl_stricmp (name, "keyseq-timeout") == 0)
+    {
+      sprintf (numbuf, "%d", _rl_keyseq_timeout);    
+      return (numbuf);
+    }
+  else if (_rl_stricmp (name, "emacs-mode-string") == 0)
+    return (_rl_emacs_mode_str ? _rl_emacs_mode_str : RL_EMACS_MODESTR_DEFAULT);
+  else if (_rl_stricmp (name, "vi-cmd-mode-string") == 0)
+    return (_rl_vi_cmd_mode_str ? _rl_vi_cmd_mode_str : RL_VI_CMD_MODESTR_DEFAULT);
+  else if (_rl_stricmp (name, "vi-ins-mode-string") == 0)
+    return (_rl_vi_ins_mode_str ? _rl_vi_ins_mode_str : RL_VI_INS_MODESTR_DEFAULT);
   else
     return (0);
 }
diff --git a/readline/callback.c b/readline/callback.c
index 7682cd0..cc3ce11 100644
--- a/readline/callback.c
+++ b/readline/callback.c
@@ -1,6 +1,6 @@
 /* callback.c -- functions to use readline as an X `callback' mechanism. */
 
-/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -50,6 +50,14 @@
 _rl_callback_func_t *_rl_callback_func = 0;
 _rl_callback_generic_arg *_rl_callback_data = 0;
 
+/* Applications can set this to non-zero to have readline's signal handlers
+   installed during the entire duration of reading a complete line, as in
+   readline-6.2.  This should be used with care, because it can result in
+   readline receiving signals and not handling them until it's called again
+   via rl_callback_read_char, thereby stealing them from the application.
+   By default, signal handlers are only active while readline is active. */   
+int rl_persistent_signal_handlers = 0;
+
 /* **************************************************************** */
 /*								    */
 /*			Callback Readline Functions		 */
@@ -62,8 +70,10 @@ _rl_callback_generic_arg *_rl_callback_data = 0;
    whenever a complete line of input is ready.  The user must then
    call rl_callback_read_char() every time some input is available, and 
    rl_callback_read_char() will call the user's function with the complete
-   text read in at each end of line.  The terminal is kept prepped and
-   signals handled all the time, except during calls to the user's function. */
+   text read in at each end of line.  The terminal is kept prepped
+   all the time, except during calls to the user's function.  Signal
+   handlers are only installed when the application calls back into
+   readline, so readline doesn't `steal' signals from the application.  */
 
 rl_vcpfunc_t *rl_linefunc;		/* user callback function */
 static int in_handler;		/* terminal_prepped and signals set? */
@@ -82,7 +92,8 @@ _rl_callback_newline ()
 	(*rl_prep_term_function) (_rl_meta_flag);
 
 #if defined (HANDLE_SIGNALS)
-      rl_set_signals ();
+      if (rl_persistent_signal_handlers)
+	rl_set_signals ();
 #endif
     }
 
@@ -102,6 +113,17 @@ rl_callback_handler_install (prompt, linefunc)
   _rl_callback_newline ();
 }
 
+#if defined (HANDLE_SIGNALS)
+#define CALLBACK_READ_RETURN() \
+  do { \
+    if (rl_persistent_signal_handlers == 0) \
+      rl_clear_signals (); \
+    return; \
+  } while (0)
+#else
+#define CALLBACK_READ_RETURN() return
+#endif
+
 /* Read one character, and dispatch to the handler if it ends the line. */
 void
 rl_callback_read_char ()
@@ -117,15 +139,25 @@ rl_callback_read_char ()
     }
 
   memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t));
+#if defined (HAVE_POSIX_SIGSETJMP)
+  jcode = sigsetjmp (_rl_top_level, 0);
+#else
   jcode = setjmp (_rl_top_level);
+#endif
   if (jcode)
     {
       (*rl_redisplay_function) ();
       _rl_want_redisplay = 0;
       memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t));
-      return;
+      CALLBACK_READ_RETURN ();
     }
 
+#if defined (HANDLE_SIGNALS)
+  /* Install signal handlers only when readline has control. */
+  if (rl_persistent_signal_handlers == 0)
+    rl_set_signals ();
+#endif
+
   do
     {
       RL_CHECK_SIGNALS ();
@@ -135,14 +167,45 @@ rl_callback_read_char ()
 	  if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
 	    rl_callback_read_char ();
 
-	  return;
+	  CALLBACK_READ_RETURN ();
 	}
       else if  (RL_ISSTATE (RL_STATE_NSEARCH))
 	{
 	  eof = _rl_nsearch_callback (_rl_nscxt);
-	  return;
+
+	  CALLBACK_READ_RETURN ();
 	}
 #if defined (VI_MODE)
+      /* States that can occur while in state VIMOTION have to be checked
+	 before RL_STATE_VIMOTION */
+      else if (RL_ISSTATE (RL_STATE_CHARSEARCH))
+	{
+	  int k;
+
+	  k = _rl_callback_data->i2;
+
+	  eof = (*_rl_callback_func) (_rl_callback_data);
+	  /* If the function `deregisters' itself, make sure the data is
+	     cleaned up. */
+	  if (_rl_callback_func == 0)	/* XXX - just sanity check */
+	    {
+	      if (_rl_callback_data)
+		{
+		  _rl_callback_data_dispose (_rl_callback_data);
+		  _rl_callback_data = 0;
+		}
+	    }
+
+	  /* Messy case where vi motion command can be char search */
+	  if (RL_ISSTATE (RL_STATE_VIMOTION))
+	    {
+	      _rl_vi_domove_motion_cleanup (k, _rl_vimvcxt);
+	      _rl_internal_char_cleanup ();
+	      CALLBACK_READ_RETURN ();	      
+	    }
+
+	  _rl_internal_char_cleanup ();
+	}
       else if (RL_ISSTATE (RL_STATE_VIMOTION))
 	{
 	  eof = _rl_vi_domove_callback (_rl_vimvcxt);
@@ -151,7 +214,7 @@ rl_callback_read_char ()
 	  if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
 	    _rl_internal_char_cleanup ();
 
-	  return;
+	  CALLBACK_READ_RETURN ();
 	}
 #endif
       else if (RL_ISSTATE (RL_STATE_NUMERICARG))
@@ -163,7 +226,7 @@ rl_callback_read_char ()
 	  else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
 	    _rl_internal_char_cleanup ();
 
-	  return;
+	  CALLBACK_READ_RETURN ();
 	}
       else if (RL_ISSTATE (RL_STATE_MULTIKEY))
 	{
@@ -180,7 +243,7 @@ rl_callback_read_char ()
 	{
 	  /* This allows functions that simply need to read an additional
 	     character (like quoted-insert) to register a function to be
-	     called when input is available.  _rl_callback_data is simply a
+	     called when input is available.  _rl_callback_data is a
 	     pointer to a struct that has the argument count originally
 	     passed to the registering function and space for any additional
 	     parameters.  */
@@ -230,6 +293,8 @@ rl_callback_read_char ()
 	}
     }
   while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT));
+
+  CALLBACK_READ_RETURN ();
 }
 
 /* Remove the handler, and make sure the terminal is in its normal state. */
@@ -264,10 +329,36 @@ _rl_callback_data_alloc (count)
   return arg;
 }
 
-void _rl_callback_data_dispose (arg)
+void
+_rl_callback_data_dispose (arg)
      _rl_callback_generic_arg *arg;
 {
   xfree (arg);
 }
 
+/* Make sure that this agrees with cases in rl_callback_read_char */
+void
+rl_callback_sigcleanup ()
+{
+  if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
+    return;
+
+  if (RL_ISSTATE (RL_STATE_ISEARCH))
+    _rl_isearch_cleanup (_rl_iscxt, 0);
+  else if (RL_ISSTATE (RL_STATE_NSEARCH))
+    _rl_nsearch_cleanup (_rl_nscxt, 0);
+  else if (RL_ISSTATE (RL_STATE_VIMOTION))
+    RL_UNSETSTATE (RL_STATE_VIMOTION);
+  else if (RL_ISSTATE (RL_STATE_NUMERICARG))
+    {
+      _rl_argcxt = 0;
+      RL_UNSETSTATE (RL_STATE_NUMERICARG);
+    }
+  else if (RL_ISSTATE (RL_STATE_MULTIKEY))
+    RL_UNSETSTATE (RL_STATE_MULTIKEY);
+  if (RL_ISSTATE (RL_STATE_CHARSEARCH))
+    RL_UNSETSTATE (RL_STATE_CHARSEARCH);
+
+  _rl_callback_func = 0;
+}
 #endif
diff --git a/readline/chardefs.h b/readline/chardefs.h
index e76c34b..3cf1326 100644
--- a/readline/chardefs.h
+++ b/readline/chardefs.h
@@ -1,6 +1,6 @@
 /* chardefs.h -- Character definitions for readline. */
 
-/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2015 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -72,8 +72,8 @@
 #  define IN_CTYPE_DOMAIN(c) isascii(c)
 #endif
 
-#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
-#  define isxdigit(c)   (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
+#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) && !defined (__cplusplus)
+#  define isxdigit(c)   (isdigit((unsigned char)(c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
 #endif
 
 #if defined (CTYPE_NON_ASCII)
@@ -87,13 +87,13 @@
 
 /* Beware:  these only work with single-byte ASCII characters. */
 
-#define ISALNUM(c)	(IN_CTYPE_DOMAIN (c) && isalnum (c))
-#define ISALPHA(c)	(IN_CTYPE_DOMAIN (c) && isalpha (c))
-#define ISDIGIT(c)	(IN_CTYPE_DOMAIN (c) && isdigit (c))
-#define ISLOWER(c)	(IN_CTYPE_DOMAIN (c) && islower (c))
-#define ISPRINT(c)	(IN_CTYPE_DOMAIN (c) && isprint (c))
-#define ISUPPER(c)	(IN_CTYPE_DOMAIN (c) && isupper (c))
-#define ISXDIGIT(c)	(IN_CTYPE_DOMAIN (c) && isxdigit (c))
+#define ISALNUM(c)	(IN_CTYPE_DOMAIN (c) && isalnum ((unsigned char)c))
+#define ISALPHA(c)	(IN_CTYPE_DOMAIN (c) && isalpha ((unsigned char)c))
+#define ISDIGIT(c)	(IN_CTYPE_DOMAIN (c) && isdigit ((unsigned char)c))
+#define ISLOWER(c)	(IN_CTYPE_DOMAIN (c) && islower ((unsigned char)c))
+#define ISPRINT(c)	(IN_CTYPE_DOMAIN (c) && isprint ((unsigned char)c))
+#define ISUPPER(c)	(IN_CTYPE_DOMAIN (c) && isupper ((unsigned char)c))
+#define ISXDIGIT(c)	(IN_CTYPE_DOMAIN (c) && isxdigit ((unsigned char)c))
 
 #define _rl_lowercase_p(c)	(NON_NEGATIVE(c) && ISLOWER(c))
 #define _rl_uppercase_p(c)	(NON_NEGATIVE(c) && ISUPPER(c))
diff --git a/readline/colors.c b/readline/colors.c
new file mode 100644
index 0000000..7859f5d
--- /dev/null
+++ b/readline/colors.c
@@ -0,0 +1,279 @@
+/* `dir', `vdir' and `ls' directory listing programs for GNU.
+
+   Modified by Chet Ramey for Readline.
+
+   Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015
+   Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Richard Stallman and David MacKenzie.  */
+
+/* Color support by Peter Anvin <Peter.Anvin@linux.org> and Dennis
+   Flaherty <dennisf@denix.elk.miles.com> based on original patches by
+   Greg Lee <lee@uhunix.uhcc.hawaii.edu>.  */
+
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#include "rlconf.h"
+
+#include <stdio.h>
+
+#include "posixstat.h" // stat related macros (S_ISREG, ...)
+#include <fcntl.h> // S_ISUID
+
+// strlen()
+#if defined (HAVE_STRING_H)
+#  include <string.h>
+#else /* !HAVE_STRING_H */
+#  include <strings.h>
+#endif /* !HAVE_STRING_H */
+
+// abort()
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#include "readline.h"
+#include "rldefs.h"
+
+#ifdef COLOR_SUPPORT
+
+#include "xmalloc.h"
+#include "colors.h"
+
+static bool is_colored (enum indicator_no type);
+static void restore_default_color (void);
+
+COLOR_EXT_TYPE *_rl_color_ext_list = 0;
+
+/* Output a color indicator (which may contain nulls).  */
+void
+_rl_put_indicator (const struct bin_str *ind) {
+  fwrite (ind->string, ind->len, 1, rl_outstream);
+}
+
+static bool
+is_colored (enum indicator_no colored_filetype)
+{
+  size_t len = _rl_color_indicator[colored_filetype].len;
+  char const *s = _rl_color_indicator[colored_filetype].string;
+  return ! (len == 0
+            || (len == 1 && strncmp (s, "0", 1) == 0)
+            || (len == 2 && strncmp (s, "00", 2) == 0));
+}
+
+static void
+restore_default_color (void)
+{
+  _rl_put_indicator (&_rl_color_indicator[C_LEFT]);
+  _rl_put_indicator (&_rl_color_indicator[C_RIGHT]);
+}
+
+void
+_rl_set_normal_color (void)
+{
+  if (is_colored (C_NORM))
+    {
+      _rl_put_indicator (&_rl_color_indicator[C_LEFT]);
+      _rl_put_indicator (&_rl_color_indicator[C_NORM]);
+      _rl_put_indicator (&_rl_color_indicator[C_RIGHT]);
+    }
+}
+
+bool
+_rl_print_prefix_color (void)
+{
+  struct bin_str *s;
+
+  /* What do we want to use for the prefix? Let's try cyan first, see colors.h */
+  s = &_rl_color_indicator[C_PREFIX];
+  if (s->string != NULL)
+    {
+      if (is_colored (C_NORM))
+	restore_default_color ();
+      _rl_put_indicator (&_rl_color_indicator[C_LEFT]);
+      _rl_put_indicator (s);
+      _rl_put_indicator (&_rl_color_indicator[C_RIGHT]);
+      return 0;
+    }
+  else
+    return 1;
+}
+  
+/* Returns whether any color sequence was printed. */
+bool
+_rl_print_color_indicator (const char *f)
+{
+  enum indicator_no colored_filetype;
+  COLOR_EXT_TYPE *ext;	/* Color extension */
+  size_t len;		/* Length of name */
+
+  const char* name;
+  char *filename;
+  struct stat astat, linkstat;
+  mode_t mode;
+  int linkok;	/* 1 == ok, 0 == dangling symlink, -1 == missing */
+  int stat_ok;
+
+  name = f;
+
+  /* This should already have undergone tilde expansion */
+  filename = 0;
+  if (rl_filename_stat_hook)
+    {
+      filename = savestring (f);
+      (*rl_filename_stat_hook) (&filename);
+      name = filename;
+    }
+
+#if defined (HAVE_LSTAT)
+  stat_ok = lstat(name, &astat);
+#else
+  stat_ok = stat(name, &astat);
+#endif
+  if (stat_ok == 0)
+    {
+      mode = astat.st_mode;
+#if defined (HAVE_LSTAT)
+      if (S_ISLNK (mode))
+	{
+	  linkok = stat (name, &linkstat) == 0;
+	  if (linkok && strncmp (_rl_color_indicator[C_LINK].string, "target", 6) == 0)
+	    mode = linkstat.st_mode;
+	}
+      else
+#endif
+	linkok = 1;
+    }
+  else
+    linkok = -1;
+
+  /* Is this a nonexistent file?  If so, linkok == -1.  */
+
+  if (linkok == -1 && _rl_color_indicator[C_MISSING].string != NULL)
+    colored_filetype = C_MISSING;
+  else if (linkok == 0 && S_ISLNK(mode) && _rl_color_indicator[C_ORPHAN].string != NULL)
+    colored_filetype = C_ORPHAN;	/* dangling symlink */
+  else if(stat_ok != 0)
+    {
+      static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS;
+      colored_filetype = filetype_indicator[normal]; //f->filetype];
+    }
+  else
+    {
+      if (S_ISREG (mode))
+        {
+          colored_filetype = C_FILE;
+
+          if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
+            colored_filetype = C_SETUID;
+          else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
+            colored_filetype = C_SETGID;
+          else if (is_colored (C_CAP) && 0) //f->has_capability)
+            colored_filetype = C_CAP;
+          else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
+            colored_filetype = C_EXEC;
+          else if ((1 < astat.st_nlink) && is_colored (C_MULTIHARDLINK))
+            colored_filetype = C_MULTIHARDLINK;
+        }
+      else if (S_ISDIR (mode))
+        {
+          colored_filetype = C_DIR;
+
+#if defined (S_ISVTX)
+          if ((mode & S_ISVTX) && (mode & S_IWOTH)
+              && is_colored (C_STICKY_OTHER_WRITABLE))
+            colored_filetype = C_STICKY_OTHER_WRITABLE;
+          else
+#endif
+          if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
+            colored_filetype = C_OTHER_WRITABLE;
+#if defined (S_ISVTX)
+          else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY))
+            colored_filetype = C_STICKY;
+#endif
+        }
+      else if (S_ISLNK (mode))
+        colored_filetype = C_LINK;
+      else if (S_ISFIFO (mode))
+        colored_filetype = C_FIFO;
+      else if (S_ISSOCK (mode))
+        colored_filetype = C_SOCK;
+      else if (S_ISBLK (mode))
+        colored_filetype = C_BLK;
+      else if (S_ISCHR (mode))
+        colored_filetype = C_CHR;
+      else
+        {
+          /* Classify a file of some other type as C_ORPHAN.  */
+          colored_filetype = C_ORPHAN;
+        }
+    }
+
+  /* Check the file's suffix only if still classified as C_FILE.  */
+  ext = NULL;
+  if (colored_filetype == C_FILE)
+    {
+      /* Test if NAME has a recognized suffix.  */
+      len = strlen (name);
+      name += len;		/* Pointer to final \0.  */
+      for (ext = _rl_color_ext_list; ext != NULL; ext = ext->next)
+        {
+          if (ext->ext.len <= len
+              && strncmp (name - ext->ext.len, ext->ext.string,
+                          ext->ext.len) == 0)
+            break;
+        }
+    }
+
+  free (filename);	/* NULL or savestring return value */
+
+  {
+    const struct bin_str *const s
+      = ext ? &(ext->seq) : &_rl_color_indicator[colored_filetype];
+    if (s->string != NULL)
+      {
+        /* Need to reset so not dealing with attribute combinations */
+        if (is_colored (C_NORM))
+	  restore_default_color ();
+        _rl_put_indicator (&_rl_color_indicator[C_LEFT]);
+        _rl_put_indicator (s);
+        _rl_put_indicator (&_rl_color_indicator[C_RIGHT]);
+        return 0;
+      }
+    else
+      return 1;
+  }
+}
+
+void
+_rl_prep_non_filename_text (void)
+{
+  if (_rl_color_indicator[C_END].string != NULL)
+    _rl_put_indicator (&_rl_color_indicator[C_END]);
+  else
+    {
+      _rl_put_indicator (&_rl_color_indicator[C_LEFT]);
+      _rl_put_indicator (&_rl_color_indicator[C_RESET]);
+      _rl_put_indicator (&_rl_color_indicator[C_RIGHT]);
+    }
+}
+#endif /* COLOR_SUPPORT */
diff --git a/readline/colors.h b/readline/colors.h
new file mode 100644
index 0000000..6561ad9
--- /dev/null
+++ b/readline/colors.h
@@ -0,0 +1,126 @@
+/* `dir', `vdir' and `ls' directory listing programs for GNU.
+
+   Modified by Chet Ramey for Readline.
+
+   Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015
+   Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Richard Stallman and David MacKenzie.  */
+
+/* Color support by Peter Anvin <Peter.Anvin@linux.org> and Dennis
+   Flaherty <dennisf@denix.elk.miles.com> based on original patches by
+   Greg Lee <lee@uhunix.uhcc.hawaii.edu>.  */
+
+#ifndef _COLORS_H_
+#define _COLORS_H_
+
+#include <stdio.h> // size_t
+
+#if defined(__TANDEM) && defined(HAVE_STDBOOL_H) && (__STDC_VERSION__ < 199901L)
+typedef int _Bool;
+#endif
+
+#if defined (HAVE_STDBOOL_H)
+#  include <stdbool.h> // bool
+#else
+typedef int _rl_bool_t;
+
+#ifdef bool
+#  undef bool
+#endif
+#define bool _rl_bool_t
+
+#ifndef true
+#  define true 1
+#  define false 0
+#endif
+
+#endif /* !HAVE_STDBOOL_H */
+
+/* Null is a valid character in a color indicator (think about Epson
+   printers, for example) so we have to use a length/buffer string
+   type. */
+struct bin_str
+  {
+    size_t len;
+    const char *string;
+  };
+
+/* file type indicators (dir, sock, fifo, ...)
+   Default value is initialized in parse-colors.c.
+   It is then modified from the values of $LS_COLORS. */
+extern struct bin_str _rl_color_indicator[];
+
+/* The LS_COLORS variable is in a termcap-like format. */
+typedef struct _color_ext_type
+  {
+    struct bin_str ext;         	/* The extension we're looking for */
+    struct bin_str seq;         	/* The sequence to output when we do */
+    struct _color_ext_type *next;	/* Next in list */
+  } COLOR_EXT_TYPE;
+
+/* file extensions indicators (.txt, .log, .jpg, ...)
+   Values are taken from $LS_COLORS in rl_parse_colors(). */
+extern COLOR_EXT_TYPE *_rl_color_ext_list;
+
+#define FILETYPE_INDICATORS				\
+  {							\
+    C_ORPHAN, C_FIFO, C_CHR, C_DIR, C_BLK, C_FILE,	\
+    C_LINK, C_SOCK, C_FILE, C_DIR			\
+  }
+
+/* Whether we used any colors in the output so far.  If so, we will
+   need to restore the default color later.  If not, we will need to
+   call prep_non_filename_text before using color for the first time. */
+
+enum indicator_no
+  {
+    C_LEFT, C_RIGHT, C_END, C_RESET, C_NORM, C_FILE, C_DIR, C_LINK,
+    C_FIFO, C_SOCK,
+    C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC, C_DOOR, C_SETUID, C_SETGID,
+    C_STICKY, C_OTHER_WRITABLE, C_STICKY_OTHER_WRITABLE, C_CAP, C_MULTIHARDLINK,
+    C_CLR_TO_EOL
+  };
+
+
+#if !S_IXUGO
+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
+#endif
+
+enum filetype
+  {
+    unknown,
+    fifo,
+    chardev,
+    directory,
+    blockdev,
+    normal,
+    symbolic_link,
+    sock,
+    whiteout,
+    arg_directory
+  };
+
+/* Prefix color, currently same as socket */
+#define C_PREFIX	C_SOCK
+
+extern void _rl_put_indicator (const struct bin_str *ind);
+extern void _rl_set_normal_color (void);
+extern bool _rl_print_prefix_color (void);
+extern bool _rl_print_color_indicator (const char *f);
+extern void _rl_prep_non_filename_text (void);
+
+#endif /* !_COLORS_H_ */
diff --git a/readline/complete.c b/readline/complete.c
index 5733d4e..ac54d76 100644
--- a/readline/complete.c
+++ b/readline/complete.c
@@ -1,6 +1,6 @@
 /* complete.c -- filename completion for readline. */
 
-/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -31,6 +31,8 @@
 #  include <sys/file.h>
 #endif
 
+#include <signal.h>
+
 #if defined (HAVE_UNISTD_H)
 #  include <unistd.h>
 #endif /* HAVE_UNISTD_H */
@@ -64,6 +66,10 @@ extern int errno;
 #include "xmalloc.h"
 #include "rlprivate.h"
 
+#if defined (COLOR_SUPPORT)
+#  include "colors.h"
+#endif
+
 #ifdef __STDC__
 typedef int QSFUNC (const void *, const void *);
 #else
@@ -94,23 +100,35 @@ extern struct passwd *getpwent PARAMS((void));
    longest string in that array. */
 rl_compdisp_func_t *rl_completion_display_matches_hook = (rl_compdisp_func_t *)NULL;
 
-#if defined (VISIBLE_STATS)
+#if defined (VISIBLE_STATS) || defined (COLOR_SUPPORT)
 #  if !defined (X_OK)
 #    define X_OK 1
 #  endif
+#endif
+
+#if defined (VISIBLE_STATS)
 static int stat_char PARAMS((char *));
 #endif
 
+#if defined (COLOR_SUPPORT)
+static int colored_stat_start PARAMS((const char *));
+static void colored_stat_end PARAMS((void));
+static int colored_prefix_start PARAMS((void));
+static void colored_prefix_end PARAMS((void));
+#endif
+
 static int path_isdir PARAMS((const char *));
 
 static char *rl_quote_filename PARAMS((char *, int, char *));
 
+static void _rl_complete_sigcleanup PARAMS((int, void *));
+
 static void set_completion_defaults PARAMS((int));
 static int get_y_or_n PARAMS((int));
 static int _rl_internal_pager PARAMS((int));
 static char *printable_part PARAMS((char *));
 static int fnwidth PARAMS((const char *));
-static int fnprint PARAMS((const char *, int));
+static int fnprint PARAMS((const char *, int, const char *));
 static int print_filename PARAMS((char *, char *, int));
 
 static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int));
@@ -156,8 +174,7 @@ int _rl_complete_mark_symlink_dirs = 0;
 int _rl_print_completions_horizontally;
 
 /* Non-zero means that case is not significant in filename completion. */
-#if defined (__MSDOS__) && !defined (__DJGPP__)	\
-  || (defined (_WIN32) && !defined (__CYGWIN__))
+#if (defined (__MSDOS__) && !defined (__DJGPP__)) || (defined (_WIN32) && !defined (__CYGWIN__))
 int _rl_completion_case_fold = 1;
 #else
 int _rl_completion_case_fold = 0;
@@ -190,6 +207,16 @@ int _rl_completion_columns = -1;
 int rl_visible_stats = 0;
 #endif /* VISIBLE_STATS */
 
+#if defined (COLOR_SUPPORT)
+/* Non-zero means to use colors to indicate file type when listing possible
+   completions.  The colors used are taken from $LS_COLORS, if set. */
+int _rl_colored_stats = 0;
+
+/* Non-zero means to use a color (currently magenta) to indicate the common
+   prefix of a set of possible word completions. */
+int _rl_colored_completion_prefix = 0;
+#endif
+
 /* If non-zero, when completing in the middle of a word, don't insert
    characters from the match that match characters following point in
    the word.  This means, for instance, completing when the cursor is
@@ -207,6 +234,8 @@ rl_icppfunc_t *rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
 
 rl_icppfunc_t *rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
 
+rl_icppfunc_t *rl_filename_stat_hook = (rl_icppfunc_t *)NULL;
+
 /* If non-zero, this is the address of a function to call when reading
    directory entries from the filesystem for completion and comparing
    them to the partial word to be completed.  The function should
@@ -381,6 +410,8 @@ static int completion_changed_buffer;
 /* The result of the query to the user about displaying completion matches */
 static int completion_y_or_n;
 
+static int _rl_complete_display_matches_interrupt = 0;
+
 /*************************************/
 /*				     */
 /*    Bindable completion functions  */
@@ -458,6 +489,18 @@ _rl_reset_completion_state ()
   rl_completion_quote_character = 0;
 }
 
+static void
+_rl_complete_sigcleanup (sig, ptr)
+     int sig;
+     void *ptr;
+{
+  if (sig == SIGINT)	/* XXX - for now */
+    {
+      _rl_free_match_list ((char **)ptr);[...]

[diff truncated at 100000 bytes]



More information about the Gdb-cvs mailing list