Import GNU Readline 8.1

This imports readline 8.1.  I did this via various hackery in a
readline git repository to make a version of readline identical to
gdb's, then did a git merge.

readline/ChangeLog
2021-03-02  Tom Tromey  <tom@tromey.com>

	* Import readline 8.1.
This commit is contained in:
Tom Tromey 2021-03-02 13:42:37 -07:00
parent bbcdf9ab73
commit b4f26d541a
58 changed files with 3783 additions and 4155 deletions

View File

@ -1,3 +1,7 @@
2021-03-02 Tom Tromey <tom@tromey.com>
* Import readline 8.1.
2020-06-30 Tom Tromey <tom@tromey.com>
* README: Update instructions.

View File

@ -1,11 +1,4 @@
2019-12-23 Eli Zaretskii <eliz@gnu.org>
* posixstat.h (S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH)
(S_IXOTH, S_IRWXG, S_IRWXO): Define if undefined, even if S_IRWXU
is defined, because non-Posix systems may defined only the user
bits.
[Readline-specific changelog. Descriptions of changes to the source are
\[Readline-specific changelog. Descriptions of changes to the source are
found in the bash changelog.]
6/9
@ -1358,3 +1351,55 @@ Makefile.in
----
Makefile.in
- installdirs: create $(pkgconfigdir) if it doesn't exist
4/8/2019
--------
readline.pc.in
- change CFLAGS to include ${includedir} instead of ${includedir}/readline,
to support the recommended `#include <readline/readline.h>'. Report
and fix from Andrea Bolognani <abologna@redhat.com>
5/13
----
configure.ac
- hpux: add -DTGETENT_BROKEN to LOCAL_CFLAGS
8/28
----
configure.ac
- hpux: add -DTGETFLAG_BROKEN to LOCAL_CFLAGS
9/6
---
examples/autoconf/RL_LIB_READLINE_VERSION
- include <stdlib.h> in the AC_TRY_RUN block to accommodate compilers
that treat functions without an existing prototype as fatal errors.
Report and fix from Florian Weimer <fweimer@redhat.com>
12/13
-----
support/shlib-install
- remove old code for FreeBSD and Dragonfly; they are ELF-only now and
can use the same code as Linux. Fix from
Baptiste Daroussin <bapt@FreeBSD.org>
5/20/2020
---------
configure.ac
- bumped version number up to 8.1
6/15
----
configure.ac
- add -Wno-parentheses -Wno-format-security to CFLAGS if gcc (or clang)
is the compiler
10/29
-----
configure.ac
- --enable-bracketed-paste-default: new invocation option, toggles the
default value of enable-bracketed-paste (on by default)
INSTALL
- document new --enable-bracketed-paste-default configure option

View File

@ -1,3 +1,126 @@
This document details the changes between this version, readline-8.1, and
the previous version, readline-8.0.
1. Changes to Readline
a. There are a number of fixes that were found as the result of fuzzing with
random input.
b. Changed the revert-all-at-newline behavior to make sure to start at the end
of the history list when doing it, instead of the line where the user hit
return.
c. When parsing `set' commands from the inputrc file or an application, readline
now allows trailing whitespace.
d. Fixed a bug that left a file descriptor open to the history file if the
file size was 0.
e. Fixed a problem with binding key sequences containing meta characters.
f. Fixed a bug that caused the wrong line to be displayed if the user tried to
move back beyond the beginning of the history list, or forward past the end
of the history list.
g. If readline catches SIGTSTP, it now sets a hook that allows the calling
application to handle it if it desires.
h. Fixed a redisplay problem with a prompt string containing embedded newlines.
i. Fixed a problem with completing filenames containing invalid multibyte
sequences when case-insensitive comparisons are enabled.
j. Fixed a redisplay problem with prompt strings containing invisible multibyte
characters.
k. Fixed a problem with multibyte characters mapped to editing commands that
modify the search string in incremental search.
l. Fixed a bug with maintaining the key sequence while resolving a bound
command in the presence of ambiguous sequences (sequences with a common
prefix), in most cases while attempting to unbind it.
m. Fixed several buffer overflows found as the result of fuzzing.
n. Reworked backslash handling when translating key sequences for key binding
to be more uniform and consistent, which introduces a slight backwards
incompatibility.
o. Fixed a bug with saving the history that resulted in errors not being
propagated to the calling application when the history file is not writable.
p. Readline only calls chown(2) on a newly-written history file if it really
needs to, instead of having it be a no-op.
q. Readline now behaves better when operate-and-get-next is used when the
history list is `full': when there are already $HISTSIZE entries.
r. Fixed a bug that could cause vi redo (`.') of a replace command not to work
correctly in the C or POSIX locale.
s. Fixed a bug with vi-mode digit arguments that caused the last command to be
set incorrectly. This prevents yank-last-arg from working as intended, for
example.
t. Make sure that all undo groups are closed when leaving vi insertion mode.
u. Make sure that the vi-mode `C' and `c' commands enter insert mode even if
the motion command doesn't have any effect.
v. Fixed several potential memory leaks in the callback mode context handling.
w. If readline is handling a SIGTTOU, make sure SIGTTOU is blocked while
executing the terminal cleanup code, since it's no longer run in a signal
handling context.
x. Fixed a bug that could cause an application with an application-specific
redisplay function to crash if the line data structures had not been
initialized.
y. Terminals that are named "dumb" or unknown do not enable bracketed paste
by default.
z. Ensure that disabling bracketed paste turns off highlighting the incremental
search string when the search is successful.
2. New Features in Readline
a. If a second consecutive completion attempt produces matches where the first
did not, treat it as a new completion attempt and insert a match as
appropriate.
b. Bracketed paste mode works in more places: incremental search strings, vi
overstrike mode, character search, and reading numeric arguments.
c. Readline automatically switches to horizontal scrolling if the terminal has
only one line.
d. Unbinding all key sequences bound to a particular readline function now
descends into keymaps for multi-key sequences.
e. rl-clear-display: new bindable command that clears the screen and, if
possible, the scrollback buffer (bound to emacs mode M-C-l by default).
f. New active mark and face feature: when enabled, it will highlight the text
inserted by a bracketed paste (the `active region') and the text found by
incremental and non-incremental history searches. This is tied to bracketed
paste and can be disabled by turning off bracketed paste.
g. Readline sets the mark in several additional commands.
h. Bracketed paste mode is enabled by default. There is a configure-time
option (--enable-bracketed-paste-default) to set the default to on or off.
i. Readline tries to take advantage of the more regular structure of UTF-8
characters to identify the beginning and end of characters when moving
through the line buffer.
j. The bindable operate-and-get-next command (and its default bindings) are
now part of readline instead of a bash-specific addition.
k. The signal cleanup code now blocks SIGINT while processing after a SIGINT.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-8.0, and the
previous version, readline-7.0.

View File

@ -1,7 +1,7 @@
Basic Installation
==================
These are installation instructions for Readline-8.0.
These are installation instructions for Readline-8.1.
The simplest way to compile readline is:
@ -183,6 +183,11 @@ The readline `configure' recognizes a single `--with-PACKAGE' option:
`--enable-static'
Build the static libraries by default. The default is `yes'.
`--enable-bracketed-paste-default'
Enable bracketed paste by default, so the initial value of the
`enable-bracketed-paste' Readline variable is `on'. The default
is `yes'.
Shared Libraries
================

View File

@ -72,10 +72,10 @@ DESTDIR =
# Programs to make tags files.
ETAGS = etags
CTAGS = ctags -tw
CTAGS = ctags -w
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"' @BRACKETED_PASTE@
CPPFLAGS = @CPPFLAGS@
DEFS = @DEFS@ @CROSS_COMPILE@

View File

@ -1,3 +1,44 @@
This is a terse description of the new features added to readline-8.1 since
the release of readline-8.0.
New Features in Readline
a. If a second consecutive completion attempt produces matches where the first
did not, treat it as a new completion attempt and insert a match as
appropriate.
b. Bracketed paste mode works in more places: incremental search strings, vi
overstrike mode, character search, and reading numeric arguments.
c. Readline automatically switches to horizontal scrolling if the terminal has
only one line.
d. Unbinding all key sequences bound to a particular readline function now
descends into keymaps for multi-key sequences.
e. rl-clear-display: new bindable command that clears the screen and, if
possible, the scrollback buffer (bound to emacs mode M-C-l by default).
f. New active mark and face feature: when enabled, it will highlight the text
inserted by a bracketed paste (the `active region') and the text found by
incremental and non-incremental history searches. This is tied to bracketed
paste and can be disabled by turning off bracketed paste.
g. Readline sets the mark in several additional commands.
h. Bracketed paste mode is enabled by default. There is a configure-time
option (--enable-bracketed-paste-default) to set the default to on or off.
i. Readline tries to take advantage of the more regular structure of UTF-8
characters to identify the beginning and end of characters when moving
through the line buffer.
j. The bindable operate-and-get-next command (and its default bindings) are
now part of readline instead of a bash-specific addition.
k. The signal cleanup code now blocks SIGINT while processing after a SIGINT.
-------------------------------------------------------------------------------
This is a terse description of the new features added to readline-8.0 since
the release of readline-7.0.
@ -178,6 +219,27 @@ n. New application-settable variable: rl_signal_event_hook; function that is
called when readline is reading terminal input and read(2) is interrupted
by a signal. Currently not called for SIGHUP or SIGTERM.
-------------------------------------------------------------------------------
This is a terse description of the new features added to readline-6.2 since
the release of readline-6.1.
a. The history library does not try to write the history filename in the
current directory if $HOME is unset. This closes a potential security
problem if the application does not specify a history filename.
b. New bindable variable `completion-display-width' to set the number of
columns used when displaying completions.
c. New bindable variable `completion-case-map' to cause case-insensitive
completion to treat `-' and `_' as identical.
d. There are new bindable vi-mode command names to avoid readline's case-
insensitive matching not allowing them to be bound separately.
e. New bindable variable `menu-complete-display-prefix' causes the menu
completion code to display the common prefix of the possible completions
before cycling through the list, instead of after.
-------------------------------------------------------------------------------
This is a terse description of the new features added to readline-6.1 since
the release of readline-6.0.

View File

@ -1,7 +1,7 @@
Introduction
============
This is the Gnu Readline library, version 8.0.
This is the Gnu Readline library, version 8.1.
The Readline library provides a set of functions for use by applications
that allow users to edit command lines as they are typed in. Both

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* bind.c -- key binding and startup file support for the readline library. */
/* Copyright (C) 1987-2017 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.
@ -135,12 +135,13 @@ rl_add_defun (const char *name, rl_command_func_t *function, int key)
int
rl_bind_key (int key, rl_command_func_t *function)
{
char keyseq[3];
char keyseq[4];
int l;
if (key < 0)
if (key < 0 || key > largest_char)
return (key);
/* Want to make this a multi-character key sequence with an ESC prefix */
if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
{
if (_rl_keymap[ESC].type == ISKMAP)
@ -153,24 +154,43 @@ rl_bind_key (int key, rl_command_func_t *function)
escmap[key].function = function;
return (0);
}
return (key);
/* Otherwise, let's just let rl_generic_bind handle the key sequence.
We start it off with ESC here and let the code below add the rest
of the sequence. */
keyseq[0] = ESC;
l = 1;
key = UNMETA(key);
goto bind_keyseq;
}
/* If it's bound to a function or macro, just overwrite. Otherwise we have
to treat it as a key sequence so rl_generic_bind handles shadow keymaps
for us. If we are binding '\' make sure to escape it so it makes it
through the call to rl_translate_keyseq. */
for us. If we are binding '\' or \C-@ (NUL) make sure to escape it so
it makes it through the call to rl_translate_keyseq. */
if (_rl_keymap[key].type != ISKMAP)
{
if (_rl_keymap[key].type == ISMACR)
xfree ((char *)_rl_keymap[key].function);
_rl_keymap[key].type = ISFUNC;
_rl_keymap[key].function = function;
}
else
{
l = 0;
bind_keyseq:
if (key == '\\')
keyseq[l++] = '\\';
keyseq[l++] = key;
{
keyseq[l++] = '\\';
keyseq[l++] = '\\';
}
else if (key == '\0')
{
keyseq[l++] = '\\';
keyseq[l++] = '0';
}
else
keyseq[l++] = key;
keyseq[l] = '\0';
rl_bind_keyseq (keyseq, function);
}
@ -242,6 +262,13 @@ rl_unbind_function_in_map (rl_command_func_t *func, Keymap map)
map[i].function = (rl_command_func_t *)NULL;
rval = 1;
}
else if (map[i].type == ISKMAP) /* TAG:readline-8.1 */
{
int r;
r = rl_unbind_function_in_map (func, FUNCTION_TO_KEYMAP (map, i));
if (r == 1)
rval = 1;
}
}
return rval;
}
@ -352,7 +379,7 @@ int
rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
{
char *keys;
int keys_len, prevkey;
int keys_len, prevkey, ic;
register int i;
KEYMAP_ENTRY k;
Keymap prevmap;
@ -385,7 +412,6 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
for (i = 0; i < keys_len; i++)
{
unsigned char uc = keys[i];
int ic;
if (i > 0)
prevkey = ic;
@ -397,6 +423,9 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
return -1;
}
/* We now rely on rl_translate_keyseq to do this conversion, so this
check is superfluous. */
#if 0
if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
{
ic = UNMETA (ic);
@ -406,6 +435,7 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
map = FUNCTION_TO_KEYMAP (map, ESC);
}
}
#endif
if ((i + 1) < keys_len)
{
@ -439,9 +469,7 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
}
else
{
if (map[ic].type == ISMACR)
xfree ((char *)map[ic].function);
else if (map[ic].type == ISKMAP)
if (map[ic].type == ISKMAP)
{
prevmap = map;
map = FUNCTION_TO_KEYMAP (map, ic);
@ -454,6 +482,8 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
if (type == ISFUNC && data == 0)
data = (char *)_rl_null_function;
}
if (map[ic].type == ISMACR)
xfree ((char *)map[ic].function);
map[ic].function = KEYMAP_TO_FUNCTION (data);
map[ic].type = type;
@ -492,59 +522,38 @@ rl_generic_bind (int type, const char *keyseq, char *data, Keymap map)
int
rl_translate_keyseq (const char *seq, char *array, int *len)
{
register int i, c, l, temp;
register int i, l, temp;
int has_control, has_meta;
unsigned char c;
for (i = l = 0; c = seq[i]; i++)
has_control = 0;
has_meta = 0;
/* When there are incomplete prefixes \C- or \M- (has_control || has_meta)
without base character at the end of SEQ, they are processed as the
prefixes for '\0'.
*/
for (i = l = 0; (c = seq[i]) || has_control || has_meta; i++)
{
if (c == '\\')
/* Only backslashes followed by a non-null character are handled
specially. Trailing backslash (backslash followed by '\0') is
processed as a normal character.
*/
if (c == '\\' && seq[i + 1] != '\0')
{
c = seq[++i];
if (c == 0)
{
array[l++] = '\\'; /* preserve trailing backslash */
break;
}
/* Handle \C- and \M- prefixes. */
if ((c == 'C' || c == 'M') && seq[i + 1] == '-')
if (c == 'C' && seq[i + 1] == '-')
{
/* Handle special case of backwards define. */
if (strncmp (&seq[i], "C-\\M-", 5) == 0)
{
array[l++] = ESC; /* ESC is meta-prefix */
i += 5;
array[l++] = CTRL (_rl_to_upper (seq[i]));
}
else if (c == 'M')
{
i++; /* seq[i] == '-' */
/* XXX - obey convert-meta setting */
if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP)
array[l++] = ESC; /* ESC is meta-prefix */
else if (seq[i+1] == '\\' && seq[i+2] == 'C' && seq[i+3] == '-')
{
i += 4;
temp = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
array[l++] = META (temp);
}
else
{
/* This doesn't yet handle things like \M-\a, which may
or may not have any reasonable meaning. You're
probably better off using straight octal or hex. */
i++;
array[l++] = META (seq[i]);
}
}
else if (c == 'C')
{
i += 2;
/* Special hack for C-?... */
array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
}
if (seq[i] == '\0')
break;
i++;
has_control = 1;
continue;
}
else if (c == 'M' && seq[i + 1] == '-')
{
i++;
has_meta = 1;
continue;
}
@ -555,34 +564,34 @@ rl_translate_keyseq (const char *seq, char *array, int *len)
switch (c)
{
case 'a':
array[l++] = '\007';
c = '\007';
break;
case 'b':
array[l++] = '\b';
c = '\b';
break;
case 'd':
array[l++] = RUBOUT; /* readline-specific */
c = RUBOUT; /* readline-specific */
break;
case 'e':
array[l++] = ESC;
c = ESC;
break;
case 'f':
array[l++] = '\f';
c = '\f';
break;
case 'n':
array[l++] = NEWLINE;
c = NEWLINE;
break;
case 'r':
array[l++] = RETURN;
c = RETURN;
break;
case 't':
array[l++] = TAB;
c = TAB;
break;
case 'v':
array[l++] = 0x0B;
c = 0x0B;
break;
case '\\':
array[l++] = '\\';
c = '\\';
break;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
@ -590,7 +599,7 @@ rl_translate_keyseq (const char *seq, char *array, int *len)
for (temp = 2, c -= '0'; ISOCTAL ((unsigned char)seq[i]) && temp--; i++)
c = (c * 8) + OCTVALUE (seq[i]);
i--; /* auto-increment in for loop */
array[l++] = c & largest_char;
c &= largest_char;
break;
case 'x':
i++;
@ -599,16 +608,40 @@ rl_translate_keyseq (const char *seq, char *array, int *len)
if (temp == 2)
c = 'x';
i--; /* auto-increment in for loop */
array[l++] = c & largest_char;
c &= largest_char;
break;
default: /* backslashes before non-special chars just add the char */
array[l++] = c;
c &= largest_char;
break; /* the backslash is stripped */
}
continue;
}
array[l++] = c;
/* Process \C- and \M- flags */
if (has_control)
{
/* Special treatment for C-? */
c = (c == '?') ? RUBOUT : CTRL (_rl_to_upper (c));
has_control = 0;
}
if (has_meta)
{
c = META (c);
has_meta = 0;
}
/* If convert-meta is turned on, convert a meta char to a key sequence */
if (META_CHAR (c) && _rl_convert_meta_chars_to_ascii)
{
array[l++] = ESC; /* ESC is meta-prefix */
array[l++] = UNMETA (c);
}
else
array[l++] = (c);
/* Null characters may be processed for incomplete prefixes at the end of
sequence */
if (seq[i] == '\0')
break;
}
*len = l;
@ -756,7 +789,7 @@ _rl_untranslate_macro_value (char *seq, int use_escapes)
/* Return a pointer to the function that STRING represents.
If STRING doesn't have a matching function, then a NULL pointer
is returned. */
is returned. The string match is case-insensitive. */
rl_command_func_t *
rl_named_function (const char *string)
{
@ -809,7 +842,7 @@ _rl_function_of_keyseq_internal (const char *keyseq, size_t len, Keymap map, int
{
/* If this is the last key in the key sequence, return the
map. */
if (keyseq[i + 1] == '\0')
if (i + 1 == len)
{
if (type)
*type = ISKMAP;
@ -822,9 +855,9 @@ _rl_function_of_keyseq_internal (const char *keyseq, size_t len, Keymap map, int
/* If we're not at the end of the key sequence, and the current key
is bound to something other than a keymap, then the entire key
sequence is not bound. */
else if (map[ic].type != ISKMAP && keyseq[i+1])
else if (map[ic].type != ISKMAP && i+1 < len)
return ((rl_command_func_t *)NULL);
else /* map[ic].type != ISKMAP && keyseq[i+1] == 0 */
else /* map[ic].type != ISKMAP && i+1 == len */
{
if (type)
*type = map[ic].type;
@ -1569,15 +1602,11 @@ rl_parse_and_bind (char *string)
/* Strip trailing whitespace from values of boolean variables. */
if (find_boolean_var (var) >= 0)
{
/* remove trailing whitespace */
remove_trailing:
e = value + strlen (value) - 1;
while (e >= value && whitespace (*e))
e--;
e++; /* skip back to whitespace or EOS */
if (*e && e >= value)
*e = '\0';
/* just read a whitespace-delimited word or empty string */
for (e = value; *e && whitespace (*e) == 0; e++)
;
if (e > value)
*e = '\0'; /* cut off everything trailing */
}
else if ((i = find_string_var (var)) >= 0)
{
@ -1589,9 +1618,24 @@ remove_trailing:
value++; /* skip past the quote */
}
else
goto remove_trailing;
{
/* remove trailing whitespace */
e = value + strlen (value) - 1;
while (e >= value && whitespace (*e))
e--;
e++; /* skip back to whitespace or EOS */
if (*e && e >= value)
*e = '\0';
}
}
else
{
/* avoid calling rl_variable_bind just to find this out */
_rl_init_file_error ("%s: unknown variable name", var);
return 1;
}
rl_variable_bind (var, value);
return 0;
}
@ -1768,7 +1812,7 @@ static const struct {
{ "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
{ "disable-completion", &rl_inhibit_completion, 0 },
{ "echo-control-characters", &_rl_echo_control_chars, 0 },
{ "enable-bracketed-paste", &_rl_enable_bracketed_paste, 0 },
{ "enable-bracketed-paste", &_rl_enable_bracketed_paste, V_SPECIAL },
{ "enable-keypad", &_rl_enable_keypad, 0 },
{ "enable-meta-key", &_rl_enable_meta, 0 },
{ "expand-tilde", &rl_complete_with_tilde_expansion, 0 },
@ -1834,6 +1878,8 @@ hack_special_boolean_var (int i)
}
else if (_rl_stricmp (name, "show-mode-in-prompt") == 0)
_rl_reset_prompt ();
else if (_rl_stricmp (name, "enable-bracketed-paste") == 0)
_rl_enable_active_region = _rl_enable_bracketed_paste;
}
typedef int _rl_sv_func_t PARAMS((const char *));
@ -1903,7 +1949,7 @@ string_varname (int i)
}
/* A boolean value that can appear in a `set variable' command is true if
the value is null or empty, `on' (case-insensitive), or "1". Any other
the value is null or empty, `on' (case-insensitive), or "1". All other
values result in 0 (false). */
static int
bool_to_int (const char *value)
@ -1928,7 +1974,7 @@ rl_variable_value (const char *name)
return (_rl_get_string_variable_value (string_varlist[i].name));
/* Unknown variable names return NULL. */
return 0;
return (char *)NULL;
}
int
@ -1959,6 +2005,8 @@ rl_variable_bind (const char *name, const char *value)
}
v = (*string_varlist[i].set_func) (value);
if (v != 0)
_rl_init_file_error ("%s: could not set value to `%s'", name, value);
return v;
}
@ -2581,20 +2629,22 @@ rl_invoking_keyseqs_in_map (rl_command_func_t *function, Keymap map)
else
sprintf (keyname, "\\e");
}
else if (CTRL_CHAR (key))
sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));
else if (key == RUBOUT)
sprintf (keyname, "\\C-?");
else if (key == '\\' || key == '"')
{
keyname[0] = '\\';
keyname[1] = (char) key;
keyname[2] = '\0';
}
else
{
keyname[0] = (char) key;
keyname[1] = '\0';
int c = key, l = 0;
if (CTRL_CHAR (c) || c == RUBOUT)
{
keyname[l++] = '\\';
keyname[l++] = 'C';
keyname[l++] = '-';
c = (c == RUBOUT) ? '?' : _rl_to_lower (UNCTRL (c));
}
if (c == '\\' || c == '"')
keyname[l++] = '\\';
keyname[l++] = (char) c;
keyname[l++] = '\0';
}
strcat (keyname, seqs[i]);

