mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 23:53:18 +02:00
commit bash-20080320 snapshot
This commit is contained in:
@@ -15380,6 +15380,9 @@ pcomplete.c
|
||||
etc.)
|
||||
- new function, pcomp_set_compspec_options, to set or unset bits in
|
||||
the options word of a passed compspec (default CURCS)
|
||||
- only call bash_dequote_filename (via rl_filename_dequoting_function)
|
||||
from pcomp_filename_completion_function if the readline state
|
||||
word indicates word completion is in progress
|
||||
|
||||
pcomplete.h
|
||||
- new extern declaration for curcs
|
||||
@@ -15393,3 +15396,37 @@ bashline.c
|
||||
the following character is one of the special ones
|
||||
- call pcomp_set_readline_variables from attempt_shell_completion
|
||||
instead of doing the equivalent inline
|
||||
|
||||
3/18
|
||||
----
|
||||
bracecomp.c
|
||||
- make sure we sort array of matches in byte order (using strcmp). so
|
||||
the brace calculations work correctly even when the locale orders
|
||||
characters like aAbBcC...zZ. Fixes bug reported by Torsten Nahm
|
||||
<torstennahm@torstennahm.de>
|
||||
|
||||
3/20
|
||||
----
|
||||
lib/readline/{rltty,signals}.c
|
||||
- move block_sigint and release_sigint from rltty.c to signals.c; add
|
||||
_rl_ prefix to make them public to the library; change callers.
|
||||
From Jan Kratchovil <jan.kratchovil@redhat.com>
|
||||
|
||||
lib/readline/rlprivate.h
|
||||
- new extern declarations for _rl_block_sigint and _rl_release_sigint
|
||||
|
||||
lib/readline/display.c
|
||||
- add calls to _rl_block_sigint and _rl_release_sigint to rl_redisplay,
|
||||
since it maniupluates global data structures. Fix from Jan
|
||||
Kratchovil <jan.kratchovil@redhat.com>
|
||||
|
||||
builtins/printf.def
|
||||
- change calls to asprintf and manually adding to vbuf to use calls
|
||||
to vsnprintf against vbuf directly -- if the number of characters
|
||||
to be written overflows the buffer, realloc the buffer and use
|
||||
vsnprintf again. This should reduce the memory used by printf.
|
||||
Idea from Yuya Katayama <yuya999@gmail.com>
|
||||
|
||||
lib/readline/doc/rltech.texi
|
||||
- documented rest of readline's state flags, including RL_STATE_CALLBACK
|
||||
- documented rl_save_state and rl_restore_state
|
||||
|
||||
@@ -15378,10 +15378,16 @@ pcomplete.c
|
||||
- new function, pcomp_set_readline_variables, that sets or unsets
|
||||
readline variables based on a passed flags value (COPT_FILENAMES,
|
||||
etc.)
|
||||
- new function, pcomp_set_compspec_options, to set or unset bits in
|
||||
the options word of a passed compspec (default CURCS)
|
||||
- only call bash_dequote_filename (via rl_filename_dequoting_function)
|
||||
from pcomp_filename_completion_function if the readline state
|
||||
word indicates word completion is in progress
|
||||
|
||||
pcomplete.h
|
||||
- new extern declaration for curcs
|
||||
- new extern declaration for pcomp_set_readline_variables
|
||||
- new extern declaration for pcomp_set_compspec_options
|
||||
|
||||
bashline.c
|
||||
- fix bash_dequote_filename to implement shell quoting conventions:
|
||||
@@ -15390,3 +15396,33 @@ bashline.c
|
||||
the following character is one of the special ones
|
||||
- call pcomp_set_readline_variables from attempt_shell_completion
|
||||
instead of doing the equivalent inline
|
||||
|
||||
3/18
|
||||
----
|
||||
bracecomp.c
|
||||
- make sure we sort array of matches in byte order (using strcmp). so
|
||||
the brace calculations work correctly even when the locale orders
|
||||
characters like aAbBcC...zZ. Fixes bug reported by Torsten Nahm
|
||||
<torstennahm@torstennahm.de>
|
||||
|
||||
3/20
|
||||
----
|
||||
lib/readline/{rltty,signals}.c
|
||||
- move block_sigint and release_sigint from rltty.c to signals.c; add
|
||||
_rl_ prefix to make them public to the library; change callers.
|
||||
From Jan Kratchovil <jan.kratchovil@redhat.com>
|
||||
|
||||
lib/readline/rlprivate.h
|
||||
- new extern declarations for _rl_block_sigint and _rl_release_sigint
|
||||
|
||||
lib/readline/display.c
|
||||
- add calls to _rl_block_sigint and _rl_release_sigint to rl_redisplay,
|
||||
since it maniupluates global data structures. Fix from Jan
|
||||
Kratchovil <jan.kratchovil@redhat.com>
|
||||
|
||||
builtins/printf.def
|
||||
- change calls to asprintf and manually adding to vbuf to use calls
|
||||
to vsnprintf against vbuf directly -- if the number of characters
|
||||
to be written overflows the buffer, realloc the buffer and use
|
||||
vsnprintf again. This should reduce the memory used by printf.
|
||||
Idea from Yuya Katayama <yuya999@gmail.com>
|
||||
|
||||
+21
-1
@@ -35,10 +35,13 @@
|
||||
#endif
|
||||
|
||||
#include "bashansi.h"
|
||||
#include "shmbutil.h"
|
||||
|
||||
#include "shell.h"
|
||||
#include <readline/readline.h>
|
||||
|
||||
static int _strcompare __P((char **, char **));
|
||||
|
||||
/* Find greatest common prefix of two strings. */
|
||||
static int
|
||||
string_gcd (s1, s2)
|
||||
@@ -145,6 +148,19 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
|
||||
return (result);
|
||||
}
|
||||
|
||||
static int
|
||||
_strcompare (s1, s2)
|
||||
char **s1, **s2;
|
||||
{
|
||||
int result;
|
||||
|
||||
result = **s1 - **s2;
|
||||
if (result == 0)
|
||||
result = strcmp (*s1, *s2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
hack_braces_completion (names)
|
||||
char **names;
|
||||
@@ -152,7 +168,11 @@ hack_braces_completion (names)
|
||||
register int i;
|
||||
char *temp;
|
||||
|
||||
temp = really_munge_braces (names, 1, strvec_len (names), 0);
|
||||
i = strvec_len (names);
|
||||
if (MB_CUR_MAX > 1 && i > 2)
|
||||
qsort (names+1, i-1, sizeof (char *), (QSFUNC *)_strcompare);
|
||||
|
||||
temp = really_munge_braces (names, 1, i, 0);
|
||||
|
||||
for (i = 0; names[i]; ++i)
|
||||
{
|
||||
|
||||
+49
-17
@@ -107,31 +107,22 @@ extern int errno;
|
||||
|
||||
#define PF(f, func) \
|
||||
do { \
|
||||
char *b = 0; \
|
||||
int nw; \
|
||||
clearerr (stdout); \
|
||||
if (have_fieldwidth && have_precision) \
|
||||
nw = asprintf(&b, f, fieldwidth, precision, func); \
|
||||
nw = vflag ? vbprintf (f, fieldwidth, precision, func) : printf (f, fieldwidth, precision, func); \
|
||||
else if (have_fieldwidth) \
|
||||
nw = asprintf(&b, f, fieldwidth, func); \
|
||||
nw = vflag ? vbprintf (f, fieldwidth, func) : printf (f, fieldwidth, func); \
|
||||
else if (have_precision) \
|
||||
nw = asprintf(&b, f, precision, func); \
|
||||
nw = vflag ? vbprintf (f, precision, func) : printf (f, fieldwidth, func); \
|
||||
else \
|
||||
nw = asprintf(&b, f, func); \
|
||||
nw = vflag ? vbprintf (f, func) : printf (f, func); \
|
||||
tw += nw; \
|
||||
if (b) \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
if (vflag) \
|
||||
(void)vbadd (b, nw); \
|
||||
else \
|
||||
(void)fputs (b, stdout); \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
sh_wrerror (); \
|
||||
clearerr (stdout); \
|
||||
return (EXECUTION_FAILURE); \
|
||||
} \
|
||||
free (b); \
|
||||
sh_wrerror (); \
|
||||
clearerr (stdout); \
|
||||
return (EXECUTION_FAILURE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -175,11 +166,16 @@ extern int errno;
|
||||
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
extern int vsnprintf __P((char *, size_t, const char *, ...)) __attribute__((__format__ (printf, 3, 4)));
|
||||
#endif
|
||||
|
||||
static void printf_erange __P((char *));
|
||||
static int printstr __P((char *, char *, int, int, int));
|
||||
static int tescape __P((char *, char *, int *));
|
||||
static char *bexpand __P((char *, int, int *, int *));
|
||||
static char *vbadd __P((char *, int));
|
||||
static int vbprintf __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
|
||||
static char *mklong __P((char *, char *, size_t));
|
||||
static int getchr __P((void));
|
||||
static char *getstr __P((void));
|
||||
@@ -862,6 +858,42 @@ vbadd (buf, blen)
|
||||
return vbuf;
|
||||
}
|
||||
|
||||
static int
|
||||
#if defined (PREFER_STDARG)
|
||||
vbprintf (const char *format, ...)
|
||||
#else
|
||||
vbprintf (format, va_alist)
|
||||
const char *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
size_t nlen;
|
||||
int blen;
|
||||
|
||||
SH_VA_START (args, format);
|
||||
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
|
||||
|
||||
nlen = vblen + blen + 1;
|
||||
if (nlen >= vbsize)
|
||||
{
|
||||
vbsize = ((nlen + 63) >> 6) << 6;
|
||||
vbuf = (char *)xrealloc (vbuf, vbsize);
|
||||
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
vblen += blen;
|
||||
vbuf[vblen] = '\0';
|
||||
|
||||
#ifdef DEBUG
|
||||
if (strlen (vbuf) != vblen)
|
||||
internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||
#endif
|
||||
|
||||
return (blen);
|
||||
}
|
||||
|
||||
static char *
|
||||
mklong (str, modifiers, mlen)
|
||||
char *str;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+51
-18
@@ -37,7 +37,7 @@ format specifications, each of which causes printing of the next successive
|
||||
argument.
|
||||
|
||||
In addition to the standard format specifications described in printf(1)
|
||||
and printf(3), print interprets:
|
||||
and printf(3), printf interprets:
|
||||
|
||||
%b expand backslash escape sequences in the corresponding argument
|
||||
%q quote the argument in a way that can be reused as shell input
|
||||
@@ -107,31 +107,22 @@ extern int errno;
|
||||
|
||||
#define PF(f, func) \
|
||||
do { \
|
||||
char *b = 0; \
|
||||
int nw; \
|
||||
clearerr (stdout); \
|
||||
if (have_fieldwidth && have_precision) \
|
||||
nw = asprintf(&b, f, fieldwidth, precision, func); \
|
||||
nw = vflag ? vbprintf (f, fieldwidth, precision, func) : printf (f, fieldwidth, precision, func); \
|
||||
else if (have_fieldwidth) \
|
||||
nw = asprintf(&b, f, fieldwidth, func); \
|
||||
nw = vflag ? vbprintf (f, fieldwidth, func) : printf (f, fieldwidth, func); \
|
||||
else if (have_precision) \
|
||||
nw = asprintf(&b, f, precision, func); \
|
||||
nw = vflag ? vbprintf (f, precision, func) : printf (f, fieldwidth, func); \
|
||||
else \
|
||||
nw = asprintf(&b, f, func); \
|
||||
nw = vflag ? vbprintf (f, func) : printf (f, func); \
|
||||
tw += nw; \
|
||||
if (b) \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
if (vflag) \
|
||||
(void)vbadd (b, nw); \
|
||||
else \
|
||||
(void)fputs (b, stdout); \
|
||||
if (ferror (stdout)) \
|
||||
{ \
|
||||
sh_wrerror (); \
|
||||
clearerr (stdout); \
|
||||
return (EXECUTION_FAILURE); \
|
||||
} \
|
||||
free (b); \
|
||||
sh_wrerror (); \
|
||||
clearerr (stdout); \
|
||||
return (EXECUTION_FAILURE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -175,11 +166,17 @@ extern int errno;
|
||||
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
extern int vsnprintf __P((char *, size_t, const char *, ...)) __attribute__((__format__ (printf, 3, 4)));
|
||||
#endif
|
||||
|
||||
static void printf_erange __P((char *));
|
||||
static int printstr __P((char *, char *, int, int, int));
|
||||
static int tescape __P((char *, char *, int *));
|
||||
static char *bexpand __P((char *, int, int *, int *));
|
||||
static char *vbadd __P((char *, int));
|
||||
static int vbprintf __P((const char *, ...))
|
||||
__attribute__((__format__ (printf, 1, 2)));
|
||||
static char *mklong __P((char *, char *, size_t));
|
||||
static int getchr __P((void));
|
||||
static char *getstr __P((void));
|
||||
@@ -862,6 +859,42 @@ vbadd (buf, blen)
|
||||
return vbuf;
|
||||
}
|
||||
|
||||
static int
|
||||
#if defined (PREFER_STDARG)
|
||||
vbprintf (const char *format, ...)
|
||||
#else
|
||||
vbprintf (format, va_alist)
|
||||
const char *format;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
size_t nlen;
|
||||
int blen;
|
||||
|
||||
SH_VA_START (args, format);
|
||||
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
|
||||
|
||||
nlen = vblen + blen + 1;
|
||||
if (nlen >= vbsize)
|
||||
{
|
||||
vbsize = ((nlen + 63) >> 6) << 6;
|
||||
vbuf = (char *)xrealloc (vbuf, vbsize);
|
||||
blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
vblen += blen;
|
||||
vbuf[vblen] = '\0';
|
||||
|
||||
#ifdef DEBUG
|
||||
if (strlen (vbuf) != vblen)
|
||||
internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf));
|
||||
#endif
|
||||
|
||||
return (blen);
|
||||
}
|
||||
|
||||
static char *
|
||||
mklong (str, modifiers, mlen)
|
||||
char *str;
|
||||
|
||||
@@ -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