Sync readline/ to version 7.0 alpha

This patch syncs our upstream copy of readline from version 6.2 to the
latest version, 7.0 alpha (released July 10 2015).

I essentially copied what was done the last time readline was synced,
when Jan updated to readline 6.2 in 2011:
http://sourceware.org/ml/gdb-patches/2011-05/msg00003.html

Procedure:

1. I extracted the readline-7.0-alpha tarball on top of readline/.
2. I deleted all the new files under doc/ that were deliberately omitted
   before.
3. I regenerated readline/configure and readline/examples/rlfe/configure
   using autoconf 2.64.  No other configure files need regenerating.
4. I updated the function gdb_printable_part in completer.c with a
   trivial change made to the readline function it is based off of,
   printable_part in readline/complete.c.  There is more work to be done in
   completer.c to sync it with readline/complete.c, but it is non-trivial
   and should probably be done separately anyway.

Local patches that had to be reapplied:

    None.  readline 7.0 alpha contains all of our local readline
    patches.

New files in readline/:

    colors.{c,h}
    examples/{hist_erasedups,hist_purgecmd,rl-callbacktest,rlbasic}.c
    parse-colors.{c,h}
    readline.pc.in
    configure.ac

Deleted files in readline/:

    configure.in

Regressions:

After the sync there is one testsuite regression, the test
"signal SIGINT" in gdb.gdb/selftest.exp which now FAILs.  Previously,
the readline 6.2 SIGINT handler would temporarily reinstall the
underlying application's SIGINT handler and immediately re-raise SIGINT
so that the orginal handler gets invoked.  But now (since readline 6.3)
its SIGINT handler does not re-raise SIGINT or directly invoke the
original handler; it now sets a flag marking that SIGINT was raised, and
waits until readline explicitly has control to call the application's
SIGINT handler.  Anyway, because SIGINT is no longer re-raised from
within readline's SIGINT handler, doing "signal SIGINT" with a stopped
inferior gdb process will no longer resume and then immediately stop the
process (since there is no 2nd SIGINT to immediately catch).  Instead,
the inferior gdb process will now just print "Quit" and continue to run.
So with this commit, this particular test case is adjusted to reflect
this change in behavior (we now have to send a 2nd SIGINT manually to
stop it).

Aside from this one testsuite regression, I personally noticed no
regression in user-visible behavior.  Though I only tested on x86_64
and on i686 Debian Stretch.

Getting this kind of change in at the start of the GDB 7.11 development
cycle will allow us to get a lot of passive testing from developers and
from bleeding-edge users.

readline/ChangeLog.gdb:

	Import readline 7.0 alpha
	* configure: Regenerate.
	* examples/rlfe/configure: Regenerate.

gdb/ChangeLog:

	* completer.c (gdb_printable_part): Sync with readline function
	it is based off of.

gdb/testsuite/ChangeLog:

	* gdb.gdb/selftest.exp (test_with_self): Update test to now
	expect the GDB inferior to no longer immediately stop after
	being resumed with "signal SIGINT".
This commit is contained in:
Patrick Palka
2015-07-14 20:29:21 -04:00
parent a496fbc880
commit 4a11f20659
98 changed files with 10096 additions and 4554 deletions

View File