View File

@ -2,7 +2,7 @@
Modified by Chet Ramey for Readline.
Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015, 2017
Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015, 2017, 2019
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@ -32,6 +32,13 @@
#include "rlconf.h"
#if defined __TANDEM
# define _XOPEN_SOURCE_EXTENDED 1
# define _TANDEM_SOURCE 1
# include <sys/types.h>
# include <sys/stat.h>
#endif
#include <stdio.h>
#include "posixstat.h" // stat related macros (S_ISREG, ...)

View File

@ -1,6 +1,6 @@
/* complete.c -- filename completion for readline. */
/* Copyright (C) 1987-2017 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.
@ -21,11 +21,18 @@
#define READLINE_LIBRARY
#if defined (__TANDEM)
# define _XOPEN_SOURCE_EXTENDED 1
#endif
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#if defined (__TANDEM)
# include <sys/stat.h>
#endif
#include <fcntl.h>
#if defined (HAVE_SYS_FILE_H)
# include <sys/file.h>
@ -141,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 *));
@ -406,6 +414,7 @@ int rl_sort_completion_matches = 1;
/* Local variable states what happened during the last completion attempt. */
static int completion_changed_buffer;
static int last_completion_failed = 0;
/* The result of the query to the user about displaying completion matches */
static int completion_y_or_n;
@ -428,7 +437,11 @@ rl_complete (int ignore, int invoking_key)
if (rl_inhibit_completion)
return (_rl_insert_char (ignore, invoking_key));
else if (rl_last_func == rl_complete && !completion_changed_buffer)
#if 0
else if (rl_last_func == rl_complete && completion_changed_buffer == 0 && last_completion_failed == 0)
#else
else if (rl_last_func == rl_complete && completion_changed_buffer == 0)
#endif
return (rl_complete_internal ('?'));
else if (_rl_complete_show_all)
return (rl_complete_internal ('!'));
@ -477,7 +490,7 @@ rl_completion_mode (rl_command_func_t *cfunc)
/* */
/************************************/
/* Reset readline state on a signal or other event. */
/* Reset public readline state on a signal or other event. */
void
_rl_reset_completion_state (void)
{
@ -1330,12 +1343,13 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
memset (&ps2, 0, sizeof (mbstate_t));
}
#endif
if (_rl_completion_case_fold)
for (si = 0; (c1 = match_list[i][si]) && (c2 = match_list[i + 1][si]); si++)
{
for (si = 0;
(c1 = _rl_to_lower(match_list[i][si])) &&
(c2 = _rl_to_lower(match_list[i + 1][si]));
si++)
if (_rl_completion_case_fold)
{
c1 = _rl_to_lower (c1);
c2 = _rl_to_lower (c2);
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
@ -1347,35 +1361,17 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
break;
continue;
}
wc1 = towlower (wc1);
wc2 = towlower (wc2);
if (_rl_completion_case_fold)
{
wc1 = towlower (wc1);
wc2 = towlower (wc2);
}
if (wc1 != wc2)
break;
else if (v1 > 1)
si += v1 - 1;
}
else
#endif
if (c1 != c2)
break;
}
else
{
for (si = 0;
(c1 = match_list[i][si]) &&
(c2 = match_list[i + 1][si]);
si++)
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
mbstate_t ps_back;
ps_back = ps1;
if (!_rl_compare_chars (match_list[i], si, &ps1, match_list[i+1], si, &ps2))
break;
else if ((v = _rl_get_char_len (&match_list[i][si], &ps_back)) > 1)
si += v - 1;
}
else
#endif
if (c1 != c2)
break;
@ -1969,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.
@ -1986,10 +2002,12 @@ rl_complete_internal (int what_to_do)
int start, end, delimiter, found_quote, i, nontrivial_lcd;
char *text, *saved_line_buffer;
char quote_char;
int tlen, mlen;
int tlen, mlen, saved_last_completion_failed;
RL_SETSTATE(RL_STATE_COMPLETING);
saved_last_completion_failed = last_completion_failed;
set_completion_defaults (what_to_do);
saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL;
@ -2013,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);
@ -2023,6 +2041,7 @@ rl_complete_internal (int what_to_do)
rl_ding ();
FREE (saved_line_buffer);
completion_changed_buffer = 0;
last_completion_failed = 1;
RL_UNSETSTATE(RL_STATE_COMPLETING);
_rl_reset_completion_state ();
return (0);
@ -2038,11 +2057,15 @@ rl_complete_internal (int what_to_do)
rl_ding ();
FREE (saved_line_buffer);
completion_changed_buffer = 0;
last_completion_failed = 1;
RL_UNSETSTATE(RL_STATE_COMPLETING);
_rl_reset_completion_state ();
return (0);
}
if (matches && matches[0] && *matches[0])
last_completion_failed = 0;
switch (what_to_do)
{
case TAB:
@ -2098,6 +2121,15 @@ rl_complete_internal (int what_to_do)
break;
case '?':
/* Let's try to insert a single match here if the last completion failed
but this attempt returned a single match. */
if (saved_last_completion_failed && matches[0] && *matches[0] && matches[1] == 0)
{
insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, &quote_char);
append_to_match (matches[0], delimiter, quote_char, nontrivial_lcd);
break;
}
if (rl_completion_display_matches_hook == 0)
{
_rl_sigcleanup = _rl_complete_sigcleanup;
@ -2761,7 +2793,7 @@ rl_old_menu_complete (int count, int invoking_key)
{
insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, &quote_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;
@ -2835,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
@ -2942,7 +2974,7 @@ rl_menu_complete (int count, int ignore)
{
insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, &quote_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;

View File

@ -1,7 +1,7 @@
#! /bin/sh
# From configure.ac for Readline 8.0, version 2.85.
# From configure.ac for Readline 8.1, version 2.90.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for readline 8.0.
# Generated by GNU Autoconf 2.69 for readline 8.1.
#
# Report bugs to <bug-readline@gnu.org>.
#
@ -581,8 +581,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='readline'
PACKAGE_TARNAME='readline'
PACKAGE_VERSION='8.0'
PACKAGE_STRING='readline 8.0'
PACKAGE_VERSION='8.1'
PACKAGE_STRING='readline 8.1'
PACKAGE_BUGREPORT='bug-readline@gnu.org'
PACKAGE_URL=''
@ -673,6 +673,7 @@ CFLAGS
CC
SET_MAKE
CROSS_COMPILE
BRACKETED_PASTE
host_os
host_vendor
host_cpu
@ -726,6 +727,7 @@ with_curses
enable_multibyte
enable_static
enable_install_examples
enable_bracketed_paste_default
enable_largefile
'
ac_precious_vars='build_alias
@ -1277,7 +1279,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures readline 8.0 to adapt to many kinds of systems.
\`configure' configures readline 8.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1342,7 +1344,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of readline 8.0:";;
short | recursive ) echo "Configuration of readline 8.1:";;
esac
cat <<\_ACEOF
@ -1354,6 +1356,9 @@ Optional Features:
--enable-static build static libraries [[default=YES]]
--disable-install-examples
don't install examples [[default=install]]
--disable-bracketed-paste-default
disable bracketed paste by default
[[default=enable]]
--disable-largefile omit support for large files
Optional Packages:
@ -1438,7 +1443,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
readline configure 8.0
readline configure 8.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -2090,7 +2095,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by readline $as_me 8.0, which was
It was created by readline $as_me 8.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -2477,7 +2482,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
ac_config_headers="$ac_config_headers config.h"
LIBVERSION=8.0
LIBVERSION=8.1
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
@ -2569,6 +2574,7 @@ opt_multibyte=yes
opt_static_libs=yes
opt_shared_libs=no
opt_install_examples=no
opt_bracketed_paste_default=yes
# Check whether --enable-multibyte was given.
if test "${enable_multibyte+set}" = set; then :
@ -2586,11 +2592,24 @@ if test "${enable_install_examples+set}" = set; then :
fi
# Check whether --enable-bracketed-paste-default was given.
if test "${enable_bracketed_paste_default+set}" = set; then :
enableval=$enable_bracketed_paste_default; opt_bracketed_paste_default=$enableval
fi
if test $opt_multibyte = no; then
$as_echo "#define NO_MULTIBYTE_SUPPORT 1" >>confdefs.h
fi
if test $opt_bracketed_paste_default = yes; then
BRACKETED_PASTE='-DBRACKETED_PASTE_DEFAULT=1'
else
BRACKETED_PASTE='-DBRACKETED_PASTE_DEFAULT=0'
fi
CROSS_COMPILE=
@ -2622,7 +2641,7 @@ echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_ve
echo ""
# We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
test -z "$CFLAGS" && want_auto_cflags=1
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
@ -3905,8 +3924,11 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
# If we're using gcc and the user hasn't specified CFLAGS, add -O2 to CFLAGS
if test -n "$want_auto_cflags" ; then
AUTO_CFLAGS="-g ${GCC+-O2}"
STYLE_CFLAGS="${GCC+-Wno-parentheses} ${GCC+-Wno-format-security}"
fi
if test $ac_cv_c_compiler_gnu = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5
@ -5316,6 +5338,7 @@ else
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdlib.h>
typedef RETSIGTYPE sigfunc();
@ -5346,6 +5369,7 @@ int s;
nsigint++;
}
int
main()
{
nsigint = 0;
@ -5396,7 +5420,9 @@ else
#include <sys/types.h>
#include <signal.h>
#include <setjmp.h>
#include <stdlib.h>
int
main()
{
#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS)
@ -5499,7 +5525,10 @@ else
#if defined (HAVE_LOCALE_H)
#include <locale.h>
#endif
#include <string.h>
#include <stdlib.h>
int
main(c, v)
int c;
char *v[];
@ -5569,7 +5598,9 @@ else
#endif
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
int
main(c, v)
int c;
char *v[];
@ -6713,6 +6744,7 @@ else
#include <locale.h>
#include <wchar.h>
int
main(c, v)
int c;
char **v;
@ -6803,6 +6835,7 @@ esac
case "$host_os" in
isc*) LOCAL_CFLAGS=-Disc386 ;;
hpux*) LOCAL_CFLAGS="-DTGETENT_BROKEN -DTGETFLAG_BROKEN" ;;
esac
# shared library configuration section
@ -6883,6 +6916,11 @@ esac
if test -n "$want_auto_cflags"; then
CFLAGS="$AUTO_CFLAGS"
fi
CFLAGS="$CFLAGS $STYLE_CFLAGS"
@ -7409,7 +7447,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by readline $as_me 8.0, which was
This file was extended by readline $as_me 8.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -7475,7 +7513,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
readline config.status 8.0
readline config.status 8.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -5,7 +5,7 @@ dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
# Copyright (C) 1987-2018 Free Software Foundation, Inc.
# Copyright (C) 1987-2020 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
@ -20,11 +20,11 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Readline 8.0, version 2.85])
AC_REVISION([for Readline 8.1, version 2.90])
m4_include([../../config/override.m4])
AC_INIT(readline, 8.0, bug-readline@gnu.org)
AC_INIT(readline, 8.1, bug-readline@gnu.org)
dnl make sure we are using a recent autoconf version
AC_PREREQ(2.50)
@ -36,7 +36,7 @@ AC_CONFIG_AUX_DIR(../..)
AC_CONFIG_HEADERS(config.h)
dnl update the value of RL_READLINE_VERSION in readline.h when this changes
LIBVERSION=8.0
LIBVERSION=8.1
AC_CANONICAL_HOST
AC_CANONICAL_BUILD
@ -56,16 +56,26 @@ opt_multibyte=yes
opt_static_libs=yes
opt_shared_libs=no
opt_install_examples=no
opt_bracketed_paste_default=yes
AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
dnl AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared], [build shared libraries [[default=YES]]]), opt_shared_libs=$enableval)
AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [build static libraries [[default=YES]]]), opt_static_libs=$enableval)
AC_ARG_ENABLE(install-examples, AC_HELP_STRING([--disable-install-examples], [don't install examples [[default=install]]]), opt_install_examples=$enableval)
AC_ARG_ENABLE(bracketed-paste-default, AC_HELP_STRING([--disable-bracketed-paste-default], [disable bracketed paste by default [[default=enable]]]), opt_bracketed_paste_default=$enableval)
if test $opt_multibyte = no; then
AC_DEFINE(NO_MULTIBYTE_SUPPORT)
fi
if test $opt_bracketed_paste_default = yes; then
BRACKETED_PASTE='-DBRACKETED_PASTE_DEFAULT=1'
else
BRACKETED_PASTE='-DBRACKETED_PASTE_DEFAULT=0'
fi
AC_SUBST(BRACKETED_PASTE)
dnl load up the cross-building cache file -- add more cases and cache
dnl files as necessary
@ -101,15 +111,18 @@ echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_ve
echo ""
# We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
test -z "$CFLAGS" && want_auto_cflags=1
AC_PROG_MAKE_SET
AC_PROG_CC
dnl AC_AIX
AC_MINIX
# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
# If we're using gcc and the user hasn't specified CFLAGS, add -O2 to CFLAGS
if test -n "$want_auto_cflags" ; then
AUTO_CFLAGS="-g ${GCC+-O2}"
STYLE_CFLAGS="${GCC+-Wno-parentheses} ${GCC+-Wno-format-security}"
fi
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
@ -219,6 +232,7 @@ esac
case "$host_os" in
isc*) LOCAL_CFLAGS=-Disc386 ;;
hpux*) LOCAL_CFLAGS="-DTGETENT_BROKEN -DTGETFLAG_BROKEN" ;;
esac
# shared library configuration section
@ -297,6 +311,11 @@ esac
AC_SUBST(BUILD_DIR)
if test -n "$want_auto_cflags"; then
CFLAGS="$AUTO_CFLAGS"
fi
CFLAGS="$CFLAGS $STYLE_CFLAGS"
AC_SUBST(CFLAGS)
AC_SUBST(LOCAL_CFLAGS)
AC_SUBST(LOCAL_LDFLAGS)

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Sun Oct 8 11:43:43 EDT 2017
.\" Last Change: Fri Jul 17 09:43:01 EDT 2020
.\"
.TH HISTORY 3 "2017 October 8" "GNU History 6.3"
.TH HISTORY 3 "2020 July 17" "GNU History 8.1"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@ -40,8 +40,8 @@
.SH NAME
history \- GNU History Library
.SH COPYRIGHT
.if t The GNU History Library is Copyright \(co 1989-2017 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2017 by the Free Software Foundation, Inc.
.if t The GNU History Library is Copyright \(co 1989-2020 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2020 by the Free Software Foundation, Inc.
.SH DESCRIPTION
Many programs read input from the user a line at a time. The GNU
History library is able to keep track of those lines, associate arbitrary
@ -49,7 +49,6 @@ data with each line, and utilize information from previous lines in
composing new ones.
.PP
.SH "HISTORY EXPANSION"
.PP
The history library supports a history expansion feature that
is identical to the history expansion in
.BR bash.
@ -80,7 +79,6 @@ history expansion character, which is \^\fB!\fP\^ by default.
Only backslash (\^\fB\e\fP\^) and single quotes can quote
the history expansion character.
.SS Event Designators
.PP
An event designator is a reference to a command line entry in the
history list.
Unless the reference is absolute, events are relative to the current
@ -118,6 +116,8 @@ containing
The trailing \fB?\fP may be omitted if
.I string
is followed immediately by a newline.
If \fIstring\fP is missing, the string from the most recent search is used;
it is an error if there is no previous search string.
.TP
.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
Quick substitution. Repeat the last command, replacing
@ -125,14 +125,13 @@ Quick substitution. Repeat the last command, replacing
with
.IR string2 .
Equivalent to
``!!:s/\fIstring1\fP/\fIstring2\fP/''
``!!:s\d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u''
(see \fBModifiers\fP below).
.TP
.B !#
The entire command line typed so far.
.PD
.SS Word Designators
.PP
Word designators are used to select desired words from the event.
A
.B :
@ -165,7 +164,8 @@ The last word. This is usually the last argument, but will expand to the
zeroth word if there is only one word in the line.
.TP
.B %
The word matched by the most recent `?\fIstring\fR?' search.
The first word matched by the most recent `?\fIstring\fR?' search,
if the search string begins with a character that is part of a word.
.TP
.I x\fB\-\fPy
A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
@ -182,14 +182,15 @@ Abbreviates \fIx\-$\fP.
.TP
.B x\-
Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
If \fBx\fP is missing, it defaults to 0.
.PD
.PP
If a word designator is supplied without an event specification, the
previous command is used as the event.
.SS Modifiers
.PP
After the optional word designator, there may appear a sequence of
one or more of the following modifiers, each preceded by a `:'.
These modify, or edit, the word or words selected from the history event.
.PP
.PD 0
.PP
@ -219,15 +220,19 @@ Quote the substituted words as with
but break into words at
.B blanks
and newlines.
The \fBq\fP and \fBx\fP modifiers are mutually exclusive; the last one
supplied is used.
.TP
.B s/\fIold\fP/\fInew\fP/
Substitute
.I new
for the first occurrence of
.I old
in the event line. Any delimiter can be used in place of /. The
final delimiter is optional if it is the last character of the
event line. The delimiter may be quoted in
in the event line.
Any character may be used as the delimiter in place of /.
The final delimiter is optional if it is the last character of the
event line.
The delimiter may be quoted in
.I old
and
.I new
@ -235,7 +240,8 @@ with a single backslash. If & appears in
.IR new ,
it is replaced by
.IR old .
A single backslash will quote the &. If
A single backslash will quote the &.
If
.I old
is null, it is set to the last
.I old
@ -245,6 +251,11 @@ the last
in a
.B !?\fIstring\fR\fB[?]\fR
search.
If
.I new
is null, each matching
.I old
is deleted.
.TP
.B &
Repeat the previous substitution.
@ -259,13 +270,13 @@ if it is the last character of the event line.
An \fBa\fP may be used as a synonym for \fBg\fP.
.TP
.B G
Apply the following `\fBs\fP' modifier once to each word in the event line.
Apply the following `\fBs\fP' or `\fB&\fP' modifier once to each word
in the event line.
.PD
.SH "PROGRAMMING WITH HISTORY FUNCTIONS"
This section describes how to use the History library in other programs.
.SS Introduction to History
.PP
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
@ -280,7 +291,7 @@ in new commands. The basic history manipulation commands are
identical to
the history substitution provided by \fBbash\fP.
.PP
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.
.PP
@ -292,9 +303,7 @@ in any file that uses the
History library's features. It supplies extern declarations for all
of the library's public functions and variables, and declares all of
the public data structures.
.SS History Storage
.PP
The history list is an array of history entries. A history entry is
declared as follows:
.PP
@ -330,7 +339,6 @@ typedef struct _hist_state {
If the flags member includes \fBHS_STIFLED\fP, the history has been
stifled.
.SH "History Functions"
.PP
This section describes the calling sequence for the various functions
exported by the GNU History library.
.SS Initializing History and State Management
@ -349,7 +357,6 @@ Return a structure describing the current state of the input history.
Set the state of the history list according to \fIstate\fP.
.SS History List Management
These functions manage individual entries on the history list, or set
parameters managing the list itself.
@ -545,7 +552,7 @@ if the returned line should be displayed, but not executed,
as with the \fB:p\fP modifier.
.PD
.RE
If an error ocurred in expansion, then \fIoutput\fP contains a descriptive
If an error occurred in expansion, then \fIoutput\fP contains a descriptive
error message.
.Fn3 "char *" get_history_event "const char *string" "int *cindex" "int qchar"
@ -583,7 +590,7 @@ The number of entries currently stored in the history list.
The maximum number of history entries. This must be changed using
\fBstifle_history()\fP.
.Vb int history_wite_timestamps
.Vb int history_write_timestamps
If non-zero, timestamps are written to the history file, so they can be
preserved between sessions. The default value is 0, meaning that
timestamps are not saved.

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--2016 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document

View File

@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988-2016 Free Software Foundation, Inc.
Copyright (C) 1988-2020 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@ -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.

View File

@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988--2018 Free Software Foundation, Inc.
Copyright (C) 1988--2020 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@ -151,7 +151,14 @@ Both @var{first} and
@var{last} may be specified as a string (to locate the most recent
command beginning with that string) or as a number (an index into the
history list, where a negative number is used as an offset from the
current command number). If @var{last} is not specified, it is set to
current command number).
When listing, a @var{first} or @var{last} of 0 is equivalent to -1
and -0 is equivalent to the current command (usually the @code{fc}
command);
otherwise 0 is equivalent to -1 and -0 is invalid.
If @var{last} is not specified, it is set to
@var{first}. If @var{first} is not specified, it is set to the previous
command for editing and @minus{}16 for listing. If the @option{-l} flag is
given, the commands are listed on standard output. The @option{-n} flag
@ -166,7 +173,7 @@ When editing is complete, the edited commands are echoed and executed.
In the second form, @var{command} is re-executed after each instance
of @var{pat} in the selected command is replaced by @var{rep}.
@var{command} is intepreted the same as @var{first} above.
@var{command} is interpreted the same as @var{first} above.
A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so
that typing @samp{r cc} runs the last command beginning with @code{cc}
@ -372,11 +379,13 @@ containing @var{string}.
The trailing
@samp{?} may be omitted if the @var{string} is followed immediately by
a newline.
If @var{string} is missing, the string from the most recent search is used;
it is an error if there is no previous search string.
@item @code{^@var{string1}^@var{string2}^}
Quick Substitution. Repeat the last command, replacing @var{string1}
with @var{string2}. Equivalent to
@code{!!:s/@var{string1}/@var{string2}/}.
@code{!!:s^@var{string1}^@var{string2}^}.
@item @code{!#}
The entire command line typed so far.
@ -428,7 +437,8 @@ The first argument; that is, word 1.
The last argument.
@item %
The word matched by the most recent @samp{?@var{string}?} search.
The first word matched by the most recent @samp{?@var{string}?} search,
if the search string begins with a character that is part of a word.
@item @var{x}-@var{y}
A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}.
@ -443,6 +453,7 @@ Abbreviates @samp{@var{x}-$}
@item @var{x}-
Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word.
If @samp{x} is missing, it defaults to 0.
@end table
@ -454,6 +465,7 @@ previous command is used as the event.
After the optional word designator, you can add a sequence of one or more
of the following modifiers, each preceded by a @samp{:}.
These modify, or edit, the word or words selected from the history event.
@table @code
@ -480,15 +492,25 @@ Quote the substituted words, escaping further substitutions.
@item x
Quote the substituted words as with @samp{q},
but break into words at spaces, tabs, and newlines.
The @samp{q} and @samp{x} modifiers are mutually exclusive; the last one
supplied is used.
@end ifset
@item s/@var{old}/@var{new}/
Substitute @var{new} for the first occurrence of @var{old} in the
event line. Any delimiter may be used in place of @samp{/}.
event line.
Any character may be used as the delimiter in place of @samp{/}.
The delimiter may be quoted in @var{old} and @var{new}
with a single backslash. If @samp{&} appears in @var{new},
it is replaced by @var{old}. A single backslash will quote
the @samp{&}. The final delimiter is optional if it is the last
the @samp{&}.
If @var{old} is null, it is set to the last @var{old}
substituted, or, if no previous history substitutions took place,
the last @var{string}
in a !?@var{string}@code{[?]}
search.
If @var{new} is is null, each matching @var{old} is deleted.
The final delimiter is optional if it is the last
character on the input line.
@item &
@ -501,6 +523,7 @@ conjunction with @samp{s}, as in @code{gs/@var{old}/@var{new}/},
or with @samp{&}.
@item G
Apply the following @samp{s} modifier once to each word in the event.
Apply the following @samp{s} or @samp{&} modifier once to each word
in the event.
@end table

View File

@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Thu Dec 28 14:49:51 EST 2017
.\" Last Change: Tue Mar 24 09:27:30 EDT 2020
.\"
.TH READLINE 3 "2017 December 28" "GNU Readline 7.0"
.TH READLINE 3 "2020 October 29" "GNU Readline 8.1"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@ -34,8 +34,8 @@ readline \- get a line from a user with editing
\fBreadline\fP (\fIconst char *prompt\fP);
.fi
.SH COPYRIGHT
.if n Readline is Copyright (C) 1989\-2014 Free Software Foundation, Inc.
.if t Readline is Copyright \(co 1989\-2014 Free Software Foundation, Inc.
.if n Readline is Copyright (C) 1989\-2020 Free Software Foundation, Inc.
.if t Readline is Copyright \(co 1989\-2020 Free Software Foundation, Inc.
.SH DESCRIPTION
.LP
.B readline
@ -163,7 +163,6 @@ In addition to command names, readline allows keys to be bound
to a string that is inserted when the key is pressed (a \fImacro\fP).
.PP
.SS Key Bindings
.PP
The syntax for controlling key bindings in the
.I inputrc
file is simple. All that is required is the name of the
@ -318,7 +317,6 @@ similar mechanisms. The
file may be edited and re-read if a program does not provide
any other means to incorporate new bindings.
.SS Variables
.PP
Readline has variables that can be used to further customize its
behavior. A variable may be set in the
.I inputrc
@ -405,10 +403,11 @@ replaced with an ellipsis when displaying possible completions.
This determines when the user is queried about viewing
the number of possible completions
generated by the \fBpossible\-completions\fP command.
It may be set to any integer value greater than or equal to
zero. If the number of possible completions is greater than
or equal to the value of this variable, the user is asked whether
or not he wishes to view them; otherwise they are simply listed
It may be set to any integer value greater than or equal to zero.
If the number of possible completions is greater than
or equal to the value of this variable,
readline will ask whether or not the user wishes to view them;
otherwise they are simply listed
on the terminal. A negative value causes readline to never ask.
.TP
.B convert\-meta (On)
@ -448,7 +447,7 @@ Use the \e1 and \e2 escapes to begin and end sequences of
non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
.TP
.B enable\-bracketed\-paste (Off)
.B enable\-bracketed\-paste (On)
When set to \fBOn\fP, 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
@ -488,6 +487,7 @@ the maximum number of history entries will be set to 500.
When set to \fBOn\fP, makes readline use a single line for display,
scrolling the input horizontally on a single screen line when it
becomes longer than the screen width rather than wrapping to a new line.
This setting is automatically enabled for terminals of height 1.
.TP
.B input\-meta (Off)
If set to \fBOn\fP, readline will enable eight-bit input (that is,
@ -633,7 +633,6 @@ by \fIstat\fP(2) is appended to the filename when listing possible
completions.
.PD
.SS Conditional Constructs
.PP
Readline implements a facility similar in spirit to the conditional
compilation features of the C preprocessor which allows key
bindings and variable settings to be performed as the result
@ -731,7 +730,6 @@ would read \fI/etc/inputrc\fP:
.fi
.RE
.SH SEARCHING
.PP
Readline provides commands for searching through the command history
for lines containing a specified string.
There are two search modes:
@ -771,7 +769,6 @@ Non-incremental searches read the entire search string before starting
to search for matching history lines. The search string may be
typed by the user or be part of the contents of the current line.
.SH EDITING COMMANDS
.PP
The following is a list of the names of the commands and the default
key sequences to which they are bound.
Command names without an accompanying key sequence are unbound by default.
@ -781,7 +778,6 @@ position, and \fImark\fP refers to a cursor position saved by the
\fBset\-mark\fP command.
The text between the point and mark is referred to as the \fIregion\fP.
.SS Commands for Moving
.PP
.PD 0
.TP
.B beginning\-of\-line (C\-a)
@ -817,8 +813,15 @@ Readline line does not take up more than one physical line or if the length
of the current Readline line is not greater than the length of the prompt
plus the screen width.
.TP
.B clear\-display (M\-C\-l)
Clear the screen and, if possible, the terminal's scrollback buffer,
then redraw the current line,
leaving the current line at the top of the screen.
.TP
.B clear\-screen (C\-l)
Clear the screen leaving the current line at the top of the screen.
Clear the screen,
then redraw the current line,
leaving the current line at the top of the screen.
With an argument, refresh the current line without clearing the
screen.
.TP
@ -826,7 +829,6 @@ screen.
Refresh the current line.
.PD
.SS Commands for Manipulating the History
.PP
.PD 0
.TP
.B accept\-line (Newline, Return)
@ -917,9 +919,17 @@ the direction to move through the history. A negative argument switches
the direction through the history (back or forward).
The history expansion facilities are used to extract the last argument,
as if the "!$" history expansion had been specified.
.TP
.B
operate\-and\-get\-next (C\-o)
Accept the current line for return to the calling application as if a
newline had been entered,
and fetch the next line relative to the current line from the history
for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
.PD
.SS Commands for Changing Text
.PP
.PD 0
.TP
.B \fIend\-of\-file\fP (usually C\-d)
@ -994,7 +1004,6 @@ Characters bound to \fBbackward\-delete\-char\fP replace the character
before point with a space. By default, this command is unbound.
.PD
.SS Killing and Yanking
.PP
.PD 0
.TP
.B kill\-line (C\-k)
@ -1057,7 +1066,6 @@ or
.BR yank\-pop .
.PD
.SS Numeric Arguments
.PP
.PD 0
.TP
.B digit\-argument (M\-0, M\-1, ..., M\-\-)
@ -1079,7 +1087,6 @@ first time makes the argument count four, a second time makes the
argument count sixteen, and so on.
.PD
.SS Completing
.PP
.PD 0
.TP
.B complete (TAB)
@ -1136,7 +1143,6 @@ If at the end of the line, behaves identically to
\fBpossible-completions\fP.
.PD
.SS Keyboard Macros
.PP
.PD 0
.TP
.B start\-kbd\-macro (C\-x (\^)
@ -1155,7 +1161,6 @@ Print the last keyboard macro defined in a format suitable for the
\fIinputrc\fP file.
.PD
.SS Miscellaneous
.PP
.PD 0
.TP
.B re\-read\-init\-file (C\-x C\-r)
@ -1331,6 +1336,7 @@ Emacs Meta bindings
"M-C-H" backward-kill-word
"M-C-I" tab-insert
"M-C-J" vi-editing-mode
"M-C-L" clear-display
"M-C-M" vi-editing-mode
"M-C-R" revert-line
"M-C-Y" yank-nth-arg
@ -1535,5 +1541,4 @@ Comments and bug reports concerning
this manual page should be directed to
.IR chet.ramey@case.edu .
.SH BUGS
.PP
It's too big and too slow.

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--2016 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document

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--2016 Free Software Foundation, Inc.
Copyright (C) 1988--2020 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@ -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
@ -1733,8 +1756,8 @@ to determine whether or not there are any pending signals.
If an application does not wish Readline to catch @code{SIGWINCH}, it may
call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force
Readline to update its idea of the terminal size when a @code{SIGWINCH}
is received.
Readline to update its idea of the terminal size when it receives
a @code{SIGWINCH}.
@deftypefun void rl_echo_signal_char (int sig)
If an application wishes to install its own signal handlers, but still
@ -1751,11 +1774,14 @@ Update Readline's internal screen size by reading values from the kernel.
Set Readline's idea of the terminal size to @var{rows} rows and
@var{cols} columns. If either @var{rows} or @var{columns} is less than
or equal to 0, Readline's idea of that terminal dimension is unchanged.
This is intended to tell Readline the physical dimensions of the terminal,
and is used internally to calculate the maximum number of characters that
may appear on a single line and on the screen.
@end deftypefun
If an application does not want to install a @code{SIGWINCH} handler, but
is still interested in the screen dimensions, Readline's idea of the screen
size may be queried.
is still interested in the screen dimensions, it may query Readline's idea
of the screen size.
@deftypefun void rl_get_screen_size (int *rows, int *cols)
Return Readline's idea of the terminal's size in the
@ -2039,7 +2065,7 @@ remove any quote characters from the directory name, because its result will
be passed directly to @code{opendir()}.
The directory rewrite hook returns an integer that should be non-zero if
the function modfies its directory argument.
the function modifies its directory argument.
The function should not modify the directory argument if it returns 0.
@end deftypevar
@ -2051,7 +2077,7 @@ is passed to @code{stat()} to determine the file's type and characteristics.
This function does not need to remove quote characters from the filename.
The stat hook returns an integer that should be non-zero if
the function modfies its directory argument.
the function modifies its directory argument.
The function should not modify the directory argument if it returns 0.
@end deftypevar
@ -2645,7 +2671,7 @@ com_help (arg)
if (!printed)
@{
printf ("No commands match `%s'. Possibilties are:\n", arg);
printf ("No commands match `%s'. Possibilities are:\n", arg);
for (i = 0; commands[i].name; i++)
@{

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--2016 Free Software Foundation, Inc.
Copyright (C) 1988--2020 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@ -350,6 +350,11 @@ file is taken from the value of the environment variable @env{INPUTRC}. If
that variable is unset, the default is @file{~/.inputrc}. If that
file does not exist or cannot be read, the ultimate default is
@file{/etc/inputrc}.
@ifset BashFeatures
The @w{@code{bind}} builtin command can also be used to set Readline
keybindings and variables.
@xref{Bash Builtins}.
@end ifset
When a program which uses the Readline library starts up, the
init file is read, and the key bindings are set.
@ -488,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}.
@ -541,7 +546,7 @@ 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{off}.
from being interpreted as editing commands. The default is @samp{On}.
@item enable-keypad
@vindex enable-keypad
@ -583,8 +588,9 @@ the maximum number of history entries will be set to 500.
This variable can be set to either @samp{on} or @samp{off}. Setting it
to @samp{on} means that the text of the lines being edited will scroll
horizontally on a single screen line when they are longer than the width
of the screen, instead of wrapping onto a new screen line. By default,
this variable is set to @samp{off}.
of the screen, instead of wrapping onto a new screen line.
This variable is automatically set to @samp{on} for terminals of height 1.
By default, this variable is set to @samp{off}.
@item input-meta
@vindex input-meta
@ -1109,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
@ -1173,11 +1179,11 @@ Move back to the start of the current or previous word.
Words are composed of letters and digits.
@ifset BashFeatures
@item shell-forward-word ()
@item shell-forward-word (M-C-f)
Move forward to the end of the next word.
Words are delimited by non-quoted shell metacharacters.
@item shell-backward-word ()
@item shell-backward-word (M-C-b)
Move back to the start of the current or previous word.
Words are delimited by non-quoted shell metacharacters.
@end ifset
@ -1195,8 +1201,14 @@ Readline line does not take up more than one physical line or if the length
of the current Readline line is not greater than the length of the prompt
plus the screen width.
@item clear-display (M-C-l)
Clear the screen and, if possible, the terminal's scrollback buffer,
then redraw the current line,
leaving the current line at the top of the screen.
@item clear-screen (C-l)
Clear the screen and redraw the current line,
Clear the screen,
then redraw the current line,
leaving the current line at the top of the screen.
@item redraw-current-line ()
@ -1242,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'
@ -1310,6 +1324,14 @@ the direction through the history (back or forward).
The history expansion facilities are used to extract the last argument,
as if the @samp{!$} history expansion had been specified.
@item operate-and-get-next (C-o)
Accept the current line for return to the calling application as if a
newline had been entered,
and fetch the next line relative to the current line from the history
for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
@end ftable
@node Commands For Text
@ -1357,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
@ -1406,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.
@ -1427,7 +1458,7 @@ Kill the word behind point.
Word boundaries are the same as @code{backward-word}.
@ifset BashFeatures
@item shell-kill-word ()
@item shell-kill-word (M-C-d)
Kill from point to the end of the current word, or if between
words, to the end of the next word.
Word boundaries are the same as @code{shell-forward-word}.
@ -1437,6 +1468,14 @@ Kill the word behind point.
Word boundaries are the same as @code{shell-backward-word}.
@end ifset
@item shell-transpose-words (M-C-t)
Drag the word before point past the word after point,
moving point past that word as well.
If the insertion point is at the end of the line, this transposes
the last two words on the line.
Word boundaries are the same as @code{shell-forward-word} and
@code{shell-backward-word}.
@item unix-word-rubout (C-w)
Kill the word behind point, using white space as a word boundary.
The killed text is saved on the kill-ring.
@ -1774,12 +1813,6 @@ Perform history and alias expansion on the current line.
@item insert-last-argument (M-. or M-_)
A synonym for @code{yank-last-arg}.
@item operate-and-get-next (C-o)
Accept the current line for execution and fetch the next line
relative to the current line from the history for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
@item edit-and-execute-command (C-x C-e)
Invoke an editor on the current command line, and execute the result as shell
commands.
@ -2044,7 +2077,7 @@ The @option{-E} option indicates that other supplied options and actions should
apply to ``empty'' command completion; that is, completion attempted on a
blank line.
The @option{-I} option indicates that other supplied options and actions should
apply to completion on the inital non-assignment word on the line, or after a
apply to completion on the initial non-assignment word on the line, or after a
command delimiter such as @samp{;} or @samp{|}, which is usually command
name completion.
If multiple options are supplied, the @option{-D} option takes precedence
@ -2255,7 +2288,7 @@ The @option{-E} option indicates that other supplied options should
apply to ``empty'' command completion; that is, completion attempted on a
blank line.
The @option{-I} option indicates that other supplied options should
apply to completion on the inital non-assignment word on the line, or after a
apply to completion on the initial non-assignment word on the line, or after a
command delimiter such as @samp{;} or @samp{|}, which is usually command
name completion.
@ -2370,7 +2403,7 @@ character to the directory name, in case we want to append to it.
The @option{-o bashdefault} option brings in the rest of the "Bash default"
completions -- possible completion that Bash adds to the default Readline
set. These include things like command name completion, variable completion
for words beginning with @samp{@{}, completions containing pathname
for words beginning with @samp{$} or @samp{$@{}, completions containing pathname
expansion patterns (@pxref{Filename Expansion}), and so on.
Once installed using @code{complete}, @code{_comp_cd} will be called every
@ -2380,7 +2413,7 @@ Many more examples -- an extensive collection of completions for most of
the common GNU, Unix, and Linux commands -- are available as part of the
bash_completion project. This is installed by default on many GNU/Linux
distributions. Originally written by Ian Macdonald, the project now lives
at @url{http://bash-completion.alioth.debian.org/}. There are ports for
at @url{https://github.com/scop/bash-completion/}. There are ports for
other systems such as Solaris and Mac OS X.
An older version of the bash_completion package is distributed with bash

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--2016 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
@ignore
Copyright (C) 1988-2018 Free Software Foundation, Inc.
Copyright (C) 1988-2020 Free Software Foundation, Inc.
@end ignore
@set EDITION 8.0
@set VERSION 8.0
@set UPDATED 30 November 2018
@set UPDATED-MONTH November 2018
@set EDITION 8.1
@set VERSION 8.1
@set UPDATED 29 October 2020
@set UPDATED-MONTH October 2020
@set LASTCHANGE Fri Nov 30 22:50:53 EST 2018
@set LASTCHANGE Thu Oct 29 16:49:01 EDT 2020

View File

@ -47,7 +47,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
{ ISFUNC, rl_clear_screen }, /* Control-l */
{ ISFUNC, rl_newline }, /* Control-m */
{ ISFUNC, rl_get_next_history }, /* Control-n */
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-o */
{ ISFUNC, rl_operate_and_get_next }, /* Control-o */
{ ISFUNC, rl_get_previous_history }, /* Control-p */
{ ISFUNC, rl_quoted_insert }, /* Control-q */
{ ISFUNC, rl_reverse_search_history }, /* Control-r */
@ -327,7 +327,7 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
{ ISFUNC, rl_tab_insert }, /* Meta-Control-i */
{ ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-k */
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-l */
{ ISFUNC, rl_clear_display }, /* Meta-Control-l */
{ ISFUNC, rl_vi_editing_mode }, /* Meta-Control-m */
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-n */
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-o */

View File

@ -12,7 +12,8 @@ AC_CACHE_VAL(bash_cv_termcap_lib,
[AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
[AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
[AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
bash_cv_termcap_lib=gnutermcap)])])])])])
[AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
bash_cv_termcap_lib=gnutermcap)])])])])])])
if test "X$_bash_needmsg" = "Xyes"; then
AC_MSG_CHECKING(which library has the termcap functions)
fi

