bash-5.2-beta release

This commit is contained in:
Chet Ramey
2022-04-13 11:01:08 -04:00
parent 4491c03014
commit 187661b892
119 changed files with 14991 additions and 12391 deletions
+15 -3
View File
@@ -818,8 +818,7 @@ glob_vector (pat, dir, flags)
add_current = ((flags & (GX_ALLDIRS|GX_ADDCURDIR)) == (GX_ALLDIRS|GX_ADDCURDIR));
/* Scan the directory, finding all names that match.
For each name that matches, allocate a struct globval
/* Scan the directory, finding all names that match For each name that matches, allocate a struct globval
on the stack and store the name in it.
Chain those structs together; lastlink is the front of the chain. */
while (1)
@@ -901,6 +900,9 @@ glob_vector (pat, dir, flags)
nextname = (char *) malloc (sdlen + 1);
if (nextlink == 0 || nextname == 0)
{
if (firstmalloc && firstmalloc == nextlink)
firstmalloc = 0;
/* If we reset FIRSTMALLOC we can free this here. */
FREE (nextlink);
FREE (nextname);
free (subdir);
@@ -936,8 +938,18 @@ glob_vector (pat, dir, flags)
nextname = (char *) malloc (D_NAMLEN (dp) + 1);
if (nextlink == 0 || nextname == 0)
{
/* We free NEXTLINK here, since it won't be added to the
LASTLINK chain. If we used malloc, and it returned non-
NULL, firstmalloc will be set to something valid. If it's
NEXTLINK, reset it before we free NEXTLINK to avoid
duplicate frees. If not, it will be taken care of by the
loop below with TMPLINK. */
if (firstmalloc)
FREE (nextlink);
{
if (firstmalloc == nextlink)
firstmalloc = 0;
FREE (nextlink);
}
FREE (nextname);
lose = 1;
break;
+17 -1
View File
@@ -1,6 +1,6 @@
/* bind.c -- key binding and startup file support for the readline library. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 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.
@@ -1983,6 +1983,8 @@ typedef int _rl_sv_func_t (const char *);
#define V_INT 2
/* Forward declarations */
static int sv_region_start_color (const char *);
static int sv_region_end_color (const char *);
static int sv_bell_style (const char *);
static int sv_combegin (const char *);
static int sv_dispprefix (const char *);
@@ -2002,6 +2004,8 @@ static const struct {
int flags;
_rl_sv_func_t *set_func;
} string_varlist[] = {
{ "active-region-end-color", V_STRING, sv_region_end_color },
{ "active-region-start-color", V_STRING, sv_region_start_color },
{ "bell-style", V_STRING, sv_bell_style },
{ "comment-begin", V_STRING, sv_combegin },
{ "completion-display-width", V_INT, sv_compwidth },
@@ -2220,6 +2224,18 @@ sv_seqtimeout (const char *value)
return 0;
}
static int
sv_region_start_color (const char *value)
{
return (_rl_reset_region_color (0, value));
}
static int
sv_region_end_color (const char *value)
{
return (_rl_reset_region_color (1, value));
}
static int
sv_bell_style (const char *value)
{
+7 -1
View File
@@ -1,6 +1,6 @@
/* callback.c -- functions to use readline as an X `callback' mechanism. */
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 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.
@@ -136,6 +136,8 @@ rl_callback_read_char (void)
abort ();
}
eof = 0;
memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t));
#if defined (HAVE_POSIX_SIGSETJMP)
jcode = sigsetjmp (_rl_top_level, 0);
@@ -276,6 +278,10 @@ rl_callback_read_char (void)
_rl_want_redisplay = 0;
}
/* Make sure application hooks can see whether we saw EOF. */
if (rl_eof_found = eof)
RL_SETSTATE(RL_STATE_EOF);
if (rl_done)
{
line = readline_internal_teardown (eof);
+1 -1
View File
@@ -1981,7 +1981,7 @@ compare_match (char *text, const char *match)
{
temp = (*rl_filename_dequoting_function) (text, rl_completion_quote_character);
r = strcmp (temp, match);
free (temp);
xfree (temp);
return r;
}
return (strcmp (text, match));
+13 -5
View File
@@ -1,6 +1,6 @@
/* display.c -- readline redisplay facility. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 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.
@@ -439,7 +439,15 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
to add them, since update_line expects them to be counted before
wrapping the line. */
if (can_add_invis)
local_prompt_newlines[newlines] = r - ret;
{
local_prompt_newlines[newlines] = r - ret;
/* If we're adding to the number of invisible characters on the
first line of the prompt, but we've already set the number of
invisible characters on that line, we need to adjust the
counter. */
if (invflset && newlines == 1)
invfl = ninvis;
}
if (p != (igstart + 1))
last = r - ret - 1;
continue;
@@ -528,7 +536,7 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
*vlp = physchars;
if (nprompt != pmt)
free (nprompt);
xfree (nprompt);
return ret;
}
@@ -1595,9 +1603,9 @@ putc_face (int c, int face, char *cur_face)
if (face != FACE_NORMAL && face != FACE_STANDOUT)
return;
if (face == FACE_STANDOUT && cf == FACE_NORMAL)
_rl_standout_on ();
_rl_region_color_on ();
if (face == FACE_NORMAL && cf == FACE_STANDOUT)
_rl_standout_off ();
_rl_region_color_off ();
*cur_face = face;
}
if (c != EOF)
+1 -1
View File
@@ -12,7 +12,7 @@ This document describes the GNU History library
a programming tool that provides a consistent user interface for
recalling lines of previously typed input.
Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
+1 -1
View File
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988-2020 Free Software Foundation, Inc.
Copyright (C) 1988-2022 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
+1 -1
View File
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988--2020 Free Software Foundation, Inc.
Copyright (C) 1988--2022 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
+1 -1
View File
@@ -13,7 +13,7 @@ This manual describes the GNU Readline Library
consistency of user interface across discrete programs which provide
a command line interface.
Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
+19 -5
View File
@@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding
in the consistency of user interface across discrete programs that need
to provide a command line interface.
Copyright (C) 1988--2020 Free Software Foundation, Inc.
Copyright (C) 1988--2022 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -323,6 +323,14 @@ and point define a @emph{region}.
@deftypevar int rl_done
Setting this to a non-zero value causes Readline to return the current
line immediately.
Readline will set this variable when it has read a key sequence bound
to @code{accept-line} and is about to return the line to the caller.
@end deftypevar
@deftypevar int rl_eof_found
Readline will set this variable when it has read an EOF character (e.g., the
stty @samp{EOF} character) on an empty line or encountered a read error and
is about to return a NULL line to the caller.
@end deftypevar
@deftypevar int rl_num_chars_to_read
@@ -597,6 +605,9 @@ and is about to return the line to the caller.
Readline has timed out (it did not receive a line or specified number of
characters before the timeout duration specified by @code{rl_set_timeout}
elapsed) and is returning that status to the caller.
@item RL_STATE_EOF
Readline has read an EOF character (e.g., the stty @samp{EOF} character)
or encountered a read error and is about to return a NULL line to the caller.
@end table
@end deftypevar
@@ -1184,10 +1195,13 @@ Returns 0 if the timeout is set successfully.
@deftypefun int rl_timeout_remaining (unsigned int *secs, unsigned int *usecs)
Return the number of seconds and microseconds remaining in the current
timeout duration in @code{*secs} and @code{*usecs}, respectively.
Returns -1 on error or when there is no timeout set, 0 when the timeout has
expired (leaving @code{*secs} and @code{*usecs} unchanged), and 1 if the
timeout has not expired. If @code{secs} and @code{usecs} are @code{NULL},
timeout duration in @var{*secs} and @var{*usecs}, respectively.
Both @var{*secs} and @var{*usecs} must be non-NULL to return any values.
The return value is -1 on error or when there is no timeout set,
0 when the timeout has expired (leaving @var{*secs} and @var{*usecs}
unchanged),
and 1 if the timeout has not expired.
If either of @var{secs} and @var{usecs} is @code{NULL},
the return value indicates whether the timeout has expired.
@end deftypefun
+36 -6
View File
@@ -9,7 +9,7 @@ use these features. There is a document entitled "readline.texinfo"
which contains both end-user and programmer documentation for the
GNU Readline Library.
Copyright (C) 1988--2020 Free Software Foundation, Inc.
Copyright (C) 1988--2022 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@@ -419,6 +419,32 @@ variables.
@cindex variables, readline
@table @code
@item active-region-start-color
@vindex active-region-start-color
A string variable that controls the text color and background when displaying
the text in the active region (see the description of
@code{enable-active-region} below).
This string must not take up any physical character positions on the display,
so it should consist only of terminal escape sequences.
It is output to the terminal before displaying the text in the active region.
This variable is reset to the default value whenever the terminal type changes.
The default value is the string that puts the terminal in standout mode,
as obtained from the terminal's terminfo description.
A sample value might be @samp{\e[01;33m}.
@item active-region-end-color
@vindex active-region-end-color
A string variable that "undoes" the effects of @code{active-region-start-color}
and restores "normal" terminal display appearance after displaying text
in the active region.
This string must not take up any physical character positions on the display,
so it should consist only of terminal escape sequences.
It is output to the terminal after displaying the text in the active region.
This variable is reset to the default value whenever the terminal type changes.
The default value is the string that restores the terminal from standout mode,
as obtained from the terminal's terminfo description.
A sample value might be @samp{\e[0m}.
@item bell-style
@vindex bell-style
Controls what happens when Readline wants to ring the terminal bell.
@@ -553,6 +579,8 @@ The text between the point and mark is referred to as the @dfn{region}.
When this variable is set to @samp{On}, Readline allows certain commands
to designate the region as @dfn{active}.
When the region is active, Readline highlights the text in the region using
the value of the @code{active-region-start-color}, which defaults to the
string that enables
the terminal's standout mode.
The active region shows the text inserted by bracketed-paste and any
matching text found by incremental and non-incremental history searches.
@@ -560,11 +588,13 @@ The default is @samp{On}.
@item enable-bracketed-paste
@vindex enable-bracketed-paste
When set to @samp{On}, Readline will configure the terminal in a way
that will enable it to insert each paste into the editing buffer as a
single string of characters, instead of treating each character as if
it had been read from the keyboard. This can prevent pasted characters
from being interpreted as editing commands. The default is @samp{On}.
When set to @samp{On}, Readline configures the terminal to insert each
paste into the editing buffer as a single string of characters, instead
of treating each character as if it had been read from the keyboard.
This is called putting the terminal into @dfn{bracketed paste mode};
it prevents Readline from executing any editing commands bound to key
sequences appearing in the pasted text.
The default is @samp{On}.
@item enable-keypad
@vindex enable-keypad
+1 -1
View File
@@ -12,7 +12,7 @@ This manual describes the end user interface of the GNU Readline Library
consistency of user interface across discrete programs which provide
a command line interface.
Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
+7 -6
View File
@@ -1,10 +1,11 @@
@ignore
Copyright (C) 1988-2021 Free Software Foundation, Inc.
Copyright (C) 1988-2022 Free Software Foundation, Inc.
@end ignore
@set EDITION 8.1
@set VERSION 8.1
@set UPDATED 15 November 2021
@set UPDATED-MONTH November 2021
@set EDITION 8.2
@set VERSION 8.2
@set LASTCHANGE Mon Nov 15 17:05:28 EST 2021
@set UPDATED 11 March 2022
@set UPDATED-MONTH March 2022
@set LASTCHANGE Fri Mar 11 10:13:51 EST 2022
+1 -1
View File
@@ -310,7 +310,7 @@ read_history_range (const char *filename, int from, int to)
if (file_size == 0)
{
free (input);
xfree (input);
close (file);
return 0; /* don't waste time if we don't have to */
}
+2 -1
View File
@@ -1,6 +1,6 @@
/* histlib.h -- internal definitions for the history library. */
/* Copyright (C) 1989-2009,2021 Free Software Foundation, Inc.
/* Copyright (C) 1989-2009,2021-2022 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -84,6 +84,7 @@ extern int _hs_history_patsearch (const char *, int, int);
/* history.c */
extern void _hs_replace_history_data (int, histdata_t *, histdata_t *);
extern int _hs_at_end_of_history (void);
/* histfile.c */
extern void _hs_append_history_line (int, const char *);
+7
View File
@@ -165,6 +165,13 @@ history_set_pos (int pos)
history_offset = pos;
return (1);
}
/* Are we currently at the end of the history list? */
int
_hs_at_end_of_history (void)
{
return (the_history == 0 || history_offset == history_length);
}
/* Return the current history array. The caller has to be careful, since this
is the actual array of data, and could be bashed or made corrupt easily.
+2 -2
View File
@@ -1,6 +1,6 @@
/* history.h -- the names of functions that you can call in history. */
/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -44,7 +44,7 @@ typedef char *histdata_t;
/* Let's not step on anyone else's define for now, since we don't use this yet. */
#ifndef HS_HISTORY_VERSION
# define HS_HISTORY_VERSION 0x0801 /* History 8.1 */
# define HS_HISTORY_VERSION 0x0802 /* History 8.2 */
#endif
/* The structure used to store a history entry. */
+1 -1
View File
@@ -248,7 +248,7 @@ _hs_history_patsearch (const char *string, int direction, int flags)
ret = history_search_internal (pat, direction, flags|PATTERN_SEARCH);
if (pat != string)
free (pat);
xfree (pat);
return ret;
}
+2 -2
View File
@@ -679,7 +679,7 @@ opcode_dispatch:
paste = _rl_bracketed_text (&pastelen);
if (paste == 0 || *paste == 0)
{
free (paste);
xfree (paste);
break;
}
if (_rl_enable_active_region)
@@ -692,7 +692,7 @@ opcode_dispatch:
memcpy (cxt->search_string + cxt->search_string_index, paste, pastelen);
cxt->search_string_index += pastelen;
cxt->search_string[cxt->search_string_index] = '\0';
free (paste);
xfree (paste);
break;
/* Add character to search string and continue search. */
+5 -1
View File
@@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 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.
@@ -50,6 +50,7 @@
#include "history.h"
#include "rlprivate.h"
#include "histlib.h"
#include "rlshell.h"
#include "xmalloc.h"
@@ -308,6 +309,7 @@ _rl_start_using_history (void)
if (_rl_saved_line_for_history)
_rl_free_saved_history_line ();
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
_rl_history_search_pos = -99; /* some random invalid history position */
}
/* Free the contents (and containing structure) of a HIST_ENTRY. */
@@ -380,6 +382,8 @@ rl_maybe_save_line (void)
int
_rl_free_saved_history_line (void)
{
UNDO_LIST *orig;
if (_rl_saved_line_for_history)
{
if (rl_undo_list && rl_undo_list == (UNDO_LIST *)_rl_saved_line_for_history->data)
+2 -1
View File
@@ -1,6 +1,6 @@
/* nls.c -- skeletal internationalization code. */
/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
/* Copyright (C) 1996-2022 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.
@@ -53,6 +53,7 @@
#include "readline.h"
#include "rlshell.h"
#include "rlprivate.h"
#include "xmalloc.h"
static int utf8locale (char *);
+23 -8
View File
@@ -1,7 +1,7 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 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.
@@ -164,6 +164,9 @@ int rl_end;
/* Make this non-zero to return the current input_line. */
int rl_done;
/* If non-zero when readline_internal returns, it means we found EOF */
int rl_eof_found = 0;
/* The last function executed by readline. */
rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
@@ -217,9 +220,6 @@ int _rl_eof_char = CTRL ('D');
/* Non-zero makes this the next keystroke to read. */
int rl_pending_input = 0;
/* If non-zero when readline_internal returns, it means we found EOF */
int _rl_eof_found = 0;
/* Pointer to a useful terminal name. */
const char *rl_terminal_name = (const char *)NULL;
@@ -240,6 +240,9 @@ char *_rl_comment_begin;
/* Keymap holding the function currently being executed. */
Keymap rl_executing_keymap;
/* The function currently being executed. */
rl_command_func_t *_rl_executing_func;
/* Keymap we're currently using to dispatch. */
Keymap _rl_dispatching_keymap;
@@ -479,12 +482,18 @@ readline_internal_teardown (int eof)
RL_CHECK_SIGNALS ();
if (eof)
RL_SETSTATE (RL_STATE_EOF); /* XXX */
/* Restore the original of this history line, iff the line that we
are editing was originally in the history, AND the line has changed. */
entry = current_history ();
/* We don't want to do this if we executed functions that call
history_set_pos to set the history offset to the line containing the
non-incremental search string. */
if (entry && rl_undo_list)
{
{
temp = savestring (the_line);
rl_revert_line (1, 0);
entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
@@ -615,6 +624,7 @@ readline_internal_charloop (void)
RL_SETSTATE(RL_STATE_DONE);
return (rl_done = 1);
#else
RL_SETSTATE(RL_STATE_EOF);
eof_found = 1;
break;
#endif
@@ -655,6 +665,7 @@ readline_internal_charloop (void)
RL_SETSTATE(RL_STATE_DONE);
return (rl_done = 1);
#else
RL_SETSTATE(RL_STATE_EOF);
eof_found = 1;
break;
#endif
@@ -671,6 +682,8 @@ readline_internal_charloop (void)
rl_executing_keymap = _rl_command_to_execute->map;
rl_executing_key = _rl_command_to_execute->key;
_rl_executing_func = _rl_command_to_execute->func;
rl_dispatching = 1;
RL_SETSTATE(RL_STATE_DISPATCHING);
r = (*(_rl_command_to_execute->func)) (_rl_command_to_execute->count, _rl_command_to_execute->key);
@@ -717,8 +730,8 @@ static char *
readline_internal (void)
{
readline_internal_setup ();
_rl_eof_found = readline_internal_charloop ();
return (readline_internal_teardown (_rl_eof_found));
rl_eof_found = readline_internal_charloop ();
return (readline_internal_teardown (rl_eof_found));
}
void
@@ -892,6 +905,8 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
rl_executing_keymap = map;
rl_executing_key = key;
_rl_executing_func = func;
RESIZE_KEYSEQ_BUFFER();
rl_executing_keyseq[rl_key_sequence_length++] = key;
rl_executing_keyseq[rl_key_sequence_length] = '\0';
@@ -1178,7 +1193,7 @@ rl_initialize (void)
/* We aren't done yet. We haven't even gotten started yet! */
rl_done = 0;
RL_UNSETSTATE(RL_STATE_DONE);
RL_UNSETSTATE(RL_STATE_DONE|RL_STATE_TIMEOUT|RL_STATE_EOF);
/* Tell the history routines what is going on. */
_rl_start_using_history ();
+9 -4
View File
@@ -1,6 +1,6 @@
/* Readline.h -- the names of functions callable from within readline. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 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.
@@ -39,9 +39,9 @@ extern "C" {
#endif
/* Hex-encoded Readline version number. */
#define RL_READLINE_VERSION 0x0801 /* Readline 8.1 */
#define RL_READLINE_VERSION 0x0802 /* Readline 8.2 */
#define RL_VERSION_MAJOR 8
#define RL_VERSION_MINOR 1
#define RL_VERSION_MINOR 2
/* Readline data structures. */
@@ -562,6 +562,10 @@ extern int rl_mark;
line and should return it. */
extern int rl_done;
/* Flag to indicate that readline has read an EOF character or read has
returned 0 or error, and is returning a NULL line as a result. */
extern int rl_eof_found;
/* If set to a character value, that will be the next keystroke read. */
extern int rl_pending_input;
@@ -917,7 +921,8 @@ extern int rl_persistent_signal_handlers;
#define RL_STATE_REDISPLAYING 0x1000000 /* updating terminal display */
#define RL_STATE_DONE 0x2000000 /* done; accepted line */
#define RL_STATE_TIMEOUT 0x4000000
#define RL_STATE_TIMEOUT 0x4000000 /* done; timed out */
#define RL_STATE_EOF 0x8000000 /* done; got eof on read */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
+9 -2
View File
@@ -1,7 +1,7 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
/* Copyright (C) 1999-2022 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.
@@ -381,6 +381,8 @@ extern void _rl_end_executing_keyseq (void);
extern void _rl_add_executing_keyseq (int);
extern void _rl_del_executing_keyseq (void);
extern rl_command_func_t *_rl_executing_func;
/* rltty.c */
extern int _rl_disable_tty_signals (void);
extern int _rl_restore_tty_signals (void);
@@ -415,6 +417,9 @@ extern void _rl_control_keypad (int);
extern void _rl_set_cursor (int, int);
extern void _rl_standout_on (void);
extern void _rl_standout_off (void);
extern int _rl_reset_region_color (int, const char *);
extern void _rl_region_color_on (void);
extern void _rl_region_color_off (void);
/* text.c */
extern void _rl_fix_point (int);
@@ -551,6 +556,8 @@ extern int _rl_echo_control_chars;
extern int _rl_show_mode_in_prompt;
extern int _rl_enable_bracketed_paste;
extern int _rl_enable_active_region;
extern char *_rl_active_region_start_color;
extern char *_rl_active_region_end_color;
extern char *_rl_comment_begin;
extern unsigned char _rl_parsing_conditionalized_out;
extern Keymap _rl_keymap;
@@ -558,7 +565,6 @@ extern FILE *_rl_in_stream;
extern FILE *_rl_out_stream;
extern int _rl_last_command_was_kill;
extern int _rl_eof_char;
extern int _rl_eof_found;
extern procenv_t _rl_top_level;
extern _rl_keyseq_cxt *_rl_kscxt;
extern int _rl_keyseq_timeout;
@@ -569,6 +575,7 @@ extern rl_hook_func_t *_rl_internal_startup_hook;
/* search.c */
extern _rl_search_cxt *_rl_nscxt;
extern int _rl_history_search_pos;
/* signals.c */
extern int volatile _rl_caught_signal;
+4 -2
View File
@@ -1,7 +1,7 @@
/* rltty.c -- functions to prepare and restore the terminal for readline's
use. */
/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
/* Copyright (C) 1992-2022 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.
@@ -692,7 +692,9 @@ rl_deprep_terminal (void)
if (terminal_prepped & TPX_BRACKPASTE)
{
fprintf (rl_outstream, BRACK_PASTE_FINI);
if (_rl_eof_found && (RL_ISSTATE (RL_STATE_TIMEOUT) == 0))
/* Since the last character in BRACK_PASTE_FINI is \r */
_rl_last_c_pos = 0;
if (rl_eof_found && (RL_ISSTATE (RL_STATE_TIMEOUT) == 0))
fprintf (rl_outstream, "\n");
else if (_rl_echoing_p == 0)
fprintf (rl_outstream, "\n");
+37 -35
View File
@@ -1,6 +1,6 @@
/* search.c - code for non-incremental searching in emacs and vi modes. */
/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
/* Copyright (C) 1992-2022 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.
@@ -60,9 +60,9 @@ static int noninc_history_pos;
static char *prev_line_found = (char *) NULL;
static int rl_history_search_len;
static int rl_history_search_pos;
static int rl_history_search_flags;
static int _rl_history_search_len;
/*static*/ int _rl_history_search_pos;
static int _rl_history_search_flags;
static char *history_search_string;
static int history_string_size;
@@ -84,9 +84,12 @@ static int _rl_nsearch_dispatch (_rl_search_cxt *, int);
static void
make_history_line_current (HIST_ENTRY *entry)
{
UNDO_LIST *xlist;
xlist = _rl_saved_line_for_history ? (UNDO_LIST *)_rl_saved_line_for_history->data : 0;
/* At this point, rl_undo_list points to a private search string list. */
if (rl_undo_list && rl_undo_list != (UNDO_LIST *)entry->data)
rl_free_undo_list ();
if (rl_undo_list && rl_undo_list != (UNDO_LIST *)entry->data && rl_undo_list != xlist)
rl_free_undo_list ();
/* Now we create a new undo list with a single insert for this text.
WE DON'T CHANGE THE ORIGINAL HISTORY ENTRY UNDO LIST */
@@ -102,9 +105,13 @@ make_history_line_current (HIST_ENTRY *entry)
#endif
/* This will need to free the saved undo list associated with the original
(pre-search) line buffer. */
(pre-search) line buffer.
XXX - look at _rl_free_saved_history_line and consider calling it if
rl_undo_list != xlist (or calling rl_free_undo list directly on
_rl_saved_line_for_history->data) */
if (_rl_saved_line_for_history)
_rl_free_saved_history_line ();
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Search the history list for STRING starting at absolute history position
@@ -523,12 +530,11 @@ rl_history_search_internal (int count, int dir)
{
HIST_ENTRY *temp;
int ret, oldpos, newcol;
int had_saved_line;
char *t;
had_saved_line = _rl_saved_line_for_history != 0;
rl_maybe_save_line ();
/* This will either be restored from the saved line or set from the
found history line. */
rl_undo_list = 0;
temp = (HIST_ENTRY *)NULL;
/* Search COUNT times through the history for a line matching
@@ -539,14 +545,14 @@ rl_history_search_internal (int count, int dir)
while (count)
{
RL_CHECK_SIGNALS ();
ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir, 0, &newcol);
ret = noninc_search_from_pos (history_search_string, _rl_history_search_pos + dir, dir, 0, &newcol);
if (ret == -1)
break;
/* Get the history entry we found. */
rl_history_search_pos = ret;
_rl_history_search_pos = ret;
oldpos = where_history ();
history_set_pos (rl_history_search_pos);
history_set_pos (_rl_history_search_pos);
temp = current_history (); /* will never be NULL after successful search */
history_set_pos (oldpos);
@@ -560,20 +566,21 @@ rl_history_search_internal (int count, int dir)
/* If we didn't find anything at all, return. */
if (temp == 0)
{
/* XXX - check had_saved_line here? */
rl_maybe_unsave_line ();
rl_ding ();
/* If you don't want the saved history line (last match) to show up
in the line buffer after the search fails, change the #if 0 to
#if 1 */
#if 0
if (rl_point > rl_history_search_len)
if (rl_point > _rl_history_search_len)
{
rl_point = rl_end = rl_history_search_len;
rl_point = rl_end = _rl_history_search_len;
rl_line_buffer[rl_end] = '\0';
rl_mark = 0;
}
#else
rl_point = rl_history_search_len; /* rl_maybe_unsave_line changes it */
rl_point = _rl_history_search_len; /* rl_maybe_unsave_line changes it */
rl_mark = rl_end;
#endif
return 1;
@@ -582,19 +589,14 @@ rl_history_search_internal (int count, int dir)
/* Copy the line we found into the current line buffer. */
make_history_line_current (temp);
/* Make sure we set the current history position to the last line found so
we can do things like operate-and-get-next from here. This is similar to
how incremental search behaves. */
history_set_pos (rl_history_search_pos); /* XXX */
/* decide where to put rl_point -- need to change this for pattern search */
if (rl_history_search_flags & ANCHORED_SEARCH)
rl_point = rl_history_search_len; /* easy case */
if (_rl_history_search_flags & ANCHORED_SEARCH)
rl_point = _rl_history_search_len; /* easy case */
else
{
#if 0
t = strstr (rl_line_buffer, history_search_string); /* XXX */
rl_point = t ? (int)(t - rl_line_buffer) + rl_history_search_len : rl_end;
rl_point = t ? (int)(t - rl_line_buffer) + _rl_history_search_len : rl_end;
#else
rl_point = (newcol >= 0) ? newcol : rl_end;
#endif
@@ -609,17 +611,17 @@ rl_history_search_reinit (int flags)
{
int sind;
rl_history_search_pos = where_history ();
rl_history_search_len = rl_point;
rl_history_search_flags = flags;
_rl_history_search_pos = where_history ();
_rl_history_search_len = rl_point;
_rl_history_search_flags = flags;
prev_line_found = (char *)NULL;
if (rl_point)
{
/* Allocate enough space for anchored and non-anchored searches */
if (rl_history_search_len >= history_string_size - 2)
if (_rl_history_search_len >= history_string_size - 2)
{
history_string_size = rl_history_search_len + 2;
history_string_size = _rl_history_search_len + 2;
history_search_string = (char *)xrealloc (history_search_string, history_string_size);
}
sind = 0;
@@ -628,7 +630,7 @@ rl_history_search_reinit (int flags)
strncpy (history_search_string + sind, rl_line_buffer, rl_point);
history_search_string[rl_point + sind] = '\0';
}
_rl_free_saved_history_line ();
_rl_free_saved_history_line (); /* XXX rl_undo_list? */
}
/* Search forward in the history for the string of characters
@@ -644,7 +646,7 @@ rl_history_search_forward (int count, int ignore)
rl_last_func != rl_history_search_backward)
rl_history_search_reinit (ANCHORED_SEARCH);
if (rl_history_search_len == 0)
if (_rl_history_search_len == 0)
return (rl_get_next_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
}
@@ -662,7 +664,7 @@ rl_history_search_backward (int count, int ignore)
rl_last_func != rl_history_search_backward)
rl_history_search_reinit (ANCHORED_SEARCH);
if (rl_history_search_len == 0)
if (_rl_history_search_len == 0)
return (rl_get_previous_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
}
@@ -681,7 +683,7 @@ rl_history_substr_search_forward (int count, int ignore)
rl_last_func != rl_history_substr_search_backward)
rl_history_search_reinit (NON_ANCHORED_SEARCH);
if (rl_history_search_len == 0)
if (_rl_history_search_len == 0)
return (rl_get_next_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
}
@@ -699,7 +701,7 @@ rl_history_substr_search_backward (int count, int ignore)
rl_last_func != rl_history_substr_search_backward)
rl_history_search_reinit (NON_ANCHORED_SEARCH);
if (rl_history_search_len == 0)
if (_rl_history_search_len == 0)
return (rl_get_previous_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
}
+83 -4
View File
@@ -1,6 +1,6 @@
/* terminal.c -- controlling the terminal with termcap. */
/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
/* Copyright (C) 1996-2022 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.
@@ -185,6 +185,11 @@ static char *_rl_term_kN;
static char *_rl_term_vs; /* very visible */
static char *_rl_term_ve; /* normal */
/* User-settable color sequences to begin and end the active region. Defaults
are rl_term_so and rl_term_se on non-dumb terminals. */
char *_rl_active_region_start_color = NULL;
char *_rl_active_region_end_color = NULL;
/* It's not clear how HPUX is so broken here. */
#ifdef TGETENT_BROKEN
# define TGETENT_SUCCESS 0
@@ -466,7 +471,7 @@ _rl_init_terminal_io (const char *terminal_name)
{
const char *term;
char *buffer;
int tty, tgetent_ret, dumbterm;
int tty, tgetent_ret, dumbterm, reset_region_colors;
term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
_rl_term_clrpag = _rl_term_cr = _rl_term_clreol = _rl_term_clrscroll = (char *)NULL;
@@ -477,6 +482,8 @@ _rl_init_terminal_io (const char *terminal_name)
dumbterm = STREQ (term, "dumb");
reset_region_colors = 1;
#ifdef __MSDOS__
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
@@ -562,6 +569,11 @@ _rl_init_terminal_io (const char *terminal_name)
escape sequences */
_rl_enable_bracketed_paste = 0;
/* No terminal so/se capabilities. */
_rl_enable_active_region = 0;
_rl_reset_region_color (0, NULL);
_rl_reset_region_color (1, NULL);
/* Reasonable defaults for tgoto(). Readline currently only uses
tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
change that later... */
@@ -616,8 +628,14 @@ _rl_init_terminal_io (const char *terminal_name)
/* There's no way to determine whether or not a given terminal supports
bracketed paste mode, so we assume a terminal named "dumb" does not. */
if (dumbterm)
_rl_enable_bracketed_paste = 0;
_rl_enable_bracketed_paste = _rl_enable_active_region = 0;
if (reset_region_colors)
{
_rl_reset_region_color (0, _rl_term_so);
_rl_reset_region_color (1, _rl_term_se);
}
return 0;
}
@@ -789,6 +807,67 @@ _rl_standout_off (void)
#endif
}
/* **************************************************************** */
/* */
/* Controlling color for a portion of the line */
/* */
/* **************************************************************** */
/* Reset the region color variables to VALUE depending on WHICH (0 == start,
1 == end). This is where all the memory allocation for the color variable
strings is performed. We might want to pass a flag saying whether or not
to translate VALUE like a key sequence, but it doesn't really matter. */
int
_rl_reset_region_color (int which, const char *value)
{
int len;
if (which == 0)
{
xfree (_rl_active_region_start_color);
if (value && *value)
{
_rl_active_region_start_color = (char *)xmalloc (2 * strlen (value) + 1);
rl_translate_keyseq (value, _rl_active_region_start_color, &len);
_rl_active_region_start_color[len] = '\0';
}
else
_rl_active_region_start_color = NULL;
}
else
{
xfree (_rl_active_region_end_color);
if (value && *value)
{
_rl_active_region_end_color = (char *)xmalloc (2 * strlen (value) + 1);
rl_translate_keyseq (value, _rl_active_region_end_color, &len);
_rl_active_region_end_color[len] = '\0';
}
else
_rl_active_region_end_color = NULL;
}
return 0;
}
void
_rl_region_color_on (void)
{
#ifndef __MSDOS__
if (_rl_active_region_start_color && _rl_active_region_end_color)
tputs (_rl_active_region_start_color, 1, _rl_output_character_function);
#endif
}
void
_rl_region_color_off (void)
{
#ifndef __MSDOS__
if (_rl_active_region_start_color && _rl_active_region_end_color)
tputs (_rl_active_region_end_color, 1, _rl_output_character_function);
#endif
}
/* **************************************************************** */
/* */
/* Controlling the Meta Key and Keypad */
+10 -3
View File
@@ -2,7 +2,7 @@
# Makefile for the Bash library
#
#
# Copyright (C) 1998-2020 Free Software Foundation, Inc.
# Copyright (C) 1998-2022 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -94,7 +94,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
wcsdup.c fpurge.c zgetline.c mbscmp.c uconvert.c ufuncs.c \
casemod.c dprintf.c input_avail.c mbscasecmp.c fnxform.c \
strchrnul.c unicode.c wcswidth.c wcsnwidth.c shmbchar.c strdup.c \
utf8.c random.c gettimeofday.c timers.c
strvis.c utf8.c random.c gettimeofday.c timers.c
# The header files for this library.
HSOURCES =
@@ -108,7 +108,7 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
strtrans.o snprintf.o mailstat.o fmtulong.o \
fmtullong.o fmtumax.o zcatfd.o zmapfd.o winsize.o wcsdup.o \
fpurge.o zgetline.o mbscmp.o uconvert.o ufuncs.o casemod.o \
input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o \
input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o strvis.o \
utf8.o random.o gettimeofday.o timers.o wcsnwidth.o ${LIBOBJS}
SUPPORT = Makefile
@@ -198,6 +198,7 @@ strtoul.o: strtoul.c
strtoull.o: strtoull.c
strtoumax.o: strtoumax.c
strtrans.o: strtrans.c
strvis.o: strvis.c
timers.o: timers.c
times.o: times.c
timeval.o: timeval.c
@@ -279,6 +280,7 @@ strtoul.o: ${BUILD_DIR}/config.h
strtoull.o: ${BUILD_DIR}/config.h
strtoumax.o: ${BUILD_DIR}/config.h
strtrans.o: ${BUILD_DIR}/config.h
strvis.o: ${BUILD_DIR}/config.h
timers.o: ${BUILD_DIR}/config.h
times.o: ${BUILD_DIR}/config.h
timeval.o: ${BUILD_DIR}/config.h
@@ -512,6 +514,11 @@ strtrans.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
strtrans.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
#strtrans.o: ${BUILD_DIR}/version.h
strvis.o: ${topdir}/bashansi.h
strvis.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/chartypes.h
strvis.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
strvis.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
times.o: ${BASHINCDIR}/systimes.h
times.o: ${BASHINCDIR}/posixtime.h
+3 -2
View File
@@ -313,10 +313,11 @@ sh_backslash_quote (string, table, flags)
#if defined (PROMPT_STRING_DECODE) || defined (TRANSLATABLE_STRINGS)
/* Quote characters that get special treatment when in double quotes in STRING
using backslashes. Return a new string. */
using backslashes. FLAGS is reserved for future use. Return a new string. */
char *
sh_backslash_quote_for_double_quotes (string)
sh_backslash_quote_for_double_quotes (string, flags)
char *string;
int flags;
{
unsigned char c;
char *result, *r, *s, *send;
-1
View File
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
+148
View File
@@ -0,0 +1,148 @@
/* strvis.c - make unsafe graphical characters in a string visible. */
/* Copyright (C) 2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash 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.
Bash 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.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
/* This is a stripped-down version suitable for the shell's use. */
#include <config.h>
#include <unistd.h>
#include "bashansi.h"
#include <stdio.h>
#include "chartypes.h"
#include "bashintl.h"
#include "shmbutil.h"
#define SAFECHAR(c) ((c) == ' ' || (c) == '\t')
#ifndef RUBOUT
#define RUBOUT 0x7f
#endif
#ifndef CTRL_CHAR
#define CTRL_CHAR(c) ((c) < 0x20)
#endif
#ifndef META_CHAR
#define META_CHAR(c) ((c) > 0x7f && (c) <= UCHAR_MAX)
#endif
#ifndef UNCTRL
#define UNCTRL(c) (TOUPPER ((c) | 0x40))
#endif
#ifndef UNMETA
#define UNMETA(c) ((c) & 0x7f)
#endif
int
sh_charvis (s, sindp, slen, ret, rindp)
const char *s;
size_t *sindp;
size_t slen;
char *ret;
size_t *rindp;
{
unsigned char c;
size_t si, ri;
const char *send;
DECLARE_MBSTATE;
si = *sindp;
ri = *rindp;
c = s[*sindp];
send = (locale_mb_cur_max > 1) ? s + slen : 0;
if (SAFECHAR (c))
{
ret[ri++] = c;
si++;
}
else if (c == RUBOUT)
{
ret[ri++] = '^';
ret[ri++] = '?';
si++;
}
else if (CTRL_CHAR (c))
{
ret[ri++] = '^';
ret[ri++] = UNCTRL (c);
si++;
}
else if (locale_utf8locale && (c & 0x80))
COPY_CHAR_I (ret, ri, s, send, si);
else if (locale_mb_cur_max > 1 && is_basic (c) == 0)
COPY_CHAR_I (ret, ri, s, send, si);
else if (META_CHAR (c))
{
ret[ri++] = 'M';
ret[ri++] = '-';
ret[ri++] = UNMETA (c);
si++;
}
else
ret[ri++] = s[si++];
*sindp = si;
*rindp = ri;
return si;
}
/* Return a new string with `unsafe' non-graphical characters in S rendered
in a visible way. */
char *
sh_strvis (string)
const char *string;
{
size_t slen, sind;
char *ret;
size_t retind, retsize;
unsigned char c;
DECLARE_MBSTATE;
if (string == 0)
return 0;
if (*string == '\0')
{
if ((ret = (char *)malloc (1)) == 0)
return 0;
ret[0] = '\0';
return ret;
}
slen = strlen (string);
retsize = 3 * slen + 1;
ret = (char *)malloc (retsize);
if (ret == 0)
return 0;
retind = 0;
sind = 0;
while (string[sind])
sind = sh_charvis (string, &sind, slen, ret, &retind);
ret[retind] = '\0';
return ret;
}