Import readline 8.0

This imports readline 8.0.

readline/ChangeLog.gdb
2019-08-12  Tom Tromey  <tom@tromey.com>

	* Imported readline 8.0.
This commit is contained in:
Tom Tromey
2019-08-12 10:24:03 -06:00
parent ca2589f3bb
commit cb41b9e70e
77 changed files with 4056 additions and 2156 deletions

View File

@@ -1,6 +1,6 @@
/* input.c -- character input functions for readline. */
/* Copyright (C) 1994-2015 Free Software Foundation, Inc.
/* Copyright (C) 1994-2017 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.
@@ -76,6 +76,10 @@ extern int errno;
# define O_NDELAY O_NONBLOCK /* Posix style */
#endif
#if defined (HAVE_PSELECT)
extern sigset_t _rl_orig_sigset;
#endif
/* Non-null means it is a pointer to a function to run while waiting for
character input. */
rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
@@ -108,10 +112,10 @@ int w32_isatty (int fd)
{
if (_isatty(fd))
{
HANDLE h = (HANDLE) _get_osfhandle (fd);
HANDLE h;
DWORD ignored;
if (h == INVALID_HANDLE_VALUE)
if ((h = (HANDLE) _get_osfhandle (fd)) == INVALID_HANDLE_VALUE)
{
errno = EBADF;
return 0;
@@ -139,13 +143,13 @@ static int ibuffer_len = sizeof (ibuffer) - 1;
#define any_typein (push_index != pop_index)
int
_rl_any_typein ()
_rl_any_typein (void)
{
return any_typein;
}
int
_rl_pushed_input_available ()
_rl_pushed_input_available (void)
{
return (push_index != pop_index);
}
@@ -153,7 +157,7 @@ _rl_pushed_input_available ()
/* Return the amount of space available in the buffer for stuffing
characters. */
static int
ibuffer_space ()
ibuffer_space (void)
{
if (pop_index > push_index)
return (pop_index - push_index - 1);
@@ -165,8 +169,7 @@ ibuffer_space ()
Return the key in KEY.
Result is non-zero if there was a key, or 0 if there wasn't. */
static int
rl_get_char (key)
int *key;
rl_get_char (int *key)
{
if (push_index == pop_index)
return (0);
@@ -186,8 +189,7 @@ rl_get_char (key)
Returns non-zero if successful, zero if there is
no space left in the buffer. */
int
_rl_unget_char (key)
int key;
_rl_unget_char (int key)
{
if (ibuffer_space ())
{
@@ -204,7 +206,7 @@ _rl_unget_char (key)
IBUFFER. Otherwise, just return. Returns number of characters read
(0 if none available) and -1 on error (EIO). */
static int
rl_gather_tyi ()
rl_gather_tyi (void)
{
int tty;
register int tem, result;
@@ -307,8 +309,7 @@ rl_gather_tyi ()
}
int
rl_set_keyboard_input_timeout (u)
int u;
rl_set_keyboard_input_timeout (int u)
{
int o;
@@ -325,7 +326,7 @@ rl_set_keyboard_input_timeout (u)
the user, it should use _rl_input_queued(timeout_value_in_microseconds)
instead. */
int
_rl_input_available ()
_rl_input_available (void)
{
#if defined(HAVE_SELECT)
fd_set readfds, exceptfds;
@@ -367,8 +368,7 @@ _rl_input_available ()
}
int
_rl_input_queued (t)
int t;
_rl_input_queued (int t)
{
int old_timeout, r;
@@ -379,8 +379,7 @@ _rl_input_queued (t)
}
void
_rl_insert_typein (c)
int c;
_rl_insert_typein (int c)
{
int key, t, i;
char *string;
@@ -405,8 +404,7 @@ _rl_insert_typein (c)
/* Add KEY to the buffer of characters to be read. Returns 1 if the
character was stuffed correctly; 0 otherwise. */
int
rl_stuff_char (key)
int key;
rl_stuff_char (int key)
{
if (ibuffer_space () == 0)
return 0;
@@ -430,8 +428,7 @@ rl_stuff_char (key)
/* Make C be the next command to be executed. */
int
rl_execute_next (c)
int c;
rl_execute_next (int c)
{
rl_pending_input = c;
RL_SETSTATE (RL_STATE_INPUTPENDING);
@@ -440,7 +437,7 @@ rl_execute_next (c)
/* Clear any pending input pushed with rl_execute_next() */
int
rl_clear_pending_input ()
rl_clear_pending_input (void)
{
rl_pending_input = 0;
RL_UNSETSTATE (RL_STATE_INPUTPENDING);
@@ -455,20 +452,20 @@ rl_clear_pending_input ()
/* Read a key, including pending input. */
int
rl_read_key ()
rl_read_key (void)
{
int c, r;
if (rl_pending_input)
{
c = rl_pending_input;
c = rl_pending_input; /* XXX - cast to unsigned char if > 0? */
rl_clear_pending_input ();
}
else
{
/* If input is coming from a macro, then use that. */
if (c = _rl_next_macro_key ())
return (c);
return ((unsigned char)c);
/* If the user has an event function, then call it periodically. */
if (rl_event_hook)
@@ -505,8 +502,7 @@ rl_read_key ()
}
int
rl_getc (stream)
FILE *stream;
rl_getc (FILE *stream)
{
int result;
unsigned char c;
@@ -527,11 +523,15 @@ rl_getc (stream)
#endif
result = 0;
#if defined (HAVE_PSELECT)
sigemptyset (&empty_set);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &empty_set);
FD_ZERO (&readfds);
FD_SET (fileno (stream), &readfds);
# if defined (HANDLE_SIGNALS)
result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &_rl_orig_sigset);
# else
sigemptyset (&empty_set);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &empty_set);
result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &empty_set);
# endif /* HANDLE_SIGNALS */
#endif
if (result >= 0)
result = read (fileno (stream), &c, sizeof (unsigned char));
@@ -618,9 +618,7 @@ handle_error:
#if defined (HANDLE_MULTIBYTE)
/* read multibyte char */
int
_rl_read_mbchar (mbchar, size)
char *mbchar;
int size;
_rl_read_mbchar (char *mbchar, int size)
{
int mb_len, c;
size_t mbchar_bytes_length;
@@ -669,12 +667,9 @@ _rl_read_mbchar (mbchar, size)
may be FIRST. Used by the search functions, among others. Very similar
to _rl_read_mbchar. */
int
_rl_read_mbstring (first, mb, mlen)
int first;
char *mb;
int mlen;
_rl_read_mbstring (int first, char *mb, int mlen)
{
int i, c;
int i, c, n;
mbstate_t ps;
c = first;
@@ -683,7 +678,8 @@ _rl_read_mbstring (first, mb, mlen)
{
mb[i] = (char)c;
memset (&ps, 0, sizeof (mbstate_t));
if (_rl_get_char_len (mb, &ps) == -2)
n = _rl_get_char_len (mb, &ps);
if (n == -2)
{
/* Read more for multibyte character */
RL_SETSTATE (RL_STATE_MOREINPUT);