View File

@ -35,6 +35,7 @@ AC_CACHE_VAL(ac_cv_rl_version,
[AC_TRY_RUN([
#include <stdio.h>
#include <readline/readline.h>
#include <stdlib.h>
extern int rl_gnu_readline_p;

View File

@ -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));

View File

@ -1,6 +1,6 @@
/* funmap.c -- attach names to functions. */
/* Copyright (C) 1987-2017 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.
@ -73,6 +73,7 @@ static const FUNMAP default_funmap[] = {
{ "capitalize-word", rl_capitalize_word },
{ "character-search", rl_char_search },
{ "character-search-backward", rl_backward_char_search },
{ "clear-display", rl_clear_display },
{ "clear-screen", rl_clear_screen },
{ "complete", rl_complete },
{ "copy-backward-word", rl_copy_backward_word },
@ -116,6 +117,7 @@ static const FUNMAP default_funmap[] = {
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
{ "old-menu-complete", rl_old_menu_complete },
{ "operate-and-get-next", rl_operate_and_get_next },
{ "overwrite-mode", rl_overwrite_mode },
#if defined (_WIN32)
{ "paste-from-clipboard", rl_paste_from_clipboard },
@ -157,7 +159,7 @@ static const FUNMAP default_funmap[] = {
{ "vi-backward-bigword", rl_vi_bWord },
{ "vi-backward-word", rl_vi_bword },
{ "vi-bWord", rl_vi_bWord },
{ "vi-bword", rl_vi_bword },
{ "vi-bword", rl_vi_bword }, /* BEWARE: name matching is case insensitive */
{ "vi-change-case", rl_vi_change_case },
{ "vi-change-char", rl_vi_change_char },
{ "vi-change-to", rl_vi_change_to },
@ -171,13 +173,13 @@ static const FUNMAP default_funmap[] = {
{ "vi-end-bigword", rl_vi_eWord },
{ "vi-end-word", rl_vi_end_word },
{ "vi-eof-maybe", rl_vi_eof_maybe },
{ "vi-eword", rl_vi_eword },
{ "vi-eword", rl_vi_eword }, /* BEWARE: name matching is case insensitive */
{ "vi-fWord", rl_vi_fWord },
{ "vi-fetch-history", rl_vi_fetch_history },
{ "vi-first-print", rl_vi_first_print },
{ "vi-forward-bigword", rl_vi_fWord },
{ "vi-forward-word", rl_vi_fword },
{ "vi-fword", rl_vi_fword },
{ "vi-fword", rl_vi_fword }, /* BEWARE: name matching is case insensitive */
{ "vi-goto-mark", rl_vi_goto_mark },
{ "vi-insert-beg", rl_vi_insert_beg },
{ "vi-insertion-mode", rl_vi_insert_mode },

View File

@ -89,7 +89,7 @@ char history_expansion_char = '!';
char history_subst_char = '^';
/* During tokenization, if this character is seen as the first character
of a word, then it, and all subsequent characters upto a newline are
of a word, then it, and all subsequent characters up to a newline are
ignored. For a Bourne shell, this should be '#'. Bash special cases
the interactive comment character to not be a comment delimiter. */
char history_comment_char = '\0';
@ -180,7 +180,7 @@ get_history_event (const char *string, int *caller_index, int delimiting_quote)
}
/* Hack case of numeric line specification. */
if (string[i] == '-')
if (string[i] == '-' && _rl_digit_p (string[i+1]))
{
sign = -1;
i++;
@ -230,10 +230,12 @@ get_history_event (const char *string, int *caller_index, int delimiting_quote)
}
#endif /* HANDLE_MULTIBYTE */
if ((!substring_okay && (whitespace (c) || c == ':' ||
(history_event_delimiter_chars && member (c, history_event_delimiter_chars)) ||
(history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
string[i] == delimiting_quote)) ||
if ((!substring_okay &&
(whitespace (c) || c == ':' ||
(i > local_index && history_event_delimiter_chars && c == '-') ||
(c != '-' && history_event_delimiter_chars && member (c, history_event_delimiter_chars)) ||
(history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
string[i] == delimiting_quote)) ||
string[i] == '\n' ||
(substring_okay && string[i] == '?'))
break;
@ -409,7 +411,10 @@ hist_error(char *s, int start, int current, int errtype)
}
temp = (char *)xmalloc (ll + elen + 3);
strncpy (temp, s + start, ll);
if (s[start])
strncpy (temp, s + start, ll);
else
ll = 0;
temp[ll] = ':';
temp[ll + 1] = ' ';
strcpy (temp + ll + 2, emsg);
@ -624,7 +629,7 @@ history_expand_internal (char *string, int start, int qc, int *end_index_ptr, ch
return an error state after adding this line to the
history. */
case 'p':
print_only++;
print_only = 1;
break;
/* :t discards all but the last part of the pathname. */
@ -1356,6 +1361,11 @@ get_history_word_specifier (char *spec, char *from, int *caller_index)
i++;
last = '$';
}
else if (spec[i] == '^')
{
i++;
last = 1;
}
#if 0
else if (!spec[i] || spec[i] == ':')
/* check against `:' because there could be a modifier separator */

View File

@ -1,6 +1,6 @@
/* histfile.c - functions to manipulate the history file. */
/* Copyright (C) 1989-2018 Free Software Foundation, Inc.
/* Copyright (C) 1989-2019 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@ -26,6 +26,8 @@
#define READLINE_LIBRARY
#if defined (__TANDEM)
# define _XOPEN_SOURCE_EXTENDED 1
# include <unistd.h>
# include <floss.h>
#endif
@ -79,6 +81,11 @@
#endif /* HISTORY_USE_MMAP */
#if defined(_WIN32)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
on win 95/98/nt), we want to open files with O_BINARY mode so that there
is no \n -> \r\n conversion performed. On other systems, we don't want to
@ -138,6 +145,7 @@ static char *history_backupfile PARAMS((const char *));
static char *history_tempfile PARAMS((const char *));
static int histfile_backup PARAMS((const char *, const char *));
static int histfile_restore PARAMS((const char *, const char *));
static int history_rename PARAMS((const char *, const char *));
/* Return the string that should be used in the place of this
filename. This only matters when you don't specify the
@ -449,6 +457,18 @@ read_history_range (const char *filename, int from, int to)
return (0);
}
/* We need a special version for WIN32 because Windows rename() refuses to
overwrite an existing file. */
static int
history_rename (const char *old, const char *new)
{
#if defined (_WIN32)
return (MoveFileEx (old, new, MOVEFILE_REPLACE_EXISTING) == 0 ? -1 : 0);
#else
return (rename (old, new));
#endif
}
/* Save FILENAME to BACK, handling case where FILENAME is a symlink
(e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */
static int
@ -462,10 +482,10 @@ histfile_backup (const char *filename, const char *back)
if ((n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0)
{
linkbuf[n] = '\0';
return (rename (linkbuf, back));
return (history_rename (linkbuf, back));
}
#endif
return (rename (filename, back));
return (history_rename (filename, back));
}
/* Restore ORIG from BACKUP handling case where ORIG is a symlink
@ -481,12 +501,18 @@ histfile_restore (const char *backup, const char *orig)
if ((n = readlink (orig, linkbuf, sizeof (linkbuf) - 1)) > 0)
{
linkbuf[n] = '\0';
return (rename (backup, linkbuf));
return (history_rename (backup, linkbuf));
}
#endif
return (rename (backup, orig));
return (history_rename (backup, orig));
}
/* Should we call chown, based on whether finfo and nfinfo describe different
files with different owners? */
#define SHOULD_CHOWN(finfo, nfinfo) \
(finfo.st_uid != nfinfo.st_uid || finfo.st_gid != nfinfo.st_gid)
/* Truncate the history file FNAME, leaving only LINES trailing lines.
If FNAME is NULL, then use ~/.history. Writes a new file and renames
it to the original name. Returns 0 on success, errno on failure. */
@ -495,7 +521,7 @@ history_truncate_file (const char *fname, int lines)
{
char *buffer, *filename, *tempname, *bp, *bp1; /* bp1 == bp+1 */
int file, chars_read, rv, orig_lines, exists, r;
struct stat finfo;
struct stat finfo, nfinfo;
size_t file_size;
history_lines_written_to_file = 0;
@ -516,6 +542,9 @@ history_truncate_file (const char *fname, int lines)
}
exists = 1;
nfinfo.st_uid = finfo.st_uid;
nfinfo.st_gid = finfo.st_gid;
if (S_ISREG (finfo.st_mode) == 0)
{
close (file);
@ -604,6 +633,9 @@ history_truncate_file (const char *fname, int lines)
if (write (file, bp, chars_read - (bp - buffer)) < 0)
rv = errno;
if (fstat (file, &nfinfo) < 0 && rv == 0)
rv = errno;
if (close (file) < 0 && rv == 0)
rv = errno;
}
@ -631,7 +663,7 @@ history_truncate_file (const char *fname, int lines)
user is running this, it's a no-op. If the shell is running after sudo
with a shared history file, we don't want to leave the history file
owned by root. */
if (rv == 0 && exists)
if (rv == 0 && exists && SHOULD_CHOWN (finfo, nfinfo))
r = chown (filename, finfo.st_uid, finfo.st_gid);
#endif
@ -650,7 +682,7 @@ history_do_write (const char *filename, int nelements, int overwrite)
register int i;
char *output, *tempname, *histname;
int file, mode, rv, exists;
struct stat finfo;
struct stat finfo, nfinfo;
#ifdef HISTORY_USE_MMAP
size_t cursize;
@ -695,15 +727,11 @@ history_do_write (const char *filename, int nelements, int overwrite)
the_history = history_list ();
/* Calculate the total number of bytes to write. */
for (buffer_size = 0, i = history_length - nelements; i < history_length; i++)
#if 0
buffer_size += 2 + HISTENT_BYTES (the_history[i]);
#else
{
if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
buffer_size += strlen (the_history[i]->timestamp) + 1;
buffer_size += strlen (the_history[i]->line) + 1;
}
#endif
/* Allocate the buffer, and fill it. */
#ifdef HISTORY_USE_MMAP

View File

@ -22,6 +22,8 @@
#define READLINE_LIBRARY
#if defined (__TANDEM)
# define _XOPEN_SOURCE_EXTENDED 1
# define _TANDEM_SOURCE 1
# include <floss.h>
#endif
@ -347,8 +349,7 @@ _rl_input_available (void)
FD_ZERO (&exceptfds);
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = _keyboard_input_timeout;
USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
#else
@ -367,6 +368,24 @@ _rl_input_available (void)
return 0;
}
int
_rl_nchars_available ()
{
int chars_avail, fd, result;
chars_avail = 0;
#if defined (FIONREAD)
fd = fileno (rl_instream);
errno = 0;
result = ioctl (fd, FIONREAD, &chars_avail);
if (result == -1 && errno == EIO)
return -1;
#endif
return chars_avail;
}
int
_rl_input_queued (int t)
{
@ -493,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 ();
}
}
@ -596,6 +615,10 @@ handle_error:
else if (_rl_caught_signal == SIGINT)
#endif
RL_CHECK_SIGNALS ();
#if defined (SIGTSTP)
else if (_rl_caught_signal == SIGTSTP)
RL_CHECK_SIGNALS ();
#endif
/* non-keyboard-generated signals of interest */
#if defined (SIGWINCH)
else if (_rl_caught_signal == SIGWINCH)
@ -631,9 +654,7 @@ _rl_read_mbchar (char *mbchar, int size)
mb_len = 0;
while (mb_len < size)
{
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
c = (mb_len == 0) ? _rl_bracketed_read_key () : rl_read_key ();
if (c < 0)
break;

View File

@ -6,7 +6,7 @@
/* */
/* **************************************************************** */
/* Copyright (C) 1987-2017 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.
@ -185,11 +185,13 @@ rl_display_search (char *search_string, int flags, int where)
strcpy (message + msglen, "i-search)`");
msglen += 10;
if (search_string)
if (search_string && *search_string)
{
strcpy (message + msglen, search_string);
msglen += searchlen;
}
else
_rl_optimize_redisplay ();
strcpy (message + msglen, "': ");
@ -255,6 +257,9 @@ _rl_isearch_init (int direction)
_rl_iscxt = cxt; /* save globally */
/* experimental right now */
_rl_init_executing_keyseq ();
return cxt;
}
@ -287,16 +292,22 @@ _rl_isearch_fini (_rl_search_cxt *cxt)
else
cxt->sline_index = strlen (rl_line_buffer);
rl_mark = cxt->save_mark;
rl_deactivate_mark ();
}
rl_point = cxt->sline_index;
/* Don't worry about where to put the mark here; rl_get_previous_history
and rl_get_next_history take care of it. */
and rl_get_next_history take care of it.
If we want to highlight the search string, this is where to set the
point and mark to do it. */
_rl_fix_point (0);
rl_deactivate_mark ();
/* _rl_optimize_redisplay (); */
rl_clear_message ();
}
/* XXX - we could use _rl_bracketed_read_mbstring () here. */
int
_rl_search_getchar (_rl_search_cxt *cxt)
{
@ -342,6 +353,24 @@ _rl_isearch_dispatch (_rl_search_cxt *cxt, int c)
return -1;
}
_rl_add_executing_keyseq (c);
/* XXX - experimental code to allow users to bracketed-paste into the search
string even when ESC is one of the isearch-terminators. Not perfect yet. */
if (_rl_enable_bracketed_paste && c == ESC && strchr (cxt->search_terminators, c) && (n = _rl_nchars_available ()) > (BRACK_PASTE_SLEN-1))
{
j = _rl_read_bracketed_paste_prefix (c);
if (j == 1)
{
cxt->lastc = -7; /* bracketed paste, see below */
goto opcode_dispatch;
}
else if (_rl_pushed_input_available ()) /* eat extra char we pushed back */
c = cxt->lastc = rl_read_key ();
else
c = cxt->lastc; /* last ditch */
}
/* If we are moving into a new keymap, modify cxt->keymap and go on.
This can be a problem if c == ESC and we want to terminate the
incremental search, so we check */
@ -387,7 +416,18 @@ add_character:
/* Translate the keys we do something with to opcodes. */
if (c >= 0 && cxt->keymap[c].type == ISFUNC)
{
f = cxt->keymap[c].function;
/* If we have a multibyte character, see if it's bound to something that
affects the search. */
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && cxt->mb[1])
f = rl_function_of_keyseq (cxt->mb, cxt->keymap, (int *)NULL);
else
#endif
{
f = cxt->keymap[c].function;
if (f == rl_do_lowercase_version)
f = cxt->keymap[_rl_to_lower (c)].function;
}
if (f == rl_reverse_search_history)
cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
@ -454,9 +494,14 @@ add_character:
}
else if (cxt->lastc > 0 && cxt->prevc > 0 && f && f != rl_insert)
{
rl_stuff_char (cxt->lastc);
rl_execute_next (cxt->prevc);
/* XXX - do we insert everything in cxt->pmb? */
_rl_term_executing_keyseq (); /* should this go in the caller? */
_rl_pending_command.map = cxt->keymap;
_rl_pending_command.count = 1; /* XXX */
_rl_pending_command.key = cxt->lastc;
_rl_pending_command.func = f;
_rl_command_to_execute = &_rl_pending_command;
return (0);
}
}
@ -502,6 +547,9 @@ add_character:
return (0);
}
_rl_init_executing_keyseq ();
opcode_dispatch:
/* Now dispatch on the character. `Opcodes' affect the search string or
state. Other characters are added to the string. */
switch (cxt->lastc)
@ -519,6 +567,7 @@ add_character:
rl_display_search (cxt->search_string, cxt->sflags, -1);
break;
}
/* XXX - restore keymap here? */
return (1);
}
else if ((cxt->sflags & SF_REVERSE) && cxt->sline_index >= 0)
@ -566,9 +615,11 @@ add_character:
rl_replace_line (cxt->lines[cxt->save_line], 0);
rl_point = cxt->save_point;
rl_mark = cxt->save_mark;
rl_deactivate_mark ();
rl_restore_prompt();
rl_clear_message ();
_rl_fix_point (1); /* in case save_line and save_point are out of sync */
return -1;
case -5: /* C-W */
@ -632,6 +683,8 @@ add_character:
free (paste);
break;
}
if (_rl_enable_active_region)
rl_activate_mark ();
if (cxt->search_string_index + pastelen + 1 >= cxt->search_string_size)
{
cxt->search_string_size += pastelen + 2;
@ -736,11 +789,15 @@ add_character:
cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0;
}
/* reset the keymaps for the next time through the loop */
cxt->keymap = cxt->okeymap = _rl_keymap;
if (cxt->sflags & SF_FAILED)
{
/* We cannot find the search string. Ding the bell. */
rl_ding ();
cxt->history_pos = cxt->last_found_line;
rl_deactivate_mark ();
rl_display_search (cxt->search_string, cxt->sflags, (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
return 1;
}
@ -752,7 +809,11 @@ add_character:
{
cxt->prev_line_found = cxt->lines[cxt->history_pos];
rl_replace_line (cxt->lines[cxt->history_pos], 0);
if (_rl_enable_active_region)
rl_activate_mark ();
rl_point = cxt->sline_index;
if (rl_mark_active_p () && cxt->search_string_index > 0)
rl_mark = rl_point + cxt->search_string_index;
cxt->last_found_line = cxt->history_pos;
rl_display_search (cxt->search_string, cxt->sflags, (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
}

View File

@ -1,6 +1,6 @@
/* kill.c -- kill ring management. */
/* Copyright (C) 1994-2017 Free Software Foundation, Inc.
/* Copyright (C) 1994-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.
@ -408,6 +408,7 @@ region_kill_internal (int delete)
_rl_copy_to_kill_ring (text, rl_point < rl_mark);
}
_rl_fix_point (1);
_rl_last_command_was_kill++;
return 0;
}
@ -427,8 +428,8 @@ rl_kill_region (int count, int key)
npoint = (rl_point < rl_mark) ? rl_point : rl_mark;
r = region_kill_internal (1);
_rl_fix_point (1);
rl_point = npoint;
_rl_fix_point (1);
return r;
}
@ -605,7 +606,7 @@ rl_yank_nth_arg_internal (int count, int key, int history_skip)
#if defined (VI_MODE)
/* Vi mode always inserts a space before yanking the argument, and it
inserts it right *after* rl_point. */
if (rl_editing_mode == vi_mode)
if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
{
rl_vi_append_mode (1, key);
rl_insert_text (" ");
@ -668,8 +669,7 @@ rl_yank_last_arg (int count, int key)
/* Having read the special escape sequence denoting the beginning of a
`bracketed paste' sequence, read the rest of the pasted input until the
closing sequence and insert the pasted text as a single unit without
interpretation. */
closing sequence and return the pasted text. */
char *
_rl_bracketed_text (size_t *lenp)
{
@ -715,6 +715,10 @@ _rl_bracketed_text (size_t *lenp)
return (buf);
}
/* Having read the special escape sequence denoting the beginning of a
`bracketed paste' sequence, read the rest of the pasted input until the
closing sequence and insert the pasted text as a single unit without
interpretation. Temporarily highlight the inserted text. */
int
rl_bracketed_paste_begin (int count, int key)
{
@ -723,12 +727,108 @@ rl_bracketed_paste_begin (int count, int key)
char *buf;
buf = _rl_bracketed_text (&len);
rl_mark = rl_point;
retval = rl_insert_text (buf) == len ? 0 : 1;
if (_rl_enable_active_region)
rl_activate_mark ();
xfree (buf);
return (retval);
}
int
_rl_read_bracketed_paste_prefix (int c)
{
char pbuf[BRACK_PASTE_SLEN+1], *pbpref;
int key, ind, j;
pbpref = BRACK_PASTE_PREF; /* XXX - debugging */
if (c != pbpref[0])
return (0);
pbuf[ind = 0] = c;
while (ind < BRACK_PASTE_SLEN-1 &&
(RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
_rl_pushed_input_available () == 0 &&
_rl_input_queued (0))
{
key = rl_read_key (); /* XXX - for now */
if (key < 0)
break;
pbuf[++ind] = key;
if (pbuf[ind] != pbpref[ind])
break;
}
if (ind < BRACK_PASTE_SLEN-1) /* read incomplete sequence */
{
while (ind >= 0)
_rl_unget_char (pbuf[ind--]);
return (key < 0 ? key : 0);
}
return (key < 0 ? key : 1);
}
/* Get a character from wherever we read input, handling input in bracketed
paste mode. If we don't have or use bracketed paste mode, this can be
used in place of rl_read_key(). */
int
_rl_bracketed_read_key ()
{
int c, r;
char *pbuf;
size_t pblen;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c < 0)
return -1;
/* read pasted data with bracketed-paste mode enabled. */
if (_rl_enable_bracketed_paste && c == ESC && (r = _rl_read_bracketed_paste_prefix (c)) == 1)
{
pbuf = _rl_bracketed_text (&pblen);
if (pblen == 0)
{
xfree (pbuf);
return 0; /* XXX */
}
c = (unsigned char)pbuf[0];
if (pblen > 1)
{
while (--pblen > 0)
_rl_unget_char ((unsigned char)pbuf[pblen]);
}
xfree (pbuf);
}
return c;
}
/* Get a character from wherever we read input, handling input in bracketed
paste mode. If we don't have or use bracketed paste mode, this can be
used in place of rl_read_key(). */
int
_rl_bracketed_read_mbstring (char *mb, int mlen)
{
int c, r;
c = _rl_bracketed_read_key ();
if (c < 0)
return -1;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = _rl_read_mbstring (c, mb, mlen);
else
#endif
mb[0] = c;
mb[mlen] = '\0'; /* just in case */
return c;
}
/* A special paste command for Windows users. */
#if defined (_WIN32)
#include <windows.h>

View File

@ -1,6 +1,6 @@
/* mbutil.c -- readline multibyte character utility functions */
/* Copyright (C) 2001-2017 Free Software Foundation, Inc.
/* Copyright (C) 2001-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.
@ -86,7 +86,7 @@ int _rl_utf8locale = 0;
static int
_rl_utf8_mblen (const char *s, size_t n)
{
unsigned char c, c1;
unsigned char c, c1, c2, c3;
if (s == 0)
return (0); /* no shift states */
@ -101,25 +101,46 @@ _rl_utf8_mblen (const char *s, size_t n)
c1 = (unsigned char)s[1];
if (c < 0xe0)
{
if (n >= 2 && (s[1] ^ 0x80) < 0x40)
if (n == 1)
return -2;
if (n >= 2 && (c1 ^ 0x80) < 0x40)
return 2;
}
else if (c < 0xf0)
{
if (n >= 3
&& (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
if (n == 1)
return -2;
if ((c1 ^ 0x80) < 0x40
&& (c >= 0xe1 || c1 >= 0xa0)
&& (c != 0xed || c1 < 0xa0))
return 3;
{
if (n == 2)
return -2;
c2 = (unsigned char)s[2];
if ((c2 ^ 0x80) < 0x40)
return 3;
}
}
else if (c < 0xf8)
else if (c < 0xf4)
{
if (n >= 4
&& (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40
if (n == 1)
return -2;
if (((c1 ^ 0x80) < 0x40)
&& (c >= 0xf1 || c1 >= 0x90)
&& (c < 0xf4 || (c == 0xf4 && c1 < 0x90)))
return 4;
{
if (n == 2)
return -2;
c2 = (unsigned char)s[2];
if ((c2 ^ 0x80) < 0x40)
{
if (n == 3)
return -2;
c3 = (unsigned char)s[3];
if ((c3 ^ 0x80) < 0x40)
return 4;
}
}
}
}
/* invalid or incomplete multibyte character */
@ -206,6 +227,66 @@ _rl_find_next_mbchar_internal (char *string, int seed, int count, int find_non_z
return point;
}
static inline int
_rl_test_nonzero (char *string, int ind, int len)
{
size_t tmp;
wchar_t wc;
mbstate_t ps;
memset (&ps, 0, sizeof (mbstate_t));
tmp = mbrtowc (&wc, string + ind, len - ind, &ps);
/* treat invalid multibyte sequences as non-zero-width */
return (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp) || WCWIDTH (wc) > 0);
}
/* experimental -- needs to handle zero-width characters better */
static int
_rl_find_prev_utf8char (char *string, int seed, int find_non_zero)
{
char *s;
unsigned char b;
int save, prev;
size_t len;
if (find_non_zero)
len = RL_STRLEN (string);
prev = seed - 1;
while (prev >= 0)
{
b = (unsigned char)string[prev];
if (UTF8_SINGLEBYTE (b))
return (prev);
save = prev;
/* Move back until we're not in the middle of a multibyte char */
if (UTF8_MBCHAR (b))
{
while (prev > 0 && (b = (unsigned char)string[--prev]) && UTF8_MBCHAR (b))
;
}
if (UTF8_MBFIRSTCHAR (b))
{
if (find_non_zero)
{
if (_rl_test_nonzero (string, prev, len))
return (prev);
else /* valid but WCWIDTH (wc) == 0 */
prev = prev - 1;
}
else
return (prev);
}
else
return (save); /* invalid utf-8 multibyte sequence */
}
return ((prev < 0) ? 0 : prev);
}
/*static*/ int
_rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero)
{
@ -214,6 +295,9 @@ _rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero)
size_t tmp;
wchar_t wc;
if (_rl_utf8locale)
return (_rl_find_prev_utf8char (string, seed, find_non_zero));
memset(&ps, 0, sizeof(mbstate_t));
length = strlen(string);

View File

@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
/* Copyright (C) 1987-2019 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.
@ -138,9 +138,7 @@ _rl_arg_dispatch (_rl_arg_cxt cxt, int c)
}
else
{
RL_SETSTATE(RL_STATE_MOREINPUT);
key = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
key = _rl_bracketed_read_key ();
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
@ -435,7 +433,7 @@ rl_replace_from_history (HIST_ENTRY *entry, int flags)
intended to be called while actively editing, and the current line is
not assumed to have been added to the history list. */
void
_rl_revert_all_lines (void)
_rl_revert_previous_lines (void)
{
int hpos;
HIST_ENTRY *entry;
@ -479,6 +477,19 @@ _rl_revert_all_lines (void)
xfree (lbuf);
}
/* Revert all lines in the history by making sure we are at the end of the
history before calling _rl_revert_previous_lines() */
void
_rl_revert_all_lines (void)
{
int pos;
pos = where_history ();
using_history ();
_rl_revert_previous_lines ();
history_set_pos (pos);
}
/* Free the history list, including private readline data and take care
of pointer aliases to history data. Resets rl_undo_list if it points
to an UNDO_LIST * saved as some history entry's data member. This
@ -626,6 +637,48 @@ rl_get_previous_history (int count, int key)
return 0;
}
/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
editing command. */
/* This could stand to be global to the readline library */
static rl_hook_func_t *_rl_saved_internal_startup_hook = 0;
static int saved_history_logical_offset = -1;
#define HISTORY_FULL() (history_is_stifled () && history_length >= history_max_entries)
static int
set_saved_history ()
{
int absolute_offset, count;
if (saved_history_logical_offset >= 0)
{
absolute_offset = saved_history_logical_offset - history_base;
count = where_history () - absolute_offset;
rl_get_previous_history (count, 0);
}
saved_history_logical_offset = -1;
_rl_internal_startup_hook = _rl_saved_internal_startup_hook;
return (0);
}
int
rl_operate_and_get_next (count, c)
int count, c;
{
/* Accept the current line. */
rl_newline (1, c);
saved_history_logical_offset = rl_explicit_arg ? count : where_history () + history_base + 1;
_rl_saved_internal_startup_hook = _rl_internal_startup_hook;
_rl_internal_startup_hook = set_saved_history;
return 0;
}
/* **************************************************************** */
/* */
/* Editing Modes */

View File

@ -1,3 +1,3 @@
# Do not edit -- exists only for use by patch
4
0

View File

@ -46,7 +46,7 @@
# define D_NAMLEN(d) ((d)->d_namlen)
#endif /* !HAVE_DIRENT_H */
/* The bash code fairly consistenly uses d_fileno; make sure it's available */
/* The bash code fairly consistently uses d_fileno; make sure it's available */
#if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (HAVE_STRUCT_DIRENT_D_FILENO)
# define d_fileno d_ino
#endif

View File

@ -1,7 +1,7 @@
/* posixstat.h -- Posix stat(2) definitions for systems that
don't have them. */
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -132,9 +132,9 @@
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#else /* !S_IRWXU */
/* S_IRWXU is defined, but "group" and "other" bits might not be
(happens in certain versions of MinGW). */
#else /* !S_IRWXU */
/* S_IRWXU is defined, but "group" and "other" bits might not be
(happens in certain versions of MinGW). */
# if !defined (S_IRGRP)
# define S_IRGRP (S_IREAD >> 3) /* read, group */
# define S_IWGRP (S_IWRITE >> 3) /* write, group */

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-2017 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.
@ -73,11 +73,11 @@ extern int errno;
#include "xmalloc.h"
#ifndef RL_LIBRARY_VERSION
# define RL_LIBRARY_VERSION "5.1"
# define RL_LIBRARY_VERSION "8.0"
#endif
#ifndef RL_READLINE_VERSION
# define RL_READLINE_VERSION 0x0501
# define RL_READLINE_VERSION 0x0800
#endif
extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
@ -199,6 +199,10 @@ int rl_key_sequence_length = 0;
before readline_internal_setup () prints the first prompt. */
rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL;
/* Any readline function can set this and have it run just before the user's
rl_startup_hook. */
rl_hook_func_t *_rl_internal_startup_hook = (rl_hook_func_t *)NULL;
/* If non-zero, this is the address of a function to call just before
readline_internal_setup () returns and readline_internal starts
reading input characters. */
@ -258,6 +262,9 @@ int rl_executing_key;
char *rl_executing_keyseq = 0;
int _rl_executing_keyseq_size = 0;
struct _rl_cmd _rl_pending_command;
struct _rl_cmd *_rl_command_to_execute = (struct _rl_cmd *)NULL;
/* Timeout (specified in milliseconds) when reading characters making up an
ambiguous multiple-key sequence */
int _rl_keyseq_timeout = 500;
@ -314,7 +321,8 @@ int _rl_show_mode_in_prompt = 0;
/* Non-zero means to attempt to put the terminal in `bracketed paste mode',
where it will prefix pasted text with an escape sequence and send
another to mark the end of the paste. */
int _rl_enable_bracketed_paste = 0;
int _rl_enable_bracketed_paste = BRACKETED_PASTE_DEFAULT;
int _rl_enable_active_region = BRACKETED_PASTE_DEFAULT;
/* **************************************************************** */
/* */
@ -417,6 +425,11 @@ readline_internal_setup (void)
if (rl_startup_hook)
(*rl_startup_hook) ();
if (_rl_internal_startup_hook)
(*_rl_internal_startup_hook) ();
rl_deactivate_mark ();
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_vi_insertion_mode (1, 'i'); /* don't want to reset last */
@ -632,12 +645,34 @@ readline_internal_charloop (void)
r = _rl_dispatch ((unsigned char)c, _rl_keymap);
RL_CHECK_SIGNALS ();
if (_rl_command_to_execute)
{
(*rl_redisplay_function) ();
rl_executing_keymap = _rl_command_to_execute->map;
rl_executing_key = _rl_command_to_execute->key;
rl_dispatching = 1;
RL_SETSTATE(RL_STATE_DISPATCHING);
r = (*(_rl_command_to_execute->func)) (_rl_command_to_execute->count, _rl_command_to_execute->key);
_rl_command_to_execute = 0;
RL_UNSETSTATE(RL_STATE_DISPATCHING);
rl_dispatching = 0;
RL_CHECK_SIGNALS ();
}
/* If there was no change in _rl_last_command_was_kill, then no kill
has taken place. Note that if input is pending we are reading
a prefix command, so nothing has changed yet. */
if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
_rl_last_command_was_kill = 0;
if (_rl_keep_mark_active)
_rl_keep_mark_active = 0;
else if (rl_mark_active_p ())
rl_deactivate_mark ();
_rl_internal_char_cleanup ();
#if defined (READLINE_CALLBACKS)
@ -856,7 +891,11 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
/* If we have input pending, then the last command was a prefix
command. Don't change the state of rl_last_func. Otherwise,
remember the last command executed in this variable. */
#if defined (VI_MODE)
if (rl_pending_input == 0 && map[key].function != rl_digit_argument && map[key].function != rl_vi_arg_digit)
#else
if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
#endif
rl_last_func = map[key].function;
RL_CHECK_SIGNALS ();
@ -870,6 +909,8 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
_rl_prev_macro_key ();
else
_rl_unget_char (key);
if (rl_key_sequence_length > 0)
rl_executing_keyseq[--rl_key_sequence_length] = '\0';
return -2;
}
else if (got_subseq)
@ -882,6 +923,8 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
_rl_prev_macro_key ();
else
_rl_unget_char (key);
if (rl_key_sequence_length > 0)
rl_executing_keyseq[--rl_key_sequence_length] = '\0';
return -1;
}
else
@ -974,7 +1017,11 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
_rl_pushed_input_available () == 0 &&
_rl_dispatching_keymap[ANYOTHERKEY].function &&
_rl_input_queued (_rl_keyseq_timeout*1000) == 0)
return (_rl_subseq_result (-2, map, key, got_subseq));
{
if (rl_key_sequence_length > 0)
rl_executing_keyseq[--rl_key_sequence_length] = '\0';
return (_rl_subseq_result (-2, map, key, got_subseq));
}
newkey = _rl_subseq_getchar (key);
if (newkey < 0)
@ -1065,6 +1112,8 @@ _rl_subseq_result (int r, Keymap map, int key, int got_subseq)
_rl_prev_macro_key ();
else
_rl_unget_char (key);
if (rl_key_sequence_length > 0)
rl_executing_keyseq[--rl_key_sequence_length] = '\0';
_rl_dispatching_keymap = map;
return -2;
}
@ -1075,6 +1124,8 @@ _rl_subseq_result (int r, Keymap map, int key, int got_subseq)
_rl_prev_macro_key ();
else
_rl_unget_char (key);
if (rl_key_sequence_length > 0)
rl_executing_keyseq[--rl_key_sequence_length] = '\0';
_rl_dispatching_keymap = map;
return -1;
}
@ -1241,7 +1292,7 @@ readline_initialize_everything (void)
rl_executing_keyseq = malloc (_rl_executing_keyseq_size = 16);
if (rl_executing_keyseq)
rl_executing_keyseq[0] = '\0';
rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
}
/* If this system allows us to look at the values of the regular
@ -1356,9 +1407,12 @@ bind_bracketed_paste_prefix (void)
_rl_keymap = emacs_standard_keymap;
rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_bracketed_paste_begin);
#if defined (VI_MODE)
_rl_keymap = vi_insertion_keymap;
rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_bracketed_paste_begin);
/* XXX - is there a reason to do this in the vi command keymap? */
#endif
_rl_keymap = xkeymap;
}
@ -1446,5 +1500,35 @@ rl_restore_state (struct readline_state *sp)
rl_attempted_completion_function = sp->attemptfunc;
rl_completer_word_break_characters = sp->wordbreakchars;
rl_deactivate_mark ();
return (0);
}
/* Functions to manage the string that is the current key sequence. */
void
_rl_init_executing_keyseq (void)
{
rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
}
void
_rl_term_executing_keyseq (void)
{
rl_executing_keyseq[rl_key_sequence_length] = '\0';
}
void
_rl_end_executing_keyseq (void)
{
if (rl_key_sequence_length > 0)
rl_executing_keyseq[--rl_key_sequence_length] = '\0';
}
void
_rl_add_executing_keyseq (int key)
{
RESIZE_KEYSEQ_BUFFER ();
rl_executing_keyseq[rl_key_sequence_length++] = key;
}

