mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-12 05:00:50 +02:00
commit bash-20081002 snapshot
This commit is contained in:
@@ -1434,6 +1434,13 @@ call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force
|
||||
Readline to update its idea of the terminal size when a @code{SIGWINCH}
|
||||
is received.
|
||||
|
||||
@deftypefun rl_echo_signal_char (int sig)
|
||||
If an application wishes to install its own signal handlers, but still
|
||||
have readline display characters that generate signals, calling this
|
||||
function with @var{sig} set to @code{SIGINT}, @code{SIGQUIT}, or
|
||||
@code{SIGTSTP} will display the character generating that signal.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void rl_resize_terminal (void)
|
||||
Update Readline's internal screen size by reading values from the kernel.
|
||||
@end deftypefun
|
||||
|
||||
@@ -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.
|
||||
@@ -1898,27 +1912,51 @@ history list.
|
||||
GNU Readline library. This application interactively allows users
|
||||
to manipulate files and their modes. */
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
#ifdef HAVE_SYS_FILE_H
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
extern char *xmalloc ();
|
||||
extern char *xmalloc PARAMS((size_t));
|
||||
|
||||
/* The names of functions that actually do the manipulation. */
|
||||
int com_list __P((char *));
|
||||
int com_view __P((char *));
|
||||
int com_rename __P((char *));
|
||||
int com_stat __P((char *));
|
||||
int com_pwd __P((char *));
|
||||
int com_delete __P((char *));
|
||||
int com_help __P((char *));
|
||||
int com_cd __P((char *));
|
||||
int com_quit __P((char *));
|
||||
int com_list PARAMS((char *));
|
||||
int com_view PARAMS((char *));
|
||||
int com_rename PARAMS((char *));
|
||||
int com_stat PARAMS((char *));
|
||||
int com_pwd PARAMS((char *));
|
||||
int com_delete PARAMS((char *));
|
||||
int com_help PARAMS((char *));
|
||||
int com_cd PARAMS((char *));
|
||||
int com_quit PARAMS((char *));
|
||||
|
||||
/* A structure which contains information on the commands this program
|
||||
can understand. */
|
||||
@@ -1951,12 +1989,12 @@ COMMAND *find_command ();
|
||||
/* The name of this program, as taken from argv[0]. */
|
||||
char *progname;
|
||||
|
||||
/* When non-zero, this means the user is done using this program. */
|
||||
/* When non-zero, this global means the user is done using this program. */
|
||||
int done;
|
||||
|
||||
char *
|
||||
dupstr (s)
|
||||
int s;
|
||||
char *s;
|
||||
@{
|
||||
char *r;
|
||||
|
||||
@@ -2081,12 +2119,12 @@ stripwhite (string)
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
char *command_generator __P((const char *, int));
|
||||
char **fileman_completion __P((const char *, int, int));
|
||||
char *command_generator PARAMS((const char *, int));
|
||||
char **fileman_completion PARAMS((const char *, int, int));
|
||||
|
||||
/* Tell the GNU Readline library how to complete. We want to try to
|
||||
complete on command names if this is the first word in the line, or
|
||||
on filenames if not. */
|
||||
/* Tell the GNU Readline library how to complete. We want to try to complete
|
||||
on command names if this is the first word in the line, or on filenames
|
||||
if not. */
|
||||
initialize_readline ()
|
||||
@{
|
||||
/* Allow conditional parsing of the ~/.inputrc file. */
|
||||
@@ -2096,11 +2134,11 @@ initialize_readline ()
|
||||
rl_attempted_completion_function = fileman_completion;
|
||||
@}
|
||||
|
||||
/* Attempt to complete on the contents of TEXT. START and END
|
||||
bound the region of rl_line_buffer that contains the word to
|
||||
complete. TEXT is the word to complete. We can use the entire
|
||||
contents of rl_line_buffer in case we want to do some simple
|
||||
parsing. Returnthe array of matches, or NULL if there aren't any. */
|
||||
/* Attempt to complete on the contents of TEXT. START and END bound the
|
||||
region of rl_line_buffer that contains the word to complete. TEXT is
|
||||
the word to complete. We can use the entire contents of rl_line_buffer
|
||||
in case we want to do some simple parsing. Return the array of matches,
|
||||
or NULL if there aren't any. */
|
||||
char **
|
||||
fileman_completion (text, start, end)
|
||||
const char *text;
|
||||
@@ -2119,9 +2157,9 @@ fileman_completion (text, start, end)
|
||||
return (matches);
|
||||
@}
|
||||
|
||||
/* Generator function for command completion. STATE lets us
|
||||
know whether to start from scratch; without any state
|
||||
(i.e. STATE == 0), then we start at the top of the list. */
|
||||
/* Generator function for command completion. STATE lets us know whether
|
||||
to start from scratch; without any state (i.e. STATE == 0), then we
|
||||
start at the top of the list. */
|
||||
char *
|
||||
command_generator (text, state)
|
||||
const char *text;
|
||||
@@ -2130,17 +2168,16 @@ command_generator (text, state)
|
||||
static int list_index, len;
|
||||
char *name;
|
||||
|
||||
/* If this is a new word to complete, initialize now. This
|
||||
includes saving the length of TEXT for efficiency, and
|
||||
initializing the index variable to 0. */
|
||||
/* If this is a new word to complete, initialize now. This includes
|
||||
saving the length of TEXT for efficiency, and initializing the index
|
||||
variable to 0. */
|
||||
if (!state)
|
||||
@{
|
||||
list_index = 0;
|
||||
len = strlen (text);
|
||||
@}
|
||||
|
||||
/* Return the next name which partially matches from the
|
||||
command list. */
|
||||
/* Return the next name which partially matches from the command list. */
|
||||
while (name = commands[list_index].name)
|
||||
@{
|
||||
list_index++;
|
||||
@@ -2180,7 +2217,12 @@ com_view (arg)
|
||||
if (!valid_argument ("view", arg))
|
||||
return 1;
|
||||
|
||||
#if defined (__MSDOS__)
|
||||
/* more.com doesn't grok slashes in pathnames */
|
||||
sprintf (syscom, "less %s", arg);
|
||||
#else
|
||||
sprintf (syscom, "more %s", arg);
|
||||
#endif
|
||||
return (system (syscom));
|
||||
@}
|
||||
|
||||
@@ -2207,7 +2249,8 @@ com_stat (arg)
|
||||
|
||||
printf ("Statistics for `%s':\n", arg);
|
||||
|
||||
printf ("%s has %d link%s, and is %d byte%s in length.\n", arg,
|
||||
printf ("%s has %d link%s, and is %d byte%s in length.\n",
|
||||
arg,
|
||||
finfo.st_nlink,
|
||||
(finfo.st_nlink == 1) ? "" : "s",
|
||||
finfo.st_size,
|
||||
@@ -2296,8 +2339,7 @@ com_pwd (ignore)
|
||||
return 0;
|
||||
@}
|
||||
|
||||
/* The user wishes to quit using this program. Just set DONE
|
||||
non-zero. */
|
||||
/* The user wishes to quit using this program. Just set DONE non-zero. */
|
||||
com_quit (arg)
|
||||
char *arg;
|
||||
@{
|
||||
@@ -2310,13 +2352,12 @@ too_dangerous (caller)
|
||||
char *caller;
|
||||
@{
|
||||
fprintf (stderr,
|
||||
"%s: Too dangerous for me to distribute.\n",
|
||||
"%s: Too dangerous for me to distribute. Write it yourself.\n",
|
||||
caller);
|
||||
fprintf (stderr, "Write it yourself.\n");
|
||||
@}
|
||||
|
||||
/* Return non-zero if ARG is a valid argument for CALLER,
|
||||
else print an error message and return zero. */
|
||||
/* Return non-zero if ARG is a valid argument for CALLER, else print
|
||||
an error message and return zero. */
|
||||
int
|
||||
valid_argument (caller, arg)
|
||||
char *caller, *arg;
|
||||
|
||||
@@ -1743,9 +1743,10 @@ Perform directory name completion if the compspec generates no matches.
|
||||
|
||||
@item filenames
|
||||
Tell Readline that the compspec generates filenames, so it can perform any
|
||||
filename-specific processing (like adding a slash to directory names or
|
||||
suppressing trailing spaces). This option is intended to be used with
|
||||
shell functions specified with @option{-F}.
|
||||
filename-specific processing (like adding a slash to directory names
|
||||
quoting special characters, or suppressing trailing spaces).
|
||||
This option is intended to be used with shell functions specified
|
||||
with @option{-F}.
|
||||
|
||||
@item nospace
|
||||
Tell Readline not to append a space (the default) to words completed at
|
||||
|
||||
@@ -4,7 +4,7 @@ Copyright (C) 1988-2008 Free Software Foundation, Inc.
|
||||
|
||||
@set EDITION 6.0
|
||||
@set VERSION 6.0
|
||||
@set UPDATED 12 August 2008
|
||||
@set UPDATED-MONTH August 2008
|
||||
@set UPDATED 4 October 2008
|
||||
@set UPDATED-MONTH October 2008
|
||||
|
||||
@set LASTCHANGE Tue Aug 12 16:41:31 EDT 2008
|
||||
@set LASTCHANGE Sun Oct 5 00:18:13 EDT 2008
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
Copyright (C) 1988-2008 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set EDITION 5.2
|
||||
@set VERSION 5.2
|
||||
@set UPDATED 8 May 2008
|
||||
@set UPDATED-MONTH May 2008
|
||||
@set EDITION 6.0
|
||||
@set VERSION 6.0
|
||||
@set UPDATED 12 August 2008
|
||||
@set UPDATED-MONTH August 2008
|
||||
|
||||
@set LASTCHANGE Thu May 8 09:29:33 EDT 2008
|
||||
@set LASTCHANGE Tue Aug 12 16:41:31 EDT 2008
|
||||
|
||||
@@ -318,6 +318,8 @@ add_history_time (string)
|
||||
{
|
||||
HIST_ENTRY *hs;
|
||||
|
||||
if (string == 0)
|
||||
return;
|
||||
hs = the_history[history_length - 1];
|
||||
FREE (hs->timestamp);
|
||||
hs->timestamp = savestring (string);
|
||||
|
||||
+15
-14
@@ -1,24 +1,23 @@
|
||||
/* history.c -- standalone history library */
|
||||
|
||||
/* Copyright (C) 1989-2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2008 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
This file contains the GNU History Library (History), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
History is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
History is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with History. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* The goal is to make the implementation transparent, so that you
|
||||
don't have to know what data types are used, just what functions
|
||||
@@ -319,6 +318,8 @@ add_history_time (string)
|
||||
{
|
||||
HIST_ENTRY *hs;
|
||||
|
||||
if (string == 0)
|
||||
return;
|
||||
hs = the_history[history_length - 1];
|
||||
FREE (hs->timestamp);
|
||||
hs->timestamp = savestring (string);
|
||||
@@ -483,7 +484,7 @@ stifle_history (max)
|
||||
|
||||
/* Stop stifling the history. This returns the previous maximum
|
||||
number of history entries. The value is positive if the history
|
||||
was stifled, negative if it wasn't. */
|
||||
was stifled, negative if it wasn't. */
|
||||
int
|
||||
unstifle_history ()
|
||||
{
|
||||
|
||||
@@ -428,7 +428,9 @@ extern int rl_clear_signals PARAMS((void));
|
||||
extern void rl_cleanup_after_signal PARAMS((void));
|
||||
extern void rl_reset_after_signal PARAMS((void));
|
||||
extern void rl_free_line_state PARAMS((void));
|
||||
|
||||
|
||||
extern void rl_echo_signal_char PARAMS((int));
|
||||
|
||||
extern int rl_set_paren_blink_timeout PARAMS((int));
|
||||
|
||||
/* Undocumented. */
|
||||
|
||||
+19
-16
@@ -2,23 +2,22 @@
|
||||
|
||||
/* 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.
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_READLINE_H_)
|
||||
#define _READLINE_H_
|
||||
@@ -40,9 +39,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Hex-encoded Readline version number. */
|
||||
#define RL_READLINE_VERSION 0x0502 /* Readline 5.2 */
|
||||
#define RL_VERSION_MAJOR 5
|
||||
#define RL_VERSION_MINOR 2
|
||||
#define RL_READLINE_VERSION 0x0600 /* Readline 6.0 */
|
||||
#define RL_VERSION_MAJOR 6
|
||||
#define RL_VERSION_MINOR 0
|
||||
|
||||
/* Readline data structures. */
|
||||
|
||||
@@ -429,7 +428,7 @@ extern int rl_clear_signals PARAMS((void));
|
||||
extern void rl_cleanup_after_signal PARAMS((void));
|
||||
extern void rl_reset_after_signal PARAMS((void));
|
||||
extern void rl_free_line_state PARAMS((void));
|
||||
|
||||
|
||||
extern int rl_set_paren_blink_timeout PARAMS((int));
|
||||
|
||||
/* Undocumented. */
|
||||
@@ -605,6 +604,10 @@ extern int rl_catch_sigwinch;
|
||||
filename completer. */
|
||||
extern rl_compentry_func_t *rl_completion_entry_function;
|
||||
|
||||
/* Optional generator for menu completion. Default is
|
||||
rl_completion_entry_function (rl_filename_completion_function). */
|
||||
extern rl_compentry_func_t *rl_menu_completion_entry_function;
|
||||
|
||||
/* If rl_ignore_some_completions_function is non-NULL it is the address
|
||||
of a function to call after all of the possible matches have been
|
||||
generated, but before the actual completion is done to the input line.
|
||||
|
||||
@@ -423,6 +423,13 @@ extern _rl_keyseq_cxt *_rl_kscxt;
|
||||
/* search.c */
|
||||
extern _rl_search_cxt *_rl_nscxt;
|
||||
|
||||
/* signals.c */
|
||||
extern int _rl_echoctl;
|
||||
|
||||
extern _rl_intr_char;
|
||||
extern _rl_quit_char;
|
||||
extern _rl_susp_char;
|
||||
|
||||
/* terminal.c */
|
||||
extern int _rl_enable_keypad;
|
||||
extern int _rl_enable_meta;
|
||||
|
||||
@@ -294,6 +294,8 @@ extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
|
||||
extern void _rl_block_sigint PARAMS((void));
|
||||
extern void _rl_release_sigint PARAMS((void));
|
||||
|
||||
extern void _rl_echo_signal_char PARAMS((int));
|
||||
|
||||
/* terminal.c */
|
||||
extern void _rl_get_screen_size PARAMS((int, int));
|
||||
extern int _rl_init_terminal_io PARAMS((const char *));
|
||||
@@ -330,11 +332,15 @@ extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *));
|
||||
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
|
||||
extern void _rl_ttymsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
extern void _rl_errmsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
extern void _rl_trace (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
#else
|
||||
extern void _rl_ttymsg ();
|
||||
extern void _rl_errmsg ();
|
||||
extern void _rl_trace ();
|
||||
#endif
|
||||
|
||||
extern int _rl_tropen PARAMS((void));
|
||||
|
||||
extern int _rl_abort_internal PARAMS((void));
|
||||
extern char *_rl_strindex PARAMS((const char *, const char *));
|
||||
extern int _rl_qsort_string_compare PARAMS((char **, char **));
|
||||
@@ -419,6 +425,13 @@ extern _rl_keyseq_cxt *_rl_kscxt;
|
||||
/* search.c */
|
||||
extern _rl_search_cxt *_rl_nscxt;
|
||||
|
||||
/* signals.c */
|
||||
extern int _rl_echoctl;
|
||||
|
||||
extern _rl_intr_char;
|
||||
extern _rl_quit_char;
|
||||
extern _rl_susp_char;
|
||||
|
||||
/* terminal.c */
|
||||
extern int _rl_enable_keypad;
|
||||
extern int _rl_enable_meta;
|
||||
|
||||
+10
-6
@@ -137,8 +137,9 @@ save_tty_chars (tiop)
|
||||
|
||||
if (tiop->flags & TCHARS_SET)
|
||||
{
|
||||
_rl_tty_chars.t_intr = tiop->tchars.t_intrc;
|
||||
_rl_tty_chars.t_quit = tiop->tchars.t_quitc;
|
||||
_rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
|
||||
_rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
|
||||
|
||||
_rl_tty_chars.t_start = tiop->tchars.t_startc;
|
||||
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
|
||||
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
|
||||
@@ -148,7 +149,8 @@ save_tty_chars (tiop)
|
||||
|
||||
if (tiop->flags & LTCHARS_SET)
|
||||
{
|
||||
_rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
|
||||
_rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
|
||||
|
||||
_rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
|
||||
_rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
|
||||
_rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
|
||||
@@ -236,6 +238,7 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
_rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
|
||||
_rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL);
|
||||
|
||||
/* Copy the original settings to the structure we're going to use for
|
||||
our settings. */
|
||||
@@ -366,10 +369,10 @@ save_tty_chars (tiop)
|
||||
#ifdef VREPRINT
|
||||
_rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
|
||||
#endif
|
||||
_rl_tty_chars.t_intr = tiop->c_cc[VINTR];
|
||||
_rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
|
||||
_rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
|
||||
_rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
|
||||
#ifdef VSUSP
|
||||
_rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
|
||||
_rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
|
||||
#endif
|
||||
#ifdef VDSUSP
|
||||
_rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
|
||||
@@ -514,6 +517,7 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
_rl_echoing_p = (oldtio.c_lflag & ECHO);
|
||||
_rl_echoctl = (oldtio.c_lflag & ECHOCTL);
|
||||
|
||||
tiop->c_lflag &= ~(ICANON | ECHO);
|
||||
|
||||
|
||||
+33
-97
@@ -3,23 +3,23 @@
|
||||
|
||||
/* Copyright (C) 1992-2005 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.
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
@@ -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 */
|
||||
@@ -204,8 +137,9 @@ save_tty_chars (tiop)
|
||||
|
||||
if (tiop->flags & TCHARS_SET)
|
||||
{
|
||||
_rl_tty_chars.t_intr = tiop->tchars.t_intrc;
|
||||
_rl_tty_chars.t_quit = tiop->tchars.t_quitc;
|
||||
_rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
|
||||
_rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
|
||||
|
||||
_rl_tty_chars.t_start = tiop->tchars.t_startc;
|
||||
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
|
||||
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
|
||||
@@ -215,7 +149,8 @@ save_tty_chars (tiop)
|
||||
|
||||
if (tiop->flags & LTCHARS_SET)
|
||||
{
|
||||
_rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
|
||||
_rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
|
||||
|
||||
_rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
|
||||
_rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
|
||||
_rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
|
||||
@@ -268,7 +203,7 @@ set_tty_settings (tty, tiop)
|
||||
ioctl (tty, TIOCSETN, &(tiop->sgttyb));
|
||||
tiop->flags &= ~SGTTY_SET;
|
||||
}
|
||||
readline_echoing_p = 1;
|
||||
_rl_echoing_p = 1;
|
||||
|
||||
#if defined (TIOCLSET)
|
||||
if (tiop->flags & LFLAG_SET)
|
||||
@@ -302,7 +237,7 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
|
||||
_rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
|
||||
|
||||
/* Copy the original settings to the structure we're going to use for
|
||||
our settings. */
|
||||
@@ -433,10 +368,10 @@ save_tty_chars (tiop)
|
||||
#ifdef VREPRINT
|
||||
_rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
|
||||
#endif
|
||||
_rl_tty_chars.t_intr = tiop->c_cc[VINTR];
|
||||
_rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
|
||||
_rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
|
||||
_rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
|
||||
#ifdef VSUSP
|
||||
_rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
|
||||
_rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
|
||||
#endif
|
||||
#ifdef VDSUSP
|
||||
_rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
|
||||
@@ -580,7 +515,7 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
readline_echoing_p = (oldtio.c_lflag & ECHO);
|
||||
_rl_echoing_p = (oldtio.c_lflag & ECHO);
|
||||
|
||||
tiop->c_lflag &= ~(ICANON | ECHO);
|
||||
|
||||
@@ -643,7 +578,7 @@ void
|
||||
rl_prep_terminal (meta_flag)
|
||||
int meta_flag;
|
||||
{
|
||||
readline_echoing_p = 1;
|
||||
_rl_echoing_p = 1;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -663,7 +598,7 @@ rl_prep_terminal (meta_flag)
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being INTerrupted. */
|
||||
block_sigint ();
|
||||
_rl_block_sigint ();
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
@@ -676,8 +611,9 @@ rl_prep_terminal (meta_flag)
|
||||
#else
|
||||
if (errno == ENOTTY || errno == EINVAL)
|
||||
#endif
|
||||
readline_echoing_p = 1; /* XXX */
|
||||
release_sigint ();
|
||||
_rl_echoing_p = 1; /* XXX */
|
||||
|
||||
_rl_release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -712,7 +648,7 @@ rl_prep_terminal (meta_flag)
|
||||
|
||||
if (set_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
release_sigint ();
|
||||
_rl_release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -723,7 +659,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 +672,7 @@ rl_deprep_terminal ()
|
||||
return;
|
||||
|
||||
/* Try to keep this function from being interrupted. */
|
||||
block_sigint ();
|
||||
_rl_block_sigint ();
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
@@ -747,14 +683,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 */
|
||||
|
||||
|
||||
@@ -94,6 +94,14 @@ int rl_catch_sigwinch = 1;
|
||||
int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
|
||||
#endif
|
||||
|
||||
/* Private variables. */
|
||||
/* If non-zero, print characters corresponding to received signals. */
|
||||
int _rl_echoctl = 0;
|
||||
|
||||
int _rl_intr_char = 0;
|
||||
int _rl_quit_char = 0;
|
||||
int _rl_susp_char = 0;
|
||||
|
||||
static int signals_set_flag;
|
||||
static int sigwinch_set_flag;
|
||||
|
||||
@@ -159,6 +167,7 @@ rl_signal_handler (sig)
|
||||
#if defined (SIGQUIT)
|
||||
case SIGQUIT:
|
||||
#endif
|
||||
rl_echo_signal_char (sig);
|
||||
rl_cleanup_after_signal ();
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
@@ -534,3 +543,41 @@ _rl_release_sigint ()
|
||||
|
||||
sigint_blocked = 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Echoing special control characters */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
void
|
||||
rl_echo_signal_char (sig)
|
||||
int sig;
|
||||
{
|
||||
char cstr[3];
|
||||
int cslen, c;
|
||||
|
||||
if (_rl_echoctl == 0)
|
||||
return;
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case SIGINT: c = _rl_intr_char; break;
|
||||
case SIGQUIT: c = _rl_quit_char; break;
|
||||
case SIGTSTP: c = _rl_susp_char; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
if (CTRL_CHAR (c) || c == RUBOUT)
|
||||
{
|
||||
cstr[0] = '^';
|
||||
cstr[1] = CTRL_CHAR (c) ? UNCTRL (c) : '?';
|
||||
cstr[cslen = 2] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
cstr[0] = c;
|
||||
cstr[cslen = 1] = '\0';
|
||||
}
|
||||
|
||||
_rl_output_some_chars (cstr, cslen);
|
||||
}
|
||||
|
||||
+129
-14
@@ -1,24 +1,24 @@
|
||||
/* signals.c -- signal handling support for readline. */
|
||||
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
@@ -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
|
||||
@@ -93,6 +94,14 @@ int rl_catch_sigwinch = 1;
|
||||
int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
|
||||
#endif
|
||||
|
||||
/* Private variables. */
|
||||
/* If non-zero, print characters corresponding to received signals. */
|
||||
int _rl_echoctl = 0;
|
||||
|
||||
int _rl_intr_char = 0;
|
||||
int _rl_quit_char = 0;
|
||||
int _rl_susp_char = 0;
|
||||
|
||||
static int signals_set_flag;
|
||||
static int sigwinch_set_flag;
|
||||
|
||||
@@ -253,7 +262,11 @@ rl_set_sighandler (sig, handler, ohandler)
|
||||
struct sigaction act;
|
||||
|
||||
act.sa_handler = handler;
|
||||
# if defined (SIGWINCH)
|
||||
act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
|
||||
# else
|
||||
act.sa_flags = 0;
|
||||
# endif /* SIGWINCH */
|
||||
sigemptyset (&act.sa_mask);
|
||||
sigemptyset (&ohandler->sa_mask);
|
||||
sigaction (sig, &act, &old_handler);
|
||||
@@ -465,3 +478,105 @@ 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;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Echoing special control characters */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
void
|
||||
rl_echo_signal_char (sig)
|
||||
int sig;
|
||||
{
|
||||
char cstr[3];
|
||||
int cslen, c;
|
||||
|
||||
if (_rl_echoctl == 0)
|
||||
return;
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case SIGINT: c = _rl_intr_char; break;
|
||||
case SIGQUIT: c = _rl_quit_char; break;
|
||||
case SIGTSTP: c = _rl_susp_char; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
if (CTRL_CHAR (c) || c == RUBOUT)
|
||||
{
|
||||
cstr[0] = '^';
|
||||
cstr[1] = CTRL_CHAR (c) ? UNCTRL (c) : '?';
|
||||
cstr[cslen = 2] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
cstr[0] = c;
|
||||
cstr[cslen = 1] = '\0';
|
||||
}
|
||||
|
||||
_rl_output_some_chars (cstr, cslen);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user