mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-12 13:10:45 +02:00
commit bash-20191219 snapshot
This commit is contained in:
+1
-1
@@ -788,7 +788,7 @@ _rl_untranslate_macro_value (char *seq, int use_escapes)
|
||||
|
||||
/* Return a pointer to the function that STRING represents.
|
||||
If STRING doesn't have a matching function, then a NULL pointer
|
||||
is returned. */
|
||||
is returned. The string match is case-insensitive. */
|
||||
rl_command_func_t *
|
||||
rl_named_function (const char *string)
|
||||
{
|
||||
|
||||
@@ -1666,6 +1666,7 @@ update_line (char *old, char *new, int current_line, int omax, int nmax, int inv
|
||||
and do a dumb update. */
|
||||
if (newwidth != oldwidth)
|
||||
{
|
||||
oe = old + omax;
|
||||
ne = new + nmax;
|
||||
nd = newbytes;
|
||||
nfd = new + nd;
|
||||
|
||||
@@ -157,7 +157,7 @@ static const FUNMAP default_funmap[] = {
|
||||
{ "vi-backward-bigword", rl_vi_bWord },
|
||||
{ "vi-backward-word", rl_vi_bword },
|
||||
{ "vi-bWord", rl_vi_bWord },
|
||||
{ "vi-bword", rl_vi_bword },
|
||||
{ "vi-bword", rl_vi_bword }, /* BEWARE: name matching is case insensitive */
|
||||
{ "vi-change-case", rl_vi_change_case },
|
||||
{ "vi-change-char", rl_vi_change_char },
|
||||
{ "vi-change-to", rl_vi_change_to },
|
||||
@@ -171,13 +171,13 @@ static const FUNMAP default_funmap[] = {
|
||||
{ "vi-end-bigword", rl_vi_eWord },
|
||||
{ "vi-end-word", rl_vi_end_word },
|
||||
{ "vi-eof-maybe", rl_vi_eof_maybe },
|
||||
{ "vi-eword", rl_vi_eword },
|
||||
{ "vi-eword", rl_vi_eword }, /* BEWARE: name matching is case insensitive */
|
||||
{ "vi-fWord", rl_vi_fWord },
|
||||
{ "vi-fetch-history", rl_vi_fetch_history },
|
||||
{ "vi-first-print", rl_vi_first_print },
|
||||
{ "vi-forward-bigword", rl_vi_fWord },
|
||||
{ "vi-forward-word", rl_vi_fword },
|
||||
{ "vi-fword", rl_vi_fword },
|
||||
{ "vi-fword", rl_vi_fword }, /* BEWARE: name matching is case insensitive */
|
||||
{ "vi-goto-mark", rl_vi_goto_mark },
|
||||
{ "vi-insert-beg", rl_vi_insert_beg },
|
||||
{ "vi-insertion-mode", rl_vi_insert_mode },
|
||||
|
||||
@@ -144,6 +144,8 @@ _rl_signal_handler (int sig)
|
||||
#if defined (SIGWINCH)
|
||||
if (sig == SIGWINCH)
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_SIGHANDLER);
|
||||
|
||||
rl_resize_terminal ();
|
||||
/* XXX - experimental for now */
|
||||
/* Call a signal hook because though we called the original signal handler
|
||||
@@ -151,6 +153,8 @@ _rl_signal_handler (int sig)
|
||||
ourselves. */
|
||||
if (rl_signal_event_hook)
|
||||
(*rl_signal_event_hook) ();
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
+70
-3
@@ -1,7 +1,7 @@
|
||||
/* input_avail.c -- check whether or not data is available for reading on a
|
||||
specified file descriptor. */
|
||||
|
||||
/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2008,2009-2019 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
# include <sys/file.h>
|
||||
#endif /* HAVE_SYS_FILE_H */
|
||||
|
||||
#if defined (HAVE_PSELECT)
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
@@ -82,10 +86,8 @@ input_avail (fd)
|
||||
timeout.tv_usec = 0;
|
||||
result = select (fd + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
|
||||
return ((result <= 0) ? 0 : 1);
|
||||
|
||||
#endif
|
||||
|
||||
result = -1;
|
||||
#if defined (FIONREAD)
|
||||
errno = 0;
|
||||
result = ioctl (fd, FIONREAD, &chars_avail);
|
||||
@@ -96,3 +98,68 @@ input_avail (fd)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Wait until NCHARS are available for reading on file descriptor FD.
|
||||
This can wait indefinitely. Return -1 on error. */
|
||||
int
|
||||
nchars_avail (fd, nchars)
|
||||
int fd;
|
||||
int nchars;
|
||||
{
|
||||
int result, chars_avail;
|
||||
#if defined(HAVE_SELECT)
|
||||
fd_set readfds, exceptfds;
|
||||
#endif
|
||||
#if defined (HAVE_PSELECT)
|
||||
sigset_t set, oset;
|
||||
#endif
|
||||
|
||||
if (fd < 0 || nchars < 0)
|
||||
return -1;
|
||||
if (nchars == 0)
|
||||
return (input_avail (fd));
|
||||
|
||||
chars_avail = 0;
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
FD_ZERO (&readfds);
|
||||
FD_ZERO (&exceptfds);
|
||||
FD_SET (fd, &readfds);
|
||||
FD_SET (fd, &exceptfds);
|
||||
#endif
|
||||
#if defined (HAVE_SELECT) || defined (HAVE_PSELECT)
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
|
||||
# ifdef SIGCHLD
|
||||
sigaddset (&set, SIGCHLD);
|
||||
# endif
|
||||
sigemptyset (&oset);
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
result = 0;
|
||||
#if defined (HAVE_PSELECT)
|
||||
/* XXX - use pselect(2) to block SIGCHLD atomically */
|
||||
result = pselect (fd + 1, &readfds, (fd_set *)NULL, &exceptfds, (struct timespec *)NULL, &set);
|
||||
#elif defined (HAVE_SELECT)
|
||||
sigprocmask (SIG_BLOCK, &set, &oset);
|
||||
result = select (fd + 1, &readfds, (fd_set *)NULL, &exceptfds, (struct timeval *)NULL);
|
||||
sigprocmask (SIG_BLOCK, &oset, (sigset_t *)NULL);
|
||||
#endif
|
||||
if (result < 0)
|
||||
return -1;
|
||||
|
||||
#if defined (FIONREAD)
|
||||
errno = 0;
|
||||
result = ioctl (fd, FIONREAD, &chars_avail);
|
||||
if (result == -1 && errno == EIO)
|
||||
return -1;
|
||||
if (chars_avail >= nchars)
|
||||
break;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/* stringlist.c - functions to handle a generic `list of strings' structure */
|
||||
|
||||
/* Copyright (C) 2000-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -255,7 +255,7 @@ strlist_sort (sl)
|
||||
{
|
||||
if (sl == 0 || sl->list_len == 0 || sl->list == 0)
|
||||
return;
|
||||
strvec_sort (sl->list);
|
||||
strvec_sort (sl->list, 0);
|
||||
}
|
||||
|
||||
STRINGLIST *
|
||||
|
||||
+28
-2
@@ -156,6 +156,28 @@ strvec_copy (array)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Comparison routine for use by qsort that conforms to the new Posix
|
||||
requirements (http://austingroupbugs.net/view.php?id=1070).
|
||||
|
||||
Perform a bytewise comparison if *S1 and *S2 collate equally. */
|
||||
int
|
||||
strvec_posixcmp (s1, s2)
|
||||
register char **s1, **s2;
|
||||
{
|
||||
int result;
|
||||
|
||||
#if defined (HAVE_STRCOLL)
|
||||
result = strcoll (*s1, *s2);
|
||||
if (result != 0)
|
||||
return result;
|
||||
#endif
|
||||
|
||||
if ((result = **s1 - **s2) == 0)
|
||||
result = strcmp (*s1, *s2);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Comparison routine for use with qsort() on arrays of strings. Uses
|
||||
strcoll(3) if available, otherwise it uses strcmp(3). */
|
||||
int
|
||||
@@ -176,10 +198,14 @@ strvec_strcmp (s1, s2)
|
||||
|
||||
/* Sort ARRAY, a null terminated array of pointers to strings. */
|
||||
void
|
||||
strvec_sort (array)
|
||||
strvec_sort (array, posix)
|
||||
char **array;
|
||||
int posix;
|
||||
{
|
||||
qsort (array, strvec_len (array), sizeof (char *), (QSFUNC *)strvec_strcmp);
|
||||
if (posix)
|
||||
qsort (array, strvec_len (array), sizeof (char *), (QSFUNC *)strvec_posixcmp);
|
||||
else
|
||||
qsort (array, strvec_len (array), sizeof (char *), (QSFUNC *)strvec_strcmp);
|
||||
}
|
||||
|
||||
/* Cons up a new array of words. The words are taken from LIST,
|
||||
|
||||
Reference in New Issue
Block a user