View File

@ -1,6 +1,6 @@
/* Readline.h -- the names of functions callable from within readline. */
/* Copyright (C) 1987-2016 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.
@ -39,9 +39,9 @@ extern "C" {
#endif
/* Hex-encoded Readline version number. */
#define RL_READLINE_VERSION 0x0800 /* Readline 8.0 */
#define RL_READLINE_VERSION 0x0801 /* Readline 8.0 */
#define RL_VERSION_MAJOR 8
#define RL_VERSION_MINOR 0
#define RL_VERSION_MINOR 1
/* Readline data structures. */
@ -95,6 +95,7 @@ extern int rl_forward_word PARAMS((int, int));
extern int rl_backward_word PARAMS((int, int));
extern int rl_refresh_line PARAMS((int, int));
extern int rl_clear_screen PARAMS((int, int));
extern int rl_clear_display PARAMS((int, int));
extern int rl_skip_csi_sequence PARAMS((int, int));
extern int rl_arrow_keys PARAMS((int, int));
@ -132,6 +133,7 @@ extern int rl_beginning_of_history PARAMS((int, int));
extern int rl_end_of_history PARAMS((int, int));
extern int rl_get_next_history PARAMS((int, int));
extern int rl_get_previous_history PARAMS((int, int));
extern int rl_operate_and_get_next PARAMS((int, int));
/* Bindable commands for managing the mark and region. */
extern int rl_set_mark PARAMS((int, int));
@ -392,6 +394,14 @@ extern int rl_clear_message PARAMS((void));
extern int rl_reset_line_state PARAMS((void));
extern int rl_crlf PARAMS((void));
/* Functions to manage the mark and region, especially the notion of an
active mark and an active region. */
extern void rl_keep_mark_active PARAMS((void));
extern void rl_activate_mark PARAMS((void));
extern void rl_deactivate_mark PARAMS((void));
extern int rl_mark_active_p PARAMS((void));
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
#else

