commit bash-20210211 snapshot

This commit is contained in:
Chet Ramey
2021-02-15 10:55:26 -05:00
parent 26db5626df
commit a6c3a43f43
11 changed files with 114 additions and 52 deletions
+1
View File
@@ -497,6 +497,7 @@ rl_read_key (void)
if ((r = rl_gather_tyi ()) < 0) /* XXX - EIO */
{
rl_done = 1;
RL_SETSTATE (RL_STATE_DONE);
return (errno == EIO ? (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF) : '\n');
}
else if (r > 0) /* read something */
+1 -1
View File
@@ -318,7 +318,7 @@ _rl_search_getchar (_rl_search_cxt *cxt)
#if defined (HANDLE_MULTIBYTE)
/* This ends up with C (and LASTC) being set to the last byte of the
multibyte character. In most cases c == lastc == mb[0] */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
if (c >= 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = cxt->lastc = _rl_read_mbstring (cxt->lastc, cxt->mb, MB_LEN_MAX);
#endif
+8 -25
View File
@@ -222,6 +222,9 @@ _rl_handle_signal (int sig)
switch (sig)
{
case SIGINT:
/* We will end up blocking SIGTTOU while we are resetting the tty, so
watch out for this if it causes problems. We could prevent this by
setting block_sig to 1 without modifying SET. */
_rl_reset_completion_state ();
rl_free_line_state ();
#if defined (READLINE_CALLBACKS)
@@ -242,8 +245,11 @@ _rl_handle_signal (int sig)
this even if we've been stopped on SIGTTOU, since we handle signals
when we have returned from the signal handler and the signal is no
longer blocked. */
sigaddset (&set, SIGTTOU);
block_sig = 1;
if (block_sig == 0)
{
sigaddset (&set, SIGTTOU);
block_sig = 1;
}
# endif
#endif /* SIGTSTP */
/* Any signals that should be blocked during cleanup should go here. */
@@ -285,19 +291,6 @@ _rl_handle_signal (int sig)
/* We don't have to bother unblocking the signal because we are not
running in a signal handler context. */
#if 0
#if defined (HAVE_POSIX_SIGNALS)
/* Make sure this signal is not blocked when we resend it to the
calling application. */
sigemptyset (&set);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
sigdelset (&set, sig);
#else /* !HAVE_POSIX_SIGNALS */
# if defined (HAVE_BSD_SIGNALS)
omask = sigblock (0);
# endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
#endif
#if defined (__EMX__)
signal (sig, SIG_ACK);
@@ -311,16 +304,6 @@ _rl_handle_signal (int sig)
/* We don't need to modify the signal mask now that this is not run in
a signal handler context. */
#if 0
/* Let the signal that we just sent through if it is blocked. */
#if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
#else /* !HAVE_POSIX_SIGNALS */
# if defined (HAVE_BSD_SIGNALS)
sigsetmask (omask & ~(sigmask (sig)));
# endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
#endif
rl_reset_after_signal ();
}
+3
View File
@@ -919,8 +919,11 @@ _rl_overwrite_char (int count, int c)
int k;
/* Read an entire multibyte character sequence to insert COUNT times. */
k = 1;
if (count > 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0)
k = _rl_read_mbstring (c, mbkey, MB_LEN_MAX);
if (k < 0)
return 1;
#endif
rl_begin_undo_group ();
+7 -4
View File
@@ -2036,6 +2036,9 @@ _rl_vi_callback_change_char (_rl_callback_generic_arg *data)
char mb[MB_LEN_MAX+1];
c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
if (c < 0)
return -1;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
strncpy (_rl_vi_last_replacement, mb, MB_LEN_MAX);
@@ -2044,9 +2047,6 @@ _rl_vi_callback_change_char (_rl_callback_generic_arg *data)
_rl_vi_last_replacement[0] = c;
_rl_vi_last_replacement[MB_LEN_MAX] = '\0'; /* XXX */
if (c < 0)
return -1;
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -2077,6 +2077,8 @@ rl_vi_change_char (int count, int key)
else
{
c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
if (c < 0)
return -1;
#ifdef HANDLE_MULTIBYTE
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
strncpy (_rl_vi_last_replacement, mb, MB_LEN_MAX);
@@ -2113,7 +2115,8 @@ rl_vi_overstrike (int count, int key)
if (count > 0)
{
_rl_overwrite_char (count, key);
if (_rl_overwrite_char (count, key) != 0)
return (1);
vi_replace_count += count;
}
+41 -17
View File
@@ -43,34 +43,51 @@
extern int errno;
#endif /* !errno */
#ifndef FREE
#define FREE(s) do { if (s) free (s); } while (0)
#endif
extern unsigned int falarm (unsigned int, unsigned int);
sh_timer *
shtimer_alloc (void)
{
sh_timer *r;
static void shtimer_zero (sh_timer *);
r = (sh_timer *)xmalloc (sizeof (sh_timer));
shtimer_flush (r);
return r;
}
void
shtimer_flush (sh_timer *t)
static void
shtimer_zero (sh_timer *t)
{
t->tmout.tv_sec = 0;
t->tmout.tv_usec = 0;
t->fd = t->flags = t->alrmflag = 0;
t->fd = -1;
t->flags = t->alrmflag = 0;
t->alrm_handler = t->old_handler = 0;
memset (t->jmpenv, '\0', sizeof (t->jmpenv));
t->handler = 0;
t->tm_handler = 0;
t->data = 0;
}
sh_timer *
shtimer_alloc (void)
{
sh_timer *t;
t = (sh_timer *)xmalloc (sizeof (sh_timer));
shtimer_zero (t);
return t;
}
void
shtimer_flush (sh_timer *t)
{
/* The caller can manage t->data arbitrarily as long as it frees and sets
t->data to 0 before calling this function. Otherwise, we do what we can
to avoid memleaks. */
FREE (t->data);
shtimer_zero (t);
}
void
shtimer_dispose (sh_timer *t)
{
@@ -120,6 +137,7 @@ shtimer_unset (sh_timer *t)
{
set_signal_handler (SIGALRM, t->old_handler);
t->flags &= ~SHTIMER_SIGSET;
t->old_handler = 0;
}
}
}
@@ -163,7 +181,7 @@ shtimer_chktimeout (sh_timer *t)
int
shtimer_select (sh_timer *t)
{
int r;
int r, nfd;
sigset_t blocked_sigs, prevmask;
struct timeval now, tv;
fd_set readfds;
@@ -191,6 +209,8 @@ shtimer_select (sh_timer *t)
{
if (t->flags & SHTIMER_LONGJMP)
sh_longjmp (t->jmpenv, 1);
else if (t->tm_handler)
return ((*t->tm_handler) (t));
else
return 0;
}
@@ -211,14 +231,16 @@ shtimer_select (sh_timer *t)
sigemptyset (&prevmask);
#endif /* !HAVE_PSELECT */
nfd = (t->fd >= 0) ? t->fd + 1 : 0;
FD_ZERO (&readfds);
FD_SET (t->fd, &readfds);
if (t->fd >= 0)
FD_SET (t->fd, &readfds);
#if defined (HAVE_PSELECT)
r = pselect(t->fd + 1, &readfds, (fd_set *)0, (fd_set *)0, &ts, &blocked_sigs);
r = pselect(nfd, &readfds, (fd_set *)0, (fd_set *)0, &ts, &blocked_sigs);
#else
sigprocmask (SIG_SETMASK, &blocked_sigs, &prevmask);
r = select(t->fd + 1, &readfds, (fd_set *)0, (fd_set *)0, &tv);
r = select(nfd, &readfds, (fd_set *)0, (fd_set *)0, &tv);
sigprocmask (SIG_SETMASK, &prevmask, NULL);
#endif
@@ -226,6 +248,8 @@ shtimer_select (sh_timer *t)
return r; /* caller will handle */
else if (r == 0 && (t->flags & SHTIMER_LONGJMP))
sh_longjmp (t->jmpenv, 1);
else if (r == 0 && t->tm_handler)
return ((*t->tm_handler) (t));
else
return r;
}