@@ -53,7 +53,7 @@ CPPFLAGS = @CPPFLAGS@
INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LDFLAGS = -g -L.. @LDFLAGS@
PURIFY = @PURIFY@
@@ -68,11 +68,19 @@ TERMCAP_LIB = @TERMCAP_LIB@
$(CC) $(CCFLAGS) -c $<
SOURCES = excallback.c fileman.c histexamp.c manexamp.c rl-fgets.c rl.c \
rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c
rlbasic.c rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c \
rl-callbacktest.c hist_erasedups.c hist_purgecmd.c
EXECUTABLES = fileman$(EXEEXT) rltest$(EXEEXT) rl$(EXEEXT) rlcat$(EXEEXT) \
rlevent$(EXEEXT) rlversion$(EXEEXT) histexamp$(EXEEXT)
OBJECTS = fileman.o rltest.o rl.o rlevent.o rlcat.o rlversion.o histexamp.o
rlevent$(EXEEXT) rlversion$(EXEEXT) histexamp$(EXEEXT) \
rl-callbacktest$(EXEEXT) rlbasic$(EXEEXT) \
hist_erasedups$(EXEEXT) hist_purgecmd$(EXEEXT)
OBJECTS = fileman.o rltest.o rl.o rlevent.o rlcat.o rlversion.o histexamp.o \
rl-callbacktest.o rlbasic.o hist_erasedups.o hist_purgecmd.o
OTHEREXE = rlptytest$(EXEEXT)
OTHEROBJ = rlptytest.o
all: $(EXECUTABLES)
everything: all
@@ -98,6 +106,9 @@ uninstall:
rl$(EXEEXT): rl.o $(READLINE_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rl.o $(READLINE_LIB) $(TERMCAP_LIB)
rlbasic$(EXEEXT): rlbasic.o $(READLINE_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rlbasic.o $(READLINE_LIB) $(TERMCAP_LIB)
rlcat$(EXEEXT): rlcat.o $(READLINE_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rlcat.o $(READLINE_LIB) $(TERMCAP_LIB)
@@ -110,6 +121,9 @@ fileman$(EXEEXT): fileman.o $(READLINE_LIB)
rltest$(EXEEXT): rltest.o $(READLINE_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB)
rl-callbacktest$(EXEEXT): rl-callbacktest.o $(READLINE_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rl-callbacktest.o $(READLINE_LIB) $(TERMCAP_LIB)
rlptytest$(EXEEXT): rlptytest.o $(READLINE_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rlptytest.o $(READLINE_LIB) $(TERMCAP_LIB)
@@ -119,9 +133,15 @@ rlversion$(EXEEXT): rlversion.o $(READLINE_LIB)
histexamp$(EXEEXT): histexamp.o $(HISTORY_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB)
hist_erasedups$(EXEEXT): hist_erasedups.o $(HISTORY_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ hist_erasedups.o -lhistory $(TERMCAP_LIB)
hist_purgecmd$(EXEEXT): hist_purgecmd.o $(HISTORY_LIB)
$(PURIFY) $(CC) $(LDFLAGS) -o $@ hist_purgecmd.o -lhistory $(TERMCAP_LIB)
clean mostlyclean:
$(RM) $(OBJECTS)
$(RM) $(EXECUTABLES) *.exe
$(RM) $(OBJECTS) $(OTHEROBJ)
$(RM) $(EXECUTABLES) $(OTHEREXE) *.exe
distclean maintainer-clean: clean
$(RM) Makefile
@@ -131,13 +151,21 @@ rltest.o: rltest.c
rl.o: rl.c
rlversion.o: rlversion.c
histexamp.o: histexamp.c
hist_erasedups.o: hist_erasedups.c
hist_purgecmd.o: hist_purgecmd.c
rlbasic.o: rlbasic.c
rlcat.o: rlcat.c
rlptytest.o: rlptytest.c
rl-callbacktest.o: rl-callbacktest.c
fileman.o: $(top_srcdir)/readline.h
rltest.o: $(top_srcdir)/readline.h
rl.o: $(top_srcdir)/readline.h
rlversion.o: $(top_srcdir)/readline.h
histexamp.o: $(top_srcdir)/history.h
hist_erasedups.o: $(top_srcdir)/history.h
hist_purgecmd.o: $(top_srcdir)/history.h
rlbasic.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
rlcat.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
rlptytest.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
rl-callbacktest.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h

View File

@@ -40,13 +40,14 @@ Copyright (C) 1999 Jeff Solomon
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <termios.h> /* xxx - should make this more general */
#ifdef READLINE_LIBRARY
@@ -55,6 +56,10 @@ Copyright (C) 1999 Jeff Solomon
# include <readline/readline.h>
#endif
#ifndef STDIN_FILENO
# define STDIN_FILENO 0
#endif
/* This little examples demonstrates the alternate interface to using readline.
* In the alternate interface, the user maintains control over program flow and
* only calls readline when STDIN is readable. Using the alternate interface,

View File

@@ -0,0 +1,121 @@
/* hist_erasedups -- remove all duplicate entries from history file */
/* Copyright (C) 2011 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.
Readline 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.
Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef READLINE_LIBRARY
#define READLINE_LIBRARY 1
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef READLINE_LIBRARY
# include "history.h"
#else
# include <readline/history.h>
#endif
#include <string.h>
#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
#define STREQN(a, b, n) ((n == 0) ? (1) \
: ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
extern int history_offset;
static void
usage()
{
fprintf (stderr, "hist_erasedups: usage: hist_erasedups [-t] [filename]\n");
exit (2);
}
int
main (argc, argv)
int argc;
char **argv;
{
char *fn;
int r;
while ((r = getopt (argc, argv, "t")) != -1)
{
switch (r)
{
case 't':
history_write_timestamps = 1;
break;
default:
usage ();
}
}
argv += optind;
argc -= optind;
fn = argc ? argv[0] : getenv ("HISTFILE");
if (fn == 0)
{
fprintf (stderr, "hist_erasedups: no history file\n");
usage ();
}
if ((r = read_history (fn)) != 0)
{
fprintf (stderr, "hist_erasedups: read_history: %s: %s\n", fn, strerror (r));
exit (1);
}
hist_erasedups ();
if ((r = write_history (fn)) != 0)
{
fprintf (stderr, "hist_erasedups: write_history: %s: %s\n", fn, strerror (r));
exit (1);
}
exit (0);
}
int
hist_erasedups ()
{
int r, n;
HIST_ENTRY *h, *temp;
using_history ();
while (h = previous_history ())
{
r = where_history ();
for (n = 0; n < r; n++)
{
temp = history_get (n+history_base);
if (STREQ (h->line, temp->line))
{
remove_history (n);
r--; /* have to get one fewer now */
n--; /* compensate for above increment */
history_offset--; /* moving backwards in history list */
}
}
}
using_history ();
return r;
}

View File

@@ -0,0 +1,151 @@
/* hist_purgecmd -- remove all instances of command or pattern from history
file */
/* Copyright (C) 2011 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.
Readline 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.
Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef READLINE_LIBRARY
#define READLINE_LIBRARY 1
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <regex.h>
#ifdef READLINE_LIBRARY
# include "history.h"
#else
# include <readline/history.h>
#endif
#include <string.h>
#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
#define STREQN(a, b, n) ((n == 0) ? (1) \
: ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
extern int history_offset;
#define PURGE_REGEXP 0x01
static void
usage()
{
fprintf (stderr, "hist_purgecmd: usage: hist_purgecmd [-r] [-t] [-f filename] command-spec\n");
exit (2);
}
int
main (argc, argv)
int argc;
char **argv;
{
char *fn;
int r, flags;
flags = 0;
fn = 0;
while ((r = getopt (argc, argv, "f:rt")) != -1)
{
switch (r)
{
case 'f':
fn = optarg;
break;
case 'r':
flags |= PURGE_REGEXP;
break;
case 't':
history_write_timestamps = 1;
break;
default:
usage ();
}
}
argv += optind;
argc -= optind;
if (fn == 0)
fn = getenv ("HISTFILE");
if (fn == 0)
{
fprintf (stderr, "hist_purgecmd: no history file\n");
usage ();
}
if ((r = read_history (fn)) != 0)
{
fprintf (stderr, "hist_purgecmd: read_history: %s: %s\n", fn, strerror (r));
exit (1);
}
for (r = 0; r < argc; r++)
hist_purgecmd (argv[r], flags);
if ((r = write_history (fn)) != 0)
{
fprintf (stderr, "hist_purgecmd: write_history: %s: %s\n", fn, strerror (r));
exit (1);
}
exit (0);
}
int
hist_purgecmd (cmd, flags)
char *cmd;
int flags;
{
int r, n, rflags;
HIST_ENTRY *temp;
regex_t regex = { 0 };
if (flags & PURGE_REGEXP)
{
rflags = REG_EXTENDED|REG_NOSUB;
if (regcomp (&regex, cmd, rflags))
{
fprintf (stderr, "hist_purgecmd: %s: invalid regular expression\n", cmd);
return -1;
}
}
r = 0;
using_history ();
r = where_history ();
for (n = 0; n < r; n++)
{
temp = history_get (n+history_base);
if (((flags & PURGE_REGEXP) && (regexec (&regex, temp->line, 0, 0, 0) == 0)) ||
((flags & PURGE_REGEXP) == 0 && STREQ (temp->line, cmd)))
{
remove_history (n);
r--; /* have to get one fewer now */
n--; /* compensate for above increment */
history_offset--; /* moving backwards in history list */
}
}
using_history ();
if (flags & PURGE_REGEXP)
regfree (&regex);
return r;
}

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* $Revision$
* $Date$
* $Author$
* $Revision: 1.2 $
* $Date: 2001/09/11 06:19:36 $
* $Author: vyzo $
*
* Contents: A streambuf which uses the GNU readline library for line I/O
* (c) 2001 by Dimitris Vyzovitis [vyzo@media.mit.edu]