View File

@ -9,4 +9,4 @@ URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html
Version: @LIBVERSION@
Requires.private: @TERMCAP_PKG_CONFIG_LIB@
Libs: -L${libdir} -lreadline
Cflags: -I${includedir}/readline
Cflags: -I${includedir}

View File

@ -28,7 +28,7 @@
/* check multibyte capability for I18N code */
/************************************************/
/* For platforms which support the ISO C amendement 1 functionality we
/* For platforms which support the ISO C amendment 1 functionality we
support user defined character classes. */
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) && defined (HAVE_LOCALE_H)

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-2015 Free Software Foundation, Inc.
/* Copyright (C) 1999-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.
@ -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
{
@ -109,6 +110,15 @@ typedef struct __rl_search_context
char *search_terminators;
} _rl_search_cxt;
struct _rl_cmd {
Keymap map;
int count;
int key;
rl_command_func_t *func;
};
extern struct _rl_cmd _rl_pending_command;
extern struct _rl_cmd *_rl_command_to_execute;
/* Callback data for reading numeric arguments */
#define NUM_SAWMINUS 0x01
#define NUM_SAWDIGITS 0x02
@ -267,23 +277,25 @@ extern void _rl_free_match_list PARAMS((char **));
/* display.c */
extern char *_rl_strip_prompt PARAMS((char *));
extern void _rl_reset_prompt PARAMS((void));
extern void _rl_move_cursor_relative PARAMS((int, const char *));
extern void _rl_move_vert PARAMS((int));
extern void _rl_save_prompt PARAMS((void));
extern void _rl_restore_prompt PARAMS((void));
extern char *_rl_make_prompt_for_search PARAMS((int));
extern void _rl_erase_at_end_of_line PARAMS((int));
extern void _rl_clear_to_eol PARAMS((int));
extern void _rl_clear_screen PARAMS((void));
extern void _rl_clear_screen PARAMS((int));
extern void _rl_update_final PARAMS((void));
extern void _rl_optimize_redisplay PARAMS((void));
extern void _rl_redisplay_after_sigwinch PARAMS((void));
extern void _rl_clean_up_for_exit PARAMS((void));
extern void _rl_erase_entire_line PARAMS((void));
extern int _rl_current_display_line PARAMS((void));
extern void _rl_refresh_line PARAMS((void));
/* input.c */
extern int _rl_any_typein PARAMS((void));
extern int _rl_input_available PARAMS((void));
extern int _rl_nchars_available PARAMS((void));
extern int _rl_input_queued PARAMS((int));
extern void _rl_insert_typein PARAMS((int));
extern int _rl_unget_char PARAMS((int));
@ -300,6 +312,10 @@ extern int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
extern int _rl_search_getchar PARAMS((_rl_search_cxt *));
/* kill.c */
#ifndef BRACKETED_PASTE_DEFAULT
# define BRACKETED_PASTE_DEFAULT 1 /* XXX - for now */
#endif
#define BRACK_PASTE_PREF "\033[200~"
#define BRACK_PASTE_SUFF "\033[201~"
@ -309,7 +325,10 @@ extern int _rl_search_getchar PARAMS((_rl_search_cxt *));
#define BRACK_PASTE_INIT "\033[?2004h"
#define BRACK_PASTE_FINI "\033[?2004l\r"
extern int _rl_read_bracketed_paste_prefix PARAMS((int));
extern char *_rl_bracketed_text PARAMS((size_t *));
extern int _rl_bracketed_read_key PARAMS((void));
extern int _rl_bracketed_read_mbstring PARAMS((char *, int));
/* macro.c */
extern void _rl_with_macro_input PARAMS((char *));
@ -332,6 +351,7 @@ extern void _rl_start_using_history PARAMS((void));
extern int _rl_free_saved_history_line PARAMS((void));
extern void _rl_set_insert_mode PARAMS((int, int));
extern void _rl_revert_previous_lines PARAMS((void));
extern void _rl_revert_all_lines PARAMS((void));
/* nls.c */
@ -348,6 +368,11 @@ extern int _rl_dispatch PARAMS((int, Keymap));
extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
extern void _rl_internal_char_cleanup PARAMS((void));
extern void _rl_init_executing_keyseq PARAMS((void));
extern void _rl_term_executing_keyseq PARAMS((void));
extern void _rl_end_executing_keyseq PARAMS((void));
extern void _rl_add_executing_keyseq PARAMS((int));
/* rltty.c */
extern int _rl_disable_tty_signals PARAMS((void));
extern int _rl_restore_tty_signals PARAMS((void));
@ -373,15 +398,19 @@ extern void _rl_output_character_function PARAMS((int));
#else
extern int _rl_output_character_function PARAMS((int));
#endif
extern void _rl_cr PARAMS((void));
extern void _rl_output_some_chars PARAMS((const char *, int));
extern int _rl_backspace PARAMS((int));
extern void _rl_enable_meta_key PARAMS((void));
extern void _rl_disable_meta_key PARAMS((void));
extern void _rl_control_keypad PARAMS((int));
extern void _rl_set_cursor PARAMS((int, int));
extern void _rl_standout_on PARAMS((void));
extern void _rl_standout_off PARAMS((void));
/* text.c */
extern void _rl_fix_point PARAMS((int));
extern void _rl_fix_mark PARAMS((void));
extern int _rl_replace_text PARAMS((const char *, int, int));
extern int _rl_forward_char_internal PARAMS((int));
extern int _rl_backward_char_internal PARAMS((int));
@ -507,6 +536,7 @@ extern int _rl_revert_all_at_newline;
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_comment_begin;
extern unsigned char _rl_parsing_conditionalized_out;
extern Keymap _rl_keymap;
@ -521,11 +551,12 @@ extern int _rl_keyseq_timeout;
extern int _rl_executing_keyseq_size;
extern rl_hook_func_t *_rl_internal_startup_hook;
/* search.c */
extern _rl_search_cxt *_rl_nscxt;
/* signals.c */
extern int _rl_interrupt_immediately;
extern int volatile _rl_caught_signal;
extern _rl_sigcleanup_func_t *_rl_sigcleanup;
@ -560,6 +591,7 @@ extern int _rl_term_autowrap;
/* text.c */
extern int _rl_optimize_typeahead;
extern int _rl_keep_mark_active;
/* undo.c */
extern int _rl_doing_an_undo;

