Bash-5.3-alpha release

This commit is contained in:
Chet Ramey
2024-04-22 10:33:38 -04:00
parent f3b6bd1945
commit 622d318652
700 changed files with 136534 additions and 96420 deletions
+71 -31
View File
@@ -1,6 +1,6 @@
/* input.c -- character input functions for readline. */
/* Copyright (C) 1994-2021 Free Software Foundation, Inc.
/* Copyright (C) 1994-2022 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.
@@ -138,20 +138,16 @@ win32_isatty (int fd)
/* Readline timeouts */
/* I don't know how to set a timeout for _getch() in MinGW32, so we use
SIGALRM. */
#if (defined (HAVE_PSELECT) || defined (HAVE_SELECT)) && !defined (__MINGW32__)
# define RL_TIMEOUT_USE_SELECT
#else
# define RL_TIMEOUT_USE_SIGALRM
#endif
/* We now define RL_TIMEOUT_USE_SELECT or RL_TIMEOUT_USE_SIGALRM in rlprivate.h */
int rl_set_timeout (unsigned int, unsigned int);
int rl_timeout_remaining (unsigned int *, unsigned int *);
int _rl_timeout_init (void);
int _rl_timeout_sigalrm_handler (void);
int _rl_timeout_handle_sigalrm (void);
#if defined (RL_TIMEOUT_USE_SELECT)
int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
#endif
static void _rl_timeout_handle (void);
#if defined (RL_TIMEOUT_USE_SIGALRM)
@@ -248,38 +244,53 @@ rl_gather_tyi (void)
register int tem, result;
int chars_avail, k;
char input;
#if defined(HAVE_SELECT)
#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
fd_set readfds, exceptfds;
struct timeval timeout;
#endif
result = -1;
chars_avail = 0;
input = 0;
tty = fileno (rl_instream);
/* Move this up here to give it first shot, but it can't set chars_avail */
/* XXX - need rl_chars_available_hook? */
if (rl_input_available_hook)
{
result = (*rl_input_available_hook) ();
if (result == 0)
result = -1;
}
#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
FD_ZERO (&readfds);
FD_ZERO (&exceptfds);
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
if (result == -1)
{
FD_ZERO (&readfds);
FD_ZERO (&exceptfds);
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
#if defined (RL_TIMEOUT_USE_SELECT)
result = _rl_timeout_select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout, NULL);
result = _rl_timeout_select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout, NULL);
#else
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
#endif
if (result <= 0)
return 0; /* Nothing to read. */
if (result <= 0)
return 0; /* Nothing to read. */
}
#endif
result = -1;
errno = 0;
#if defined (FIONREAD)
result = ioctl (tty, FIONREAD, &chars_avail);
if (result == -1 && errno == EIO)
return -1;
if (result == -1)
chars_avail = 0;
{
errno = 0;
result = ioctl (tty, FIONREAD, &chars_avail);
if (result == -1 && errno == EIO)
return -1;
if (result == -1)
chars_avail = 0;
}
#endif
#if defined (O_NDELAY)
@@ -306,8 +317,11 @@ rl_gather_tyi (void)
#if defined (__MINGW32__)
/* Use getch/_kbhit to check for available console input, in the same way
that we read it normally. */
chars_avail = isatty (tty) ? _kbhit () : 0;
result = 0;
if (result == -1)
{
chars_avail = isatty (tty) ? _kbhit () : 0;
result = 0;
}
#endif
/* If there's nothing available, don't waste time trying to read
@@ -649,7 +663,7 @@ rl_timeout_remaining (unsigned int *secs, unsigned int *usecs)
/* This should only be called if RL_TIMEOUT_USE_SELECT is defined. */
#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
#if defined (RL_TIMEOUT_USE_SELECT)
int
_rl_timeout_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout, const sigset_t *sigmask)
{
@@ -802,10 +816,10 @@ rl_read_key (void)
int
rl_getc (FILE *stream)
{
int result;
int result, ostate, osig;
unsigned char c;
int fd;
#if defined (HAVE_PSELECT)
#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
sigset_t empty_set;
fd_set readfds;
#endif
@@ -813,12 +827,26 @@ rl_getc (FILE *stream)
fd = fileno (stream);
while (1)
{
osig = _rl_caught_signal;
ostate = rl_readline_state;
RL_CHECK_SIGNALS ();
#if defined (READLINE_CALLBACKS)
/* Do signal handling post-processing here, but just in callback mode
for right now because the signal cleanup can change some of the
callback state, and we need to either let the application have a
chance to react or abort some current operation that gets cleaned
up by rl_callback_sigcleanup(). If not, we'll just run through the
loop again. */
if (osig != 0 && (ostate & RL_STATE_CALLBACK))
goto postproc_signal;
#endif
/* We know at this point that _rl_caught_signal == 0 */
#if defined (__MINGW32__)
if (isatty (fd)
if (isatty (fd))
return (_getch ()); /* "There is no error return." */
#endif
result = 0;
@@ -878,6 +906,9 @@ rl_getc (FILE *stream)
/* fprintf(stderr, "rl_getc: result = %d errno = %d\n", result, errno); */
handle_error:
osig = _rl_caught_signal;
ostate = rl_readline_state;
/* If the error that we received was EINTR, then try again,
this is simply an interrupted system call to read (). We allow
the read to be interrupted if we caught SIGHUP, SIGTERM, or any
@@ -918,8 +949,17 @@ handle_error:
RL_CHECK_SIGNALS ();
#endif /* SIGALRM */
postproc_signal:
/* POSIX says read(2)/pselect(2)/select(2) don't return EINTR for any
reason other than being interrupted by a signal, so we can safely
call the application's signal event hook. */
if (rl_signal_event_hook)
(*rl_signal_event_hook) ();
#if defined (READLINE_CALLBACKS)
else if (osig == SIGINT && (ostate & RL_STATE_CALLBACK) && (ostate & (RL_STATE_ISEARCH|RL_STATE_NSEARCH|RL_STATE_NUMERICARG)))
/* just these cases for now */
_rl_abort_internal ();
#endif
}
}