1
/* bind.c -- key binding and startup file support for the readline library. */
3
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
5
This file is part of the GNU Readline Library, a library for
6
reading lines of text with interactive input and history editing.
8
The GNU Readline Library is free software; you can redistribute it
9
and/or modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2, or
11
(at your option) any later version.
13
The GNU Readline Library is distributed in the hope that it will be
14
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
The GNU General Public License is often shipped with GNU software, and
19
is generally kept in a file called COPYING or LICENSE. If you do not
20
have a copy of the license, write to the Free Software Foundation,
21
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
23
#define READLINE_LIBRARY
25
#if defined (__TANDEM)
29
#if defined (HAVE_CONFIG_H)
30
# include "config_readline.h"
34
#include <sys/types.h>
36
#if defined (HAVE_SYS_FILE_H)
37
# include <sys/file.h>
38
#endif /* HAVE_SYS_FILE_H */
40
#if defined (HAVE_UNISTD_H)
42
#endif /* HAVE_UNISTD_H */
44
#if defined (HAVE_STDLIB_H)
47
# include "ansi_stdlib.h"
48
#endif /* HAVE_STDLIB_H */
56
#include "posixstat.h"
58
/* System-specific feature definitions and include files. */
61
/* Some standard library routines. */
65
#include "rlprivate.h"
69
#if !defined (strchr) && !defined (__STDC__)
70
extern char *strchr (), *strrchr ();
71
#endif /* !strchr && !__STDC__ */
73
/* Variables exported by this file. */
74
Keymap rl_binding_keymap;
76
static char *_rl_read_file PARAMS((char *, size_t *));
77
static void _rl_init_file_error PARAMS((const char *));
78
static int _rl_read_init_file PARAMS((const char *, int));
79
static int glean_key_from_name PARAMS((char *));
80
static int find_boolean_var PARAMS((const char *));
82
static const char *_rl_get_string_variable_value PARAMS((const char *));
83
static int substring_member_of_array PARAMS((char *, const char **));
85
static int currently_reading_init_file;
87
/* used only in this file */
88
static int _rl_prefer_visible_bell = 1;
90
/* **************************************************************** */
94
/* **************************************************************** */
96
/* rl_add_defun (char *name, rl_command_func_t *function, int key)
97
Add NAME to the list of named functions. Make FUNCTION be the function
98
that gets called. If KEY is not -1, then bind it. */
100
rl_add_defun (name, function, key)
102
rl_command_func_t *function;
106
rl_bind_key (key, function);
107
rl_add_funmap_entry (name, function);
111
/* Bind KEY to FUNCTION. Returns non-zero if KEY is out of range. */
113
rl_bind_key (key, function)
115
rl_command_func_t *function;
120
if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
122
if (_rl_keymap[ESC].type == ISKMAP)
126
escmap = FUNCTION_TO_KEYMAP (_rl_keymap, ESC);
128
escmap[key].type = ISFUNC;
129
escmap[key].function = function;
135
_rl_keymap[key].type = ISFUNC;
136
_rl_keymap[key].function = function;
137
rl_binding_keymap = _rl_keymap;
141
/* Bind KEY to FUNCTION in MAP. Returns non-zero in case of invalid
144
rl_bind_key_in_map (key, function, map)
146
rl_command_func_t *function;
154
result = rl_bind_key (key, function);
159
/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right
160
now, this is always used to attempt to bind the arrow keys, hence the
161
check for rl_vi_movement_mode. */
163
rl_bind_key_if_unbound_in_map (key, default_func, kmap)
165
rl_command_func_t *default_func;
170
keyseq[0] = (unsigned char)key;
172
return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap));
176
rl_bind_key_if_unbound (key, default_func)
178
rl_command_func_t *default_func;
182
keyseq[0] = (unsigned char)key;
184
return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap));
187
/* Make KEY do nothing in the currently selected keymap.
188
Returns non-zero in case of error. */
193
return (rl_bind_key (key, (rl_command_func_t *)NULL));
196
/* Make KEY do nothing in MAP.
197
Returns non-zero in case of error. */
199
rl_unbind_key_in_map (key, map)
203
return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map));
206
/* Unbind all keys bound to FUNCTION in MAP. */
208
rl_unbind_function_in_map (func, map)
209
rl_command_func_t *func;
212
register int i, rval;
214
for (i = rval = 0; i < KEYMAP_SIZE; i++)
216
if (map[i].type == ISFUNC && map[i].function == func)
218
map[i].function = (rl_command_func_t *)NULL;
226
rl_unbind_command_in_map (command, map)
230
rl_command_func_t *func;
232
func = rl_named_function (command);
235
return (rl_unbind_function_in_map (func, map));
238
/* Bind the key sequence represented by the string KEYSEQ to
239
FUNCTION, starting in the current keymap. This makes new
240
keymaps as necessary. */
242
rl_bind_keyseq (keyseq, function)
244
rl_command_func_t *function;
246
return (rl_generic_bind (ISFUNC, keyseq, (char *)function, _rl_keymap));
249
/* Bind the key sequence represented by the string KEYSEQ to
250
FUNCTION. This makes new keymaps as necessary. The initial
251
place to do bindings is in MAP. */
253
rl_bind_keyseq_in_map (keyseq, function, map)
255
rl_command_func_t *function;
258
return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
261
/* Backwards compatibility; equivalent to rl_bind_keyseq_in_map() */
263
rl_set_key (keyseq, function, map)
265
rl_command_func_t *function;
268
return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
271
/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right
272
now, this is always used to attempt to bind the arrow keys, hence the
273
check for rl_vi_movement_mode. */
275
rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap)
277
rl_command_func_t *default_func;
280
rl_command_func_t *func;
284
func = rl_function_of_keyseq (keyseq, kmap, (int *)NULL);
285
#if defined (VI_MODE)
286
if (!func || func == rl_do_lowercase_version || func == rl_vi_movement_mode)
288
if (!func || func == rl_do_lowercase_version)
290
return (rl_bind_keyseq_in_map (keyseq, default_func, kmap));
298
rl_bind_keyseq_if_unbound (keyseq, default_func)
300
rl_command_func_t *default_func;
302
return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap));
305
/* Bind the key sequence represented by the string KEYSEQ to
306
the string of characters MACRO. This makes new keymaps as
307
necessary. The initial place to do bindings is in MAP. */
309
rl_macro_bind (keyseq, macro, map)
310
const char *keyseq, *macro;
316
macro_keys = (char *)xmalloc ((2 * strlen (macro)) + 1);
318
if (rl_translate_keyseq (macro, macro_keys, ¯o_keys_len))
323
rl_generic_bind (ISMACR, keyseq, macro_keys, map);
327
/* Bind the key sequence represented by the string KEYSEQ to
328
the arbitrary pointer DATA. TYPE says what kind of data is
329
pointed to by DATA, right now this can be a function (ISFUNC),
330
a macro (ISMACR), or a keymap (ISKMAP). This makes new keymaps
331
as necessary. The initial place to do bindings is in MAP. */
333
rl_generic_bind (type, keyseq, data, map)
342
KEYMAP_ENTRY k= { 0, NULL };
344
/* If no keys to bind to, exit right away. */
345
if (keyseq == 0 || *keyseq == 0)
352
keys = (char *)xmalloc (1 + (2 * strlen (keyseq)));
354
/* Translate the ASCII representation of KEYSEQ into an array of
355
characters. Stuff the characters into KEYS, and the length of
356
KEYS into KEYS_LEN. */
357
if (rl_translate_keyseq (keyseq, keys, &keys_len))
363
/* Bind keys, making new keymaps as necessary. */
364
for (i = 0; i < keys_len; i++)
366
unsigned char uc = keys[i];
370
if (ic < 0 || ic >= KEYMAP_SIZE)
376
if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
379
if (map[ESC].type == ISKMAP)
380
map = FUNCTION_TO_KEYMAP (map, ESC);
383
if ((i + 1) < keys_len)
385
if (map[ic].type != ISKMAP)
387
/* We allow subsequences of keys. If a keymap is being
388
created that will `shadow' an existing function or macro
389
key binding, we save that keybinding into the ANYOTHERKEY
390
index in the new map. The dispatch code will look there
391
to find the function to execute if the subsequence is not
392
matched. ANYOTHERKEY was chosen to be greater than
396
map[ic].type = ISKMAP;
397
map[ic].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap());
399
map = FUNCTION_TO_KEYMAP (map, ic);
400
/* The dispatch code will return this function if no matching
401
key sequence is found in the keymap. This (with a little
402
help from the dispatch code in readline.c) allows `a' to be
403
mapped to something, `abc' to be mapped to something else,
404
and the function bound to `a' to be executed when the user
405
types `abx', leaving `bx' in the input queue. */
406
if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR))
408
map[ANYOTHERKEY] = k;
414
if (map[ic].type == ISMACR)
415
free ((char *)map[ic].function);
416
else if (map[ic].type == ISKMAP)
418
map = FUNCTION_TO_KEYMAP (map, ic);
422
map[ic].function = KEYMAP_TO_FUNCTION (data);
426
rl_binding_keymap = map;
432
/* Translate the ASCII representation of SEQ, stuffing the values into ARRAY,
433
an array of characters. LEN gets the final length of ARRAY. Return
434
non-zero if there was an error parsing SEQ. */
436
rl_translate_keyseq (seq, array, len)
441
register int i, c, l, temp;
443
for (i = l = 0; (c = seq[i]); i++)
452
/* Handle \C- and \M- prefixes. */
453
if ((c == 'C' || c == 'M') && seq[i + 1] == '-')
455
/* Handle special case of backwards define. */
456
if (strncmp (&seq[i], "C-\\M-", 5) == 0)
458
array[l++] = ESC; /* ESC is meta-prefix */
460
array[l++] = CTRL (_rl_to_upper (seq[i]));
466
i++; /* seq[i] == '-' */
467
/* XXX - obey convert-meta setting */
468
if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP)
469
array[l++] = ESC; /* ESC is meta-prefix */
470
else if (seq[i+1] == '\\' && seq[i+2] == 'C' && seq[i+3] == '-')
473
temp = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
474
array[l++] = META (temp);
478
/* This doesn't yet handle things like \M-\a, which may
479
or may not have any reasonable meaning. You're
480
probably better off using straight octal or hex. */
482
array[l++] = META (seq[i]);
488
/* Special hack for C-?... */
489
array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
494
/* Translate other backslash-escaped characters. These are the
495
same escape sequences that bash's `echo' and `printf' builtins
496
handle, with the addition of \d -> RUBOUT. A backslash
497
preceding a character that is not special is stripped. */
507
array[l++] = RUBOUT; /* readline-specific */
516
array[l++] = NEWLINE;
530
case '0': case '1': case '2': case '3':
531
case '4': case '5': case '6': case '7':
533
for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++)
534
c = (c * 8) + OCTVALUE (seq[i]);
535
i--; /* auto-increment in for loop */
536
array[l++] = c & largest_char;
540
for (temp = 2, c = 0; ISXDIGIT ((unsigned char)seq[i]) && temp--; i++)
541
c = (c * 16) + HEXVALUE (seq[i]);
544
i--; /* auto-increment in for loop */
545
array[l++] = c & largest_char;
547
default: /* backslashes before non-special chars just add the char */
549
break; /* the backslash is stripped */
563
rl_untranslate_keyseq (seq)
566
static char kseq[16];
583
else if (CTRL_CHAR (c))
588
c = _rl_to_lower (UNCTRL (c));
590
else if (c == RUBOUT)
603
else if (c == '\\' || c == '"')
608
kseq[i++] = (unsigned char) c;
614
_rl_untranslate_macro_value (seq)
620
r = ret = (char *)xmalloc (7 * strlen (seq) + 1);
621
for (s = seq; *s; s++)
636
else if (CTRL_CHAR (c))
641
c = _rl_to_lower (UNCTRL (c));
643
else if (c == RUBOUT)
656
else if (c == '\\' || c == '"')
659
*r++ = (unsigned char)c;
665
/* Return a pointer to the function that STRING represents.
666
If STRING doesn't have a matching function, then a NULL pointer
669
rl_named_function (string)
674
rl_initialize_funmap ();
676
for (i = 0; funmap[i]; i++)
677
if (_rl_stricmp (funmap[i]->name, string) == 0)
678
return (funmap[i]->function);
679
return ((rl_command_func_t *)NULL);
682
/* Return the function (or macro) definition which would be invoked via
683
KEYSEQ if executed in MAP. If MAP is NULL, then the current keymap is
684
used. TYPE, if non-NULL, is a pointer to an int which will receive the
685
type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap),
686
or ISMACR (macro). */
688
rl_function_of_keyseq (keyseq, map, type)
698
for (i = 0; keyseq && keyseq[i]; i++)
700
unsigned char ic = keyseq[i];
702
if (META_CHAR_FOR_UCHAR (ic) && _rl_convert_meta_chars_to_ascii)
704
if (map[ESC].type == ISKMAP)
706
map = FUNCTION_TO_KEYMAP (map, ESC);
709
/* XXX - should we just return NULL here, since this obviously
714
*type = map[ESC].type;
716
return (map[ESC].function);
720
if (map[ic].type == ISKMAP)
722
/* If this is the last key in the key sequence, return the
724
if (keyseq[i + 1] == '\0')
729
return (map[ic].function);
732
map = FUNCTION_TO_KEYMAP (map, ic);
734
/* If we're not at the end of the key sequence, and the current key
735
is bound to something other than a keymap, then the entire key
736
sequence is not bound. */
737
else if (map[ic].type != ISKMAP && keyseq[i+1])
738
return ((rl_command_func_t *)NULL);
739
else /* map[ic].type != ISKMAP && keyseq[i+1] == 0 */
742
*type = map[ic].type;
744
return (map[ic].function);
747
return ((rl_command_func_t *) NULL);
750
/* The last key bindings file read. */
751
static char *last_readline_init_file = (char *)NULL;
753
/* The file we're currently reading key bindings from. */
754
static const char *current_readline_init_file;
755
static int current_readline_init_include_level;
756
static int current_readline_init_lineno;
758
/* Read FILENAME into a locally-allocated buffer and return the buffer.
759
The size of the buffer is returned in *SIZEP. Returns NULL if any
760
errors were encountered. */
762
_rl_read_file (filename, sizep)
771
if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0)
772
return ((char *)NULL);
774
file_size = (size_t)finfo.st_size;
776
/* check for overflow on very large files */
777
if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
778
file_size + 1 < file_size)
785
return ((char *)NULL);
788
/* Read the file into BUFFER. */
789
buffer = (char *)xmalloc (file_size + 1);
790
i = read (file, buffer, file_size);
796
return ((char *)NULL);
806
/* Re-read the current keybindings file. */
808
rl_re_read_init_file (count, ignore)
809
int count __attribute__((unused)), ignore __attribute__((unused));
812
r = rl_read_init_file ((const char *)NULL);
813
rl_set_keymap_from_edit_mode ();
817
/* Do key bindings from a file. If FILENAME is NULL it defaults
818
to the first non-null filename from this list:
819
1. the filename used for the previous call
820
2. the value of the shell variable `INPUTRC'
823
If the file existed and could be opened and read, 0 is returned,
824
otherwise errno is returned. */
826
rl_read_init_file (filename)
827
const char *filename;
829
/* Default the filename. */
831
filename = last_readline_init_file;
833
filename = sh_get_env_value ("INPUTRC");
834
if (filename == 0 || *filename == 0)
836
filename = DEFAULT_INPUTRC;
837
/* Try to read DEFAULT_INPUTRC; fall back to SYS_INPUTRC on failure */
838
if (_rl_read_init_file (filename, 0) == 0)
840
filename = SYS_INPUTRC;
843
#if defined (__MSDOS__)
844
if (_rl_read_init_file (filename, 0) == 0)
846
filename = "~/_inputrc";
848
return (_rl_read_init_file (filename, 0));
852
_rl_read_init_file (filename, include_level)
853
const char *filename;
857
char *buffer, *openname, *line, *end;
860
current_readline_init_file = filename;
861
current_readline_init_include_level = include_level;
863
openname = tilde_expand (filename);
864
buffer = _rl_read_file (openname, &file_size);
870
if (include_level == 0 && filename != last_readline_init_file)
872
FREE (last_readline_init_file);
873
last_readline_init_file = savestring (filename);
876
currently_reading_init_file = 1;
878
/* Loop over the lines in the file. Lines that start with `#' are
879
comments; all other lines are commands for readline initialization. */
880
current_readline_init_lineno = 1;
882
end = buffer + file_size;
885
/* Find the end of this line. */
886
for (i = 0; line + i != end && line[i] != '\n'; i++);
888
#if defined (__CYGWIN__)
889
/* ``Be liberal in what you accept.'' */
890
if (line[i] == '\n' && line[i-1] == '\r')
894
/* Mark end of line. */
897
/* Skip leading whitespace. */
898
while (*line && whitespace (*line))
904
/* If the line is not a comment, then parse it. */
905
if (*line && *line != '#')
906
rl_parse_and_bind (line);
908
/* Move to the next line. */
910
current_readline_init_lineno++;
914
currently_reading_init_file = 0;
919
_rl_init_file_error (msg)
922
if (currently_reading_init_file)
923
fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
924
current_readline_init_lineno, msg);
926
fprintf (stderr, "readline: %s\n", msg);
929
/* **************************************************************** */
931
/* Parser Directives */
933
/* **************************************************************** */
935
typedef int _rl_parser_func_t PARAMS((char *));
937
/* Things that mean `Control'. */
938
const char *_rl_possible_control_prefixes[] = {
939
"Control-", "C-", "CTRL-", (const char *)NULL
942
const char *_rl_possible_meta_prefixes[] = {
943
"Meta", "M-", (const char *)NULL
948
/* Calling programs set this to have their argv[0]. */
949
const char *rl_readline_name = "other";
951
/* Stack of previous values of parsing_conditionalized_out. */
952
static unsigned char *if_stack = (unsigned char *)NULL;
953
static int if_stack_depth;
954
static int if_stack_size;
956
/* Push _rl_parsing_conditionalized_out, and set parser state based
964
/* Push parser state. */
965
if (if_stack_depth + 1 >= if_stack_size)
968
if_stack = (unsigned char *)xmalloc (if_stack_size = 20);
970
if_stack = (unsigned char *)xrealloc (if_stack, if_stack_size += 20);
972
if_stack[if_stack_depth++] = _rl_parsing_conditionalized_out;
974
/* If parsing is turned off, then nothing can turn it back on except
975
for finding the matching endif. In that case, return right now. */
976
if (_rl_parsing_conditionalized_out)
979
/* Isolate first argument. */
980
for (i = 0; args[i] && !whitespace (args[i]); i++);
985
/* Handle "$if term=foo" and "$if mode=emacs" constructs. If this
986
isn't term=foo, or mode=emacs, then check to see if the first
987
word in ARGS is the same as the value stored in rl_readline_name. */
988
if (rl_terminal_name && _rl_strnicmp (args, "term=", 5) == 0)
992
/* Terminals like "aaa-60" are equivalent to "aaa". */
993
tname = savestring (rl_terminal_name);
994
tem = strchr (tname, '-');
998
/* Test the `long' and `short' forms of the terminal name so that
999
if someone has a `sun-cmd' and does not want to have bindings
1000
that will be executed if the terminal is a `sun', they can put
1001
`$if term=sun-cmd' into their .inputrc. */
1002
_rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) &&
1003
_rl_stricmp (args + 5, rl_terminal_name);
1006
#if defined (VI_MODE)
1007
else if (_rl_strnicmp (args, "mode=", 5) == 0)
1011
if (_rl_stricmp (args + 5, "emacs") == 0)
1013
else if (_rl_stricmp (args + 5, "vi") == 0)
1018
_rl_parsing_conditionalized_out = mode != rl_editing_mode;
1020
#endif /* VI_MODE */
1021
/* Check to see if the first word in ARGS is the same as the
1022
value stored in rl_readline_name. */
1023
else if (_rl_stricmp (args, rl_readline_name) == 0)
1024
_rl_parsing_conditionalized_out = 0;
1026
_rl_parsing_conditionalized_out = 1;
1030
/* Invert the current parser state if there is anything on the stack. */
1033
char *args __attribute__((unused));
1037
if (if_stack_depth == 0)
1039
_rl_init_file_error ("$else found without matching $if");
1044
/* Check the previous (n - 1) levels of the stack to make sure that
1045
we haven't previously turned off parsing. */
1046
for (i = 0; i < if_stack_depth - 1; i++)
1048
/* Check the previous (n) levels of the stack to make sure that
1049
we haven't previously turned off parsing. */
1050
for (i = 0; i < if_stack_depth; i++)
1052
if (if_stack[i] == 1)
1055
/* Invert the state of parsing if at top level. */
1056
_rl_parsing_conditionalized_out = !_rl_parsing_conditionalized_out;
1060
/* Terminate a conditional, popping the value of
1061
_rl_parsing_conditionalized_out from the stack. */
1064
char *args __attribute__((unused));
1067
_rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
1069
_rl_init_file_error ("$endif without matching $if");
1074
parser_include (args)
1077
const char *old_init_file;
1079
int old_line_number, old_include_level, r;
1081
if (_rl_parsing_conditionalized_out)
1084
old_init_file = current_readline_init_file;
1085
old_line_number = current_readline_init_lineno;
1086
old_include_level = current_readline_init_include_level;
1088
e = strchr (args, '\n');
1091
r = _rl_read_init_file ((const char *)args, old_include_level + 1);
1093
current_readline_init_file = old_init_file;
1094
current_readline_init_lineno = old_line_number;
1095
current_readline_init_include_level = old_include_level;
1100
/* Associate textual names with actual functions. */
1103
_rl_parser_func_t *function;
1104
} parser_directives [] = {
1105
{ "if", parser_if },
1106
{ "endif", parser_endif },
1107
{ "else", parser_else },
1108
{ "include", parser_include },
1109
{ (char *)0x0, (_rl_parser_func_t *)0x0 }
1112
/* Handle a parser directive. STATEMENT is the line of the directive
1113
without any leading `$'. */
1115
handle_parser_directive (statement)
1119
char *directive, *args;
1121
/* Isolate the actual directive. */
1123
/* Skip whitespace. */
1124
for (i = 0; whitespace (statement[i]); i++);
1126
directive = &statement[i];
1128
for (; statement[i] && !whitespace (statement[i]); i++);
1131
statement[i++] = '\0';
1133
for (; statement[i] && whitespace (statement[i]); i++);
1135
args = &statement[i];
1137
/* Lookup the command, and act on it. */
1138
for (i = 0; parser_directives[i].name; i++)
1139
if (_rl_stricmp (directive, parser_directives[i].name) == 0)
1141
(*parser_directives[i].function) (args);
1145
/* display an error message about the unknown parser directive */
1146
_rl_init_file_error ("unknown parser directive");
1150
/* Read the binding command from STRING and perform it.
1151
A key binding command looks like: Keyname: function-name\0,
1152
a variable binding command looks like: set variable value.
1153
A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */
1155
rl_parse_and_bind (string)
1158
char *funname, *kname;
1160
int key, equivalency;
1162
while (string && whitespace (*string))
1165
if (!string || !*string || *string == '#')
1168
/* If this is a parser directive, act on it. */
1171
handle_parser_directive (&string[1]);
1175
/* If we aren't supposed to be parsing right now, then we're done. */
1176
if (_rl_parsing_conditionalized_out)
1180
/* If this keyname is a complex key expression surrounded by quotes,
1181
advance to after the matching close quote. This code allows the
1182
backslash to quote characters in the key expression. */
1187
for (i = 1; (c = string[i]); i++)
1204
/* If we didn't find a closing quote, abort the line. */
1205
if (string[i] == '\0')
1207
_rl_init_file_error ("no closing `\"' in key binding");
1212
/* Advance to the colon (:) or whitespace which separates the two objects. */
1213
for (; (c = string[i]) && c != ':' && c != ' ' && c != '\t'; i++ );
1215
equivalency = (c == ':' && string[i + 1] == '=');
1217
/* Mark the end of the command (or keyname). */
1221
/* If doing assignment, skip the '=' sign as well. */
1225
/* If this is a command to set a variable, then do that. */
1226
if (_rl_stricmp (string, "set") == 0)
1228
char *var, *value, *e;
1231
/* Make VAR point to start of variable name. */
1232
while (*var && whitespace (*var)) var++;
1234
/* Make VALUE point to start of value string. */
1236
while (*value && !whitespace (*value)) value++;
1239
while (*value && whitespace (*value)) value++;
1241
/* Strip trailing whitespace from values to boolean variables. Temp
1242
fix until I get a real quoted-string parser here. */
1243
i = find_boolean_var (var);
1246
/* remove trailing whitespace */
1247
e = value + strlen (value) - 1;
1248
while (e >= value && whitespace (*e))
1250
e++; /* skip back to whitespace or EOS */
1251
if (*e && e >= value)
1255
rl_variable_bind (var, value);
1259
/* Skip any whitespace between keyname and funname. */
1260
for (; string[i] && whitespace (string[i]); i++);
1261
funname = &string[i];
1263
/* Now isolate funname.
1264
For straight function names just look for whitespace, since
1265
that will signify the end of the string. But this could be a
1266
macro definition. In that case, the string is quoted, so skip
1267
to the matching delimiter. We allow the backslash to quote the
1268
delimiter characters in the macro body. */
1269
/* This code exists to allow whitespace in macro expansions, which
1270
would otherwise be gobbled up by the next `for' loop.*/
1271
/* XXX - it may be desirable to allow backslash quoting only if " is
1272
the quoted string delimiter, like the shell. */
1273
if (*funname == '\'' || *funname == '"')
1275
int delimiter, passc;
1277
delimiter = string[i++];
1278
for (passc = 0; (c = string[i]); i++)
1299
/* Advance to the end of the string. */
1300
for (; string[i] && !whitespace (string[i]); i++);
1302
/* No extra whitespace at the end of the string. */
1305
/* Handle equivalency bindings here. Make the left-hand side be exactly
1306
whatever the right-hand evaluates to, including keymaps. */
1312
/* If this is a new-style key-binding, then do the binding with
1313
rl_bind_keyseq (). Otherwise, let the older code deal with it. */
1317
register int j, k, passc;
1319
seq = (char *)xmalloc (1 + strlen (string));
1320
for (j = 1, k = passc = 0; string[j]; j++)
1322
/* Allow backslash to quote characters, but leave them in place.
1323
This allows a string to end with a backslash quoting another
1324
backslash, or with a backslash quoting a double quote. The
1325
backslashes are left in place for rl_translate_keyseq (). */
1326
if (passc || (string[j] == '\\'))
1328
seq[k++] = string[j];
1333
if (string[j] == '"')
1336
seq[k++] = string[j];
1340
/* Binding macro? */
1341
if (*funname == '\'' || *funname == '"')
1343
j = strlen (funname);
1345
/* Remove the delimiting quotes from each end of FUNNAME. */
1346
if (j && funname[j - 1] == *funname)
1347
funname[j - 1] = '\0';
1349
rl_macro_bind (seq, &funname[1], _rl_keymap);
1352
rl_bind_keyseq (seq, rl_named_function (funname));
1358
/* Get the actual character we want to deal with. */
1359
kname = strrchr (string, '-');
1365
key = glean_key_from_name (kname);
1367
/* Add in control and meta bits. */
1368
if (substring_member_of_array (string, _rl_possible_control_prefixes))
1369
key = CTRL (_rl_to_upper (key));
1371
if (substring_member_of_array (string, _rl_possible_meta_prefixes))
1374
/* Temporary. Handle old-style keyname with macro-binding. */
1375
if (*funname == '\'' || *funname == '"')
1378
int fl = strlen (funname);
1380
useq[0] = key; useq[1] = '\0';
1381
if (fl && funname[fl - 1] == *funname)
1382
funname[fl - 1] = '\0';
1384
rl_macro_bind (useq, &funname[1], _rl_keymap);
1386
#if defined (PREFIX_META_HACK)
1387
/* Ugly, but working hack to keep prefix-meta around. */
1388
else if (_rl_stricmp (funname, "prefix-meta") == 0)
1394
rl_generic_bind (ISKMAP, seq, (char *)emacs_meta_keymap, _rl_keymap);
1396
#endif /* PREFIX_META_HACK */
1398
rl_bind_key (key, rl_named_function (funname));
1402
/* Simple structure for boolean readline variables (i.e., those that can
1403
have one of two values; either "On" or 1 for truth, or "Off" or 0 for
1406
#define V_SPECIAL 0x1
1412
} boolean_varlist [] = {
1413
{ "bind-tty-special-chars", &_rl_bind_stty_chars, 0 },
1414
{ "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL },
1415
{ "byte-oriented", &rl_byte_oriented, 0 },
1416
{ "completion-ignore-case", &_rl_completion_case_fold, 0 },
1417
{ "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
1418
{ "disable-completion", &rl_inhibit_completion, 0 },
1419
{ "enable-keypad", &_rl_enable_keypad, 0 },
1420
{ "expand-tilde", &rl_complete_with_tilde_expansion, 0 },
1421
{ "history-preserve-point", &_rl_history_preserve_point, 0 },
1422
{ "horizontal-scroll-mode", &_rl_horizontal_scroll_mode, 0 },
1423
{ "input-meta", &_rl_meta_flag, 0 },
1424
{ "mark-directories", &_rl_complete_mark_directories, 0 },
1425
{ "mark-modified-lines", &_rl_mark_modified_lines, 0 },
1426
{ "mark-symlinked-directories", &_rl_complete_mark_symlink_dirs, 0 },
1427
{ "match-hidden-files", &_rl_match_hidden_files, 0 },
1428
{ "meta-flag", &_rl_meta_flag, 0 },
1429
{ "output-meta", &_rl_output_meta_chars, 0 },
1430
{ "page-completions", &_rl_page_completions, 0 },
1431
{ "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL },
1432
{ "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
1433
{ "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
1434
{ "show-all-if-unmodified", &_rl_complete_show_unmodified, 0 },
1435
#if defined (VISIBLE_STATS)
1436
{ "visible-stats", &rl_visible_stats, 0 },
1437
#endif /* VISIBLE_STATS */
1438
{ (char *)NULL, (int *)NULL, 0 }
1442
find_boolean_var (name)
1447
for (i = 0; boolean_varlist[i].name; i++)
1448
if (_rl_stricmp (name, boolean_varlist[i].name) == 0)
1453
/* Hooks for handling special boolean variables, where a
1454
function needs to be called or another variable needs
1455
to be changed when they're changed. */
1457
hack_special_boolean_var (i)
1462
name = boolean_varlist[i].name;
1464
if (_rl_stricmp (name, "blink-matching-paren") == 0)
1465
_rl_enable_paren_matching (rl_blink_matching_paren);
1466
else if (_rl_stricmp (name, "prefer-visible-bell") == 0)
1468
if (_rl_prefer_visible_bell)
1469
_rl_bell_preference = VISIBLE_BELL;
1471
_rl_bell_preference = AUDIBLE_BELL;
1475
typedef int _rl_sv_func_t PARAMS((const char *));
1477
/* These *must* correspond to the array indices for the appropriate
1478
string variable. (Though they're not used right now.) */
1479
#define V_BELLSTYLE 0
1480
#define V_COMBEGIN 1
1481
#define V_EDITMODE 2
1482
#define V_ISRCHTERM 3
1488
/* Forward declarations */
1489
static int sv_bell_style PARAMS((const char *));
1490
static int sv_combegin PARAMS((const char *));
1491
static int sv_compquery PARAMS((const char *));
1492
static int sv_editmode PARAMS((const char *));
1493
static int sv_isrchterm PARAMS((const char *));
1494
static int sv_keymap PARAMS((const char *));
1499
_rl_sv_func_t *set_func;
1500
} string_varlist[] = {
1501
{ "bell-style", V_STRING, sv_bell_style },
1502
{ "comment-begin", V_STRING, sv_combegin },
1503
{ "completion-query-items", V_INT, sv_compquery },
1504
{ "editing-mode", V_STRING, sv_editmode },
1505
{ "isearch-terminators", V_STRING, sv_isrchterm },
1506
{ "keymap", V_STRING, sv_keymap },
1507
{ (char *)NULL, 0, (_rl_sv_func_t*)NULL }
1511
find_string_var (name)
1516
for (i = 0; string_varlist[i].name; i++)
1517
if (_rl_stricmp (name, string_varlist[i].name) == 0)
1522
/* A boolean value that can appear in a `set variable' command is true if
1523
the value is null or empty, `on' (case-insenstive), or "1". Any other
1524
values result in 0 (false). */
1529
return (value == 0 || *value == '\0' ||
1530
(_rl_stricmp (value, "on") == 0) ||
1531
(value[0] == '1' && value[1] == '\0'));
1535
rl_variable_value (name)
1540
/* Check for simple variables first. */
1541
i = find_boolean_var (name);
1543
return (*boolean_varlist[i].value ? "on" : "off");
1545
i = find_string_var (name);
1547
return (_rl_get_string_variable_value (string_varlist[i].name));
1549
/* Unknown variable names return NULL. */
1554
rl_variable_bind (name, value)
1555
const char *name, *value;
1560
/* Check for simple variables first. */
1561
i = find_boolean_var (name);
1564
*boolean_varlist[i].value = bool_to_int (value);
1565
if (boolean_varlist[i].flags & V_SPECIAL)
1566
hack_special_boolean_var (i);
1570
i = find_string_var (name);
1572
/* For the time being, unknown variable names or string names without a
1573
handler function are simply ignored. */
1574
if (i < 0 || string_varlist[i].set_func == 0)
1577
v = (*string_varlist[i].set_func) (value);
1585
if (_rl_strnicmp (value, "vi", 2) == 0)
1587
#if defined (VI_MODE)
1588
_rl_keymap = vi_insertion_keymap;
1589
rl_editing_mode = vi_mode;
1590
#endif /* VI_MODE */
1593
else if (_rl_strnicmp (value, "emacs", 5) == 0)
1595
_rl_keymap = emacs_standard_keymap;
1596
rl_editing_mode = emacs_mode;
1606
if (value && *value)
1608
FREE (_rl_comment_begin);
1609
_rl_comment_begin = savestring (value);
1616
sv_compquery (value)
1621
if (value && *value)
1623
nval = atoi (value);
1627
rl_completion_query_items = nval;
1637
kmap = rl_get_keymap_by_name (value);
1640
rl_set_keymap (kmap);
1647
sv_bell_style (value)
1650
if (value == 0 || *value == '\0')
1651
_rl_bell_preference = AUDIBLE_BELL;
1652
else if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
1653
_rl_bell_preference = NO_BELL;
1654
else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
1655
_rl_bell_preference = AUDIBLE_BELL;
1656
else if (_rl_stricmp (value, "visible") == 0)
1657
_rl_bell_preference = VISIBLE_BELL;
1664
sv_isrchterm (value)
1667
int beg, end, delim;
1673
/* Isolate the value and translate it into a character string. */
1674
v = savestring (value);
1675
FREE (_rl_isearch_terminators);
1676
if (v[0] == '"' || v[0] == '\'')
1679
for (beg = end = 1; v[end] && v[end] != delim; end++)
1684
for (beg = end = 0; whitespace (v[end]) == 0; end++)
1690
/* The value starts at v + beg. Translate it into a character string. */
1691
_rl_isearch_terminators = (char *)xmalloc (2 * strlen (v) + 1);
1692
rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
1693
_rl_isearch_terminators[end] = '\0';
1699
/* Return the character which matches NAME.
1700
For example, `Space' returns ' '. */
1707
static assoc_list name_key_alist[] = {
1710
{ "Escape", '\033' },
1712
{ "Newline", '\n' },
1723
glean_key_from_name (name)
1728
for (i = 0; name_key_alist[i].name; i++)
1729
if (_rl_stricmp (name, name_key_alist[i].name) == 0)
1730
return (name_key_alist[i].value);
1732
return (*(unsigned char *)name); /* XXX was return (*name) */
1735
/* Auxiliary functions to manage keymaps. */
1739
} keymap_names[] = {
1740
{ "emacs", emacs_standard_keymap },
1741
{ "emacs-standard", emacs_standard_keymap },
1742
{ "emacs-meta", emacs_meta_keymap },
1743
{ "emacs-ctlx", emacs_ctlx_keymap },
1744
#if defined (VI_MODE)
1745
{ "vi", vi_movement_keymap },
1746
{ "vi-move", vi_movement_keymap },
1747
{ "vi-command", vi_movement_keymap },
1748
{ "vi-insert", vi_insertion_keymap },
1749
#endif /* VI_MODE */
1750
{ (char *)0x0, (Keymap)0x0 }
1754
rl_get_keymap_by_name (name)
1759
for (i = 0; keymap_names[i].name; i++)
1760
if (_rl_stricmp (name, keymap_names[i].name) == 0)
1761
return (keymap_names[i].map);
1762
return ((Keymap) NULL);
1766
rl_get_keymap_name (map)
1770
for (i = 0; keymap_names[i].name; i++)
1771
if (map == keymap_names[i].map)
1772
return ((char *)keymap_names[i].name);
1773
return ((char *)NULL);
1787
return (_rl_keymap);
1791
rl_set_keymap_from_edit_mode ()
1793
if (rl_editing_mode == emacs_mode)
1794
_rl_keymap = emacs_standard_keymap;
1795
#if defined (VI_MODE)
1796
else if (rl_editing_mode == vi_mode)
1797
_rl_keymap = vi_insertion_keymap;
1798
#endif /* VI_MODE */
1802
rl_get_keymap_name_from_edit_mode ()
1804
if (rl_editing_mode == emacs_mode)
1806
#if defined (VI_MODE)
1807
else if (rl_editing_mode == vi_mode)
1809
#endif /* VI_MODE */
1814
/* **************************************************************** */
1816
/* Key Binding and Function Information */
1818
/* **************************************************************** */
1820
/* Each of the following functions produces information about the
1821
state of keybindings and functions known to Readline. The info
1822
is always printed to rl_outstream, and in such a way that it can
1823
be read back in (i.e., passed to rl_parse_and_bind ()). */
1825
/* Print the names of functions known to Readline. */
1827
rl_list_funmap_names ()
1830
const char **funmap_names;
1832
funmap_names = rl_funmap_names ();
1837
for (i = 0; funmap_names[i]; i++)
1838
fprintf (rl_outstream, "%s\n", funmap_names[i]);
1840
free (funmap_names);
1844
_rl_get_keyname (key)
1850
keyname = (char *)xmalloc (8);
1853
/* Since this is going to be used to write out keysequence-function
1854
pairs for possible inclusion in an inputrc file, we don't want to
1855
do any special meta processing on KEY. */
1858
/* XXX - Experimental */
1859
/* We might want to do this, but the old version of the code did not. */
1861
/* If this is an escape character, we don't want to do any more processing.
1862
Just add the special ESC key sequence and return. */
1872
/* RUBOUT is translated directly into \C-? */
1884
/* Now add special prefixes needed for control characters. This can
1885
potentially change C. */
1888
keyname[i++] = '\\';
1891
c = _rl_to_lower (UNCTRL (c));
1894
/* XXX experimental code. Turn the characters that are not ASCII or
1895
ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237).
1897
if (c >= 128 && c <= 159)
1899
keyname[i++] = '\\';
1902
keyname[i++] = (c / 8) + '0';
1906
/* Now, if the character needs to be quoted with a backslash, do that. */
1907
if (c == '\\' || c == '"')
1908
keyname[i++] = '\\';
1910
/* Now add the key, terminate the string, and return it. */
1911
keyname[i++] = (char) c;
1917
/* Return a NULL terminated array of strings which represent the key
1918
sequences that are used to invoke FUNCTION in MAP. */
1920
rl_invoking_keyseqs_in_map (function, map)
1921
rl_command_func_t *function;
1926
int result_index, result_size;
1928
result = (char **)NULL;
1929
result_index = result_size = 0;
1931
for (key = 0; key < KEYMAP_SIZE; key++)
1933
switch (map[key].type)
1936
/* Macros match, if, and only if, the pointers are identical.
1937
Thus, they are treated exactly like functions in here. */
1939
/* If the function in the keymap is the one we are looking for,
1940
then add the current KEY to the list of invoking keys. */
1941
if (map[key].function == function)
1945
keyname = _rl_get_keyname (key);
1947
if (result_index + 2 > result_size)
1950
result = (char **)xrealloc (result, result_size * sizeof (char *));
1953
result[result_index++] = keyname;
1954
result[result_index] = (char *)NULL;
1963
/* Find the list of keyseqs in this map which have FUNCTION as
1964
their target. Add the key sequences found to RESULT. */
1965
if (map[key].function)
1967
rl_invoking_keyseqs_in_map (function, FUNCTION_TO_KEYMAP (map, key));
1974
for (i = 0; seqs[i]; i++)
1976
char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));
1980
/* If ESC is the meta prefix and we're converting chars
1981
with the eighth bit set to ESC-prefixed sequences, then
1982
we can use \M-. Otherwise we need to use the sequence
1984
if (_rl_convert_meta_chars_to_ascii && map[ESC].type == ISKMAP)
1985
sprintf (keyname, "\\M-");
1987
sprintf (keyname, "\\e");
1989
else if (CTRL_CHAR (key))
1990
sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));
1991
else if (key == RUBOUT)
1992
sprintf (keyname, "\\C-?");
1993
else if (key == '\\' || key == '"')
1996
keyname[1] = (char) key;
2001
keyname[0] = (char) key;
2005
strcat (keyname, seqs[i]);
2008
if (result_index + 2 > result_size)
2011
result = (char **)xrealloc (result, result_size * sizeof (char *));
2014
result[result_index++] = keyname;
2015
result[result_index] = (char *)NULL;
2026
/* Return a NULL terminated array of strings which represent the key
2027
sequences that can be used to invoke FUNCTION using the current keymap. */
2029
rl_invoking_keyseqs (function)
2030
rl_command_func_t *function;
2032
return (rl_invoking_keyseqs_in_map (function, _rl_keymap));
2035
/* Print all of the functions and their bindings to rl_outstream. If
2036
PRINT_READABLY is non-zero, then print the output in such a way
2037
that it can be read back in. */
2039
rl_function_dumper (print_readably)
2046
names = rl_funmap_names ();
2048
fprintf (rl_outstream, "\n");
2050
for (i = 0; (name = names[i]); i++)
2052
rl_command_func_t *function;
2055
function = rl_named_function (name);
2056
invokers = rl_invoking_keyseqs_in_map (function, _rl_keymap);
2061
fprintf (rl_outstream, "# %s (not bound)\n", name);
2066
for (j = 0; invokers[j]; j++)
2068
fprintf (rl_outstream, "\"%s\": %s\n",
2079
fprintf (rl_outstream, "%s is not bound to any keys\n",
2085
fprintf (rl_outstream, "%s can be found on ", name);
2087
for (j = 0; invokers[j] && j < 5; j++)
2089
fprintf (rl_outstream, "\"%s\"%s", invokers[j],
2090
invokers[j + 1] ? ", " : ".\n");
2093
if (j == 5 && invokers[j])
2094
fprintf (rl_outstream, "...\n");
2096
for (j = 0; invokers[j]; j++)
2105
/* Print all of the current functions and their bindings to
2106
rl_outstream. If an explicit argument is given, then print
2107
the output in such a way that it can be read back in. */
2109
rl_dump_functions (count, key)
2110
int count __attribute__((unused)), key __attribute__((unused));
2113
fprintf (rl_outstream, "\r\n");
2114
rl_function_dumper (rl_explicit_arg);
2120
_rl_macro_dumper_internal (print_readably, map, prefix)
2126
char *keyname, *out;
2129
for (key = 0; key < KEYMAP_SIZE; key++)
2131
switch (map[key].type)
2134
keyname = _rl_get_keyname (key);
2135
out = _rl_untranslate_macro_value ((char *)map[key].function);
2138
fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "",
2142
fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "",
2151
prefix_len = prefix ? strlen (prefix) : 0;
2154
keyname = (char *)xmalloc (3 + prefix_len);
2156
strcpy (keyname, prefix);
2157
keyname[prefix_len] = '\\';
2158
keyname[prefix_len + 1] = 'e';
2159
keyname[prefix_len + 2] = '\0';
2163
keyname = _rl_get_keyname (key);
2166
out = (char *)xmalloc (strlen (keyname) + prefix_len + 1);
2167
strcpy (out, prefix);
2168
strcpy (out + prefix_len, keyname);
2174
_rl_macro_dumper_internal (print_readably, FUNCTION_TO_KEYMAP (map, key), keyname);
2182
rl_macro_dumper (print_readably)
2185
_rl_macro_dumper_internal (print_readably, _rl_keymap, (char *)NULL);
2189
rl_dump_macros (count, key)
2190
int count __attribute__((unused)), key __attribute__((unused));
2193
fprintf (rl_outstream, "\r\n");
2194
rl_macro_dumper (rl_explicit_arg);
2200
_rl_get_string_variable_value (name)
2203
static char numbuf[32];
2207
if (_rl_stricmp (name, "bell-style") == 0)
2209
switch (_rl_bell_preference)
2220
else if (_rl_stricmp (name, "comment-begin") == 0)
2221
return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
2222
else if (_rl_stricmp (name, "completion-query-items") == 0)
2224
sprintf (numbuf, "%d", rl_completion_query_items);
2227
else if (_rl_stricmp (name, "editing-mode") == 0)
2228
return (rl_get_keymap_name_from_edit_mode ());
2229
else if (_rl_stricmp (name, "isearch-terminators") == 0)
2231
if (_rl_isearch_terminators == 0)
2233
tmp = _rl_untranslate_macro_value (_rl_isearch_terminators);
2236
strncpy (numbuf, tmp, sizeof (numbuf) - 1);
2238
numbuf[sizeof(numbuf) - 1] = '\0';
2244
else if (_rl_stricmp (name, "keymap") == 0)
2246
ret = rl_get_keymap_name (_rl_keymap);
2248
ret = rl_get_keymap_name_from_edit_mode ();
2249
return (ret ? ret : "none");
2256
rl_variable_dumper (print_readably)
2262
for (i = 0; boolean_varlist[i].name; i++)
2265
fprintf (rl_outstream, "set %s %s\n", boolean_varlist[i].name,
2266
*boolean_varlist[i].value ? "on" : "off");
2268
fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name,
2269
*boolean_varlist[i].value ? "on" : "off");
2272
for (i = 0; string_varlist[i].name; i++)
2274
v = _rl_get_string_variable_value (string_varlist[i].name);
2275
if (v == 0) /* _rl_isearch_terminators can be NULL */
2278
fprintf (rl_outstream, "set %s %s\n", string_varlist[i].name, v);
2280
fprintf (rl_outstream, "%s is set to `%s'\n", string_varlist[i].name, v);
2284
/* Print all of the current variables and their values to
2285
rl_outstream. If an explicit argument is given, then print
2286
the output in such a way that it can be read back in. */
2288
rl_dump_variables (count, key)
2289
int count __attribute__((unused)), key __attribute__((unused));
2292
fprintf (rl_outstream, "\r\n");
2293
rl_variable_dumper (rl_explicit_arg);
2298
/* Return non-zero if any members of ARRAY are a substring in STRING. */
2300
substring_member_of_array (string, array)
2306
if (_rl_strindex (string, *array))