View File

@ -1,6 +1,6 @@
/* search.c - code for non-incremental searching in emacs and vi modes. */
/* Copyright (C) 1992-2017 Free Software Foundation, Inc.
/* Copyright (C) 1992-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.
@ -159,7 +159,7 @@ noninc_search_from_pos (char *string, int pos, int dir, int flags, int *ncp)
static int
noninc_dosearch (char *string, int dir, int flags)
{
int oldpos, pos;
int oldpos, pos, ind;
HIST_ENTRY *entry;
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
@ -168,7 +168,7 @@ noninc_dosearch (char *string, int dir, int flags)
return 0;
}
pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir, flags, (int *)0);
pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir, flags, &ind);
if (pos == -1)
{
/* Search failed, current history position unchanged. */
@ -192,8 +192,19 @@ noninc_dosearch (char *string, int dir, int flags)
make_history_line_current (entry);
rl_point = 0;
rl_mark = rl_end;
if (_rl_enable_active_region && ((flags & SF_PATTERN) == 0) && ind > 0 && ind < rl_end)
{
rl_point = ind;
rl_mark = ind + strlen (string);
if (rl_mark > rl_end)
rl_mark = rl_end; /* can't happen? */
rl_activate_mark ();
}
else
{
rl_point = 0;
rl_mark = rl_end;
}
rl_clear_message ();
return 1;
@ -256,6 +267,7 @@ _rl_nsearch_abort (_rl_search_cxt *cxt)
rl_clear_message ();
rl_point = cxt->save_point;
rl_mark = cxt->save_mark;
_rl_fix_point (1);
rl_restore_prompt ();
RL_UNSETSTATE (RL_STATE_NSEARCH);
@ -267,6 +279,8 @@ _rl_nsearch_abort (_rl_search_cxt *cxt)
static int
_rl_nsearch_dispatch (_rl_search_cxt *cxt, int c)
{
int n;
if (c < 0)
c = CTRL ('C');
@ -300,6 +314,28 @@ _rl_nsearch_dispatch (_rl_search_cxt *cxt, int c)
_rl_nsearch_abort (cxt);
return -1;
case ESC:
/* XXX - experimental code to allow users to bracketed-paste into the
search string. Similar code is in isearch.c:_rl_isearch_dispatch().
The difference here is that the bracketed paste sometimes doesn't
paste everything, so checking for the prefix and the suffix in the
input queue doesn't work well. We just have to check to see if the
number of chars in the input queue is enough for the bracketed paste
prefix and hope for the best. */
if (_rl_enable_bracketed_paste && ((n = _rl_nchars_available ()) >= (BRACK_PASTE_SLEN-1)))
{
if (_rl_read_bracketed_paste_prefix (c) == 1)
rl_bracketed_paste_begin (1, c);
else
{
c = rl_read_key (); /* get the ESC that got pushed back */
_rl_insert_char (1, c);
}
}
else
_rl_insert_char (1, c);
break;
default:
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
@ -311,6 +347,7 @@ _rl_nsearch_dispatch (_rl_search_cxt *cxt, int c)
}
(*rl_redisplay_function) ();
rl_deactivate_mark ();
return 1;
}

View File

@ -64,7 +64,7 @@ localedir = @localedir@
DESTDIR =
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"' @BRACKETED_PASTE@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@ @CFLAGS@

View File

@ -99,7 +99,6 @@ int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
#endif
/* Private variables. */
int _rl_interrupt_immediately = 0;
int volatile _rl_caught_signal = 0; /* should be sig_atomic_t, but that requires including <signal.h> everywhere */
/* If non-zero, print characters corresponding to received signals as long as
@ -136,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)
{
@ -145,6 +144,8 @@ _rl_signal_handler (int sig)
#if defined (SIGWINCH)
if (sig == SIGWINCH)
{
RL_SETSTATE(RL_STATE_SIGHANDLER);
rl_resize_terminal ();
/* XXX - experimental for now */
/* Call a signal hook because though we called the original signal handler
@ -152,6 +153,8 @@ _rl_signal_handler (int sig)
ourselves. */
if (rl_signal_event_hook)
(*rl_signal_event_hook) ();
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
}
else
#endif
@ -163,22 +166,20 @@ _rl_signal_handler (int sig)
static RETSIGTYPE
rl_signal_handler (int sig)
{
if (_rl_interrupt_immediately)
{
_rl_interrupt_immediately = 0;
_rl_handle_signal (sig);
}
else
_rl_caught_signal = sig;
_rl_caught_signal = 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;
@ -208,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:
@ -223,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 aready 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);
@ -263,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);
@ -274,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 */
@ -282,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 ();
}

View File

