commit bash-20190215 snapshot

This commit is contained in:
Chet Ramey
2019-02-18 09:56:34 -05:00
parent 439b8c2c5f
commit be4078d25f
56 changed files with 12464 additions and 5238 deletions
+46 -14
View File
@@ -135,12 +135,13 @@ rl_add_defun (const char *name, rl_command_func_t *function, int key)
int
rl_bind_key (int key, rl_command_func_t *function)
{
char keyseq[3];
char keyseq[4];
int l;
if (key < 0)
if (key < 0 || key > largest_char)
return (key);
/* Want to make this a multi-character key sequence with an ESC prefix */
if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
{
if (_rl_keymap[ESC].type == ISKMAP)
@@ -153,7 +154,14 @@ rl_bind_key (int key, rl_command_func_t *function)
escmap[key].function = function;
return (0);
}
return (key);
/* Otherwise, let's just let rl_generic_bind handle the key sequence.
We start it off with ESC here and let the code below add the rest
of the sequence. */
keyseq[0] = ESC;
l = 1;
key = UNMETA(key);
goto bind_keyseq;
}
/* If it's bound to a function or macro, just overwrite. Otherwise we have
@@ -168,6 +176,7 @@ rl_bind_key (int key, rl_command_func_t *function)
else
{
l = 0;
bind_keyseq:
if (key == '\\')
keyseq[l++] = '\\';
keyseq[l++] = key;
@@ -397,6 +406,9 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
return -1;
}
/* We now rely on rl_translate_keyseq to do this conversion, so this
check is superfluous. */
#if 0
if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
{
ic = UNMETA (ic);
@@ -406,6 +418,7 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
map = FUNCTION_TO_KEYMAP (map, ESC);
}
}
#endif
if ((i + 1) < keys_len)
{
@@ -486,13 +499,25 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
return 0;
}
#define ADD_NORMAL_CHAR(c) \
do { \
if (META_CHAR (c) && _rl_convert_meta_chars_to_ascii) \
{ \
array[l++] = ESC; \
array[l++] = UNMETA (c); \
} \
else \
array[l++] = (c); \
} while (0)
/* Translate the ASCII representation of SEQ, stuffing the values into ARRAY,
an array of characters. LEN gets the final length of ARRAY. Return
non-zero if there was an error parsing SEQ. */
int
rl_translate_keyseq (const char *seq, char *array, int *len)
{
register int i, c, l, temp;
register int i, l, temp;
unsigned char c;
for (i = l = 0; c = seq[i]; i++)
{
@@ -519,9 +544,13 @@ rl_translate_keyseq (const char *seq, char *array, int *len)
else if (c == 'M')
{
i++; /* seq[i] == '-' */
/* XXX - obey convert-meta setting */
if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP)
array[l++] = ESC; /* ESC is meta-prefix */
/* XXX - obey convert-meta setting, convert to key seq */
if (_rl_convert_meta_chars_to_ascii)
{
array[l++] = ESC; /* ESC is meta-prefix */
i++;
array[l++] = UNMETA (seq[i]); /* UNMETA just in case */
}
else if (seq[i+1] == '\\' && seq[i+2] == 'C' && seq[i+3] == '-')
{
i += 4;
@@ -590,7 +619,8 @@ rl_translate_keyseq (const char *seq, char *array, int *len)
for (temp = 2, c -= '0'; ISOCTAL ((unsigned char)seq[i]) && temp--; i++)
c = (c * 8) + OCTVALUE (seq[i]);
i--; /* auto-increment in for loop */
array[l++] = c & largest_char;
c &= largest_char;
ADD_NORMAL_CHAR (c);
break;
case 'x':
i++;
@@ -599,16 +629,18 @@ rl_translate_keyseq (const char *seq, char *array, int *len)
if (temp == 2)
c = 'x';
i--; /* auto-increment in for loop */
array[l++] = c & largest_char;
c &= largest_char;
ADD_NORMAL_CHAR (c);
break;
default: /* backslashes before non-special chars just add the char */
array[l++] = c;
c &= largest_char;
ADD_NORMAL_CHAR (c);
break; /* the backslash is stripped */
}
continue;
}
array[l++] = c;
ADD_NORMAL_CHAR (c);
}
*len = l;
@@ -809,7 +841,7 @@ _rl_function_of_keyseq_internal (const char *keyseq, size_t len, Keymap map, int
{
/* If this is the last key in the key sequence, return the
map. */
if (keyseq[i + 1] == '\0')
if (i + 1 == len)
{
if (type)
*type = ISKMAP;
@@ -822,9 +854,9 @@ _rl_function_of_keyseq_internal (const char *keyseq, size_t len, Keymap map, int
/* If we're not at the end of the key sequence, and the current key
is bound to something other than a keymap, then the entire key
sequence is not bound. */
else if (map[ic].type != ISKMAP && keyseq[i+1])
else if (map[ic].type != ISKMAP && i+1 < len)
return ((rl_command_func_t *)NULL);
else /* map[ic].type != ISKMAP && keyseq[i+1] == 0 */
else /* map[ic].type != ISKMAP && i+1 == len */
{
if (type)
*type = map[ic].type;
+15 -2
View File
@@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
/* Copyright (C) 1987-2019 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.
@@ -435,7 +435,7 @@ rl_replace_from_history (HIST_ENTRY *entry, int flags)
intended to be called while actively editing, and the current line is
not assumed to have been added to the history list. */
void
_rl_revert_all_lines (void)
_rl_revert_previous_lines (void)
{
int hpos;
HIST_ENTRY *entry;
@@ -479,6 +479,19 @@ _rl_revert_all_lines (void)
xfree (lbuf);
}
/* Revert all lines in the history by making sure we are at the end of the
history before calling _rl_revert_previous_lines() */
void
_rl_revert_all_lines (void)
{
int pos;
pos = where_history ();
using_history ();
_rl_revert_previous_lines ();
history_set_pos (pos);
}
/* Free the history list, including private readline data and take care
of pointer aliases to history data. Resets rl_undo_list if it points
to an UNDO_LIST * saved as some history entry's data member. This
+2 -8
View File
@@ -1,7 +1,7 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
/* Copyright (C) 1987-2019 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.
@@ -458,7 +458,6 @@ readline_internal_teardown (int eof)
{
char *temp;
HIST_ENTRY *entry;
int pos;
RL_CHECK_SIGNALS ();
@@ -478,12 +477,7 @@ readline_internal_teardown (int eof)
}
if (_rl_revert_all_at_newline)
{
pos = where_history ();
using_history ();
_rl_revert_all_lines ();
history_set_pos (pos);
}
_rl_revert_all_lines ();
/* At any rate, it is highly likely that this line has an undo list. Get
rid of it now. */
+2 -1
View File
@@ -1,7 +1,7 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999-2015 Free Software Foundation, Inc.
/* Copyright (C) 1999-2019 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.
@@ -332,6 +332,7 @@ extern void _rl_start_using_history PARAMS((void));
extern int _rl_free_saved_history_line PARAMS((void));
extern void _rl_set_insert_mode PARAMS((int, int));
extern void _rl_revert_previous_lines PARAMS((void));
extern void _rl_revert_all_lines PARAMS((void));
/* nls.c */
+1 -1
View File
@@ -103,9 +103,9 @@ _rl_abort_internal (void)
_rl_reset_argument ();
rl_clear_pending_input ();
RL_UNSETSTATE (RL_STATE_MACRODEF);
while (rl_executing_macro)
_rl_pop_executing_macro ();
_rl_kill_kbd_macro ();
RL_UNSETSTATE (RL_STATE_MULTIKEY); /* XXX */