summaryrefslogtreecommitdiff
path: root/lib/readline
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2020-09-09 15:25:32 -0400
committerChet Ramey <chet.ramey@case.edu>2020-09-09 15:25:32 -0400
commit3eb0018e75b74bb886df7fba4b1712529ce7258f (patch)
tree13b53713ef8f483a82295324e314da48b59c9346 /lib/readline
parent712f80b0a49c3a0227d0b52bff5e0b763747697e (diff)
downloadbash-5.1-beta.tar.gz
bash-5.1 beta releasebash-5.1-beta
Diffstat (limited to 'lib/readline')
-rw-r--r--lib/readline/complete.c31
-rw-r--r--lib/readline/doc/hstech.texi4
-rw-r--r--lib/readline/doc/rltech.texi23
-rw-r--r--lib/readline/doc/rluser.texi21
-rw-r--r--lib/readline/doc/version.texi10
-rw-r--r--lib/readline/examples/fileman.c4
-rw-r--r--lib/readline/input.c2
-rw-r--r--lib/readline/rlprivate.h3
-rw-r--r--lib/readline/signals.c73
-rw-r--r--lib/readline/vi_mode.c38
10 files changed, 162 insertions, 47 deletions
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index 989b15c2..fc5c3adb 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -1,6 +1,6 @@
/* complete.c -- filename completion for readline. */
-/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2020 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.
@@ -148,6 +148,7 @@ static int complete_fncmp PARAMS((const char *, int, const char *, int));
static void display_matches PARAMS((char **));
static int compute_lcd_of_matches PARAMS((char **, int, const char *));
static int postprocess_matches PARAMS((char ***, int));
+static int compare_match PARAMS((char *, const char *));
static int complete_get_screenwidth PARAMS((void));
static char *make_quoted_replacement PARAMS((char *, int, char *));
@@ -1964,6 +1965,26 @@ _rl_free_match_list (char **matches)
xfree (matches);
}
+/* Compare a possibly-quoted filename TEXT from the line buffer and a possible
+ MATCH that is the product of filename completion, which acts on the dequoted
+ text. */
+static int
+compare_match (char *text, const char *match)
+{
+ char *temp;
+ int r;
+
+ if (rl_filename_completion_desired && rl_filename_quoting_desired &&
+ rl_completion_found_quote && rl_filename_dequoting_function)
+ {
+ temp = (*rl_filename_dequoting_function) (text, rl_completion_quote_character);
+ r = strcmp (temp, match);
+ free (temp);
+ return r;
+ }
+ return (strcmp (text, match));
+}
+
/* Complete the word at or before point.
WHAT_TO_DO says what to do with the completion.
`?' means list the possible completions.
@@ -2010,7 +2031,7 @@ rl_complete_internal (int what_to_do)
matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char);
/* nontrivial_lcd is set if the common prefix adds something to the word
being completed. */
- nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
+ nontrivial_lcd = matches && compare_match (text, matches[0]) != 0;
if (what_to_do == '!' || what_to_do == '@')
tlen = strlen (text);
xfree (text);
@@ -2772,7 +2793,7 @@ rl_old_menu_complete (int count, int invoking_key)
{
insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, &quote_char);
append_to_match (matches[match_list_index], delimiter, quote_char,
- strcmp (orig_text, matches[match_list_index]));
+ compare_match (orig_text, matches[match_list_index]));
}
completion_changed_buffer = 1;
@@ -2846,7 +2867,7 @@ rl_menu_complete (int count, int ignore)
matches = gen_completion_matches (orig_text, orig_start, orig_end,
our_func, found_quote, quote_char);
- nontrivial_lcd = matches && strcmp (orig_text, matches[0]) != 0;
+ nontrivial_lcd = matches && compare_match (orig_text, matches[0]) != 0;
/* If we are matching filenames, the attempted completion function will
have set rl_filename_completion_desired to a non-zero value. The basic
@@ -2953,7 +2974,7 @@ rl_menu_complete (int count, int ignore)
{
insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, &quote_char);
append_to_match (matches[match_list_index], delimiter, quote_char,
- strcmp (orig_text, matches[match_list_index]));
+ compare_match (orig_text, matches[match_list_index]));
}
completion_changed_buffer = 1;
diff --git a/lib/readline/doc/hstech.texi b/lib/readline/doc/hstech.texi
index dbc21c14..2de62f76 100644
--- a/lib/readline/doc/hstech.texi
+++ b/lib/readline/doc/hstech.texi
@@ -48,7 +48,7 @@ History library is able to keep track of those lines, associate arbitrary
data with each line, and utilize information from previous lines in
composing new ones.
-The programmer using the History library has available functions
+A programmer using the History library has available functions
for remembering lines on a history list, associating arbitrary data
with a line, removing lines from the list, searching through the list
for a line containing an arbitrary text string, and referencing any line
@@ -62,7 +62,7 @@ commands for manipulating the text of previous lines and using that text
in new commands. The basic history manipulation commands are similar to
the history substitution provided by @code{csh}.
-If the programmer desires, he can use the Readline library, which
+The programmer can also use the Readline library, which
includes some history manipulation by default, and has the added
advantage of command line editing.
diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi
index 4547469e..bbf57c23 100644
--- a/lib/readline/doc/rltech.texi
+++ b/lib/readline/doc/rltech.texi
@@ -1342,6 +1342,29 @@ This differs from @code{clear_history} because it frees private data
Readline saves in the history list.
@end deftypefun
+@deftypefun {void} rl_activate_mark (void)
+Enable an @emph{active} mark.
+When this is enabled, the text between point and mark (the @var{region}) is
+displayed in the terminal's standout mode (a @var{face}).
+This is called by various readline functions that set the mark and insert
+text, and is available for applications to call.
+@end deftypefun
+
+@deftypefun {void} rl_deactivate_mark (void)
+Turn off the active mark.
+@end deftypefun
+
+@deftypefun {void} rl_keep_mark_active (void)
+Indicate that the mark should remain active when the current readline function
+completes and after redisplay occurs.
+In most cases, the mark remains active for only the duration of a single
+bindable readline function.
+@end deftypefun
+
+@deftypefun {int} rl_mark_active_p (void)
+Return a non-zero value if the mark is currently active; zero otherwise.
+@end deftypefun
+
@node Alternate Interface
@subsection Alternate Interface
diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi
index d71aa4de..746e38c8 100644
--- a/lib/readline/doc/rluser.texi
+++ b/lib/readline/doc/rluser.texi
@@ -493,9 +493,9 @@ replaced with an ellipsis when displaying possible completions.
@vindex completion-query-items
The number of possible completions that determines when the user is
asked whether the list of possibilities should be displayed.
-If the number of possible completions is greater than this value,
-Readline will ask the user whether or not he wishes to view
-them; otherwise, they are simply listed.
+If the number of possible completions is greater than or equal to this value,
+Readline will ask whether or not the user wishes to view them;
+otherwise, they are simply listed.
This variable must be set to an integer value greater than or equal to 0.
A negative value means Readline should never ask.
The default limit is @code{100}.
@@ -1115,8 +1115,8 @@ set convert-meta off
# rather than as meta-prefixed characters
set output-meta on
-# if there are more than 150 possible completions for
-# a word, ask the user if he wants to see all of them
+# if there are 150 or more possible completions for a word,
+# ask whether or not the user wants to see all of them
set completion-query-items 150
# For FTP
@@ -1254,10 +1254,12 @@ being entered.
@item reverse-search-history (C-r)
Search backward starting at the current line and moving `up' through
the history as necessary. This is an incremental search.
+This command sets the region to the matched text and activates the mark.
@item forward-search-history (C-s)
Search forward starting at the current line and moving `down' through
the history as necessary. This is an incremental search.
+This command sets the region to the matched text and activates the mark.
@item non-incremental-reverse-search-history (M-p)
Search backward starting at the current line and moving `up'
@@ -1377,6 +1379,11 @@ each character as if it had been read from the keyboard. The characters
are inserted as if each one was bound to @code{self-insert} instead of
executing any editing commands.
+Bracketed paste sets the region (the characters between point and the mark)
+to the inserted text. It uses the concept of an @emph{active mark}: when the
+mark is active, Readline redisplay uses the terminal's standout mode to
+denote the region.
+
@item transpose-chars (C-t)
Drag the character before the cursor forward over
the character at the cursor, moving the
@@ -1426,9 +1433,13 @@ By default, this command is unbound.
@item kill-line (C-k)
Kill the text from point to the end of the line.
+With a negative numeric argument, kill backward from the cursor to the
+beginning of the current line.
@item backward-kill-line (C-x Rubout)
Kill backward from the cursor to the beginning of the current line.
+With a negative numeric argument, kill forward from the cursor to the
+end of the current line.
@item unix-line-discard (C-u)
Kill backward from the cursor to the beginning of the current line.
diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi
index ba51a075..cb495abf 100644
--- a/lib/readline/doc/version.texi
+++ b/lib/readline/doc/version.texi
@@ -2,9 +2,9 @@
Copyright (C) 1988-2020 Free Software Foundation, Inc.
@end ignore
-@set EDITION 8.0
-@set VERSION 8.0
-@set UPDATED 4 May 2020
-@set UPDATED-MONTH May 2020
+@set EDITION 8.1
+@set VERSION 8.1
+@set UPDATED 17 July 2020
+@set UPDATED-MONTH July 2020
-@set LASTCHANGE Mon May 4 14:55:02 EDT 2020
+@set LASTCHANGE Fri Jul 17 09:35:36 EDT 2020
diff --git a/lib/readline/examples/fileman.c b/lib/readline/examples/fileman.c
index 6391ae6b..2a8b097a 100644
--- a/lib/readline/examples/fileman.c
+++ b/lib/readline/examples/fileman.c
@@ -377,11 +377,11 @@ com_stat (arg)
printf ("Statistics for `%s':\n", arg);
- printf ("%s has %d link%s, and is %d byte%s in length.\n",
+ printf ("%s has %d link%s, and is %lu byte%s in length.\n",
arg,
finfo.st_nlink,
(finfo.st_nlink == 1) ? "" : "s",
- finfo.st_size,
+ (unsigned long)finfo.st_size,
(finfo.st_size == 1) ? "" : "s");
printf ("Inode Last Change at: %s", ctime (&finfo.st_ctime));
printf (" Last access at: %s", ctime (&finfo.st_atime));
diff --git a/lib/readline/input.c b/lib/readline/input.c
index 9a69e13c..61b0fde3 100644
--- a/lib/readline/input.c
+++ b/lib/readline/input.c
@@ -512,7 +512,7 @@ rl_read_key (void)
{
if (rl_get_char (&c) == 0)
c = (*rl_getc_function) (rl_instream);
-/* fprintf(stderr, "rl_read_key: calling RL_CHECK_SIGNALS: _rl_caught_signal = %d", _rl_caught_signal); */
+/* fprintf(stderr, "rl_read_key: calling RL_CHECK_SIGNALS: _rl_caught_signal = %d\r\n", _rl_caught_signal); */
RL_CHECK_SIGNALS ();
}
}
diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h
index 954031d8..050f5068 100644
--- a/lib/readline/rlprivate.h
+++ b/lib/readline/rlprivate.h
@@ -65,7 +65,8 @@
#define SF_FOUND 0x02
#define SF_FAILED 0x04
#define SF_CHGKMAP 0x08
-#define SF_PATTERN 0x10 /* unused so far */
+#define SF_PATTERN 0x10
+#define SF_NOCASE 0x20 /* unused so far */
typedef struct __rl_search_context
{
diff --git a/lib/readline/signals.c b/lib/readline/signals.c
index 055de2ee..f9174ab8 100644
--- a/lib/readline/signals.c
+++ b/lib/readline/signals.c
@@ -135,7 +135,7 @@ void *_rl_sigcleanarg;
/* Readline signal handler functions. */
-/* Called from RL_CHECK_SIGNALS() macro */
+/* Called from RL_CHECK_SIGNALS() macro to run signal handling code. */
RETSIGTYPE
_rl_signal_handler (int sig)
{
@@ -170,11 +170,16 @@ rl_signal_handler (int sig)
SIGHANDLER_RETURN;
}
+/* This is called to handle a signal when it is safe to do so (out of the
+ signal handler execution path). Called by _rl_signal_handler for all the
+ signals readline catches except SIGWINCH. */
static RETSIGTYPE
_rl_handle_signal (int sig)
{
+ int block_sig;
+
#if defined (HAVE_POSIX_SIGNALS)
- sigset_t set;
+ sigset_t set, oset;
#else /* !HAVE_POSIX_SIGNALS */
# if defined (HAVE_BSD_SIGNALS)
long omask;
@@ -204,7 +209,16 @@ _rl_handle_signal (int sig)
_rl_sigcleanup = 0;
_rl_sigcleanarg = 0;
}
-
+
+#if defined (HAVE_POSIX_SIGNALS)
+ /* Get the current set of blocked signals. If we want to block a signal for
+ the duration of the cleanup functions, make sure to add it to SET and
+ set block_sig = 1 (see the SIGHUP case below). */
+ block_sig = 0; /* sentinel to block signals with sigprocmask */
+ sigemptyset (&set);
+ sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
+#endif
+
switch (sig)
{
case SIGINT:
@@ -219,38 +233,60 @@ _rl_handle_signal (int sig)
#if defined (SIGTSTP)
case SIGTSTP:
case SIGTTIN:
+ case SIGTTOU:
# if defined (HAVE_POSIX_SIGNALS)
/* Block SIGTTOU so we can restore the terminal settings to something
sane without stopping on SIGTTOU if we have been placed into the
background. Even trying to get the current terminal pgrp with
- tcgetpgrp() will generate SIGTTOU, so we don't bother. Don't bother
- doing this if we've been stopped on SIGTTOU; it's already too late. */
- sigemptyset (&set);
+ tcgetpgrp() will generate SIGTTOU, so we don't bother. We still do
+ 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);
- sigprocmask (SIG_BLOCK, &set, (sigset_t *)NULL);
+ block_sig = 1;
# endif
- case SIGTTOU:
#endif /* SIGTSTP */
- case SIGTERM:
+ /* Any signals that should be blocked during cleanup should go here. */
#if defined (SIGHUP)
case SIGHUP:
-#endif
+# if defined (_AIX)
+ if (block_sig == 0)
+ {
+ sigaddset (&set, sig);
+ block_sig = 1;
+ }
+# endif // _AIX
+#endif
+ /* Signals that don't require blocking during cleanup should go here. */
+ case SIGTERM:
#if defined (SIGALRM)
case SIGALRM:
#endif
#if defined (SIGQUIT)
case SIGQUIT:
#endif
+
+ if (block_sig)
+ sigprocmask (SIG_BLOCK, &set, &oset);
+
rl_echo_signal_char (sig);
rl_cleanup_after_signal ();
+ /* At this point, the application's signal handler, if any, is the
+ current handler. */
+
#if defined (HAVE_POSIX_SIGNALS)
-# if defined (SIGTSTP)
- /* Unblock SIGTTOU blocked above */
- if (sig == SIGTTIN || sig == SIGTSTP)
- sigprocmask (SIG_UNBLOCK, &set, (sigset_t *)NULL);
-# endif
+ /* Unblock any signal(s) blocked above */
+ if (block_sig)
+ sigprocmask (SIG_UNBLOCK, &oset, (sigset_t *)NULL);
+#endif
+ /* 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);
@@ -259,6 +295,7 @@ _rl_handle_signal (int sig)
omask = sigblock (0);
# endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
+#endif
#if defined (__EMX__)
signal (sig, SIG_ACK);
@@ -270,7 +307,10 @@ _rl_handle_signal (int sig)
raise (sig); /* assume we have raise */
#endif
- /* Let the signal that we just sent through. */
+ /* 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 */
@@ -278,6 +318,7 @@ _rl_handle_signal (int sig)
sigsetmask (omask & ~(sigmask (sig)));
# endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
+#endif
rl_reset_after_signal ();
}
diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c
index a5ec2f8b..742341e3 100644
--- a/lib/readline/vi_mode.c
+++ b/lib/readline/vi_mode.c
@@ -875,8 +875,8 @@ _rl_vi_done_inserting (void)
{
if (_rl_vi_doing_insert)
{
- /* The `C', `s', and `S' commands set this. */
- rl_end_undo_group ();
+ /* The `c', `s', `S', and `R' commands set this. */
+ rl_end_undo_group (); /* for the group in rl_vi_start_inserting */
/* Now, the text between rl_undo_list->next->start and
rl_undo_list->next->end is what was inserted while in insert
mode. It gets copied to VI_INSERT_BUFFER because it depends
@@ -887,7 +887,9 @@ _rl_vi_done_inserting (void)
_rl_vi_save_replace (); /* Half the battle */
else
_rl_vi_save_insert (rl_undo_list->next);
- vi_continued_command = 1;
+ /* sanity check, should always be >= 1 here */
+ if (_rl_undo_group_level > 0)
+ rl_end_undo_group (); /* for the group in the command (change or replace) */
}
else
{
@@ -899,10 +901,12 @@ _rl_vi_done_inserting (void)
/* XXX - Other keys probably need to be checked. */
else if (_rl_vi_last_key_before_insert == 'C')
rl_end_undo_group ();
- while (_rl_undo_group_level > 0)
- rl_end_undo_group ();
- vi_continued_command = 0;
}
+
+ /* Sanity check, make sure all the undo groups are closed before we leave
+ insert mode */
+ while (_rl_undo_group_level > 0)
+ rl_end_undo_group ();
}
int
@@ -1210,6 +1214,10 @@ _rl_vi_domove_motion_cleanup (int c, _rl_vimotion_cxt *m)
/* No change in position means the command failed. */
if (rl_mark == rl_point)
{
+ /* 'c' and 'C' enter insert mode after the delete even if the motion
+ didn't delete anything, as long as the motion command is valid. */
+ if (_rl_to_upper (m->key) == 'C' && _rl_vi_motion_command (c))
+ return (vidomove_dispatch (m));
RL_UNSETSTATE (RL_STATE_VIMOTION);
return (-1);
}
@@ -1382,7 +1390,11 @@ rl_vi_delete_to (int count, int key)
{
int c, r;
- _rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
+ if (_rl_vimvcxt)
+ _rl_mvcxt_init (_rl_vimvcxt, VIM_DELETE, key);
+ else
+ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
+
_rl_vimvcxt->start = rl_point;
rl_mark = rl_point;
@@ -1470,7 +1482,10 @@ rl_vi_change_to (int count, int key)
{
int c, r;
- _rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
+ if (_rl_vimvcxt)
+ _rl_mvcxt_init (_rl_vimvcxt, VIM_CHANGE, key);
+ else
+ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
_rl_vimvcxt->start = rl_point;
rl_mark = rl_point;
@@ -1539,7 +1554,10 @@ rl_vi_yank_to (int count, int key)
{
int c, r;
- _rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
+ if (_rl_vimvcxt)
+ _rl_mvcxt_init (_rl_vimvcxt, VIM_YANK, key);
+ else
+ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
_rl_vimvcxt->start = rl_point;
rl_mark = rl_point;
@@ -2247,7 +2265,7 @@ rl_vi_replace (int count, int key)
rl_vi_start_inserting (key, 1, rl_arg_sign);
- _rl_vi_last_key_before_insert = key;
+ _rl_vi_last_key_before_insert = 'R'; /* in case someone rebinds it */
_rl_keymap = vi_replace_map;
if (_rl_enable_bracketed_paste)