commit bash-20180921 snapshot

This commit is contained in:
Chet Ramey
2018-09-25 09:54:29 -04:00
parent 9282e182d8
commit 3d31a311da
25 changed files with 306 additions and 57 deletions
+2
View File
@@ -617,6 +617,8 @@ glob_vector (pat, dir, flags)
firstmalloc = 0;
nalloca = 0;
name_vector = NULL;
/*itrace("glob_vector: pat = `%s' dir = `%s' flags = 0x%x", pat, dir, flags);*/
/* If PAT is empty, skip the loop, but return one (empty) filename. */
if (pat == 0 || *pat == '\0')
+92 -13
View File
@@ -95,6 +95,9 @@ static const char *string_varname PARAMS((int));
static char *_rl_get_string_variable_value PARAMS((const char *));
static int substring_member_of_array PARAMS((const char *, const char * const *));
static int _rl_get_keymap_by_name PARAMS((const char *));
static int _rl_get_keymap_by_map PARAMS((Keymap));
static int currently_reading_init_file;
/* used only in this file */
@@ -2255,10 +2258,12 @@ glean_key_from_name (char *name)
}
/* Auxiliary functions to manage keymaps. */
static const struct {
const char * const name;
struct name_and_keymap {
char *name;
Keymap map;
} keymap_names[] = {
};
static struct name_and_keymap builtin_keymap_names[] = {
{ "emacs", emacs_standard_keymap },
{ "emacs-standard", emacs_standard_keymap },
{ "emacs-meta", emacs_meta_keymap },
@@ -2272,27 +2277,101 @@ static const struct {
{ (char *)0x0, (Keymap)0x0 }
};
Keymap
rl_get_keymap_by_name (const char *name)
/* -1 for NULL entry */
#define NUM_BUILTIN_KEYMAPS (sizeof (builtin_keymap_names) / sizeof (builtin_keymap_names[0]) - 1)
static struct name_and_keymap *keymap_names = builtin_keymap_names;
static int
_rl_get_keymap_by_name (const char *name)
{
register int i;
for (i = 0; keymap_names[i].name; i++)
if (_rl_stricmp (name, keymap_names[i].name) == 0)
return (keymap_names[i].map);
return ((Keymap) NULL);
return (i);
return -1;
}
Keymap
rl_get_keymap_by_name (const char *name)
{
int i;
i = _rl_get_keymap_by_name (name);
return ((i >= 0) ? keymap_names[i].map : (Keymap) NULL);
}
static int
_rl_get_keymap_by_map (Keymap map)
{
register int i;
for (i = 0; keymap_names[i].name; i++)
if (map == keymap_names[i].map)
return (i);
return -1;
}
char *
rl_get_keymap_name (Keymap map)
{
register int i;
for (i = 0; keymap_names[i].name; i++)
if (map == keymap_names[i].map)
return ((char *)keymap_names[i].name);
return ((char *)NULL);
int i;
i = _rl_get_keymap_by_map (map);
return ((i >= 0) ? keymap_names[i].name : (char *)NULL);
}
int
rl_set_keymap_name (const char *name, Keymap map)
{
int i, ni, mi;
/* First check whether or not we're trying to rename a builtin keymap */
mi = _rl_get_keymap_by_map (map);
if (mi >= 0 && mi < NUM_BUILTIN_KEYMAPS)
return -1;
/* Then reject attempts to set one of the builtin names to a new map */
ni = _rl_get_keymap_by_name (name);
if (ni >= 0 && ni < NUM_BUILTIN_KEYMAPS)
return -1;
/* Renaming a keymap we already added */
if (mi >= 0) /* XXX - could be >= NUM_BUILTIN_KEYMAPS */
{
xfree (keymap_names[mi].name);
keymap_names[mi].name = savestring (name);
return mi;
}
/* Associating new keymap with existing name */
if (ni >= 0)
{
keymap_names[ni].map = map;
return ni;
}
for (i = 0; keymap_names[i].name; i++)
;
if (keymap_names == builtin_keymap_names)
{
keymap_names = xmalloc ((i + 2) * sizeof (struct name_and_keymap));
memcpy (keymap_names, builtin_keymap_names, i * sizeof (struct name_and_keymap));
}
else
keymap_names = xrealloc (keymap_names, (i + 2) * sizeof (struct name_and_keymap));
keymap_names[i].name = savestring (name);
keymap_names[i].map = map;
keymap_names[i+1].name = NULL;
keymap_names[i+1].map = NULL;
return i;
}
void
rl_set_keymap (Keymap map)
{
+15
View File
@@ -720,6 +720,21 @@ Return the name matching @var{keymap}. @var{name} is one which would
be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}).
@end deftypefun
@deftypefun void rl_set_keymap (const char *name, Keymap keymap)
Set the name of @var{keymap}. This name will then be "registered" and
available for use in a @code{set keymap} inputrc directive
@pxref{Readline Init File}).
The @var{name} may not be one of Readline's builtin names;
you may not add a different name for one of Readline's builtin keymaps.
Readline will make a copy of @var{name}.
You may replace the name associated with a given keymap by calling this
function two or more times with the same @var{keymap} argument.
You can associate a registered name with a new keymap by calling this
function two or more times with the same @var{name} argument.
There is no way to remove a named keymap once the name has been
registered.
@end deftypefun
@node Binding Keys
@subsection Binding Keys
+2 -1
View File
@@ -606,7 +606,7 @@ If this variable has not been given a value, the characters @key{ESC} and
@item keymap
@vindex keymap
Sets Readline's idea of the current keymap for key binding commands.
Acceptable @code{keymap} names are
Built-in @code{keymap} names are
@code{emacs},
@code{emacs-standard},
@code{emacs-meta},
@@ -617,6 +617,7 @@ Acceptable @code{keymap} names are
@code{vi-insert}.
@code{vi} is equivalent to @code{vi-command} (@code{vi-move} is also a
synonym); @code{emacs} is equivalent to @code{emacs-standard}.
Applications may add additional names.
The default value is @code{emacs}.
The value of the @code{editing-mode} variable also affects the
default keymap.
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2018 Free Software Foundation, Inc.
@set EDITION 8.0
@set VERSION 8.0
@set UPDATED 6 July 2018
@set UPDATED-MONTH July 2018
@set UPDATED 18 September 2018
@set UPDATED-MONTH September 2018
@set LASTCHANGE Fri Jul 6 16:25:22 MDT 2018
@set LASTCHANGE Tue Sep 18 13:08:12 EDT 2018
+10 -5
View File
@@ -327,7 +327,7 @@ _rl_search_getchar (_rl_search_cxt *cxt)
int
_rl_isearch_dispatch (_rl_search_cxt *cxt, int c)
{
int n, wstart, wlen, limit, cval;
int n, wstart, wlen, limit, cval, incr;
rl_command_func_t *f;
f = (rl_command_func_t *)NULL;
@@ -622,20 +622,25 @@ add_character:
/* Add character to search string and continue search. */
default:
if (cxt->search_string_index + 2 >= cxt->search_string_size)
#if defined (HANDLE_MULTIBYTE)
wlen = (cxt->mb[0] == 0 || cxt->mb[1] == 0) ? 1 : RL_STRLEN (cxt->mb);
#else
wlen = 1;
#endif
if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
{
cxt->search_string_size += 128;
cxt->search_string_size += 128; /* 128 much greater than MB_CUR_MAX */
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int j, l;
int j;
if (cxt->mb[0] == 0 || cxt->mb[1] == 0)
cxt->search_string[cxt->search_string_index++] = cxt->mb[0];
else
for (j = 0, l = RL_STRLEN (cxt->mb); j < l; )
for (j = 0; j < wlen; )
cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
}
else
+3
View File
@@ -90,6 +90,9 @@ extern Keymap rl_get_keymap PARAMS((void));
/* Set the current keymap to MAP. */
extern void rl_set_keymap PARAMS((Keymap));
/* Set the name of MAP to NAME */
extern int rl_set_keymap_name PARAMS((const char *, Keymap));
#ifdef __cplusplus
}
#endif
+3
View File
@@ -357,6 +357,9 @@ extern Keymap rl_get_keymap_by_name PARAMS((const char *));
extern char *rl_get_keymap_name PARAMS((Keymap));
extern void rl_set_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap PARAMS((void));
extern int rl_set_keymap_name PARAMS((const char *, Keymap));
/* Undocumented; used internally only. */
extern void rl_set_keymap_from_edit_mode PARAMS((void));
extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
-1
View File
@@ -396,7 +396,6 @@ save_tty_chars (TIOTYPE *tiop)
/* Currently this is only used on AIX */
static void
rltty_warning (char *msg)
char *msg;
{
_rl_errmsg ("warning: %s", msg);
}
+1 -1
View File
@@ -227,7 +227,7 @@ sh_canonpath (path, flags)
if (result[2] == '\0') /* short-circuit for bare `//' */
result[1] = '\0';
else
strcpy (result, result + 1);
memmove (result, result + 1, strlen (result + 1) + 1);
}
return (result);
+1 -1
View File
@@ -245,7 +245,7 @@ error:
if (result[2] == '\0') /* short-circuit for bare `//' */
result[1] = '\0';
else
strcpy (result, result + 1);
memmove (result, result + 1, strlen (result + 1) + 1);
}
return (result);