mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-16 16:36:03 +02:00
commit bash-20080320 snapshot
This commit is contained in:
@@ -506,9 +506,13 @@ rl_redisplay ()
|
||||
int _rl_wrapped_multicolumn = 0;
|
||||
#endif
|
||||
|
||||
if (!readline_echoing_p)
|
||||
if (readline_echoing_p == 0)
|
||||
return;
|
||||
|
||||
/* Block keyboard interrupts because this function manipulates global
|
||||
data structures. */
|
||||
_rl_block_sigint ();
|
||||
|
||||
if (!rl_display_prompt)
|
||||
rl_display_prompt = "";
|
||||
|
||||
@@ -1233,6 +1237,8 @@ rl_redisplay ()
|
||||
else
|
||||
visible_wrap_offset = wrap_offset;
|
||||
}
|
||||
|
||||
_rl_release_sigint ();
|
||||
}
|
||||
|
||||
/* PWP: update_line() is based on finding the middle difference of each
|
||||
|
||||
@@ -656,7 +656,6 @@ rl_redisplay ()
|
||||
#endif
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (line_state_invisible
|
||||
memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wbsize * sizeof (int));
|
||||
num = 0;
|
||||
#endif
|
||||
|
||||
@@ -523,6 +523,20 @@ Readline is performing word completion.
|
||||
Readline is currently executing the readline signal handler.
|
||||
@item RL_STATE_UNDOING
|
||||
Readline is performing an undo.
|
||||
@item RL_STATE_INPUTPENDING
|
||||
Readline has input pending due to a call to @code{rl_execute_next()}.
|
||||
@item RL_STATE_TTYCSAVED
|
||||
Readline has saved the values of the terminal's special characters.
|
||||
@item RL_STATE_CALLBACK
|
||||
Readline is currently using the alternate (callback) interface
|
||||
(@pxref{Alternate Interface}).
|
||||
@item RL_STATE_VIMOTION
|
||||
Readline is reading the argument to a vi-mode "motion" command.
|
||||
@item RL_STATE_MULTIKEY
|
||||
Readline is reading a multiple-keystroke command.
|
||||
@item RL_STATE_VICMDONCE
|
||||
Readline has entered vi command (movement) mode at least one time during
|
||||
the current call to @code{readline()}.
|
||||
@item RL_STATE_DONE
|
||||
Readline has read a key sequence bound to @code{accept-line}
|
||||
and is about to return the line to the caller.
|
||||
@@ -1083,6 +1097,21 @@ environment variable is used.
|
||||
@node Utility Functions
|
||||
@subsection Utility Functions
|
||||
|
||||
@deftypefun int rl_save_state (struct readline_state *sp)
|
||||
Save a snapshot of Readline's internal state to @var{sp}.
|
||||
The contents of the @var{readline_state} structure are documented
|
||||
in @file{readline.h}.
|
||||
The caller is responsible for allocating the structure.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int rl_restore_state (struct readline_state *sp)
|
||||
Restore Readline's internal state to that stored in @var{sp}, which must
|
||||
have been saved by a call to @code{rl_save_state}.
|
||||
The contents of the @var{readline_state} structure are documented
|
||||
in @file{readline.h}.
|
||||
The caller is responsible for freeing the structure.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void rl_free (void *mem)
|
||||
Deallocate the memory pointed to by @var{mem}. @var{mem} must have been
|
||||
allocated by @code{malloc}.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
@comment %**start of header (This is for running Texinfo on a region.)
|
||||
@setfilename rltech.info
|
||||
@comment %**end of header (This is for running Texinfo on a region.)
|
||||
@setchapternewpage odd
|
||||
|
||||
@ifinfo
|
||||
This document describes the GNU Readline Library, a utility for aiding
|
||||
@@ -1084,6 +1083,21 @@ environment variable is used.
|
||||
@node Utility Functions
|
||||
@subsection Utility Functions
|
||||
|
||||
@deftypefun int rl_save_state (struct readline_state *sp)
|
||||
Save a snapshot of Readline's internal state to @var{sp}.
|
||||
The contents of the @var{readline_state} structure are documented
|
||||
in @file{readline.h}.
|
||||
The caller is responsible for allocating the structure.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun int rl_restore_state (struct readline_state *sp)
|
||||
Restore Readline's internal state to that stored in @var{sp}, which must
|
||||
have been saved by a call to @code{rl_save_state}.
|
||||
The contents of the @var{readline_state} structure are documented
|
||||
in @file{readline.h}.
|
||||
The caller is responsible for freeing the structure.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void rl_free (void *mem)
|
||||
Deallocate the memory pointed to by @var{mem}. @var{mem} must have been
|
||||
allocated by @code{malloc}.
|
||||
|
||||
@@ -305,7 +305,9 @@ readline (prompt)
|
||||
const char *prompt;
|
||||
{
|
||||
char *value;
|
||||
#if 0
|
||||
int in_callback;
|
||||
#endif
|
||||
|
||||
/* If we are at EOF return a NULL string. */
|
||||
if (rl_pending_input == EOF)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* readline.c -- a general facility for reading lines of input
|
||||
with emacs style editing and completion. */
|
||||
|
||||
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
@@ -1189,6 +1189,7 @@ rl_save_state (sp)
|
||||
sp->prompt = rl_prompt;
|
||||
|
||||
sp->rlstate = rl_readline_state;
|
||||
sp->in_callback = RL_ISSTATE (RL_STATE_CALLBACK).
|
||||
sp->done = rl_done;
|
||||
sp->kmap = _rl_keymap;
|
||||
|
||||
@@ -1223,6 +1224,7 @@ rl_restore_state (sp)
|
||||
rl_prompt = sp->prompt;
|
||||
|
||||
rl_readline_state = sp->rlstate;
|
||||
/* Don't need to do anything with sp->in_callback */
|
||||
rl_done = sp->done;
|
||||
_rl_keymap = sp->kmap;
|
||||
|
||||
|
||||
@@ -294,6 +294,10 @@ extern int _rl_restore_tty_signals PARAMS((void));
|
||||
/* search.c */
|
||||
extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
|
||||
|
||||
/* signals.c */
|
||||
extern void _rl_block_sigint PARAMS((void));
|
||||
extern void _rl_release_sigint PARAMS((void));
|
||||
|
||||
/* terminal.c */
|
||||
extern void _rl_get_screen_size PARAMS((int, int));
|
||||
extern int _rl_init_terminal_io PARAMS((const char *));
|
||||
|
||||
@@ -216,6 +216,7 @@ extern void _rl_callback_data_dispose PARAMS((_rl_callback_generic_arg *));
|
||||
/* bind.c */
|
||||
|
||||
/* complete.c */
|
||||
extern void _rl_reset_completion_state PARAMS((void));
|
||||
extern char _rl_find_completion_word PARAMS((int *, int *));
|
||||
extern void _rl_free_match_list PARAMS((char **));
|
||||
|
||||
|
||||
+8
-74
@@ -52,75 +52,8 @@ extern int errno;
|
||||
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
|
||||
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
|
||||
|
||||
static void block_sigint PARAMS((void));
|
||||
static void release_sigint PARAMS((void));
|
||||
|
||||
static void set_winsize PARAMS((int));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Signal Management */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
static sigset_t sigint_set, sigint_oset;
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
static int sigint_oldmask;
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
static int sigint_blocked;
|
||||
|
||||
/* Cause SIGINT to not be delivered until the corresponding call to
|
||||
release_sigint(). */
|
||||
static void
|
||||
block_sigint ()
|
||||
{
|
||||
if (sigint_blocked)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigemptyset (&sigint_set);
|
||||
sigemptyset (&sigint_oset);
|
||||
sigaddset (&sigint_set, SIGINT);
|
||||
sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigint_oldmask = sigblock (sigmask (SIGINT));
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
# if defined (HAVE_USG_SIGHOLD)
|
||||
sighold (SIGINT);
|
||||
# endif /* HAVE_USG_SIGHOLD */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
sigint_blocked = 1;
|
||||
}
|
||||
|
||||
/* Allow SIGINT to be delivered. */
|
||||
static void
|
||||
release_sigint ()
|
||||
{
|
||||
if (sigint_blocked == 0)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
|
||||
#else
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigsetmask (sigint_oldmask);
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
# if defined (HAVE_USG_SIGHOLD)
|
||||
sigrelse (SIGINT);
|
||||
# endif /* HAVE_USG_SIGHOLD */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
sigint_blocked = 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Saving and Restoring the TTY */
|
||||
@@ -663,7 +596,7 @@ rl_prep_terminal (meta_flag)
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being INTerrupted. */
|
||||
block_sigint ();
|
||||
_rl_block_sigint ();
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
@@ -677,7 +610,8 @@ rl_prep_terminal (meta_flag)
|
||||
if (errno == ENOTTY || errno == EINVAL)
|
||||
#endif
|
||||
readline_echoing_p = 1; /* XXX */
|
||||
release_sigint ();
|
||||
|
||||
_rl_release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -712,7 +646,7 @@ rl_prep_terminal (meta_flag)
|
||||
|
||||
if (set_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
_rl_release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -723,7 +657,7 @@ rl_prep_terminal (meta_flag)
|
||||
terminal_prepped = 1;
|
||||
RL_SETSTATE(RL_STATE_TERMPREPPED);
|
||||
|
||||
release_sigint ();
|
||||
_rl_release_sigint ();
|
||||
}
|
||||
|
||||
/* Restore the terminal's normal settings and modes. */
|
||||
@@ -736,7 +670,7 @@ rl_deprep_terminal ()
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being interrupted. */
|
||||
block_sigint ();
|
||||
_rl_block_sigint ();
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
@@ -747,14 +681,14 @@ rl_deprep_terminal ()
|
||||
|
||||
if (set_tty_settings (tty, &otio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
_rl_release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
terminal_prepped = 0;
|
||||
RL_UNSETSTATE(RL_STATE_TERMPREPPED);
|
||||
|
||||
release_sigint ();
|
||||
_rl_release_sigint ();
|
||||
}
|
||||
#endif /* !NO_TTY_DRIVER */
|
||||
|
||||
|
||||
@@ -670,10 +670,11 @@ rl_prep_terminal (meta_flag)
|
||||
if (get_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
#if defined (ENOTSUP)
|
||||
/* MacOS X, at least, lies about the value of errno if tcgetattr fails. */
|
||||
if (errno == ENOTTY || errno == ENOTSUP)
|
||||
/* MacOS X and Linux, at least, lie about the value of errno if
|
||||
tcgetattr fails. */
|
||||
if (errno == ENOTTY || errno == EINVAL || errno == ENOTSUP)
|
||||
#else
|
||||
if (errno == ENOTTY)
|
||||
if (errno == ENOTTY || errno == EINVAL)
|
||||
#endif
|
||||
readline_echoing_p = 1; /* XXX */
|
||||
release_sigint ();
|
||||
|
||||
+66
-1
@@ -40,13 +40,14 @@
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL */
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
|
||||
#if !defined (RETSIGTYPE)
|
||||
# if defined (VOID_SIGHANDLER)
|
||||
# define RETSIGTYPE void
|
||||
@@ -465,3 +466,67 @@ rl_free_line_state ()
|
||||
}
|
||||
|
||||
#endif /* HANDLE_SIGNALS */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* SIGINT Management */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
static sigset_t sigint_set, sigint_oset;
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
static int sigint_oldmask;
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
static int sigint_blocked;
|
||||
|
||||
/* Cause SIGINT to not be delivered until the corresponding call to
|
||||
release_sigint(). */
|
||||
void
|
||||
_rl_block_sigint ()
|
||||
{
|
||||
if (sigint_blocked)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigemptyset (&sigint_set);
|
||||
sigemptyset (&sigint_oset);
|
||||
sigaddset (&sigint_set, SIGINT);
|
||||
sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigint_oldmask = sigblock (sigmask (SIGINT));
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
# if defined (HAVE_USG_SIGHOLD)
|
||||
sighold (SIGINT);
|
||||
# endif /* HAVE_USG_SIGHOLD */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
sigint_blocked = 1;
|
||||
}
|
||||
|
||||
/* Allow SIGINT to be delivered. */
|
||||
void
|
||||
_rl_release_sigint ()
|
||||
{
|
||||
if (sigint_blocked == 0)
|
||||
return;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL);
|
||||
#else
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigsetmask (sigint_oldmask);
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
# if defined (HAVE_USG_SIGHOLD)
|
||||
sigrelse (SIGINT);
|
||||
# endif /* HAVE_USG_SIGHOLD */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
sigint_blocked = 0;
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ rl_signal_handler (sig)
|
||||
switch (sig)
|
||||
{
|
||||
case SIGINT:
|
||||
_rl_reset_completion_state ();
|
||||
rl_free_line_state ();
|
||||
/* FALLTHROUGH */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user