@ -1,8 +1,8 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2019 Free Software Foundation, Inc.
# Copyright 1992-2020 Free Software Foundation, Inc.
timestamp='2019-08-04'
timestamp='2020-11-07'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -32,7 +32,7 @@ timestamp='2019-08-04'
# Please send patches to <config-patches@gnu.org>.
me=`echo "$0" | sed -e 's,.*/,,'`
me=$(echo "$0" | sed -e 's,.*/,,')
usage="\
Usage: $0 [OPTION]
@ -50,7 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright 1992-2019 Free Software Foundation, Inc.
Copyright 1992-2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -99,9 +99,11 @@ tmp=
trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
set_cc_for_build() {
# prevent multiple calls if $tmp is already set
test "$tmp" && return 0
: "${TMPDIR=/tmp}"
# shellcheck disable=SC2039
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ tmp=$( (umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null) && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
@ -129,10 +131,10 @@ if test -f /.attbin/uname ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
UNAME_MACHINE=$( (uname -m) 2>/dev/null) || UNAME_MACHINE=unknown
UNAME_RELEASE=$( (uname -r) 2>/dev/null) || UNAME_RELEASE=unknown
UNAME_SYSTEM=$( (uname -s) 2>/dev/null) || UNAME_SYSTEM=unknown
UNAME_VERSION=$( (uname -v) 2>/dev/null) || UNAME_VERSION=unknown
case "$UNAME_SYSTEM" in
Linux|GNU|GNU/*)
@ -148,17 +150,15 @@ Linux|GNU|GNU/*)
#elif defined(__dietlibc__)
LIBC=dietlibc
#else
#include <stdarg.h>
#ifdef __DEFINED_va_list
LIBC=musl
#else
LIBC=gnu
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
# If ldd exists, use it to detect musl libc.
if command -v ldd >/dev/null && \
ldd --version 2>&1 | grep -q ^musl
then
LIBC=musl
fi
eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g')"
;;
esac
@ -177,19 +177,20 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \
"/sbin/$sysctl" 2>/dev/null || \
"/usr/sbin/$sysctl" 2>/dev/null || \
echo unknown)`
echo unknown))
case "$UNAME_MACHINE_ARCH" in
aarch64eb) machine=aarch64_be-unknown ;;
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
earmv*)
arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
arch=$(echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,')
endian=$(echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p')
machine="${arch}${endian}"-unknown
;;
*) machine="$UNAME_MACHINE_ARCH"-unknown ;;
@ -220,7 +221,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
case "$UNAME_MACHINE_ARCH" in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
abi=$(echo "$UNAME_MACHINE_ARCH" | sed -e "$expr")
;;
esac
# The OS release
@ -233,7 +234,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
release='-gnu'
;;
*)
release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
release=$(echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2)
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
@ -242,19 +243,15 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
echo "$machine-${os}${release}${abi-}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
UNAME_MACHINE_ARCH=$(arch | sed 's/Bitrig.//')
echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
UNAME_MACHINE_ARCH=$(arch | sed 's/OpenBSD.//')
echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
exit ;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
UNAME_MACHINE_ARCH=$(arch | sed 's/^.*BSD\.//')
echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
exit ;;
*:MidnightBSD:*:*)
@ -266,6 +263,9 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
*:SolidBSD:*:*)
echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
exit ;;
*:OS108:*:*)
echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE"
exit ;;
macppc:MirBSD:*:*)
echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
exit ;;
@ -275,26 +275,29 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
*:Sortix:*:*)
echo "$UNAME_MACHINE"-unknown-sortix
exit ;;
*:Twizzler:*:*)
echo "$UNAME_MACHINE"-unknown-twizzler
exit ;;
*:Redox:*:*)
echo "$UNAME_MACHINE"-unknown-redox
exit ;;
mips:OSF1:*.*)
echo mips-dec-osf1
exit ;;
echo mips-dec-osf1
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $3}')
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $4}')
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
ALPHA_CPU_TYPE=$(/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1)
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE=alpha ;;
@ -332,7 +335,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
echo "$UNAME_MACHINE"-dec-osf"$(echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)"
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
exitcode=$?
trap '' 0
@ -366,7 +369,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
exit ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
if test "$( (/bin/universe) 2>/dev/null)" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
@ -379,20 +382,17 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
echo sparc-icl-nx6
exit ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
case $(/usr/bin/uname -p) in
sparc) echo sparc-icl-nx7; exit ;;
esac ;;
s390x:SunOS:*:*)
echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
echo "$UNAME_MACHINE"-ibm-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')"
exit ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
echo sparc-hal-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux"$UNAME_RELEASE"
echo sparc-sun-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')"
exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux"$UNAME_RELEASE"
@ -403,7 +403,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
@ -411,30 +411,30 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
SUN_ARCH=x86_64
fi
fi
echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
echo "$SUN_ARCH"-pc-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
echo sparc-sun-solaris3"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
case "$(/usr/bin/arch -k)" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
UNAME_RELEASE=$(uname -v)
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
echo sparc-sun-sunos"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/')"
exit ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos"$UNAME_RELEASE"
exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
UNAME_RELEASE=$( (sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null)
test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
case "`/bin/arch`" in
case "$(/bin/arch)" in
sun3)
echo m68k-sun-sunos"$UNAME_RELEASE"
;;
@ -514,8 +514,8 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
}
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
dummyarg=$(echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p') &&
SYSTEM_NAME=$("$dummy" "$dummyarg") &&
{ echo "$SYSTEM_NAME"; exit; }
echo mips-mips-riscos"$UNAME_RELEASE"
exit ;;
@ -542,11 +542,11 @@ EOF
exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
UNAME_PROCESSOR=$(/usr/bin/uname -p)
if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
then
if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
[ "$TARGET_BINARY_INTERFACE"x = x ]
if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
test "$TARGET_BINARY_INTERFACE"x = x
then
echo m88k-dg-dgux"$UNAME_RELEASE"
else
@ -570,17 +570,17 @@ EOF
echo m68k-tektronix-bsd
exit ;;
*:IRIX*:*:*)
echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
echo mips-sgi-irix"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/g')"
exit ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
exit ;; # Note that: echo "'$(uname -s)'" gives 'AIX '
i*86:AIX:*:*)
echo i386-ibm-aix
exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
if test -x /usr/bin/oslevel ; then
IBM_REV=$(/usr/bin/oslevel)
else
IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
fi
@ -600,7 +600,7 @@ EOF
exit(0);
}
EOF
if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy")
then
echo "$SYSTEM_NAME"
else
@ -613,15 +613,15 @@ EOF
fi
exit ;;
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
IBM_CPU_ID=$(/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }')
if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/lslpp ] ; then
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
if test -x /usr/bin/lslpp ; then
IBM_REV=$(/usr/bin/lslpp -Lqc bos.rte.libc |
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/)
else
IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
fi
@ -649,14 +649,14 @@ EOF
echo m68k-hp-bsd4.4
exit ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//')
case "$UNAME_MACHINE" in
9000/31?) HP_ARCH=m68000 ;;
9000/[34]??) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
if test -x /usr/bin/getconf; then
sc_cpu_version=$(/usr/bin/getconf SC_CPU_VERSION 2>/dev/null)
sc_kernel_bits=$(/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null)
case "$sc_cpu_version" in
523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
@ -668,7 +668,7 @@ EOF
esac ;;
esac
fi
if [ "$HP_ARCH" = "" ]; then
if test "$HP_ARCH" = ""; then
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
@ -703,11 +703,11 @@ EOF
exit (0);
}
EOF
(CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
(CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=$("$dummy")
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ "$HP_ARCH" = hppa2.0w ]
if test "$HP_ARCH" = hppa2.0w
then
set_cc_for_build
@ -731,7 +731,7 @@ EOF
echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
exit ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//')
echo ia64-hp-hpux"$HPUX_REV"
exit ;;
3050*:HI-UX:*:*)
@ -761,7 +761,7 @@ EOF
exit (0);
}
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") &&
{ echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
exit ;;
@ -781,7 +781,7 @@ EOF
echo hppa1.0-hp-osf
exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
if test -x /usr/sbin/sysversion ; then
echo "$UNAME_MACHINE"-unknown-osf1mk
else
echo "$UNAME_MACHINE"-unknown-osf1
@ -830,14 +830,14 @@ EOF
echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
FUJITSU_PROC=$(uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)
FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///')
FUJITSU_REL=$(echo "$UNAME_RELEASE" | sed -e 's/ /_/')
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///')
FUJITSU_REL=$(echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/')
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
@ -850,25 +850,25 @@ EOF
echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
exit ;;
arm:FreeBSD:*:*)
UNAME_PROCESSOR=`uname -p`
UNAME_PROCESSOR=$(uname -p)
set_cc_for_build
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi
echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabi
else
echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf
echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabihf
fi
exit ;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`/usr/bin/uname -p`
UNAME_PROCESSOR=$(/usr/bin/uname -p)
case "$UNAME_PROCESSOR" in
amd64)
UNAME_PROCESSOR=x86_64 ;;
i386)
UNAME_PROCESSOR=i586 ;;
esac
echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
echo "$UNAME_PROCESSOR"-unknown-freebsd"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')"
exit ;;
i*:CYGWIN*:*)
echo "$UNAME_MACHINE"-pc-cygwin
@ -876,9 +876,6 @@ EOF
*:MINGW64*:*)
echo "$UNAME_MACHINE"-pc-mingw64
exit ;;
*:MINGW64*:*)
echo "$UNAME_MACHINE"-pc-mingw64
exit ;;
*:MINGW*:*)
echo "$UNAME_MACHINE"-pc-mingw32
exit ;;
@ -907,15 +904,15 @@ EOF
echo x86_64-pc-cygwin
exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
echo powerpcle-unknown-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')"
exit ;;
*:GNU:*:*)
# the GNU system
echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
echo "$(echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,')-unknown-$LIBC$(echo "$UNAME_RELEASE"|sed -e 's,/.*$,,')"
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
echo "$UNAME_MACHINE-unknown-$(echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]")$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')-$LIBC"
exit ;;
*:Minix:*:*)
echo "$UNAME_MACHINE"-unknown-minix
@ -928,31 +925,7 @@ EOF
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
aarch64:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
case $(sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null) in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
@ -1061,7 +1034,7 @@ EOF
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`"
eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI')"
test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
;;
mips64el:Linux:*:*)
@ -1081,7 +1054,7 @@ EOF
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
case $(grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2) in
PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
*) echo hppa-unknown-linux-"$LIBC" ;;
@ -1121,7 +1094,17 @@ EOF
echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
exit ;;
x86_64:Linux:*:*)
echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
set_cc_for_build
LIBCABI=$LIBC
if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_X32 >/dev/null
then
LIBCABI="$LIBC"x32
fi
fi
echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI"
exit ;;
xtensa*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
@ -1161,7 +1144,7 @@ EOF
echo "$UNAME_MACHINE"-pc-msdosdjgpp
exit ;;
i*86:*:4.*:*)
UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
UNAME_REL=$(echo "$UNAME_RELEASE" | sed 's/\/MP$//')
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
else
@ -1170,7 +1153,7 @@ EOF
exit ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
case $(/bin/uname -X | grep "^Machine") in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
@ -1179,10 +1162,10 @@ EOF
exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
UNAME_REL=$(sed -n 's/.*Version //p' </usr/options/cb.name)
echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
UNAME_REL=$( (/bin/uname -X|grep Release|sed -e 's/.*= //'))
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
@ -1232,7 +1215,7 @@ EOF
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
&& OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
@ -1243,7 +1226,7 @@ EOF
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
&& OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
@ -1276,7 +1259,7 @@ EOF
exit ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
UNAME_MACHINE=$( (uname -p) 2>/dev/null)
echo "$UNAME_MACHINE"-sni-sysv4
else
echo ns32k-sni-sysv
@ -1310,7 +1293,7 @@ EOF
echo mips-sony-newsos6
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
if test -d /usr/nec; then
echo mips-nec-sysv"$UNAME_RELEASE"
else
echo mips-unknown-sysv"$UNAME_RELEASE"
@ -1358,44 +1341,48 @@ EOF
*:Rhapsody:*:*)
echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
exit ;;
arm64:Darwin:*:*)
echo aarch64-apple-darwin"$UNAME_RELEASE"
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
set_cc_for_build
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
UNAME_PROCESSOR=$(uname -p)
case $UNAME_PROCESSOR in
unknown) UNAME_PROCESSOR=powerpc ;;
esac
if command -v xcode-select > /dev/null 2> /dev/null && \
! xcode-select --print-path > /dev/null 2> /dev/null ; then
# Avoid executing cc if there is no toolchain installed as
# cc will be a stub that puts up a graphical alert
# prompting the user to install developer tools.
CC_FOR_BUILD=no_compiler_found
else
set_cc_for_build
fi
if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_PPC >/dev/null
then
UNAME_PROCESSOR=powerpc
fi
if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_PPC >/dev/null
then
UNAME_PROCESSOR=powerpc
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
# Avoid executing cc on OS X 10.9, as it ships with a stub
# that puts up a graphical alert prompting to install
# developer tools. Any system running Mac OS X 10.7 or
# later (Darwin 11 and later) is required to have a 64-bit
# processor. This is not true of the ARM version of Darwin
# that Apple uses in portable devices.
UNAME_PROCESSOR=x86_64
# uname -m returns i386 or x86_64
UNAME_PROCESSOR=$UNAME_MACHINE
fi
echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
UNAME_PROCESSOR=$(uname -p)
if test "$UNAME_PROCESSOR" = x86; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
@ -1463,10 +1450,10 @@ EOF
echo mips-sei-seiux"$UNAME_RELEASE"
exit ;;
*:DragonFly:*:*)
echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
echo "$UNAME_MACHINE"-unknown-dragonfly"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')"
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
UNAME_MACHINE=$( (uname -p) 2>/dev/null)
case "$UNAME_MACHINE" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
@ -1476,7 +1463,7 @@ EOF
echo i386-pc-xenix
exit ;;
i*86:skyos:*:*)
echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
echo "$UNAME_MACHINE"-pc-skyos"$(echo "$UNAME_RELEASE" | sed -e 's/ .*$//')"
exit ;;
i*86:rdos:*:*)
echo "$UNAME_MACHINE"-pc-rdos
@ -1493,15 +1480,6 @@ EOF
*:Unleashed:*:*)
echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE"
exit ;;
i*86:AROS:*:*)
echo "$UNAME_MACHINE"-pc-aros
exit ;;
x86_64:VMkernel:*:*)
echo "$UNAME_MACHINE"-unknown-esx
exit ;;
amd64:Isilon\ OneFS:*:*)
echo x86_64-unknown-onefs
exit ;;
esac
# No uname command or uname output not recognized.
@ -1543,7 +1521,7 @@ main ()
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
version=$( (hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null);
if (version < 4)
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
else
@ -1627,16 +1605,15 @@ main ()
#endif
#endif
case "$UNAME_MACHINE:$UNAME_SYSTEM" in
mips:Linux | mips64:Linux)
# If we got here on MIPS GNU/Linux, output extra information.
cat >&2 <<EOF
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
the system type. Please install a C compiler and try again.
exit (1);
}
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` &&
$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=$($dummy) &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
@ -1664,6 +1641,12 @@ copies of config.guess and config.sub with the latest versions from:
https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
and
https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
EOF
year=$(echo $timestamp | sed 's,-.*,,')
# shellcheck disable=SC2003
if test "$(expr "$(date +%Y)" - "$year")" -lt 3 ; then
cat >&2 <<EOF
If $0 has already been updated, send the following data and any
information you think might be pertinent to config-patches@gnu.org to
@ -1671,26 +1654,27 @@ provide the necessary information to handle your system.
config.guess timestamp = $timestamp
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
uname -m = $( (uname -m) 2>/dev/null || echo unknown)
uname -r = $( (uname -r) 2>/dev/null || echo unknown)
uname -s = $( (uname -s) 2>/dev/null || echo unknown)
uname -v = $( (uname -v) 2>/dev/null || echo unknown)
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
/usr/bin/uname -p = $( (/usr/bin/uname -p) 2>/dev/null)
/bin/uname -X = $( (/bin/uname -X) 2>/dev/null)
hostinfo = `(hostinfo) 2>/dev/null`
/bin/universe = `(/bin/universe) 2>/dev/null`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
/bin/arch = `(/bin/arch) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
hostinfo = $( (hostinfo) 2>/dev/null)
/bin/universe = $( (/bin/universe) 2>/dev/null)
/usr/bin/arch -k = $( (/usr/bin/arch -k) 2>/dev/null)
/bin/arch = $( (/bin/arch) 2>/dev/null)
/usr/bin/oslevel = $( (/usr/bin/oslevel) 2>/dev/null)
/usr/convex/getsysinfo = $( (/usr/convex/getsysinfo) 2>/dev/null)
UNAME_MACHINE = "$UNAME_MACHINE"
UNAME_RELEASE = "$UNAME_RELEASE"
UNAME_SYSTEM = "$UNAME_SYSTEM"
UNAME_VERSION = "$UNAME_VERSION"
EOF
fi
exit 1

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@ LDCONFIG=ldconfig
PROGNAME=`basename $0`
USAGE="$PROGNAME [-D] -O host_os [-V host_vendor] -d installation-dir [-b bin-dir] -i install-prog [-U] library"
# process options
# process options - should use getopts
while [ $# -gt 0 ]; do
case "$1" in
@ -118,7 +118,7 @@ INSTALL_LINK2='${echo} cd $INSTALLDIR && ${echo} ${LN} $LIBNAME $LINK2'
# Create symlinks to the installed library. This section is incomplete.
#
case "$host_os-$host_vendor" in
*linux*|freebsd*-gentoo)
*linux*|freebsd*|dragonfly*)
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
@ -154,38 +154,6 @@ solaris2*|aix4.[2-9]*|aix[5-9]*|osf*|irix[56]*|sysv[45]*|dgux*|interix*)
fi
;;
# FreeBSD 3.x and above can have either a.out or ELF shared libraries
freebsd3*|freebsdaout*)
if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
eval $INSTALL_LINK1
fi
else
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
eval $INSTALL_LINK2
fi
# libname.so -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
eval $INSTALL_LINK1
fi
fi
;;
freebsd[4-9]*|freebsd1[0-9]*|freebsdelf*|dragonfly*)
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
eval $INSTALL_LINK1
fi
;;
hpux1*)
# libname.sl -> libname.M
${echo} ${RM} ${INSTALLDIR}/$LINK1.sl

View File

@ -10,7 +10,7 @@
# Chet Ramey
# chet@po.cwru.edu
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Copyright (C) 1996-2019 Free Software Foundation, Inc.
#
# This file is part of GNU Bash, the Bourne Again SHell.
#
@ -65,7 +65,7 @@ while [ $# -gt 0 ]; do
done
case "${host_os}-${SHOBJ_CC}-${host_vendor}" in
nsk-cc-tandem)
nsk-cc-tandem|nsk-c99-tandem)
SHOBJ_CFLAGS=-Wglobalized
case `uname -m` in
NSR*)
@ -123,7 +123,7 @@ sunos5*|solaris2*)
;;
# All versions of Linux (including Gentoo/FreeBSD) or the semi-mythical GNU Hurd.
linux*-*|gnu*-*|k*bsd*-gnu-*|freebsd*-gentoo)
linux*-*|gnu*-*|k*bsd*-gnu-*|freebsd*|dragonfly*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
@ -132,44 +132,6 @@ linux*-*|gnu*-*|k*bsd*-gnu-*|freebsd*-gentoo)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
freebsd2*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-x -Bshareable'
SHLIB_XLDFLAGS='-R$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
# FreeBSD-3.x ELF
freebsd3*|freebsdaout*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
else
SHOBJ_LDFLAGS='-shared'
SHLIB_XLDFLAGS='-R$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
fi
;;
# FreeBSD-4.x and later have only ELF
freebsd[4-9]*|freebsd1[0-9]*|freebsdelf*|dragonfly*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
# Darwin/MacOS X
darwin*)
# Common definitions for all darwin/mac os x versions
@ -402,18 +364,15 @@ hpux11*)
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code (I have not tested it)
# SHOBJ_STATUS=supported
# SHLIB_STATUS=supported
#
# this code from michael.osipov@siemens.com (I have not tested it)
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b +s +h $@'
# SHOBJ_LD='$(CC)'
# SHOBJ_LDFLAGS='-b -Wl,+s -Wl,+h,$@'
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
# SHLIB_LIBSUFF='so'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
# SHLIB_LIBS='$(TERMCAP_LIB)'
;;
sysv4*-*gcc*)

View File

@ -152,6 +152,10 @@ static int term_has_meta;
static char *_rl_term_mm;
static char *_rl_term_mo;
/* The sequences to enter and exit standout mode. */
static char *_rl_term_so;
static char *_rl_term_se;
/* The key sequences output by the arrow keys, if this terminal has any. */
static char *_rl_term_ku;
static char *_rl_term_kd;
@ -177,6 +181,19 @@ static char *_rl_term_kI;
static char *_rl_term_vs; /* very visible */
static char *_rl_term_ve; /* normal */
/* It's not clear how HPUX is so broken here. */
#ifdef TGETENT_BROKEN
# define TGETENT_SUCCESS 0
#else
# define TGETENT_SUCCESS 1
#endif
#ifdef TGETFLAG_BROKEN
# define TGETFLAG_SUCCESS 0
#else
# define TGETFLAG_SUCCESS 1
#endif
#define TGETFLAG(cap) (tgetflag (cap) == TGETFLAG_SUCCESS)
static void bind_termcap_arrow_keys PARAMS((Keymap));
/* Variables that hold the screen dimensions, used by the display code. */
@ -410,6 +427,8 @@ static const struct _tc_string tc_strings[] =
{ "mo", &_rl_term_mo },
{ "nd", &_rl_term_forward_char },
{ "pc", &_rl_term_pc },
{ "se", &_rl_term_se },
{ "so", &_rl_term_so },
{ "up", &_rl_term_up },
{ "vb", &_rl_visible_bell },
{ "vs", &_rl_term_vs },
@ -437,7 +456,7 @@ _rl_init_terminal_io (const char *terminal_name)
{
const char *term;
char *buffer;
int tty, tgetent_ret;
int tty, tgetent_ret, dumbterm;
term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
_rl_term_clrpag = _rl_term_cr = _rl_term_clreol = _rl_term_clrscroll = (char *)NULL;
@ -446,6 +465,8 @@ _rl_init_terminal_io (const char *terminal_name)
if (term == 0)
term = "dumb";
dumbterm = STREQ (term, "dumb");
#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;
@ -457,6 +478,7 @@ _rl_init_terminal_io (const char *terminal_name)
_rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
_rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
_rl_term_so = _rl_term_se = (char *)NULL;
#if defined(HACK_TERMCAP_MOTION)
_rl_term_forward_char = (char *)NULL;
#endif
@ -483,7 +505,7 @@ _rl_init_terminal_io (const char *terminal_name)
tgetent_ret = tgetent (term_buffer, term);
}
if (tgetent_ret <= 0)
if (tgetent_ret != TGETENT_SUCCESS)
{
FREE (term_string_buffer);
FREE (term_buffer);
@ -521,8 +543,13 @@ _rl_init_terminal_io (const char *terminal_name)
_rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_term_ve = _rl_term_vs = (char *)NULL;
_rl_term_forward_char = (char *)NULL;
_rl_term_so = _rl_term_se = (char *)NULL;
_rl_terminal_can_insert = term_has_meta = 0;
/* Assume generic unknown terminal can't handle the enable/disable
escape sequences */
_rl_enable_bracketed_paste = 0;
/* 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... */
@ -541,10 +568,10 @@ _rl_init_terminal_io (const char *terminal_name)
BC = _rl_term_backspace;
UP = _rl_term_up;
if (!_rl_term_cr)
if (_rl_term_cr == 0)
_rl_term_cr = "\r";
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
_rl_term_autowrap = TGETFLAG ("am") && TGETFLAG ("xn");
/* Allow calling application to set default height and width, using
rl_set_screen_size */
@ -559,7 +586,7 @@ _rl_init_terminal_io (const char *terminal_name)
/* Check to see if this terminal has a meta key and clear the capability
variables if there is none. */
term_has_meta = tgetflag ("km") != 0;
term_has_meta = TGETFLAG ("km");
if (term_has_meta == 0)
_rl_term_mm = _rl_term_mo = (char *)NULL;
#endif /* !__MSDOS__ */
@ -574,6 +601,11 @@ _rl_init_terminal_io (const char *terminal_name)
bind_termcap_arrow_keys (vi_insertion_keymap);
#endif /* VI_MODE */
/* 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;
return 0;
}
@ -676,6 +708,16 @@ rl_crlf (void)
return 0;
}
void
_rl_cr (void)
{
#if defined (__MSDOS__)
putc ('\r', rl_outstream);
#else
tputs (_rl_term_cr, 1, _rl_output_character_function);
#endif
}
/* Ring the terminal bell. */
int
rl_ding (void)
@ -708,6 +750,30 @@ rl_ding (void)
return (-1);
}
/* **************************************************************** */
/* */
/* Entering and leaving terminal standout mode */
/* */
/* **************************************************************** */
void
_rl_standout_on (void)
{
#ifndef __MSDOS__
if (_rl_term_so && _rl_term_se)
tputs (_rl_term_so, 1, _rl_output_character_function);
#endif
}
void
_rl_standout_off (void)
{
#ifndef __MSDOS__
if (_rl_term_so && _rl_term_se)
tputs (_rl_term_se, 1, _rl_output_character_function);
#endif
}
/* **************************************************************** */
/* */
/* Controlling the Meta Key and Keypad */

View File

@ -1,6 +1,6 @@
/* text.c -- text handling commands for readline. */
/* Copyright (C) 1987-2017 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.
@ -154,6 +154,7 @@ rl_delete_text (int from, int to)
rl_end -= diff;
rl_line_buffer[rl_end] = '\0';
_rl_fix_mark ();
return (diff);
}
@ -176,6 +177,12 @@ _rl_fix_point (int fix_mark_too)
if (fix_mark_too)
_RL_FIX_POINT (rl_mark);
}
void
_rl_fix_mark (void)
{
_RL_FIX_POINT (rl_mark);
}
#undef _RL_FIX_POINT
/* Replace the contents of the line buffer between START and END with
@ -479,6 +486,8 @@ rl_forward_word (int count, int key)
while (count)
{
if (rl_point > rl_end)
rl_point = rl_end;
if (rl_point == rl_end)
return 0;
@ -498,6 +507,8 @@ rl_forward_word (int count, int key)
}
}
if (rl_point > rl_end)
rl_point = rl_end;
if (rl_point == rl_end)
return 0;
@ -569,18 +580,8 @@ rl_backward_word (int count, int key)
int
rl_refresh_line (int ignore1, int ignore2)
{
int curr_line;
curr_line = _rl_current_display_line ();
_rl_move_vert (curr_line);
_rl_move_cursor_relative (0, rl_line_buffer); /* XXX is this right */
_rl_clear_to_eol (0); /* arg of 0 means to not use spaces */
rl_redraw_prompt_last_line ();
_rl_refresh_line ();
rl_display_fixed = 1;
return 0;
}
@ -596,7 +597,18 @@ rl_clear_screen (int count, int key)
return 0;
}
_rl_clear_screen (); /* calls termcap function to clear screen */
_rl_clear_screen (0); /* calls termcap function to clear screen */
rl_keep_mark_active ();
rl_forced_update_display ();
rl_display_fixed = 1;
return 0;
}
int
rl_clear_display (int count, int key)
{
_rl_clear_screen (1); /* calls termcap function to clear screen and scrollback buffer */
rl_forced_update_display ();
rl_display_fixed = 1;
@ -1080,6 +1092,13 @@ rl_tab_insert (int count, int key)
int
rl_newline (int count, int key)
{
if (rl_mark_active_p ())
{
rl_deactivate_mark ();
(*rl_redisplay_function) ();
_rl_want_redisplay = 0;
}
rl_done = 1;
if (_rl_history_preserve_point)
@ -1452,7 +1471,18 @@ rl_change_case (int count, int op)
if (nwc != wc) /* just skip unchanged characters */
{
char *s, *e;
mlen = wcrtomb (mb, nwc, &mps);
mbstate_t ts;
memset (&ts, 0, sizeof (mbstate_t));
mlen = wcrtomb (mb, nwc, &ts);
if (mlen < 0)
{
nwc = wc;
memset (&ts, 0, sizeof (mbstate_t));
mlen = wcrtomb (mb, nwc, &ts);
if (mlen < 0) /* should not happen */
strncpy (mb, rl_line_buffer + start, mlen = m);
}
if (mlen > 0)
mb[mlen] = '\0';
/* what to do if m != mlen? adjust below */
@ -1472,7 +1502,9 @@ rl_change_case (int count, int op)
}
else if (m < mlen)
{
rl_extend_line_buffer (mlen - m + 1);
rl_extend_line_buffer (rl_end + mlen + (e - s) - m + 2);
s = rl_line_buffer + start; /* have to redo this */
e = rl_line_buffer + rl_end;
memmove (s + mlen, s + m, (e - s) - m);
memcpy (s, mb, mlen);
next += mlen - m; /* next char changes */
@ -1711,10 +1743,7 @@ _rl_char_search (int count, int fdir, int bdir)
{
int c;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
c = _rl_bracketed_read_key ();
if (c < 0)
return 1;
@ -1809,7 +1838,43 @@ rl_exchange_point_and_mark (int count, int key)
return 1;
}
else
SWAP (rl_point, rl_mark);
{
SWAP (rl_point, rl_mark);
rl_activate_mark ();
}
return 0;
}
/* Active mark support */
/* Is the region active? */
static int mark_active = 0;
/* Does the current command want the mark to remain active when it completes? */
int _rl_keep_mark_active;
void
rl_keep_mark_active (void)
{
_rl_keep_mark_active++;
}
void
rl_activate_mark (void)
{
mark_active = 1;
rl_keep_mark_active ();
}
void
rl_deactivate_mark (void)
{
mark_active = 0;
}
int
rl_mark_active_p (void)
{
return (mark_active);
}

View File

@ -1,6 +1,6 @@
/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
/* Copyright (C) 1988-2017 Free Software Foundation, Inc.
/* Copyright (C) 1988-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.
@ -57,10 +57,10 @@ static void *xmalloc (), *xrealloc ();
#if !defined (HAVE_GETPW_DECLS)
# if defined (HAVE_GETPWUID)
extern struct passwd *getpwuid PARAMS((uid_t));
extern struct passwd *getpwuid (uid_t);
# endif
# if defined (HAVE_GETPWNAM)
extern struct passwd *getpwnam PARAMS((const char *));
extern struct passwd *getpwnam (const char *);
# endif
#endif /* !HAVE_GETPW_DECLS */
@ -79,8 +79,8 @@ extern struct passwd *getpwnam PARAMS((const char *));
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
extern char *sh_get_home_dir PARAMS((void));
extern char *sh_get_env_value PARAMS((const char *));
extern char *sh_get_home_dir (void);
extern char *sh_get_env_value (const char *);
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
@ -116,10 +116,10 @@ char **tilde_additional_prefixes = (char **)default_prefixes;
`:' and `=~'. */
char **tilde_additional_suffixes = (char **)default_suffixes;
static int tilde_find_prefix PARAMS((const char *, int *));
static int tilde_find_suffix PARAMS((const char *));
static char *isolate_tilde_prefix PARAMS((const char *, int *));
static char *glue_prefix_and_suffix PARAMS((char *, const char *, int));
static int tilde_find_prefix (const char *, int *);
static int tilde_find_suffix (const char *);
static char *isolate_tilde_prefix (const char *, int *);
static char *glue_prefix_and_suffix (char *, const char *, int);
/* Find the start of a tilde expansion in STRING, and return the index of
the tilde which starts the expansion. Place the length of the text

View File

@ -196,6 +196,7 @@ rl_do_undo (void)
/* Undoing deletes means inserting some text. */
case UNDO_DELETE:
rl_point = start;
_rl_fix_point (1);
rl_insert_text (rl_undo_list->text);
xfree (rl_undo_list->text);
break;
@ -204,6 +205,7 @@ rl_do_undo (void)
case UNDO_INSERT:
rl_delete_text (start, end);
rl_point = start;
_rl_fix_point (1);
break;
/* Undoing an END means undoing everything 'til we get to a BEGIN. */

View File

@ -102,10 +102,11 @@ _rl_abort_internal (void)
rl_clear_message ();
_rl_reset_argument ();
rl_clear_pending_input ();
rl_deactivate_mark ();
RL_UNSETSTATE (RL_STATE_MACRODEF);
while (rl_executing_macro)
_rl_pop_executing_macro ();
_rl_kill_kbd_macro ();
RL_UNSETSTATE (RL_STATE_MULTIKEY); /* XXX */
@ -502,17 +503,14 @@ _rl_tropen (void)
if (_rl_tracefp)
fclose (_rl_tracefp);
#if defined (_WIN32) && !defined (__CYGWIN__)
/* Windows doesn't have /var/tmp, so open the trace file in the
user's temporary directory instead. */
snprintf (fnbuf, sizeof (fnbuf), "%s/rltrace.%ld",
(sh_get_env_value ("TEMP")
? sh_get_env_value ("TEMP")
: "."),
getpid ());
x = sh_get_env_value ("TEMP");
if (x == 0)
x = ".";
#else
sprintf (fnbuf, "/var/tmp/rltrace.%ld", (long) getpid ());
x = "/var/tmp";
#endif
unlink (fnbuf);
snprintf (fnbuf, sizeof (fnbuf), "%s/rltrace.%ld", x, (long)getpid());
unlink(fnbuf);
_rl_tracefp = fopen (fnbuf, "w+");
return _rl_tracefp != 0;
}

View File

@ -1,7 +1,7 @@
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
/* Copyright (C) 1987-2018 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.
@ -298,6 +298,11 @@ rl_vi_redo (int count, int c)
if (rl_point > 0)
_rl_vi_backup ();
}
else if (_rl_vi_last_command == '.' && _rl_keymap == vi_movement_keymap)
{
rl_ding ();
r = 0;
}
else
r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
@ -320,9 +325,9 @@ rl_vi_yank_arg (int count, int key)
/* Readline thinks that the first word on a line is the 0th, while vi
thinks the first word on a line is the 1st. Compensate. */
if (rl_explicit_arg)
rl_yank_nth_arg (count - 1, 0);
rl_yank_nth_arg (count - 1, key);
else
rl_yank_nth_arg ('$', 0);
rl_yank_nth_arg ('$', key);
return (0);
}
@ -837,6 +842,12 @@ _rl_vi_save_replace (void)
start = end - vi_replace_count + 1;
len = vi_replace_count + 1;
if (start < 0)
{
len = end + 1;
start = 0;
}
vi_save_insert_buffer (start, len);
}
@ -864,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
@ -876,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
{
@ -888,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
@ -1162,6 +1177,7 @@ rl_domove_motion_callback (_rl_vimotion_cxt *m)
/* Append a blank character temporarily so that the motion routines
work right at the end of the line. Original value of rl_end is saved
as m->end. */
rl_extend_line_buffer (rl_end + 1);
rl_line_buffer[rl_end++] = ' ';
rl_line_buffer[rl_end] = '\0';
@ -1193,12 +1209,15 @@ _rl_vi_domove_motion_cleanup (int c, _rl_vimotion_cxt *m)
/* Remove the blank that we added in rl_domove_motion_callback. */
rl_end = m->end;
rl_line_buffer[rl_end] = '\0';
if (rl_point > rl_end)
rl_point = rl_end;
_rl_fix_point (0);
/* 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);
}
@ -1316,13 +1335,7 @@ rl_domove_read_callback (_rl_vimotion_cxt *m)
static int
rl_vi_domove_getchar (_rl_vimotion_cxt *m)
{
int c;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
return c;
return (_rl_bracketed_read_key ());
}
#if defined (READLINE_CALLBACKS)
@ -1377,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;
@ -1465,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;
@ -1524,6 +1544,8 @@ vi_yank_dispatch (_rl_vimotion_cxt *m)
rl_do_undo ();
rl_point = m->start;
_rl_fix_point (1);
return (0);
}
@ -1532,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;
@ -2000,21 +2025,7 @@ _rl_vi_change_char (int count, int c, char *mb)
static int
_rl_vi_callback_getchar (char *mb, int mlen)
{
int c;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c < 0)
return -1;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = _rl_read_mbstring (c, mb, mlen);
#endif
return c;
return (_rl_bracketed_read_mbstring (mb, mlen));
}
#if defined (READLINE_CALLBACKS)
@ -2026,10 +2037,11 @@ _rl_vi_callback_change_char (_rl_callback_generic_arg *data)
c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
#if defined (HANDLE_MULTIBYTE)
strncpy (_rl_vi_last_replacement, mb, MB_LEN_MAX);
#else
_rl_vi_last_replacement[0] = c;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
strncpy (_rl_vi_last_replacement, mb, MB_LEN_MAX);
else
#endif
_rl_vi_last_replacement[0] = c;
_rl_vi_last_replacement[MB_LEN_MAX] = '\0'; /* XXX */
if (c < 0)
@ -2066,10 +2078,11 @@ rl_vi_change_char (int count, int key)
{
c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
#ifdef HANDLE_MULTIBYTE
strncpy (_rl_vi_last_replacement, mb, MB_LEN_MAX);
#else
_rl_vi_last_replacement[0] = c;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
strncpy (_rl_vi_last_replacement, mb, MB_LEN_MAX);
else
#endif
_rl_vi_last_replacement[0] = c;
_rl_vi_last_replacement[MB_LEN_MAX] = '\0'; /* just in case */
}
@ -2122,7 +2135,7 @@ rl_vi_overstrike_delete (int count, int key)
s = rl_point;
if (rl_do_undo ())
vi_replace_count--;
vi_replace_count--; /* XXX */
if (rl_point == s)
rl_backward_char (1, key);
@ -2137,6 +2150,67 @@ rl_vi_overstrike_delete (int count, int key)
return (0);
}
static int
rl_vi_overstrike_kill_line (int count, int key)
{
int r, end;
end = rl_end;
r = rl_unix_line_discard (count, key);
vi_replace_count -= end - rl_end;
return r;
}
static int
rl_vi_overstrike_kill_word (int count, int key)
{
int r, end;
end = rl_end;
r = rl_vi_unix_word_rubout (count, key);
vi_replace_count -= end - rl_end;
return r;
}
static int
rl_vi_overstrike_yank (int count, int key)
{
int r, end;
end = rl_end;
r = rl_yank (count, key);
vi_replace_count += rl_end - end;
return r;
}
/* Read bracketed paste mode pasted text and insert it in overwrite mode */
static int
rl_vi_overstrike_bracketed_paste (int count, int key)
{
int r;
char *pbuf;
size_t pblen;
pbuf = _rl_bracketed_text (&pblen);
if (pblen == 0)
{
xfree (pbuf);
return 0;
}
r = pblen;
while (--r >= 0)
_rl_unget_char ((unsigned char)pbuf[r]);
xfree (pbuf);
while (_rl_pushed_input_available ())
{
key = rl_read_key ();
r = rl_vi_overstrike (1, key);
}
return r;
}
int
rl_vi_replace (int count, int key)
{
@ -2169,6 +2243,21 @@ rl_vi_replace (int count, int key)
vi_insertion_keymap[CTRL ('H')].function == rl_rubout)
vi_replace_map[CTRL ('H')].function = rl_vi_overstrike_delete;
/* Same for ^U and unix-line-discard. */
if (vi_insertion_keymap[CTRL ('U')].type == ISFUNC &&
vi_insertion_keymap[CTRL ('U')].function == rl_unix_line_discard)
vi_replace_map[CTRL ('U')].function = rl_vi_overstrike_kill_line;
/* And for ^W and unix-word-rubout. */
if (vi_insertion_keymap[CTRL ('W')].type == ISFUNC &&
vi_insertion_keymap[CTRL ('W')].function == rl_vi_unix_word_rubout)
vi_replace_map[CTRL ('W')].function = rl_vi_overstrike_kill_word;
/* And finally for ^Y and yank. */
if (vi_insertion_keymap[CTRL ('Y')].type == ISFUNC &&
vi_insertion_keymap[CTRL ('Y')].function == rl_yank)
vi_replace_map[CTRL ('Y')].function = rl_vi_overstrike_yank;
/* Make sure this is the value we need. */
vi_replace_map[ANYOTHERKEY].type = ISFUNC;
vi_replace_map[ANYOTHERKEY].function = (rl_command_func_t *)NULL;
@ -2176,9 +2265,12 @@ 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)
rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_vi_overstrike_bracketed_paste);
return (0);
}
@ -2268,6 +2360,7 @@ _rl_vi_goto_mark (void)
if (ch == '`')
{
rl_point = rl_mark;
_rl_fix_point (1);
return 0;
}
else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
@ -2283,6 +2376,7 @@ _rl_vi_goto_mark (void)
return 1;
}
rl_point = vi_mark_chars[ch];
_rl_fix_point (1);
return 0;
}