View File

@@ -0,0 +1,90 @@
/* Standard include files. stdio.h is required. */
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* Used for select(2) */
#include <sys/types.h>
#include <sys/select.h>
#include <errno.h>
#include <stdio.h>
/* Standard readline include files. */
#if defined (READLINE_LIBRARY)
# include "readline.h"
# include "history.h"
#else
# include <readline/readline.h>
# include <readline/history.h>
#endif
extern int errno;
static void cb_linehandler (char *);
int running;
const char *prompt = "rltest$ ";
/* Callback function called for each line when accept-line executed, EOF
seen, or EOF character read. This sets a flag and returns; it could
also call exit(3). */
static void
cb_linehandler (char *line)
{
/* Can use ^D (stty eof) or `exit' to exit. */
if (line == NULL || strcmp (line, "exit") == 0)
{
if (line == 0)
printf ("\n");
printf ("exit\n");
/* This function needs to be called to reset the terminal settings,
and calling it from the line handler keeps one extra prompt from
being displayed. */
rl_callback_handler_remove ();
running = 0;
}
else
{
if (*line)
add_history (line);
printf ("input line: %s\n", line);
free (line);
}
}
int
main (int c, char **v)
{
fd_set fds;
int r;
/* Install the line handler. */
rl_callback_handler_install (prompt, cb_linehandler);
/* Enter a simple event loop. This waits until something is available
to read on readline's input stream (defaults to standard input) and
calls the builtin character read callback to read it. It does not
have to modify the user's terminal settings. */
running = 1;
while (running)
{
FD_ZERO (&fds);
FD_SET (fileno (rl_instream), &fds);
r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
if (r < 0 && errno != EINTR)
{
perror ("rltest: select");
rl_callback_handler_remove ();
break;
}
if (FD_ISSET (fileno (rl_instream), &fds))
rl_callback_read_char ();
}
printf ("rltest: Event loop has exited\n");
return 0;
}

