mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-17 00:46:38 +02:00
bash-5.1 beta release
This commit is contained in:
@@ -583,15 +583,10 @@ BRACKMATCH (p, test, flags)
|
||||
isrange = 1;
|
||||
}
|
||||
|
||||
#if 0 /* TAG: bash-5.1 */
|
||||
if (isrange == 0 && test == cstart)
|
||||
goto matched;
|
||||
if (isrange && RANGECMP (test, cstart, forcecoll) >= 0 && RANGECMP (test, cend, forcecoll) <= 0)
|
||||
goto matched;
|
||||
#else
|
||||
if (RANGECMP (test, cstart, forcecoll) >= 0 && RANGECMP (test, cend, forcecoll) <= 0)
|
||||
goto matched;
|
||||
#endif
|
||||
|
||||
if (c == L(']'))
|
||||
break;
|
||||
|
||||
+85
-25
@@ -36,6 +36,12 @@
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if FNMATCH_EQUIV_FALLBACK
|
||||
/* We don't include <fnmatch.h> in order to avoid namespace collisions; the
|
||||
internal strmatch still uses the FNM_ constants. */
|
||||
extern int fnmatch (const char *, const char *, int);
|
||||
#endif
|
||||
|
||||
/* First, compile `sm_loop.c' for single-byte characters. */
|
||||
#define CHAR unsigned char
|
||||
#define U_CHAR unsigned char
|
||||
@@ -55,6 +61,32 @@ extern int errno;
|
||||
|
||||
int glob_asciirange = GLOBASCII_DEFAULT;
|
||||
|
||||
#if FNMATCH_EQUIV_FALLBACK
|
||||
/* Construct a string w1 = "c1" and a pattern w2 = "[[=c2=]]" and pass them
|
||||
to fnmatch to see if wide characters c1 and c2 collate as members of the
|
||||
same equivalence class. We can't really do this portably any other way */
|
||||
static int
|
||||
_fnmatch_fallback (s, p)
|
||||
int s, p; /* string char, patchar */
|
||||
{
|
||||
char s1[2]; /* string */
|
||||
char s2[8]; /* constructed pattern */
|
||||
|
||||
s1[0] = (unsigned char)s;
|
||||
s1[1] = '\0';
|
||||
|
||||
/* reconstruct the pattern */
|
||||
s2[0] = s2[1] = '[';
|
||||
s2[2] = '=';
|
||||
s2[3] = (unsigned char)p;
|
||||
s2[4] = '=';
|
||||
s2[5] = s2[6] = ']';
|
||||
s2[7] = '\0';
|
||||
|
||||
return (fnmatch ((const char *)s2, (const char *)s1, 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We use strcoll(3) for range comparisons in bracket expressions,
|
||||
even though it can have unwanted side effects in locales
|
||||
other than POSIX or US. For instance, in the de locale, [A-Z] matches
|
||||
@@ -63,9 +95,11 @@ int glob_asciirange = GLOBASCII_DEFAULT;
|
||||
straight ordering as if in the C locale. */
|
||||
|
||||
#if defined (HAVE_STRCOLL)
|
||||
/* Helper function for collating symbol equivalence. */
|
||||
/* Helper functions for collating symbol equivalence. */
|
||||
|
||||
/* Return 0 if C1 == C2 or collates equally if FORCECOLL is non-zero. */
|
||||
static int
|
||||
rangecmp (c1, c2, forcecoll)
|
||||
charcmp (c1, c2, forcecoll)
|
||||
int c1, c2;
|
||||
int forcecoll;
|
||||
{
|
||||
@@ -86,8 +120,21 @@ rangecmp (c1, c2, forcecoll)
|
||||
s1[0] = c1;
|
||||
s2[0] = c2;
|
||||
|
||||
if ((ret = strcoll (s1, s2)) != 0)
|
||||
return ret;
|
||||
return (strcoll (s1, s2));
|
||||
}
|
||||
|
||||
static int
|
||||
rangecmp (c1, c2, forcecoll)
|
||||
int c1, c2;
|
||||
int forcecoll;
|
||||
{
|
||||
int r;
|
||||
|
||||
r = charcmp (c1, c2, forcecoll);
|
||||
|
||||
/* We impose a total ordering here by returning c1-c2 if charcmp returns 0 */
|
||||
if (r != 0)
|
||||
return r;
|
||||
return (c1 - c2); /* impose total ordering */
|
||||
}
|
||||
#else /* !HAVE_STRCOLL */
|
||||
@@ -95,14 +142,23 @@ rangecmp (c1, c2, forcecoll)
|
||||
#endif /* !HAVE_STRCOLL */
|
||||
|
||||
#if defined (HAVE_STRCOLL)
|
||||
/* Returns 1 if chars C and EQUIV collate equally in the current locale. */
|
||||
static int
|
||||
collequiv (c1, c2)
|
||||
int c1, c2;
|
||||
collequiv (c, equiv)
|
||||
int c, equiv;
|
||||
{
|
||||
return (rangecmp (c1, c2, 1) == 0);
|
||||
if (charcmp (c, equiv, 1) == 0)
|
||||
return 1;
|
||||
|
||||
#if FNMATCH_EQUIV_FALLBACK
|
||||
return (_fnmatch_fallback (c, equiv) == 0);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
#else
|
||||
# define collequiv(c1, c2) ((c1) == (c2))
|
||||
# define collequiv(c, equiv) ((c) == (equiv))
|
||||
#endif
|
||||
|
||||
#define _COLLSYM _collsym
|
||||
@@ -290,10 +346,6 @@ is_cclass (c, name)
|
||||
extern char *mbsmbchar PARAMS((const char *));
|
||||
|
||||
#if FNMATCH_EQUIV_FALLBACK
|
||||
/* We don't include <fnmatch.h> in order to avoid namespace collisions; the
|
||||
internal strmatch still uses the FNM_ constants. */
|
||||
extern int fnmatch (const char *, const char *, int);
|
||||
|
||||
/* Construct a string w1 = "c1" and a pattern w2 = "[[=c2=]]" and pass them
|
||||
to fnmatch to see if wide characters c1 and c2 collate as members of the
|
||||
same equivalence class. We can't really do this portably any other way */
|
||||
@@ -325,13 +377,13 @@ _fnmatch_fallback_wc (c1, c2)
|
||||
#endif
|
||||
|
||||
static int
|
||||
rangecmp_wc (c1, c2, forcecoll)
|
||||
charcmp_wc (c1, c2, forcecoll)
|
||||
wint_t c1, c2;
|
||||
int forcecoll;
|
||||
{
|
||||
static wchar_t s1[2] = { L' ', L'\0' };
|
||||
static wchar_t s2[2] = { L' ', L'\0' };
|
||||
int r, oerrno;
|
||||
int r;
|
||||
|
||||
if (c1 == c2)
|
||||
return 0;
|
||||
@@ -342,27 +394,35 @@ rangecmp_wc (c1, c2, forcecoll)
|
||||
s1[0] = c1;
|
||||
s2[0] = c2;
|
||||
|
||||
#if 0 /* TAG:bash-5.1 */
|
||||
/* We impose a total ordering here by returning c1-c2 if wcscoll returns 0,
|
||||
as we do above in the single-byte case. If we do this, we can no longer
|
||||
use this code in collequiv_wc */
|
||||
if ((r = wcscoll (s1, s2)) != 0)
|
||||
return r;
|
||||
return ((int)(c1 - c2)); /* impose total ordering */
|
||||
#else
|
||||
return (wcscoll (s1, s2));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Returns non-zero on success */
|
||||
static int
|
||||
rangecmp_wc (c1, c2, forcecoll)
|
||||
wint_t c1, c2;
|
||||
int forcecoll;
|
||||
{
|
||||
int r;
|
||||
|
||||
r = charcmp_wc (c1, c2, forcecoll);
|
||||
|
||||
/* We impose a total ordering here by returning c1-c2 if charcmp returns 0,
|
||||
as we do above in the single-byte case. */
|
||||
if (r != 0 || forcecoll)
|
||||
return r;
|
||||
return ((int)(c1 - c2)); /* impose total ordering */
|
||||
}
|
||||
|
||||
/* Returns 1 if wide chars C and EQUIV collate equally in the current locale. */
|
||||
static int
|
||||
collequiv_wc (c, equiv)
|
||||
wint_t c, equiv;
|
||||
{
|
||||
wchar_t s, p;
|
||||
|
||||
if (rangecmp_wc (c, equiv, 1) == 0)
|
||||
if (charcmp_wc (c, equiv, 1) == 0)
|
||||
return 1;
|
||||
|
||||
#if FNMATCH_EQUIV_FALLBACK
|
||||
/* We check explicitly for success (fnmatch returns 0) to avoid problems if
|
||||
our local definition of FNM_NOMATCH (strmatch.h) doesn't match the
|
||||
|
||||
+3
-3
@@ -319,7 +319,7 @@ extern char *sbrk ();
|
||||
#endif /* !HAVE_DECL_SBRK */
|
||||
|
||||
#ifdef SHELL
|
||||
extern int interrupt_immediately, running_trap;
|
||||
extern int running_trap;
|
||||
extern int signal_is_trapped PARAMS((int));
|
||||
#endif
|
||||
|
||||
@@ -620,9 +620,9 @@ morecore (nu)
|
||||
blocked_sigs = 0;
|
||||
#ifdef SHELL
|
||||
# if defined (SIGCHLD)
|
||||
if (interrupt_immediately || running_trap || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
|
||||
if (running_trap || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
|
||||
# else
|
||||
if (interrupt_immediately || running_trap || signal_is_trapped (SIGINT))
|
||||
if (running_trap || signal_is_trapped (SIGINT))
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@
|
||||
#include "table.h"
|
||||
|
||||
#ifdef SHELL
|
||||
extern int interrupt_immediately, running_trap;
|
||||
extern int running_trap;
|
||||
extern int signal_is_trapped PARAMS((int));
|
||||
#endif
|
||||
|
||||
@@ -174,7 +174,7 @@ mregister_alloc (tag, mem, size, file, line)
|
||||
/* Block all signals in case we are executed from a signal handler. */
|
||||
blocked_sigs = 0;
|
||||
#ifdef SHELL
|
||||
if (interrupt_immediately || running_trap || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
|
||||
if (running_trap || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
|
||||
#endif
|
||||
{
|
||||
_malloc_block_signals (&set, &oset);
|
||||
@@ -229,7 +229,7 @@ mregister_free (mem, size, file, line)
|
||||
/* Block all signals in case we are executed from a signal handler. */
|
||||
blocked_sigs = 0;
|
||||
#ifdef SHELL
|
||||
if (interrupt_immediately || running_trap || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
|
||||
if (running_trap || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
|
||||
#endif
|
||||
{
|
||||
_malloc_block_signals (&set, &oset);
|
||||
|
||||
+26
-5
@@ -1,6 +1,6 @@
|
||||
/* complete.c -- filename completion for readline. */
|
||||
|
||||
/* Copyright (C) 1987-2019 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.
|
||||
@@ -148,6 +148,7 @@ static int complete_fncmp PARAMS((const char *, int, const char *, int));
|
||||
static void display_matches PARAMS((char **));
|
||||
static int compute_lcd_of_matches PARAMS((char **, int, const char *));
|
||||
static int postprocess_matches PARAMS((char ***, int));
|
||||
static int compare_match PARAMS((char *, const char *));
|
||||
static int complete_get_screenwidth PARAMS((void));
|
||||
|
||||
static char *make_quoted_replacement PARAMS((char *, int, char *));
|
||||
@@ -1964,6 +1965,26 @@ _rl_free_match_list (char **matches)
|
||||
xfree (matches);
|
||||
}
|
||||
|
||||
/* Compare a possibly-quoted filename TEXT from the line buffer and a possible
|
||||
MATCH that is the product of filename completion, which acts on the dequoted
|
||||
text. */
|
||||
static int
|
||||
compare_match (char *text, const char *match)
|
||||
{
|
||||
char *temp;
|
||||
int r;
|
||||
|
||||
if (rl_filename_completion_desired && rl_filename_quoting_desired &&
|
||||
rl_completion_found_quote && rl_filename_dequoting_function)
|
||||
{
|
||||
temp = (*rl_filename_dequoting_function) (text, rl_completion_quote_character);
|
||||
r = strcmp (temp, match);
|
||||
free (temp);
|
||||
return r;
|
||||
}
|
||||
return (strcmp (text, match));
|
||||
}
|
||||
|
||||
/* Complete the word at or before point.
|
||||
WHAT_TO_DO says what to do with the completion.
|
||||
`?' means list the possible completions.
|
||||
@@ -2010,7 +2031,7 @@ rl_complete_internal (int what_to_do)
|
||||
matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char);
|
||||
/* nontrivial_lcd is set if the common prefix adds something to the word
|
||||
being completed. */
|
||||
nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
|
||||
nontrivial_lcd = matches && compare_match (text, matches[0]) != 0;
|
||||
if (what_to_do == '!' || what_to_do == '@')
|
||||
tlen = strlen (text);
|
||||
xfree (text);
|
||||
@@ -2772,7 +2793,7 @@ rl_old_menu_complete (int count, int invoking_key)
|
||||
{
|
||||
insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, "e_char);
|
||||
append_to_match (matches[match_list_index], delimiter, quote_char,
|
||||
strcmp (orig_text, matches[match_list_index]));
|
||||
compare_match (orig_text, matches[match_list_index]));
|
||||
}
|
||||
|
||||
completion_changed_buffer = 1;
|
||||
@@ -2846,7 +2867,7 @@ rl_menu_complete (int count, int ignore)
|
||||
matches = gen_completion_matches (orig_text, orig_start, orig_end,
|
||||
our_func, found_quote, quote_char);
|
||||
|
||||
nontrivial_lcd = matches && strcmp (orig_text, matches[0]) != 0;
|
||||
nontrivial_lcd = matches && compare_match (orig_text, matches[0]) != 0;
|
||||
|
||||
/* If we are matching filenames, the attempted completion function will
|
||||
have set rl_filename_completion_desired to a non-zero value. The basic
|
||||
@@ -2953,7 +2974,7 @@ rl_menu_complete (int count, int ignore)
|
||||
{
|
||||
insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, "e_char);
|
||||
append_to_match (matches[match_list_index], delimiter, quote_char,
|
||||
strcmp (orig_text, matches[match_list_index]));
|
||||
compare_match (orig_text, matches[match_list_index]));
|
||||
}
|
||||
|
||||
completion_changed_buffer = 1;
|
||||
|
||||
@@ -48,7 +48,7 @@ History library is able to keep track of those lines, associate arbitrary
|
||||
data with each line, and utilize information from previous lines in
|
||||
composing new ones.
|
||||
|
||||
The programmer using the History library has available functions
|
||||
A programmer using the History library has available functions
|
||||
for remembering lines on a history list, associating arbitrary data
|
||||
with a line, removing lines from the list, searching through the list
|
||||
for a line containing an arbitrary text string, and referencing any line
|
||||
@@ -62,7 +62,7 @@ commands for manipulating the text of previous lines and using that text
|
||||
in new commands. The basic history manipulation commands are similar to
|
||||
the history substitution provided by @code{csh}.
|
||||
|
||||
If the programmer desires, he can use the Readline library, which
|
||||
The programmer can also use the Readline library, which
|
||||
includes some history manipulation by default, and has the added
|
||||
advantage of command line editing.
|
||||
|
||||
|
||||
@@ -1342,6 +1342,29 @@ This differs from @code{clear_history} because it frees private data
|
||||
Readline saves in the history list.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {void} rl_activate_mark (void)
|
||||
Enable an @emph{active} mark.
|
||||
When this is enabled, the text between point and mark (the @var{region}) is
|
||||
displayed in the terminal's standout mode (a @var{face}).
|
||||
This is called by various readline functions that set the mark and insert
|
||||
text, and is available for applications to call.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {void} rl_deactivate_mark (void)
|
||||
Turn off the active mark.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {void} rl_keep_mark_active (void)
|
||||
Indicate that the mark should remain active when the current readline function
|
||||
completes and after redisplay occurs.
|
||||
In most cases, the mark remains active for only the duration of a single
|
||||
bindable readline function.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {int} rl_mark_active_p (void)
|
||||
Return a non-zero value if the mark is currently active; zero otherwise.
|
||||
@end deftypefun
|
||||
|
||||
@node Alternate Interface
|
||||
@subsection Alternate Interface
|
||||
|
||||
|
||||
@@ -493,9 +493,9 @@ replaced with an ellipsis when displaying possible completions.
|
||||
@vindex completion-query-items
|
||||
The number of possible completions that determines when the user is
|
||||
asked whether the list of possibilities should be displayed.
|
||||
If the number of possible completions is greater than this value,
|
||||
Readline will ask the user whether or not he wishes to view
|
||||
them; otherwise, they are simply listed.
|
||||
If the number of possible completions is greater than or equal to this value,
|
||||
Readline will ask whether or not the user wishes to view them;
|
||||
otherwise, they are simply listed.
|
||||
This variable must be set to an integer value greater than or equal to 0.
|
||||
A negative value means Readline should never ask.
|
||||
The default limit is @code{100}.
|
||||
@@ -1115,8 +1115,8 @@ set convert-meta off
|
||||
# rather than as meta-prefixed characters
|
||||
set output-meta on
|
||||
|
||||
# if there are more than 150 possible completions for
|
||||
# a word, ask the user if he wants to see all of them
|
||||
# if there are 150 or more possible completions for a word,
|
||||
# ask whether or not the user wants to see all of them
|
||||
set completion-query-items 150
|
||||
|
||||
# For FTP
|
||||
@@ -1254,10 +1254,12 @@ being entered.
|
||||
@item reverse-search-history (C-r)
|
||||
Search backward starting at the current line and moving `up' through
|
||||
the history as necessary. This is an incremental search.
|
||||
This command sets the region to the matched text and activates the mark.
|
||||
|
||||
@item forward-search-history (C-s)
|
||||
Search forward starting at the current line and moving `down' through
|
||||
the history as necessary. This is an incremental search.
|
||||
This command sets the region to the matched text and activates the mark.
|
||||
|
||||
@item non-incremental-reverse-search-history (M-p)
|
||||
Search backward starting at the current line and moving `up'
|
||||
@@ -1377,6 +1379,11 @@ each character as if it had been read from the keyboard. The characters
|
||||
are inserted as if each one was bound to @code{self-insert} instead of
|
||||
executing any editing commands.
|
||||
|
||||
Bracketed paste sets the region (the characters between point and the mark)
|
||||
to the inserted text. It uses the concept of an @emph{active mark}: when the
|
||||
mark is active, Readline redisplay uses the terminal's standout mode to
|
||||
denote the region.
|
||||
|
||||
@item transpose-chars (C-t)
|
||||
Drag the character before the cursor forward over
|
||||
the character at the cursor, moving the
|
||||
@@ -1426,9 +1433,13 @@ By default, this command is unbound.
|
||||
|
||||
@item kill-line (C-k)
|
||||
Kill the text from point to the end of the line.
|
||||
With a negative numeric argument, kill backward from the cursor to the
|
||||
beginning of the current line.
|
||||
|
||||
@item backward-kill-line (C-x Rubout)
|
||||
Kill backward from the cursor to the beginning of the current line.
|
||||
With a negative numeric argument, kill forward from the cursor to the
|
||||
end of the current line.
|
||||
|
||||
@item unix-line-discard (C-u)
|
||||
Kill backward from the cursor to the beginning of the current line.
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
Copyright (C) 1988-2020 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set EDITION 8.0
|
||||
@set VERSION 8.0
|
||||
@set UPDATED 4 May 2020
|
||||
@set UPDATED-MONTH May 2020
|
||||
@set EDITION 8.1
|
||||
@set VERSION 8.1
|
||||
@set UPDATED 17 July 2020
|
||||
@set UPDATED-MONTH July 2020
|
||||
|
||||
@set LASTCHANGE Mon May 4 14:55:02 EDT 2020
|
||||
@set LASTCHANGE Fri Jul 17 09:35:36 EDT 2020
|
||||
|
||||
@@ -377,11 +377,11 @@ com_stat (arg)
|
||||
|
||||
printf ("Statistics for `%s':\n", arg);
|
||||
|
||||
printf ("%s has %d link%s, and is %d byte%s in length.\n",
|
||||
printf ("%s has %d link%s, and is %lu byte%s in length.\n",
|
||||
arg,
|
||||
finfo.st_nlink,
|
||||
(finfo.st_nlink == 1) ? "" : "s",
|
||||
finfo.st_size,
|
||||
(unsigned long)finfo.st_size,
|
||||
(finfo.st_size == 1) ? "" : "s");
|
||||
printf ("Inode Last Change at: %s", ctime (&finfo.st_ctime));
|
||||
printf (" Last access at: %s", ctime (&finfo.st_atime));
|
||||
|
||||
@@ -512,7 +512,7 @@ rl_read_key (void)
|
||||
{
|
||||
if (rl_get_char (&c) == 0)
|
||||
c = (*rl_getc_function) (rl_instream);
|
||||
/* fprintf(stderr, "rl_read_key: calling RL_CHECK_SIGNALS: _rl_caught_signal = %d", _rl_caught_signal); */
|
||||
/* fprintf(stderr, "rl_read_key: calling RL_CHECK_SIGNALS: _rl_caught_signal = %d\r\n", _rl_caught_signal); */
|
||||
RL_CHECK_SIGNALS ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,8 @@
|
||||
#define SF_FOUND 0x02
|
||||
#define SF_FAILED 0x04
|
||||
#define SF_CHGKMAP 0x08
|
||||
#define SF_PATTERN 0x10 /* unused so far */
|
||||
#define SF_PATTERN 0x10
|
||||
#define SF_NOCASE 0x20 /* unused so far */
|
||||
|
||||
typedef struct __rl_search_context
|
||||
{
|
||||
|
||||
+57
-16
@@ -135,7 +135,7 @@ void *_rl_sigcleanarg;
|
||||
|
||||
/* Readline signal handler functions. */
|
||||
|
||||
/* Called from RL_CHECK_SIGNALS() macro */
|
||||
/* Called from RL_CHECK_SIGNALS() macro to run signal handling code. */
|
||||
RETSIGTYPE
|
||||
_rl_signal_handler (int sig)
|
||||
{
|
||||
@@ -170,11 +170,16 @@ rl_signal_handler (int sig)
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
|
||||
/* This is called to handle a signal when it is safe to do so (out of the
|
||||
signal handler execution path). Called by _rl_signal_handler for all the
|
||||
signals readline catches except SIGWINCH. */
|
||||
static RETSIGTYPE
|
||||
_rl_handle_signal (int sig)
|
||||
{
|
||||
int block_sig;
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigset_t set;
|
||||
sigset_t set, oset;
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
long omask;
|
||||
@@ -204,7 +209,16 @@ _rl_handle_signal (int sig)
|
||||
_rl_sigcleanup = 0;
|
||||
_rl_sigcleanarg = 0;
|
||||
}
|
||||
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
/* Get the current set of blocked signals. If we want to block a signal for
|
||||
the duration of the cleanup functions, make sure to add it to SET and
|
||||
set block_sig = 1 (see the SIGHUP case below). */
|
||||
block_sig = 0; /* sentinel to block signals with sigprocmask */
|
||||
sigemptyset (&set);
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
|
||||
#endif
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case SIGINT:
|
||||
@@ -219,38 +233,60 @@ _rl_handle_signal (int sig)
|
||||
#if defined (SIGTSTP)
|
||||
case SIGTSTP:
|
||||
case SIGTTIN:
|
||||
case SIGTTOU:
|
||||
# if defined (HAVE_POSIX_SIGNALS)
|
||||
/* Block SIGTTOU so we can restore the terminal settings to something
|
||||
sane without stopping on SIGTTOU if we have been placed into the
|
||||
background. Even trying to get the current terminal pgrp with
|
||||
tcgetpgrp() will generate SIGTTOU, so we don't bother. Don't bother
|
||||
doing this if we've been stopped on SIGTTOU; it's already too late. */
|
||||
sigemptyset (&set);
|
||||
tcgetpgrp() will generate SIGTTOU, so we don't bother. We still do
|
||||
this even if we've been stopped on SIGTTOU, since we handle signals
|
||||
when we have returned from the signal handler and the signal is no
|
||||
longer blocked. */
|
||||
sigaddset (&set, SIGTTOU);
|
||||
sigprocmask (SIG_BLOCK, &set, (sigset_t *)NULL);
|
||||
block_sig = 1;
|
||||
# endif
|
||||
case SIGTTOU:
|
||||
#endif /* SIGTSTP */
|
||||
case SIGTERM:
|
||||
/* Any signals that should be blocked during cleanup should go here. */
|
||||
#if defined (SIGHUP)
|
||||
case SIGHUP:
|
||||
# if defined (_AIX)
|
||||
if (block_sig == 0)
|
||||
{
|
||||
sigaddset (&set, sig);
|
||||
block_sig = 1;
|
||||
}
|
||||
# endif // _AIX
|
||||
#endif
|
||||
/* Signals that don't require blocking during cleanup should go here. */
|
||||
case SIGTERM:
|
||||
#if defined (SIGALRM)
|
||||
case SIGALRM:
|
||||
#endif
|
||||
#if defined (SIGQUIT)
|
||||
case SIGQUIT:
|
||||
#endif
|
||||
|
||||
if (block_sig)
|
||||
sigprocmask (SIG_BLOCK, &set, &oset);
|
||||
|
||||
rl_echo_signal_char (sig);
|
||||
rl_cleanup_after_signal ();
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
# if defined (SIGTSTP)
|
||||
/* Unblock SIGTTOU blocked above */
|
||||
if (sig == SIGTTIN || sig == SIGTSTP)
|
||||
sigprocmask (SIG_UNBLOCK, &set, (sigset_t *)NULL);
|
||||
# endif
|
||||
/* At this point, the application's signal handler, if any, is the
|
||||
current handler. */
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
/* Unblock any signal(s) blocked above */
|
||||
if (block_sig)
|
||||
sigprocmask (SIG_UNBLOCK, &oset, (sigset_t *)NULL);
|
||||
#endif
|
||||
|
||||
/* We don't have to bother unblocking the signal because we are not
|
||||
running in a signal handler context. */
|
||||
#if 0
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
/* Make sure this signal is not blocked when we resend it to the
|
||||
calling application. */
|
||||
sigemptyset (&set);
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
|
||||
sigdelset (&set, sig);
|
||||
@@ -259,6 +295,7 @@ _rl_handle_signal (int sig)
|
||||
omask = sigblock (0);
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
#endif
|
||||
|
||||
#if defined (__EMX__)
|
||||
signal (sig, SIG_ACK);
|
||||
@@ -270,7 +307,10 @@ _rl_handle_signal (int sig)
|
||||
raise (sig); /* assume we have raise */
|
||||
#endif
|
||||
|
||||
/* Let the signal that we just sent through. */
|
||||
/* We don't need to modify the signal mask now that this is not run in
|
||||
a signal handler context. */
|
||||
#if 0
|
||||
/* Let the signal that we just sent through if it is blocked. */
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
@@ -278,6 +318,7 @@ _rl_handle_signal (int sig)
|
||||
sigsetmask (omask & ~(sigmask (sig)));
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
#endif
|
||||
|
||||
rl_reset_after_signal ();
|
||||
}
|
||||
|
||||
+28
-10
@@ -875,8 +875,8 @@ _rl_vi_done_inserting (void)
|
||||
{
|
||||
if (_rl_vi_doing_insert)
|
||||
{
|
||||
/* The `C', `s', and `S' commands set this. */
|
||||
rl_end_undo_group ();
|
||||
/* The `c', `s', `S', and `R' commands set this. */
|
||||
rl_end_undo_group (); /* for the group in rl_vi_start_inserting */
|
||||
/* Now, the text between rl_undo_list->next->start and
|
||||
rl_undo_list->next->end is what was inserted while in insert
|
||||
mode. It gets copied to VI_INSERT_BUFFER because it depends
|
||||
@@ -887,7 +887,9 @@ _rl_vi_done_inserting (void)
|
||||
_rl_vi_save_replace (); /* Half the battle */
|
||||
else
|
||||
_rl_vi_save_insert (rl_undo_list->next);
|
||||
vi_continued_command = 1;
|
||||
/* sanity check, should always be >= 1 here */
|
||||
if (_rl_undo_group_level > 0)
|
||||
rl_end_undo_group (); /* for the group in the command (change or replace) */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -899,10 +901,12 @@ _rl_vi_done_inserting (void)
|
||||
/* XXX - Other keys probably need to be checked. */
|
||||
else if (_rl_vi_last_key_before_insert == 'C')
|
||||
rl_end_undo_group ();
|
||||
while (_rl_undo_group_level > 0)
|
||||
rl_end_undo_group ();
|
||||
vi_continued_command = 0;
|
||||
}
|
||||
|
||||
/* Sanity check, make sure all the undo groups are closed before we leave
|
||||
insert mode */
|
||||
while (_rl_undo_group_level > 0)
|
||||
rl_end_undo_group ();
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1210,6 +1214,10 @@ _rl_vi_domove_motion_cleanup (int c, _rl_vimotion_cxt *m)
|
||||
/* No change in position means the command failed. */
|
||||
if (rl_mark == rl_point)
|
||||
{
|
||||
/* 'c' and 'C' enter insert mode after the delete even if the motion
|
||||
didn't delete anything, as long as the motion command is valid. */
|
||||
if (_rl_to_upper (m->key) == 'C' && _rl_vi_motion_command (c))
|
||||
return (vidomove_dispatch (m));
|
||||
RL_UNSETSTATE (RL_STATE_VIMOTION);
|
||||
return (-1);
|
||||
}
|
||||
@@ -1382,7 +1390,11 @@ rl_vi_delete_to (int count, int key)
|
||||
{
|
||||
int c, r;
|
||||
|
||||
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
|
||||
if (_rl_vimvcxt)
|
||||
_rl_mvcxt_init (_rl_vimvcxt, VIM_DELETE, key);
|
||||
else
|
||||
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
|
||||
|
||||
_rl_vimvcxt->start = rl_point;
|
||||
|
||||
rl_mark = rl_point;
|
||||
@@ -1470,7 +1482,10 @@ rl_vi_change_to (int count, int key)
|
||||
{
|
||||
int c, r;
|
||||
|
||||
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
|
||||
if (_rl_vimvcxt)
|
||||
_rl_mvcxt_init (_rl_vimvcxt, VIM_CHANGE, key);
|
||||
else
|
||||
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
|
||||
_rl_vimvcxt->start = rl_point;
|
||||
|
||||
rl_mark = rl_point;
|
||||
@@ -1539,7 +1554,10 @@ rl_vi_yank_to (int count, int key)
|
||||
{
|
||||
int c, r;
|
||||
|
||||
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
|
||||
if (_rl_vimvcxt)
|
||||
_rl_mvcxt_init (_rl_vimvcxt, VIM_YANK, key);
|
||||
else
|
||||
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
|
||||
_rl_vimvcxt->start = rl_point;
|
||||
|
||||
rl_mark = rl_point;
|
||||
@@ -2247,7 +2265,7 @@ rl_vi_replace (int count, int key)
|
||||
|
||||
rl_vi_start_inserting (key, 1, rl_arg_sign);
|
||||
|
||||
_rl_vi_last_key_before_insert = key;
|
||||
_rl_vi_last_key_before_insert = 'R'; /* in case someone rebinds it */
|
||||
_rl_keymap = vi_replace_map;
|
||||
|
||||
if (_rl_enable_bracketed_paste)
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ mailstat(path, st)
|
||||
struct stat st_ret, st_tmp;
|
||||
DIR *dd;
|
||||
struct dirent *fn;
|
||||
char dir[PATH_MAX * 2], file[PATH_MAX * 2];
|
||||
char dir[PATH_MAX * 2], file[PATH_MAX * 2 + 1];
|
||||
int i, l;
|
||||
time_t atime, mtime;
|
||||
|
||||
|
||||
+10
-1
@@ -62,6 +62,7 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(TM_IN_SYS_TIME)
|
||||
#include <sys/types.h>
|
||||
@@ -80,6 +81,10 @@
|
||||
|
||||
#undef strchr /* avoid AIX weirdness */
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if defined (SHELL)
|
||||
extern char *get_string_value (const char *);
|
||||
#endif
|
||||
@@ -172,7 +177,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
char *start = s;
|
||||
auto char tbuf[100];
|
||||
long off;
|
||||
int i, w;
|
||||
int i, w, oerrno;
|
||||
long y;
|
||||
static short first = 1;
|
||||
#ifdef POSIX_SEMANTICS
|
||||
@@ -217,6 +222,8 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
};
|
||||
static const char *ampm[] = { "AM", "PM", };
|
||||
|
||||
oerrno = errno;
|
||||
|
||||
if (s == NULL || format == NULL || timeptr == NULL || maxsize == 0)
|
||||
return 0;
|
||||
|
||||
@@ -716,6 +723,8 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
|
||||
out:
|
||||
if (s < endp && *format == '\0') {
|
||||
*s = '\0';
|
||||
if (s == start)
|
||||
errno = oerrno;
|
||||
return (s - start);
|
||||
} else
|
||||
return 0;
|
||||
|
||||
+5
-1
@@ -34,6 +34,10 @@
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifndef ZBUFSIZ
|
||||
# define ZBUFSIZ 4096
|
||||
#endif
|
||||
|
||||
extern ssize_t zread PARAMS((int, char *, size_t));
|
||||
extern int zwrite PARAMS((int, char *, ssize_t));
|
||||
|
||||
@@ -46,7 +50,7 @@ zcatfd (fd, ofd, fn)
|
||||
{
|
||||
ssize_t nr;
|
||||
int rval;
|
||||
char lbuf[1024];
|
||||
char lbuf[ZBUFSIZ];
|
||||
|
||||
rval = 0;
|
||||
while (1)
|
||||
|
||||
+7
-3
@@ -36,6 +36,10 @@
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifndef ZBUFSIZ
|
||||
# define ZBUFSIZ 4096
|
||||
#endif
|
||||
|
||||
extern ssize_t zread PARAMS((int, char *, size_t));
|
||||
|
||||
/* Dump contents of file descriptor FD to *OSTR. FN is the filename for
|
||||
@@ -48,12 +52,12 @@ zmapfd (fd, ostr, fn)
|
||||
{
|
||||
ssize_t nr;
|
||||
int rval;
|
||||
char lbuf[512];
|
||||
char lbuf[ZBUFSIZ];
|
||||
char *result;
|
||||
int rsize, rind;
|
||||
|
||||
rval = 0;
|
||||
result = (char *)xmalloc (rsize = 512);
|
||||
result = (char *)xmalloc (rsize = ZBUFSIZ);
|
||||
rind = 0;
|
||||
|
||||
while (1)
|
||||
@@ -72,7 +76,7 @@ zmapfd (fd, ostr, fn)
|
||||
return -1;
|
||||
}
|
||||
|
||||
RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, 512);
|
||||
RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, ZBUFSIZ);
|
||||
memcpy (result+rind, lbuf, nr);
|
||||
rind += nr;
|
||||
}
|
||||
|
||||
+6
-2
@@ -1,6 +1,6 @@
|
||||
/* zread - read data from file descriptor into buffer with retries */
|
||||
|
||||
/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -37,6 +37,10 @@ extern int errno;
|
||||
# define SEEK_CUR 1
|
||||
#endif
|
||||
|
||||
#ifndef ZBUFSIZ
|
||||
# define ZBUFSIZ 4096
|
||||
#endif
|
||||
|
||||
extern int executing_builtin;
|
||||
|
||||
extern void check_signals_and_traps (void);
|
||||
@@ -117,7 +121,7 @@ zreadintr (fd, buf, len)
|
||||
in read(2). This does some local buffering to avoid many one-character
|
||||
calls to read(2), like those the `read' builtin performs. */
|
||||
|
||||
static char lbuf[128];
|
||||
static char lbuf[ZBUFSIZ];
|
||||
static size_t lind, lused;
|
||||
|
||||
ssize_t
|
||||
|
||||
Reference in New Issue
Block a user