TheGNUGeneralPublicLicenseisoftenshippedwithGNUsoftware,and isgenerallykeptinafilecalledCOPYINGorLICENSE.Ifyoudonot haveacopyofthelicense,writetotheFreeSoftwareFoundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */
#define READLINE_LIBRARY
#ifdefined (__TANDEM) # include <floss.h> #endif
#ifdefined (HAVE_CONFIG_H) # include "config_readline.h" #endif
/* rl_add_defun (char *name, rl_command_func_t *function, int key) AddNAMEtothelistofnamedfunctions.MakeFUNCTIONbethefunction
that gets called. If KEY is not -1, then bind it. */ int
rl_add_defun (name, function, key) constchar *name;
rl_command_func_t *function; int key;
{ if (key != -1)
rl_bind_key (key, function);
rl_add_funmap_entry (name, function); return0;
}
/* Bind KEY to FUNCTION. Returns non-zero if KEY is out of range. */ int
rl_bind_key (key, function) int key;
rl_command_func_t *function;
{ if (key < 0) return (key);
if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
{ if (_rl_keymap[ESC].type == ISKMAP)
{
Keymap escmap;
/* Bind KEY to FUNCTION in MAP. Returns non-zero in case of invalid
KEY. */ int
rl_bind_key_in_map (key, function, map) int key;
rl_command_func_t *function;
Keymap map;
{ int result;
Keymap oldmap;
/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right now,thisisalwaysusedtoattempttobindthearrowkeys,hencethe
check for rl_vi_movement_mode. */ int
rl_bind_key_if_unbound_in_map (key, default_func, kmap) int key;
rl_command_func_t *default_func;
Keymap kmap;
{ char keyseq[2];
/* Make KEY do nothing in the currently selected keymap.
Returns non-zero in case of error. */ int
rl_unbind_key (key) int key;
{ return (rl_bind_key (key, (rl_command_func_t *)NULL));
}
/* Make KEY do nothing in MAP.
Returns non-zero in case of error. */ int
rl_unbind_key_in_map (key, map) int key;
Keymap map;
{ return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map));
}
/* Unbind all keys bound to FUNCTION in MAP. */ int
rl_unbind_function_in_map (func, map)
rl_command_func_t *func;
Keymap map;
{ registerint i, rval;
for (i = rval = 0; i < KEYMAP_SIZE; i++)
{ if (map[i].type == ISFUNC && map[i].function == func)
{
map[i].function = (rl_command_func_t *)NULL;
rval = 1;
}
} return rval;
}
/* Bind the key sequence represented by the string KEYSEQ to FUNCTION,startinginthecurrentkeymap.Thismakesnew
keymaps as necessary. */ int
rl_bind_keyseq (keyseq, function) constchar *keyseq;
rl_command_func_t *function;
{ return (rl_generic_bind (ISFUNC, keyseq, (char *)function, _rl_keymap));
}
/* Bind the key sequence represented by the string KEYSEQ to FUNCTION.Thismakesnewkeymapsasnecessary.Theinitial
place to do bindings is in MAP. */ int
rl_bind_keyseq_in_map (keyseq, function, map) constchar *keyseq;
rl_command_func_t *function;
Keymap map;
{ return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
}
/* Bind the key sequence represented by the string KEYSEQ to thestringofcharactersMACRO.Thismakesnewkeymapsas
necessary. The initial place to do bindings is in MAP. */ int
rl_macro_bind (keyseq, macro, map) constchar *keyseq, *macro;
Keymap map;
{ char *macro_keys; int macro_keys_len;
/* Bind the key sequence represented by the string KEYSEQ to thearbitrarypointerDATA.TYPEsayswhatkindofdatais pointedtobyDATA,rightnowthiscanbeafunction(ISFUNC), amacro(ISMACR),orakeymap(ISKMAP).Thismakesnewkeymaps
as necessary. The initial place to do bindings is in MAP. */ int
rl_generic_bind (type, keyseq, data, map) int type; constchar *keyseq; char *data;
Keymap map;
{ char *keys; int keys_len; registerint i;
KEYMAP_ENTRY k= { 0, NULL };
/* If no keys to bind to, exit right away. */ if (keyseq == 0 || *keyseq == 0)
{ if (type == ISMACR)
free (data); return -1;
}
/* Translate the ASCII representation of KEYSEQ into an array of characters.StuffthecharactersintoKEYS,andthelengthof
KEYS into KEYS_LEN. */ if (rl_translate_keyseq (keyseq, keys, &keys_len))
{
free (keys); return -1;
}
/* Bind keys, making new keymaps as necessary. */ for (i = 0; i < keys_len; i++)
{ unsignedchar uc = keys[i]; int ic;
ic = uc; if (ic < 0 || ic >= KEYMAP_SIZE)
{
free (keys); return -1;
}
if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
{
ic = UNMETA (ic); if (map[ESC].type == ISKMAP)
map = FUNCTION_TO_KEYMAP (map, ESC);
}
if ((i + 1) < keys_len)
{ if (map[ic].type != ISKMAP)
{ /* We allow subsequences of keys. If a keymap is being createdthatwill`shadow'anexistingfunctionormacro keybinding,wesavethatkeybindingintotheANYOTHERKEY indexinthenewmap.Thedispatchcodewilllookthere tofindthefunctiontoexecuteifthesubsequenceisnot matched.ANYOTHERKEYwaschosentobegreaterthan
UCHAR_MAX. */
k = map[ic];
map[ic].type = ISKMAP;
map[ic].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap());
}
map = FUNCTION_TO_KEYMAP (map, ic); /* The dispatch code will return this function if no matching keysequenceisfoundinthekeymap.This(withalittle helpfromthedispatchcodeinreadline.c)allows`a'tobe mappedtosomething,`abc'tobemappedtosomethingelse, andthefunctionboundto`a'tobeexecutedwhentheuser
types `abx', leaving `bx' in the input queue. */ if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR))
{
map[ANYOTHERKEY] = k;
k.function = 0;
}
} else
{ if (map[ic].type == ISMACR)
free ((char *)map[ic].function); elseif (map[ic].type == ISKMAP)
{
map = FUNCTION_TO_KEYMAP (map, ic);
ic = ANYOTHERKEY;
}
/* Translate the ASCII representation of SEQ, stuffing the values into ARRAY, anarrayofcharacters.LENgetsthefinallengthofARRAY.Return
non-zero if there was an error parsing SEQ. */ int
rl_translate_keyseq (seq, array, len) constchar *seq; char *array; int *len;
{ registerint i, c, l, temp;
for (i = l = 0; (c = seq[i]); i++)
{ if (c == '\\')
{
c = seq[++i];
if (c == 0) break;
/* Handle \C- and \M- prefixes. */ if ((c == 'C' || c == 'M') && 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])); if (seq[i] == '\0')
i--;
} elseif (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 */ elseif (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 ormaynothaveanyreasonablemeaning.You're
probably better off using straight octal or hex. */
i++;
array[l++] = META (seq[i]);
}
} elseif (c == 'C')
{
i += 2; /* Special hack for C-?... */
array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
} continue;
}
/* Translate other backslash-escaped characters. These are the sameescapesequencesthatbash's`echo'and`printf'builtins handle,withtheadditionof\d->RUBOUT.Abackslash
preceding a character that is not special is stripped. */ switch (c)
{ case'a':
array[l++] = '\007'; break; case'b':
array[l++] = '\b'; break; case'd':
array[l++] = RUBOUT; /* readline-specific */ break; case'e':
array[l++] = ESC; break; case'f':
array[l++] = '\f'; break; case'n':
array[l++] = NEWLINE; break; case'r':
array[l++] = RETURN; break; case't':
array[l++] = TAB; break; case'v':
array[l++] = 0x0B; break; case'\\':
array[l++] = '\\'; break; case'0': case'1': case'2': case'3': case'4': case'5': case'6': case'7':
i++; for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++)
c = (c * 8) + OCTVALUE (seq[i]);
i--; /* auto-increment in for loop */
array[l++] = c & largest_char; break; case'x':
i++; for (temp = 2, c = 0; ISXDIGIT ((unsignedchar)seq[i]) && temp--; i++)
c = (c * 16) + HEXVALUE (seq[i]); if (temp == 2)
c = 'x';
i--; /* auto-increment in for loop */
array[l++] = c & largest_char; break; default: /* backslashes before non-special chars just add the char */
array[l++] = c; break; /* the backslash is stripped */
} continue;
}
array[l++] = c;
}
*len = l;
array[l] = '\0'; return (0);
}
char *
rl_untranslate_keyseq (seq) int seq;
{ staticchar kseq[16]; int i, c;
/* Return a pointer to the function that STRING represents. IfSTRINGdoesn'thaveamatchingfunction,thenaNULLpointer
is returned. */
rl_command_func_t *
rl_named_function (string) constchar *string;
{ registerint i;
rl_initialize_funmap ();
for (i = 0; funmap[i]; i++) if (_rl_stricmp (funmap[i]->name, string) == 0) return (funmap[i]->function); return ((rl_command_func_t *)NULL);
}
/* Return the function (or macro) definition which would be invoked via KEYSEQifexecutedinMAP.IfMAPisNULL,thenthecurrentkeymapis used.TYPE,ifnon-NULL,isapointertoanintwhichwillreceivethe typeoftheobjectpointedto.OneofISFUNC(function),ISKMAP(keymap),
or ISMACR (macro). */
rl_command_func_t *
rl_function_of_keyseq (keyseq, map, type) constchar *keyseq;
Keymap map; int *type;
{ registerint i;
if (map == 0)
map = _rl_keymap;
for (i = 0; keyseq && keyseq[i]; i++)
{ unsignedchar ic = keyseq[i];
if (META_CHAR_FOR_UCHAR(ic) && _rl_convert_meta_chars_to_ascii)
{ if (map[ESC].type == ISKMAP)
{
map = FUNCTION_TO_KEYMAP (map, ESC);
ic = UNMETA (ic);
} /* XXX - should we just return NULL here, since this obviously
doesn't match? */ else
{ if (type)
*type = map[ESC].type;
return (map[ESC].function);
}
}
if (map[ic].type == ISKMAP)
{ /* If this is the last key in the key sequence, return the
map. */ if (keyseq[i + 1] == '\0')
{ if (type)
*type = ISKMAP;
return (map[ic].function);
} else
map = FUNCTION_TO_KEYMAP (map, ic);
} /* If we're not at the end of the key sequence, and the current key isboundtosomethingotherthanakeymap,thentheentirekey
sequence is not bound. */ elseif (map[ic].type != ISKMAP && keyseq[i+1]) return ((rl_command_func_t *)NULL); else/* map[ic].type != ISKMAP && keyseq[i+1] == 0 */
{ if (type)
*type = map[ic].type;
/* The last key bindings file read. */ staticchar *last_readline_init_file = (char *)NULL;
/* The file we're currently reading key bindings from. */ staticconstchar *current_readline_init_file; staticint current_readline_init_include_level; staticint current_readline_init_lineno;
/* Read FILENAME into a locally-allocated buffer and return the buffer. Thesizeofthebufferisreturnedin*SIZEP.ReturnsNULLifany
errors were encountered. */ staticchar *
_rl_read_file (filename, sizep) char *filename;
size_t *sizep;
{ struct stat finfo;
size_t file_size; char *buffer; int i, file;
if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0) return ((char *)NULL);
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */ if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
file_size + 1 < file_size)
{ if (file >= 0)
close (file); #ifdefined (EFBIG)
errno = EFBIG; #endif return ((char *)NULL);
}
/* Read the file into BUFFER. */
buffer = (char *)xmalloc (file_size + 1);
i = read (file, buffer, file_size);
close (file);
if (i < 0)
{
free (buffer); return ((char *)NULL);
}
buffer[i] = '\0'; if (sizep)
*sizep = i;
return (buffer);
}
/* Re-read the current keybindings file. */ int
rl_re_read_init_file (count, ignore) int count __attribute__((unused)), ignore __attribute__((unused));
{ int r;
r = rl_read_init_file ((constchar *)NULL);
rl_set_keymap_from_edit_mode (); return r;
}
/* Do key bindings from a file. If FILENAME is NULL it defaults tothefirstnon-nullfilenamefromthislist: 1.thefilenameusedforthepreviouscall 2.thevalueoftheshellvariable`INPUTRC' 3.~/.inputrc 4./etc/inputrc Ifthefileexistedandcouldbeopenedandread,0isreturned,
otherwise errno is returned. */ int
rl_read_init_file (filename) constchar *filename;
{ /* Default the filename. */ if (filename == 0)
filename = last_readline_init_file; if (filename == 0)
filename = sh_get_env_value ("INPUTRC"); if (filename == 0 || *filename == 0)
{
filename = DEFAULT_INPUTRC; /* Try to read DEFAULT_INPUTRC; fall back to SYS_INPUTRC on failure */ if (_rl_read_init_file (filename, 0) == 0) return0;
filename = SYS_INPUTRC;
}
/* Loop over the lines in the file. Lines that start with `#' are
comments; all other lines are commands for readline initialization. */
current_readline_init_lineno = 1;
line = buffer;
end = buffer + file_size; while (line < end)
{ /* Find the end of this line. */ for (i = 0; line + i != end && line[i] != '\n'; i++);
#ifdefined (__CYGWIN__) /* ``Be liberal in what you accept.'' */ if (line[i] == '\n' && line[i-1] == '\r')
line[i - 1] = '\0'; #endif
/* Mark end of line. */
line[i] = '\0';
/* Skip leading whitespace. */ while (*line && whitespace (*line))
{
line++;
i--;
}
/* If the line is not a comment, then parse it. */ if (*line && *line != '#')
rl_parse_and_bind (line);
/* Move to the next line. */
line += i + 1;
current_readline_init_lineno++;
}
/* If parsing is turned off, then nothing can turn it back on except
for finding the matching endif. In that case, return right now. */ if (_rl_parsing_conditionalized_out) return0;
/* Isolate first argument. */ for (i = 0; args[i] && !whitespace (args[i]); i++);
if (args[i])
args[i++] = '\0';
/* Handle "$if term=foo" and "$if mode=emacs" constructs. If this isn'tterm=foo,ormode=emacs,thenchecktoseeifthefirst
word in ARGS is the same as the value stored in rl_readline_name. */ if (rl_terminal_name && _rl_strnicmp (args, "term=", 5) == 0)
{ char *tem, *tname;
/* Terminals like "aaa-60" are equivalent to "aaa". */
tname = savestring (rl_terminal_name);
tem = strchr (tname, '-'); if (tem)
*tem = '\0';
/* Test the `long' and `short' forms of the terminal name so that ifsomeonehasa`sun-cmd'anddoesnotwanttohavebindings thatwillbeexecutediftheterminalisa`sun',theycanput
`$if term=sun-cmd' into their .inputrc. */
_rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) &&
_rl_stricmp (args + 5, rl_terminal_name);
free (tname);
} #ifdefined (VI_MODE) elseif (_rl_strnicmp (args, "mode=", 5) == 0)
{ int mode;
_rl_parsing_conditionalized_out = mode != rl_editing_mode;
} #endif/* VI_MODE */ /* Check to see if the first word in ARGS is the same as the
value stored in rl_readline_name. */ elseif (_rl_stricmp (args, rl_readline_name) == 0)
_rl_parsing_conditionalized_out = 0; else
_rl_parsing_conditionalized_out = 1; return0;
}
/* Invert the current parser state if there is anything on the stack. */ staticint
parser_else (args) char *args __attribute__((unused));
{ registerint i;
if (if_stack_depth == 0)
{
_rl_init_file_error ("$else found without matching $if"); return0;
}
#if0 /* Check the previous (n - 1) levels of the stack to make sure that
we haven't previously turned off parsing. */ for (i = 0; i < if_stack_depth - 1; i++) #else /* Check the previous (n) levels of the stack to make sure that
we haven't previously turned off parsing. */ for (i = 0; i < if_stack_depth; i++) #endif if (if_stack[i] == 1) return0;
/* Invert the state of parsing if at top level. */
_rl_parsing_conditionalized_out = !_rl_parsing_conditionalized_out; return0;
}
/* Terminate a conditional, popping the value of
_rl_parsing_conditionalized_out from the stack. */ staticint
parser_endif (args) char *args __attribute__((unused));
{ if (if_stack_depth)
_rl_parsing_conditionalized_out = if_stack[--if_stack_depth]; else
_rl_init_file_error ("$endif without matching $if"); return0;
}
/* Handle a parser directive. STATEMENT is the line of the directive
without any leading `$'. */ staticint
handle_parser_directive (statement) char *statement;
{ registerint i; char *directive, *args;
/* Isolate the actual directive. */
/* Skip whitespace. */ for (i = 0; whitespace (statement[i]); i++);
directive = &statement[i];
for (; statement[i] && !whitespace (statement[i]); i++);
if (statement[i])
statement[i++] = '\0';
for (; statement[i] && whitespace (statement[i]); i++);
args = &statement[i];
/* Lookup the command, and act on it. */ for (i = 0; parser_directives[i].name; i++) if (_rl_stricmp (directive, parser_directives[i].name) == 0)
{
(*parser_directives[i].function) (args); return (0);
}
/* display an error message about the unknown parser directive */
_rl_init_file_error ("unknown parser directive"); return (1);
}
/* Read the binding command from STRING and perform it. Akeybindingcommandlookslike:Keyname:function-name\0, avariablebindingcommandlookslike:setvariablevalue.
A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */ int
rl_parse_and_bind (string) char *string;
{ char *funname, *kname; registerint c, i; int key, equivalency;
while (string && whitespace (*string))
string++;
if (!string || !*string || *string == '#') return0;
/* If this is a parser directive, act on it. */ if (*string == '$')
{
handle_parser_directive (&string[1]); return0;
}
/* If we aren't supposed to be parsing right now, then we're done. */ if (_rl_parsing_conditionalized_out) return0;
i = 0; /* If this keyname is a complex key expression surrounded by quotes, advancetoafterthematchingclosequote.Thiscodeallowsthe
backslash to quote characters in the key expression. */ if (*string == '"')
{ int passc = 0;
for (i = 1; (c = string[i]); i++)
{ if (passc)
{
passc = 0; continue;
}
if (c == '\\')
{
passc++; continue;
}
if (c == '"') break;
} /* If we didn't find a closing quote, abort the line. */ if (string[i] == '\0')
{
_rl_init_file_error ("no closing `\"' in key binding"); return1;
}
}
/* Advance to the colon (:) or whitespace which separates the two objects. */ for (; (c = string[i]) && c != ':' && c != ' ' && c != '\t'; i++ );
equivalency = (c == ':' && string[i + 1] == '=');
/* Mark the end of the command (or keyname). */ if (string[i])
string[i++] = '\0';
/* If doing assignment, skip the '=' sign as well. */ if (equivalency)
string[i++] = '\0';
/* If this is a command to set a variable, then do that. */ if (_rl_stricmp (string, "set") == 0)
{ char *var, *value, *e;
var = string + i; /* Make VAR point to start of variable name. */ while (*var && whitespace (*var)) var++;
/* Make VALUE point to start of value string. */
value = var; while (*value && !whitespace (*value)) value++; if (*value)
*value++ = '\0'; while (*value && whitespace (*value)) value++;
/* Strip trailing whitespace from values to boolean variables. Temp
fix until I get a real quoted-string parser here. */
i = find_boolean_var (var); if (i >= 0)
{ /* 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';
}
rl_variable_bind (var, value); return0;
}
/* Skip any whitespace between keyname and funname. */ for (; string[i] && whitespace (string[i]); i++);
funname = &string[i];
/* Now isolate funname. Forstraightfunctionnamesjustlookforwhitespace,since thatwillsignifytheendofthestring.Butthiscouldbea macrodefinition.Inthatcase,thestringisquoted,soskip tothematchingdelimiter.Weallowthebackslashtoquotethe
delimiter characters in the macro body. */ /* This code exists to allow whitespace in macro expansions, which
would otherwise be gobbled up by the next `for' loop.*/ /* XXX - it may be desirable to allow backslash quoting only if " is
the quoted string delimiter, like the shell. */ if (*funname == '\'' || *funname == '"')
{ int delimiter, passc;
delimiter = string[i++]; for (passc = 0; (c = string[i]); i++)
{ if (passc)
{
passc = 0; continue;
}
if (c == '\\')
{
passc = 1; continue;
}
if (c == delimiter) break;
} if (c)
i++;
}
/* Advance to the end of the string. */ for (; string[i] && !whitespace (string[i]); i++);
/* No extra whitespace at the end of the string. */
string[i] = '\0';
/* Handle equivalency bindings here. Make the left-hand side be exactly
whatever the right-hand evaluates to, including keymaps. */ if (equivalency)
{ return0;
}
/* If this is a new-style key-binding, then do the binding with
rl_bind_keyseq (). Otherwise, let the older code deal with it. */ if (*string == '"')
{ char *seq; registerint j, k, passc;
seq = (char *)xmalloc (1 + strlen (string)); for (j = 1, k = passc = 0; string[j]; j++)
{ /* Allow backslash to quote characters, but leave them in place. Thisallowsastringtoendwithabackslashquotinganother backslash,orwithabackslashquotingadoublequote.The
backslashes are left in place for rl_translate_keyseq (). */ if (passc || (string[j] == '\\'))
{
seq[k++] = string[j];
passc = !passc; continue;
}
for (i = 0; boolean_varlist[i].name; i++) if (_rl_stricmp (name, boolean_varlist[i].name) == 0) return i; return -1;
}
/* Hooks for handling special boolean variables, where a functionneedstobecalledoranothervariableneeds
to be changed when they're changed. */ staticvoid
hack_special_boolean_var (i) int i;
{ constchar *name;
/* These *must* correspond to the array indices for the appropriate
string variable. (Though they're not used right now.) */ #define V_BELLSTYLE 0 #define V_COMBEGIN 1 #define V_EDITMODE 2 #define V_ISRCHTERM 3 #define V_KEYMAP 4
int
rl_variable_bind (name, value) constchar *name, *value;
{ registerint i; int v;
/* Check for simple variables first. */
i = find_boolean_var (name); if (i >= 0)
{
*boolean_varlist[i].value = bool_to_int (value); if (boolean_varlist[i].flags & V_SPECIAL)
hack_special_boolean_var (i); return0;
}
i = find_string_var (name);
/* For the time being, unknown variable names or string names without a
handler function are simply ignored. */ if (i < 0 || string_varlist[i].set_func == 0) return0;
v = (*string_varlist[i].set_func) (value); return v;
}
/* Isolate the value and translate it into a character string. */
v = savestring (value);
FREE (_rl_isearch_terminators); if (v[0] == '"' || v[0] == '\'')
{
delim = v[0]; for (beg = end = 1; v[end] && v[end] != delim; end++)
;
} else
{ for (beg = end = 0; whitespace (v[end]) == 0; end++)
;
}
v[end] = '\0';
/* The value starts at v + beg. Translate it into a character string. */
_rl_isearch_terminators = (char *)xmalloc (2 * strlen (v) + 1);
rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
_rl_isearch_terminators[end] = '\0';
free (v); return0;
}
/* Return the character which matches NAME.
For example, `Space' returns ' '. */
typedefstruct { constchar *name; int value;
} assoc_list;
/* **************************************************************** */ /* */ /* Key Binding and Function Information */ /* */ /* **************************************************************** */
/* Each of the following functions produces information about the stateofkeybindingsandfunctionsknowntoReadline.Theinfo isalwaysprintedtorl_outstream,andinsuchawaythatitcan
be read back in (i.e., passed to rl_parse_and_bind ()). */
/* Print the names of functions known to Readline. */ void
rl_list_funmap_names ()
{ registerint i; constchar **funmap_names;
funmap_names = rl_funmap_names ();
if (!funmap_names) return;
for (i = 0; funmap_names[i]; i++)
fprintf (rl_outstream, "%s\n", funmap_names[i]);
free (funmap_names);
}
staticchar *
_rl_get_keyname (key) int key;
{ char *keyname; int i, c;
keyname = (char *)xmalloc (8);
c = key; /* Since this is going to be used to write out keysequence-function pairsforpossibleinclusioninaninputrcfile,wedon'twantto
do any special meta processing on KEY. */
#if1 /* XXX - Experimental */ /* We might want to do this, but the old version of the code did not. */
/* If this is an escape character, we don't want to do any more processing.
Just add the special ESC key sequence and return. */ if (c == ESC)
{
keyname[0] = '\\';
keyname[1] = 'e';
keyname[2] = '\0'; return keyname;
} #endif
i = 0; /* Now add special prefixes needed for control characters. This can
potentially change C. */ if (CTRL_CHAR (c))
{
keyname[i++] = '\\';
keyname[i++] = 'C';
keyname[i++] = '-';
c = _rl_to_lower (UNCTRL (c));
}
/* XXX experimental code. Turn the characters that are not ASCII or ISOLatin1(128-159)intooctalescapesequences(\200-\237).
This changes C. */ if (c >= 128 && c <= 159)
{
keyname[i++] = '\\';
keyname[i++] = '2';
c -= 128;
keyname[i++] = (c / 8) + '0';
c = (c % 8) + '0';
}
/* Now, if the character needs to be quoted with a backslash, do that. */ if (c == '\\' || c == '"')
keyname[i++] = '\\';
/* Now add the key, terminate the string, and return it. */
keyname[i++] = (char) c;
keyname[i] = '\0';
return keyname;
}
/* Return a NULL terminated array of strings which represent the key
sequences that are used to invoke FUNCTION in MAP. */ char **
rl_invoking_keyseqs_in_map (function, map)
rl_command_func_t *function;
Keymap map;
{ registerint key; char **result; int result_index, result_size;
result = (char **)NULL;
result_index = result_size = 0;
for (key = 0; key < KEYMAP_SIZE; key++)
{ switch (map[key].type)
{ case ISMACR: /* Macros match, if, and only if, the pointers are identical.
Thus, they are treated exactly like functions in here. */ case ISFUNC: /* If the function in the keymap is the one we are looking for,
then add the current KEY to the list of invoking keys. */ if (map[key].function == function)
{ char *keyname;
/* Find the list of keyseqs in this map which have FUNCTION as
their target. Add the key sequences found to RESULT. */ if (map[key].function)
seqs =
rl_invoking_keyseqs_in_map (function, FUNCTION_TO_KEYMAP (map, key)); else break;
if (seqs == 0) break;
for (i = 0; seqs[i]; i++)
{ char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));
/* Return a NULL terminated array of strings which represent the key
sequences that can be used to invoke FUNCTION using the current keymap. */ char **
rl_invoking_keyseqs (function)
rl_command_func_t *function;
{ return (rl_invoking_keyseqs_in_map (function, _rl_keymap));
}
/* Print all of the functions and their bindings to rl_outstream. If PRINT_READABLYisnon-zero,thenprinttheoutputinsuchaway
that it can be read back in. */ void
rl_function_dumper (print_readably) int print_readably;
{ registerint i; constchar **names; constchar *name;
names = rl_funmap_names ();
fprintf (rl_outstream, "\n");
for (i = 0; (name = names[i]); i++)
{
rl_command_func_t *function; char **invokers;
function = rl_named_function (name);
invokers = rl_invoking_keyseqs_in_map (function, _rl_keymap);
if (print_readably)
{ if (!invokers)
fprintf (rl_outstream, "# %s (not bound)\n", name); else
{ registerint j;
if (j == 5 && invokers[j])
fprintf (rl_outstream, "...\n");
for (j = 0; invokers[j]; j++)
free (invokers[j]);
free (invokers);
}
}
}
}
/* Print all of the current functions and their bindings to rl_outstream.Ifanexplicitargumentisgiven,thenprint
the output in such a way that it can be read back in. */ int
rl_dump_functions (count, key) int count __attribute__((unused)), key __attribute__((unused));
{ if (rl_dispatching)
fprintf (rl_outstream, "\r\n");
rl_function_dumper (rl_explicit_arg);
rl_on_new_line (); return (0);
}
staticvoid
_rl_macro_dumper_internal (print_readably, map, prefix) int print_readably;
Keymap map; char *prefix;
{ registerint key; char *keyname, *out; int prefix_len;
for (key = 0; key < KEYMAP_SIZE; key++)
{ switch (map[key].type)
{ case ISMACR:
keyname = _rl_get_keyname (key);
out = _rl_untranslate_macro_value ((char *)map[key].function);
void
rl_variable_dumper (print_readably) int print_readably;
{ int i; constchar *v;
for (i = 0; boolean_varlist[i].name; i++)
{ if (print_readably)
fprintf (rl_outstream, "set %s %s\n", boolean_varlist[i].name,
*boolean_varlist[i].value ? "on" : "off"); else
fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name,
*boolean_varlist[i].value ? "on" : "off");
}
for (i = 0; string_varlist[i].name; i++)
{
v = _rl_get_string_variable_value (string_varlist[i].name); if (v == 0) /* _rl_isearch_terminators can be NULL */ continue; if (print_readably)
fprintf (rl_outstream, "set %s %s\n", string_varlist[i].name, v); else
fprintf (rl_outstream, "%s is set to `%s'\n", string_varlist[i].name, v);
}
}
/* Print all of the current variables and their values to rl_outstream.Ifanexplicitargumentisgiven,thenprint
the output in such a way that it can be read back in. */ int
rl_dump_variables (count, key) int count __attribute__((unused)), key __attribute__((unused));
{ if (rl_dispatching)
fprintf (rl_outstream, "\r\n");
rl_variable_dumper (rl_explicit_arg);
rl_on_new_line (); return (0);
}
/* Return non-zero if any members of ARRAY are a substring in STRING. */ staticint
substring_member_of_array (string, array) char *string; constchar **array;
{ while (*array)
{ if (_rl_strindex (string, *array)) return (1);
array++;
} return (0);
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.84Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.