View File

@@ -0,0 +1,28 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#if defined (READLINE_LIBRARY)
# include "readline.h"
# include "history.h"
#else
# include <readline/readline.h>
# include <readline/history.h>
#endif
int
main (int c, char **v)
{
char *input;
for (;;) {
input = readline ((char *)NULL);
if (input == 0)
break;
printf ("%s\n", input);
if (strcmp (input, "exit") == 0)
break;
free (input);
}
exit (0);
}

View File

@@ -21,7 +21,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
****************************************************************
* $Id$ FAU
* $Id: config.h.in,v 1.12 1994/05/31 12:31:36 mlschroe Exp $ FAU
*/
@@ -377,3 +377,7 @@
#undef HAVE_SYS_STROPTS_H
#undef HAVE_SYS_WAIT_H
#undef HAVE_SGTTY_H
#undef HAVE_SYS_SELECT_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
m4_include([../../../config/override.m4])
AC_INIT(rlfe.c)
AC_CONFIG_HEADER(config.h)
VERSION=0.4
@@ -225,6 +223,7 @@ AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
AC_MSG_ERROR(!!! no tgetent - no screen))))))
AC_TRY_RUN([
extern char *tgoto();
main()
{
exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
@@ -437,6 +436,7 @@ main()
fi
AC_CHECK_HEADERS(sys/stropts.h sys/wait.h)
AC_CHECK_HEADERS(sys/stropts.h sys/wait.h sgtty.h sys/select.h)
AC_CHECK_HEADERS(term.h)
AC_OUTPUT(Makefile)

View File

@@ -19,7 +19,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
****************************************************************
* $Id$ FAU
* $Id: extern.h,v 1.18 1994/05/31 12:31:57 mlschroe Exp $ FAU
*/
#if !defined(__GNUC__) || __GNUC__ < 2

View File

@@ -19,7 +19,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
****************************************************************
* $Id$ FAU
* $Id: os.h,v 1.10 1994/05/31 12:32:22 mlschroe Exp $ FAU
*/
#include <stdio.h>
@@ -208,7 +208,9 @@ extern int errno;
# include <cytermio.h>
# endif
# else /* TERMIO */
# include <sgtty.h>
# if defined (HAVE_SGTTY_H)
# include <sgtty.h>
# endif
# endif /* TERMIO */
#endif /* POSIX */
@@ -490,7 +492,7 @@ extern int errno;
* select stuff
*/
#if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_)
#if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_) || defined (__INTERIX)
#include <sys/select.h> /* for timeval + FD... */
#endif

View File

@@ -547,7 +547,14 @@ main(int argc, char** argv)
#endif
t.c_lflag &= ~(ICANON | ISIG | ECHO | ECHOCTL | ECHOE | \
ECHOK | ECHOKE | ECHONL | ECHOPRT );
ECHOK | ECHONL
#if defined (ECHOKE)
| ECHOKE
#endif
#if defined (ECHOPRT)
| ECHOPRT
#endif
);
t.c_iflag &= ~ICRNL;
t.c_iflag |= IGNBRK;
t.c_cc[VMIN] = 1;

View File

@@ -19,7 +19,7 @@
#include <signal.h>
#if 0 /* LINUX */
#if 1 /* LINUX */
#include <pty.h>
#else
#include <util.h>
@@ -316,6 +316,8 @@ main()
if (val == -1)
return -1;
signal (SIGINT, sigint);
val = init_readline (slavefd, slavefd);
if (val == -1)
return -1;
@@ -324,8 +326,6 @@ main()
if (val == -1)
return -1;
signal (SIGINT, sigint);
val = main_loop ();
tty_reset (STDIN_FILENO);