Imported from ../bash-4.0.tar.gz.

This commit is contained in:
Jari Aalto 2009-02-19 22:21:29 +00:00
commit 17345e5ad2
134 changed files with 74214 additions and 4584 deletions

View file

@ -796,6 +796,8 @@ _rl_read_file (filename, sizep)
return ((char *)NULL);
}
RL_CHECK_SIGNALS ();
buffer[i] = '\0';
if (sizep)
*sizep = i;
@ -864,6 +866,7 @@ _rl_read_init_file (filename, include_level)
buffer = _rl_read_file (openname, &file_size);
xfree (openname);
RL_CHECK_SIGNALS ();
if (buffer == 0)
return (errno);

View file

@ -87,6 +87,7 @@ _rl_callback_newline ()
}
readline_internal_setup ();
RL_CHECK_SIGNALS ();
}
/* Install a readline handler, set up the terminal, and issue the prompt. */
@ -127,6 +128,7 @@ rl_callback_read_char ()
do
{
RL_CHECK_SIGNALS ();
if (RL_ISSTATE (RL_STATE_ISEARCH))
{
eof = _rl_isearch_callback (_rl_iscxt);
@ -186,6 +188,7 @@ rl_callback_read_char ()
else
eof = readline_internal_char ();
RL_CHECK_SIGNALS ();
if (rl_done == 0 && _rl_want_redisplay)
{
(*rl_redisplay_function) ();
@ -223,6 +226,7 @@ rl_callback_handler_remove ()
{
rl_linefunc = NULL;
RL_UNSETSTATE (RL_STATE_CALLBACK);
RL_CHECK_SIGNALS ();
if (in_handler)
{
in_handler = 0;

View file

@ -1019,7 +1019,9 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
variable rl_attempted_completion_function. */
if (rl_attempted_completion_function)
{
_rl_interrupt_immediately++;
matches = (*rl_attempted_completion_function) (text, start, end);
_rl_interrupt_immediately--;
if (matches || rl_attempted_completion_over)
{
@ -1881,6 +1883,7 @@ rl_completion_matches (text, entry_function)
match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *));
match_list[1] = (char *)NULL;
_rl_interrupt_immediately++;
while (string = (*entry_function) (text, matches))
{
if (matches + 1 == match_list_size)
@ -1890,6 +1893,7 @@ rl_completion_matches (text, entry_function)
match_list[++matches] = string;
match_list[matches + 1] = (char *)NULL;
}
_rl_interrupt_immediately--;
/* If there were any matches, then look through them finding out the
lowest common denominator. That then becomes match_list[0]. */

View file

@ -1016,7 +1016,7 @@ history_expand (hstring, output)
}
else if (string[i] == history_expansion_char)
{
if (!cc || member (cc, history_no_expand_chars))
if (cc == 0 || member (cc, history_no_expand_chars))
continue;
/* If the calling application has set
history_inhibit_expansion_function to a function that checks
@ -1164,7 +1164,8 @@ history_expand (hstring, output)
/* If the history_expansion_char is followed by one of the
characters in history_no_expand_chars, then it is not a
candidate for expansion of any kind. */
if (member (cc, history_no_expand_chars))
if (cc == 0 || member (cc, history_no_expand_chars) ||
(history_inhibit_expansion_function && (*history_inhibit_expansion_function) (string, i)))
{
ADD_CHAR (string[i]);
break;

View file

@ -252,6 +252,7 @@ rl_gather_tyi ()
{
while (chars_avail--)
{
RL_CHECK_SIGNALS ();
k = (*rl_getc_function) (rl_instream);
if (rl_stuff_char (k) == 0)
break; /* some problem; no more room */
@ -437,6 +438,7 @@ rl_read_key ()
while (rl_event_hook && rl_get_char (&c) == 0)
{
(*rl_event_hook) ();
RL_CHECK_SIGNALS ();
if (rl_done) /* XXX - experimental */
return ('\n');
if (rl_gather_tyi () < 0) /* XXX - EIO */
@ -450,6 +452,7 @@ rl_read_key ()
{
if (rl_get_char (&c) == 0)
c = (*rl_getc_function) (rl_instream);
RL_CHECK_SIGNALS ();
}
}
@ -465,6 +468,8 @@ rl_getc (stream)
while (1)
{
RL_CHECK_SIGNALS ();
#if defined (__MINGW32__)
if (isatty (fileno (stream)))
return (getch ());

View file

@ -383,7 +383,7 @@ _rl_isearch_dispatch (cxt, c)
{
if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc))
{
/* This sets rl_pending_input to c; it will be picked up the next
/* This sets rl_pending_input to LASTC; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (cxt->lastc);
return (0);

View file

@ -397,6 +397,8 @@ readline_internal_setup ()
if (rl_pre_input_hook)
(*rl_pre_input_hook) ();
RL_CHECK_SIGNALS ();
}
STATIC_CALLBACK char *
@ -406,6 +408,8 @@ readline_internal_teardown (eof)
char *temp;
HIST_ENTRY *entry;
RL_CHECK_SIGNALS ();
/* Restore the original of this history line, iff the line that we
are editing was originally in the history, AND the line has changed. */
entry = current_history ();
@ -542,6 +546,7 @@ readline_internal_charloop ()
lastc = c;
_rl_dispatch ((unsigned char)c, _rl_keymap);
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
@ -662,7 +667,6 @@ _rl_dispatch_callback (cxt)
int nkey, r;
/* For now */
#if 1
/* The first time this context is used, we want to read input and dispatch
on it. When traversing the chain of contexts back `up', we want to use
the value from the next context down. We're simulating recursion using
@ -680,13 +684,11 @@ _rl_dispatch_callback (cxt)
}
else
r = cxt->childval;
#else
r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
#endif
/* For now */
r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
RL_CHECK_SIGNALS ();
if (r == 0) /* success! */
{
_rl_keyseq_chain_dispose ();
@ -773,6 +775,8 @@ _rl_dispatch_subseq (key, map, got_subseq)
remember the last command executed in this variable. */
if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
rl_last_func = map[key].function;
RL_CHECK_SIGNALS ();
}
else if (map[ANYOTHERKEY].function)
{

View file

@ -37,6 +37,11 @@
#define VI_COMMAND_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
#define VI_INSERT_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_insertion_keymap)
#define RL_CHECK_SIGNALS() \
do { \
if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \
} while (0)
/*************************************************************************
* *
* Global structs undocumented in texinfo manual and not in readline.h *
@ -291,6 +296,8 @@ extern int _rl_restore_tty_signals PARAMS((void));
extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
/* signals.c */
extern void _rl_signal_handler PARAMS((int));
extern void _rl_block_sigint PARAMS((void));
extern void _rl_release_sigint PARAMS((void));
@ -424,6 +431,9 @@ extern _rl_keyseq_cxt *_rl_kscxt;
extern _rl_search_cxt *_rl_nscxt;
/* signals.c */
extern int _rl_interrupt_immediately;
extern int volatile _rl_caught_signal;
extern int _rl_echoctl;
extern int _rl_intr_char;

View file

@ -81,6 +81,9 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt
static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
static RETSIGTYPE rl_signal_handler PARAMS((int));
static RETSIGTYPE _rl_handle_signal PARAMS((int));
/* Exported variables for use by applications. */
/* If non-zero, readline will install its own signal handlers for
@ -95,6 +98,9 @@ int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
#endif
/* Private variables. */
int _rl_interrupt_immediately = 0;
int volatile _rl_caught_signal = 0; /* should be sig_atomic_t, but that requires including <signal.h> everywhere */
/* If non-zero, print characters corresponding to received signals. */
int _rl_echoctl = 0;
@ -121,9 +127,33 @@ static sighandler_cxt old_winch;
/* Readline signal handler functions. */
/* Called from RL_CHECK_SIGNALS() macro */
RETSIGTYPE
_rl_signal_handler (sig)
{
_rl_caught_signal = 0; /* XXX */
_rl_handle_signal (sig);
SIGHANDLER_RETURN;
}
static RETSIGTYPE
rl_signal_handler (sig)
int sig;
{
if (_rl_interrupt_immediately)
{
_rl_interrupt_immediately = 0;
_rl_handle_signal (sig);
}
_rl_caught_signal = sig;
SIGHANDLER_RETURN;
}
static RETSIGTYPE
_rl_handle_signal (sig)
int sig;
{
#if defined (HAVE_POSIX_SIGNALS)
sigset_t set;

View file

@ -114,7 +114,7 @@ rl_free_undo_list ()
rl_undo_list = rl_undo_list->next;
if (release->what == UNDO_DELETE)
free (release->text);
xfree (release->text);
xfree (release);
}
@ -191,7 +191,7 @@ rl_do_undo ()
case UNDO_DELETE:
rl_point = start;
rl_insert_text (rl_undo_list->text);
free (rl_undo_list->text);
xfree (rl_undo_list->text);
break;
/* Undoing inserts means deleting some text. */