mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-01 17:39:56 +02:00
commit bash-20200420 snapshot
This commit is contained in:
+19
-2
@@ -349,8 +349,7 @@ _rl_input_available (void)
|
||||
FD_ZERO (&exceptfds);
|
||||
FD_SET (tty, &readfds);
|
||||
FD_SET (tty, &exceptfds);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = _keyboard_input_timeout;
|
||||
USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
|
||||
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
|
||||
#else
|
||||
|
||||
@@ -369,6 +368,24 @@ _rl_input_available (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_nchars_available ()
|
||||
{
|
||||
int chars_avail, fd, result;
|
||||
|
||||
chars_avail = 0;
|
||||
|
||||
#if defined (FIONREAD)
|
||||
fd = fileno (rl_instream);
|
||||
errno = 0;
|
||||
result = ioctl (fd, FIONREAD, &chars_avail);
|
||||
if (result == -1 && errno == EIO)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
return chars_avail;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_input_queued (int t)
|
||||
{
|
||||
|
||||
+36
-6
@@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Copyright (C) 1987-2017 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.
|
||||
@@ -257,6 +257,9 @@ _rl_isearch_init (int direction)
|
||||
|
||||
_rl_iscxt = cxt; /* save globally */
|
||||
|
||||
/* experimental right now */
|
||||
_rl_init_executing_keyseq ();
|
||||
|
||||
return cxt;
|
||||
}
|
||||
|
||||
@@ -289,12 +292,16 @@ _rl_isearch_fini (_rl_search_cxt *cxt)
|
||||
else
|
||||
cxt->sline_index = strlen (rl_line_buffer);
|
||||
rl_mark = cxt->save_mark;
|
||||
rl_deactivate_mark ();
|
||||
}
|
||||
|
||||
rl_point = cxt->sline_index;
|
||||
/* Don't worry about where to put the mark here; rl_get_previous_history
|
||||
and rl_get_next_history take care of it. */
|
||||
and rl_get_next_history take care of it.
|
||||
If we want to highlight the search string, this is where to set the
|
||||
point and mark to do it. */
|
||||
_rl_fix_point (0);
|
||||
rl_deactivate_mark ();
|
||||
|
||||
/* _rl_optimize_redisplay (); */
|
||||
rl_clear_message ();
|
||||
@@ -346,6 +353,8 @@ _rl_isearch_dispatch (_rl_search_cxt *cxt, int c)
|
||||
return -1;
|
||||
}
|
||||
|
||||
_rl_add_executing_keyseq (c);
|
||||
|
||||
/* If we are moving into a new keymap, modify cxt->keymap and go on.
|
||||
This can be a problem if c == ESC and we want to terminate the
|
||||
incremental search, so we check */
|
||||
@@ -396,7 +405,11 @@ add_character:
|
||||
if (cxt->mb[1])
|
||||
f = rl_function_of_keyseq (cxt->mb, cxt->keymap, (int *)NULL);
|
||||
else
|
||||
f = cxt->keymap[c].function;
|
||||
{
|
||||
f = cxt->keymap[c].function;
|
||||
if (f == rl_do_lowercase_version)
|
||||
f = cxt->keymap[_rl_to_lower (c)].function;
|
||||
}
|
||||
|
||||
if (f == rl_reverse_search_history)
|
||||
cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
|
||||
@@ -463,9 +476,14 @@ add_character:
|
||||
}
|
||||
else if (cxt->lastc > 0 && cxt->prevc > 0 && f && f != rl_insert)
|
||||
{
|
||||
rl_stuff_char (cxt->lastc);
|
||||
rl_execute_next (cxt->prevc);
|
||||
/* XXX - do we insert everything in cxt->pmb? */
|
||||
_rl_term_executing_keyseq (); /* should this go in the caller? */
|
||||
|
||||
_rl_pending_command.map = cxt->keymap;
|
||||
_rl_pending_command.count = 1; /* XXX */
|
||||
_rl_pending_command.key = cxt->lastc;
|
||||
_rl_pending_command.func = f;
|
||||
_rl_command_to_execute = &_rl_pending_command;
|
||||
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@@ -511,6 +529,8 @@ add_character:
|
||||
return (0);
|
||||
}
|
||||
|
||||
_rl_init_executing_keyseq ();
|
||||
|
||||
/* Now dispatch on the character. `Opcodes' affect the search string or
|
||||
state. Other characters are added to the string. */
|
||||
switch (cxt->lastc)
|
||||
@@ -528,6 +548,7 @@ add_character:
|
||||
rl_display_search (cxt->search_string, cxt->sflags, -1);
|
||||
break;
|
||||
}
|
||||
/* XXX - restore keymap here? */
|
||||
return (1);
|
||||
}
|
||||
else if ((cxt->sflags & SF_REVERSE) && cxt->sline_index >= 0)
|
||||
@@ -575,6 +596,7 @@ add_character:
|
||||
rl_replace_line (cxt->lines[cxt->save_line], 0);
|
||||
rl_point = cxt->save_point;
|
||||
rl_mark = cxt->save_mark;
|
||||
rl_deactivate_mark ();
|
||||
rl_restore_prompt();
|
||||
rl_clear_message ();
|
||||
|
||||
@@ -641,6 +663,7 @@ add_character:
|
||||
free (paste);
|
||||
break;
|
||||
}
|
||||
rl_activate_mark ();
|
||||
if (cxt->search_string_index + pastelen + 1 >= cxt->search_string_size)
|
||||
{
|
||||
cxt->search_string_size += pastelen + 2;
|
||||
@@ -745,11 +768,15 @@ add_character:
|
||||
cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0;
|
||||
}
|
||||
|
||||
/* reset the keymaps for the next time through the loop */
|
||||
cxt->keymap = cxt->okeymap = _rl_keymap;
|
||||
|
||||
if (cxt->sflags & SF_FAILED)
|
||||
{
|
||||
/* We cannot find the search string. Ding the bell. */
|
||||
rl_ding ();
|
||||
cxt->history_pos = cxt->last_found_line;
|
||||
rl_deactivate_mark ();
|
||||
rl_display_search (cxt->search_string, cxt->sflags, (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
|
||||
return 1;
|
||||
}
|
||||
@@ -761,7 +788,10 @@ add_character:
|
||||
{
|
||||
cxt->prev_line_found = cxt->lines[cxt->history_pos];
|
||||
rl_replace_line (cxt->lines[cxt->history_pos], 0);
|
||||
rl_activate_mark ();
|
||||
rl_point = cxt->sline_index;
|
||||
if (rl_mark_active_p () && cxt->search_string_index > 0)
|
||||
rl_mark = rl_point + cxt->search_string_index;
|
||||
cxt->last_found_line = cxt->history_pos;
|
||||
rl_display_search (cxt->search_string, cxt->sflags, (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
|
||||
}
|
||||
|
||||
+51
-3
@@ -73,11 +73,11 @@ extern int errno;
|
||||
#include "xmalloc.h"
|
||||
|
||||
#ifndef RL_LIBRARY_VERSION
|
||||
# define RL_LIBRARY_VERSION "5.1"
|
||||
# define RL_LIBRARY_VERSION "8.0"
|
||||
#endif
|
||||
|
||||
#ifndef RL_READLINE_VERSION
|
||||
# define RL_READLINE_VERSION 0x0501
|
||||
# define RL_READLINE_VERSION 0x0800
|
||||
#endif
|
||||
|
||||
extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
@@ -258,6 +258,9 @@ int rl_executing_key;
|
||||
char *rl_executing_keyseq = 0;
|
||||
int _rl_executing_keyseq_size = 0;
|
||||
|
||||
struct _rl_cmd _rl_pending_command;
|
||||
struct _rl_cmd *_rl_command_to_execute = (struct _rl_cmd *)NULL;
|
||||
|
||||
/* Timeout (specified in milliseconds) when reading characters making up an
|
||||
ambiguous multiple-key sequence */
|
||||
int _rl_keyseq_timeout = 500;
|
||||
@@ -634,6 +637,23 @@ readline_internal_charloop (void)
|
||||
r = _rl_dispatch ((unsigned char)c, _rl_keymap);
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
if (_rl_command_to_execute)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
|
||||
rl_executing_keymap = _rl_command_to_execute->map;
|
||||
rl_executing_key = _rl_command_to_execute->key;
|
||||
|
||||
rl_dispatching = 1;
|
||||
RL_SETSTATE(RL_STATE_DISPATCHING);
|
||||
r = (*(_rl_command_to_execute->func)) (_rl_command_to_execute->count, _rl_command_to_execute->key);
|
||||
_rl_command_to_execute = 0;
|
||||
RL_UNSETSTATE(RL_STATE_DISPATCHING);
|
||||
rl_dispatching = 0;
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
}
|
||||
|
||||
/* If there was no change in _rl_last_command_was_kill, then no kill
|
||||
has taken place. Note that if input is pending we are reading
|
||||
a prefix command, so nothing has changed yet. */
|
||||
@@ -1260,7 +1280,7 @@ readline_initialize_everything (void)
|
||||
|
||||
rl_executing_keyseq = malloc (_rl_executing_keyseq_size = 16);
|
||||
if (rl_executing_keyseq)
|
||||
rl_executing_keyseq[0] = '\0';
|
||||
rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
|
||||
}
|
||||
|
||||
/* If this system allows us to look at the values of the regular
|
||||
@@ -1472,3 +1492,31 @@ rl_restore_state (struct readline_state *sp)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Functions to manage the string that is the current key sequence. */
|
||||
|
||||
void
|
||||
_rl_init_executing_keyseq (void)
|
||||
{
|
||||
rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
_rl_term_executing_keyseq (void)
|
||||
{
|
||||
rl_executing_keyseq[rl_key_sequence_length] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
_rl_end_executing_keyseq (void)
|
||||
{
|
||||
if (rl_key_sequence_length > 0)
|
||||
rl_executing_keyseq[--rl_key_sequence_length] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
_rl_add_executing_keyseq (int key)
|
||||
{
|
||||
RESIZE_KEYSEQ_BUFFER ();
|
||||
rl_executing_keyseq[rl_key_sequence_length++] = key;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Readline.h -- the names of functions callable from within readline. */
|
||||
|
||||
/* Copyright (C) 1987-2016 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.
|
||||
|
||||
@@ -109,6 +109,15 @@ typedef struct __rl_search_context
|
||||
char *search_terminators;
|
||||
} _rl_search_cxt;
|
||||
|
||||
struct _rl_cmd {
|
||||
Keymap map;
|
||||
int count;
|
||||
int key;
|
||||
rl_command_func_t *func;
|
||||
};
|
||||
extern struct _rl_cmd _rl_pending_command;
|
||||
extern struct _rl_cmd *_rl_command_to_execute;
|
||||
|
||||
/* Callback data for reading numeric arguments */
|
||||
#define NUM_SAWMINUS 0x01
|
||||
#define NUM_SAWDIGITS 0x02
|
||||
@@ -285,6 +294,7 @@ extern void _rl_refresh_line PARAMS((void));
|
||||
/* input.c */
|
||||
extern int _rl_any_typein PARAMS((void));
|
||||
extern int _rl_input_available PARAMS((void));
|
||||
extern int _rl_nchars_available PARAMS((void));
|
||||
extern int _rl_input_queued PARAMS((int));
|
||||
extern void _rl_insert_typein PARAMS((int));
|
||||
extern int _rl_unget_char PARAMS((int));
|
||||
@@ -353,6 +363,11 @@ extern int _rl_dispatch PARAMS((int, Keymap));
|
||||
extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
|
||||
extern void _rl_internal_char_cleanup PARAMS((void));
|
||||
|
||||
extern void _rl_init_executing_keyseq PARAMS((void));
|
||||
extern void _rl_term_executing_keyseq PARAMS((void));
|
||||
extern void _rl_end_executing_keyseq PARAMS((void));
|
||||
extern void _rl_add_executing_keyseq PARAMS((int));
|
||||
|
||||
/* rltty.c */
|
||||
extern int _rl_disable_tty_signals PARAMS((void));
|
||||
extern int _rl_restore_tty_signals PARAMS((void));
|
||||
|
||||
Reference in New Issue
Block a user