Bash-4.4 distribution sources and documentation

This commit is contained in:
Chet Ramey
2016-09-15 16:59:08 -04:00
parent 30a978b7d8
commit a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions
+58 -9
View File
@@ -1,6 +1,6 @@
/* input.c -- character input functions for readline. */
/* Copyright (C) 1994-2013 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.
@@ -95,6 +95,22 @@ static int ibuffer_space PARAMS((void));
static int rl_get_char PARAMS((int *));
static int rl_gather_tyi PARAMS((void));
/* Windows isatty returns true for every character device, including the null
device, so we need to perform additional checks. */
#if defined (_WIN32) && !defined (__CYGWIN__)
#include <io.h>
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
int
win32_isatty (int fd)
{
return (_isatty (fd) ? ((((long) (HANDLE) _get_osfhandle (fd)) & 3) == 3) : 0);
}
#define isatty(x) win32_isatty(x)
#endif
/* **************************************************************** */
/* */
/* Character Input Buffering */
@@ -185,6 +201,7 @@ rl_gather_tyi ()
#endif
chars_avail = 0;
input = 0;
tty = fileno (rl_instream);
#if defined (HAVE_SELECT)
@@ -199,11 +216,13 @@ rl_gather_tyi ()
#endif
result = -1;
#if defined (FIONREAD)
errno = 0;
#if defined (FIONREAD)
result = ioctl (tty, FIONREAD, &chars_avail);
if (result == -1 && errno == EIO)
return -1;
if (result == -1)
chars_avail = 0;
#endif
#if defined (O_NDELAY)
@@ -217,6 +236,8 @@ rl_gather_tyi ()
fcntl (tty, F_SETFL, tem);
if (chars_avail == -1 && errno == EAGAIN)
return 0;
if (chars_avail == -1 && errno == EIO)
return -1;
if (chars_avail == 0) /* EOF */
{
rl_stuff_char (EOF);
@@ -445,7 +466,7 @@ rl_read_key ()
if ((r = rl_gather_tyi ()) < 0) /* XXX - EIO */
{
rl_done = 1;
return ('\n');
return (errno == EIO ? (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF) : '\n');
}
else if (r > 0) /* read something */
continue;
@@ -474,6 +495,10 @@ rl_getc (stream)
{
int result;
unsigned char c;
#if defined (HAVE_PSELECT)
sigset_t empty_set;
fd_set readfds;
#endif
while (1)
{
@@ -483,9 +508,17 @@ rl_getc (stream)
#if defined (__MINGW32__)
if (isatty (fileno (stream)))
return (getch ());
return (_getch ()); /* "There is no error return." */
#endif
result = read (fileno (stream), &c, sizeof (unsigned char));
result = 0;
#if defined (HAVE_PSELECT)
sigemptyset (&empty_set);
FD_ZERO (&readfds);
FD_SET (fileno (stream), &readfds);
result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &empty_set);
#endif
if (result >= 0)
result = read (fileno (stream), &c, sizeof (unsigned char));
if (result == sizeof (unsigned char))
return (c);
@@ -524,26 +557,42 @@ rl_getc (stream)
/* fprintf(stderr, "rl_getc: result = %d errno = %d\n", result, errno); */
handle_error:
/* 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 or SIGTERM (but
not SIGINT; let the signal handler deal with that), but if the
the read to be interrupted if we caught SIGHUP, SIGTERM, or any
of the other signals readline treats specially. If the
application sets an event hook, call it for other signals.
Otherwise (not EINTR), some error occurred, also signifying EOF. */
if (errno != EINTR)
return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
/* fatal signals of interest */
#if defined (SIGHUP)
else if (_rl_caught_signal == SIGHUP || _rl_caught_signal == SIGTERM)
#else
else if (_rl_caught_signal == SIGTERM)
#endif
return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
/* keyboard-generated signals of interest */
#if defined (SIGQUIT)
else if (_rl_caught_signal == SIGINT || _rl_caught_signal == SIGQUIT)
#else
else if (_rl_caught_signal == SIGINT)
#endif
RL_CHECK_SIGNALS ();
/* non-keyboard-generated signals of interest */
#if defined (SIGWINCH)
else if (_rl_caught_signal == SIGWINCH)
RL_CHECK_SIGNALS ();
#endif /* SIGWINCH */
#if defined (SIGALRM)
else if (_rl_caught_signal == SIGALRM
#if defined (SIGVTALRM)
# if defined (SIGVTALRM)
|| _rl_caught_signal == SIGVTALRM
#endif
# endif
)
RL_CHECK_SIGNALS ();
#endif /* SIGALRM */
if (rl_signal_event_hook)
(*rl_signal_event_hook) ();