Deleted Added
full compact
bind.c (26497) bind.c (35486)
1/* bind.c -- key binding and startup file support for the readline library. */
2
3/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
4
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
7
8 The GNU Readline Library is free software; you can redistribute it

--- 56 unchanged lines hidden (view full) ---

65extern int _rl_horizontal_scroll_mode;
66extern int _rl_mark_modified_lines;
67extern int _rl_bell_preference;
68extern int _rl_meta_flag;
69extern int _rl_convert_meta_chars_to_ascii;
70extern int _rl_output_meta_chars;
71extern int _rl_complete_show_all;
72extern int _rl_complete_mark_directories;
1/* bind.c -- key binding and startup file support for the readline library. */
2
3/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
4
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
7
8 The GNU Readline Library is free software; you can redistribute it

--- 56 unchanged lines hidden (view full) ---

65extern int _rl_horizontal_scroll_mode;
66extern int _rl_mark_modified_lines;
67extern int _rl_bell_preference;
68extern int _rl_meta_flag;
69extern int _rl_convert_meta_chars_to_ascii;
70extern int _rl_output_meta_chars;
71extern int _rl_complete_show_all;
72extern int _rl_complete_mark_directories;
73extern int _rl_print_completions_horizontally;
74extern int _rl_completion_case_fold;
73extern int _rl_enable_keypad;
74#if defined (PAREN_MATCHING)
75extern int rl_blink_matching_paren;
76#endif /* PAREN_MATCHING */
77#if defined (VISIBLE_STATS)
78extern int rl_visible_stats;
79#endif /* VISIBLE_STATS */
80extern int rl_complete_with_tilde_expansion;

--- 19 unchanged lines hidden (view full) ---

100extern char *get_env_value ();
101
102/* Variables exported by this file. */
103Keymap rl_binding_keymap;
104
105/* Forward declarations */
106void rl_set_keymap_from_edit_mode ();
107
75extern int _rl_enable_keypad;
76#if defined (PAREN_MATCHING)
77extern int rl_blink_matching_paren;
78#endif /* PAREN_MATCHING */
79#if defined (VISIBLE_STATS)
80extern int rl_visible_stats;
81#endif /* VISIBLE_STATS */
82extern int rl_complete_with_tilde_expansion;

--- 19 unchanged lines hidden (view full) ---

102extern char *get_env_value ();
103
104/* Variables exported by this file. */
105Keymap rl_binding_keymap;
106
107/* Forward declarations */
108void rl_set_keymap_from_edit_mode ();
109
110static int _rl_read_init_file ();
108static int glean_key_from_name ();
109static int substring_member_of_array ();
110
111extern char *xmalloc (), *xrealloc ();
112
113/* **************************************************************** */
114/* */
115/* Binding keys */

--- 77 unchanged lines hidden (view full) ---

193int
194rl_unbind_key_in_map (key, map)
195 int key;
196 Keymap map;
197{
198 return (rl_bind_key_in_map (key, (Function *)NULL, map));
199}
200
111static int glean_key_from_name ();
112static int substring_member_of_array ();
113
114extern char *xmalloc (), *xrealloc ();
115
116/* **************************************************************** */
117/* */
118/* Binding keys */

--- 77 unchanged lines hidden (view full) ---

196int
197rl_unbind_key_in_map (key, map)
198 int key;
199 Keymap map;
200{
201 return (rl_bind_key_in_map (key, (Function *)NULL, map));
202}
203
204/* Unbind all keys bound to FUNCTION in MAP. */
205int
206rl_unbind_function_in_map (func, map)
207 Function *func;
208 Keymap map;
209{
210 register int i;
211
212 for (i = 0; i < KEYMAP_SIZE; i++)
213 {
214 if (map[i].type == ISFUNC && map[i].function == func)
215 map[i].function = (Function *)NULL;
216 }
217}
218
219int
220rl_unbind_command_in_map (command, map)
221 char *command;
222 Keymap map;
223{
224 Function *func;
225 register int i;
226
227 func = rl_named_function (command);
228 if (func == 0)
229 return 0;
230 return (rl_unbind_function_in_map (func, map));
231}
232
201/* Bind the key sequence represented by the string KEYSEQ to
202 FUNCTION. This makes new keymaps as necessary. The initial
203 place to do bindings is in MAP. */
204int
205rl_set_key (keyseq, function, map)
206 char *keyseq;
207 Function *function;
208 Keymap map;

--- 99 unchanged lines hidden (view full) ---

308/* Translate the ASCII representation of SEQ, stuffing the values into ARRAY,
309 an array of characters. LEN gets the final length of ARRAY. Return
310 non-zero if there was an error parsing SEQ. */
311int
312rl_translate_keyseq (seq, array, len)
313 char *seq, *array;
314 int *len;
315{
233/* Bind the key sequence represented by the string KEYSEQ to
234 FUNCTION. This makes new keymaps as necessary. The initial
235 place to do bindings is in MAP. */
236int
237rl_set_key (keyseq, function, map)
238 char *keyseq;
239 Function *function;
240 Keymap map;

--- 99 unchanged lines hidden (view full) ---

340/* Translate the ASCII representation of SEQ, stuffing the values into ARRAY,
341 an array of characters. LEN gets the final length of ARRAY. Return
342 non-zero if there was an error parsing SEQ. */
343int
344rl_translate_keyseq (seq, array, len)
345 char *seq, *array;
346 int *len;
347{
316 register int i, c, l;
348 register int i, c, l, temp;
317
318 for (i = l = 0; c = seq[i]; i++)
319 {
320 if (c == '\\')
321 {
322 c = seq[++i];
323
324 if (c == 0)
325 break;
326
349
350 for (i = l = 0; c = seq[i]; i++)
351 {
352 if (c == '\\')
353 {
354 c = seq[++i];
355
356 if (c == 0)
357 break;
358
327 if (((c == 'C' || c == 'M') && seq[i + 1] == '-') || (c == 'e'))
359 /* Handle \C- and \M- prefixes. */
360 if ((c == 'C' || c == 'M') && seq[i + 1] == '-')
328 {
329 /* Handle special case of backwards define. */
330 if (strncmp (&seq[i], "C-\\M-", 5) == 0)
331 {
332 array[l++] = ESC;
333 i += 5;
334 array[l++] = CTRL (_rl_to_upper (seq[i]));
361 {
362 /* Handle special case of backwards define. */
363 if (strncmp (&seq[i], "C-\\M-", 5) == 0)
364 {
365 array[l++] = ESC;
366 i += 5;
367 array[l++] = CTRL (_rl_to_upper (seq[i]));
335 if (!seq[i])
368 if (seq[i] == '\0')
336 i--;
369 i--;
337 continue;
338 }
370 }
339
340 switch (c)
371 else if (c == 'M')
341 {
372 {
342 case 'M':
343 i++;
344 array[l++] = ESC; /* XXX */
373 i++;
374 array[l++] = ESC; /* XXX */
345 break;
346
347 case 'C':
375 }
376 else if (c == 'C')
377 {
348 i += 2;
349 /* Special hack for C-?... */
350 array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
378 i += 2;
379 /* Special hack for C-?... */
380 array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
351 break;
352
353 case 'e':
354 array[l++] = ESC;
355 }
381 }
356
357 continue;
382 continue;
383 }
384
385 /* Translate other backslash-escaped characters. These are the
386 same escape sequences that bash's `echo' and `printf' builtins
387 handle, with the addition of \d -> RUBOUT. A backslash
388 preceding a character that is not special is stripped. */
389 switch (c)
390 {
391 case 'a':
392 array[l++] = '\007';
393 break;
394 case 'b':
395 array[l++] = '\b';
396 break;
397 case 'd':
398 array[l++] = RUBOUT; /* readline-specific */
399 break;
400 case 'e':
401 array[l++] = ESC;
402 break;
403 case 'f':
404 array[l++] = '\f';
405 break;
406 case 'n':
407 array[l++] = NEWLINE;
408 break;
409 case 'r':
410 array[l++] = RETURN;
411 break;
412 case 't':
413 array[l++] = TAB;
414 break;
415 case 'v':
416 array[l++] = 0x0B;
417 break;
418 case '\\':
419 array[l++] = '\\';
420 break;
421 case '0': case '1': case '2': case '3':
422 case '4': case '5': case '6': case '7':
423 i++;
424 for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++)
425 c = (c * 8) + OCTVALUE (seq[i]);
426 i--; /* auto-increment in for loop */
427 array[l++] = c % (largest_char + 1);
428 break;
429 case 'x':
430 i++;
431 for (temp = 3, c = 0; isxdigit (seq[i]) && temp--; i++)
432 c = (c * 16) + HEXVALUE (seq[i]);
433 if (temp == 3)
434 c = 'x';
435 i--; /* auto-increment in for loop */
436 array[l++] = c % (largest_char + 1);
437 break;
438 default: /* backslashes before non-special chars just add the char */
439 array[l++] = c;
440 break; /* the backslash is stripped */
358 }
441 }
442 continue;
359 }
443 }
444
360 array[l++] = c;
361 }
362
363 *len = l;
364 array[l] = '\0';
365 return (0);
366}
367

--- 168 unchanged lines hidden (view full) ---

536 return ((Function *) NULL);
537}
538
539/* The last key bindings file read. */
540static char *last_readline_init_file = (char *)NULL;
541
542/* The file we're currently reading key bindings from. */
543static char *current_readline_init_file;
445 array[l++] = c;
446 }
447
448 *len = l;
449 array[l] = '\0';
450 return (0);
451}
452

--- 168 unchanged lines hidden (view full) ---

621 return ((Function *) NULL);
622}
623
624/* The last key bindings file read. */
625static char *last_readline_init_file = (char *)NULL;
626
627/* The file we're currently reading key bindings from. */
628static char *current_readline_init_file;
629static int current_readline_init_include_level;
544static int current_readline_init_lineno;
545
630static int current_readline_init_lineno;
631
632/* Read FILENAME into a locally-allocated buffer and return the buffer.
633 The size of the buffer is returned in *SIZEP. Returns NULL if any
634 errors were encountered. */
635static char *
636_rl_read_file (filename, sizep)
637 char *filename;
638 size_t *sizep;
639{
640 struct stat finfo;
641 size_t file_size;
642 char *buffer;
643 int i, file;
644
645 if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0)
646 return ((char *)NULL);
647
648 file_size = (size_t)finfo.st_size;
649
650 /* check for overflow on very large files */
651 if (file_size != finfo.st_size || file_size + 1 < file_size)
652 {
653 if (file >= 0)
654 close (file);
655#if defined (EFBIG)
656 errno = EFBIG;
657#endif
658 return ((char *)NULL);
659 }
660
661 /* Read the file into BUFFER. */
662 buffer = (char *)xmalloc (file_size + 1);
663 i = read (file, buffer, file_size);
664 close (file);
665
666 if (i < file_size)
667 {
668 free (buffer);
669 return ((char *)NULL);
670 }
671
672 buffer[file_size] = '\0';
673 if (sizep)
674 *sizep = file_size;
675 return (buffer);
676}
677
546/* Re-read the current keybindings file. */
547int
548rl_re_read_init_file (count, ignore)
549 int count, ignore;
550{
551 int r;
552 r = rl_read_init_file ((char *)NULL);
553 rl_set_keymap_from_edit_mode ();

--- 6 unchanged lines hidden (view full) ---

560 2. the value of the shell variable `INPUTRC'
561 3. ~/.inputrc
562 If the file existed and could be opened and read, 0 is returned,
563 otherwise errno is returned. */
564int
565rl_read_init_file (filename)
566 char *filename;
567{
678/* Re-read the current keybindings file. */
679int
680rl_re_read_init_file (count, ignore)
681 int count, ignore;
682{
683 int r;
684 r = rl_read_init_file ((char *)NULL);
685 rl_set_keymap_from_edit_mode ();

--- 6 unchanged lines hidden (view full) ---

692 2. the value of the shell variable `INPUTRC'
693 3. ~/.inputrc
694 If the file existed and could be opened and read, 0 is returned,
695 otherwise errno is returned. */
696int
697rl_read_init_file (filename)
698 char *filename;
699{
568 register int i;
569 char *buffer, *openname, *line, *end;
570 struct stat finfo;
571 int file;
572
573 /* Default the filename. */
574 if (filename == 0)
575 {
576 filename = last_readline_init_file;
577 if (filename == 0)
578 filename = get_env_value ("INPUTRC");
579 if (filename == 0)
580 filename = DEFAULT_INPUTRC;
581 }
582
583 if (*filename == 0)
584 filename = DEFAULT_INPUTRC;
585
700 /* Default the filename. */
701 if (filename == 0)
702 {
703 filename = last_readline_init_file;
704 if (filename == 0)
705 filename = get_env_value ("INPUTRC");
706 if (filename == 0)
707 filename = DEFAULT_INPUTRC;
708 }
709
710 if (*filename == 0)
711 filename = DEFAULT_INPUTRC;
712
586 current_readline_init_file = filename;
587 openname = tilde_expand (filename);
713 return (_rl_read_init_file (filename, 0));
714}
588
715
589 if ((stat (openname, &finfo) < 0) ||
590 (file = open (openname, O_RDONLY, 0666)) < 0)
591 {
592 free (openname);
593 return (errno);
594 }
595 else
596 free (openname);
716static int
717_rl_read_init_file (filename, include_level)
718 char *filename;
719 int include_level;
720{
721 register int i;
722 char *buffer, *openname, *line, *end;
723 size_t file_size;
597
724
598 if (filename != last_readline_init_file)
599 {
600 if (last_readline_init_file)
601 free (last_readline_init_file);
725 current_readline_init_file = filename;
726 current_readline_init_include_level = include_level;
602
727
728 openname = tilde_expand (filename);
729 buffer = _rl_read_file (openname, &file_size);
730 if (buffer == 0)
731 return (errno);
732
733 if (include_level == 0 && filename != last_readline_init_file)
734 {
735 FREE (last_readline_init_file);
603 last_readline_init_file = savestring (filename);
604 }
605
736 last_readline_init_file = savestring (filename);
737 }
738
606 /* Read the file into BUFFER. */
607 buffer = (char *)xmalloc ((int)finfo.st_size + 1);
608 i = read (file, buffer, finfo.st_size);
609 close (file);
610
611 if (i != finfo.st_size)
612 return (errno);
613
614 /* Loop over the lines in the file. Lines that start with `#' are
615 comments; all other lines are commands for readline initialization. */
616 current_readline_init_lineno = 1;
617 line = buffer;
739 /* Loop over the lines in the file. Lines that start with `#' are
740 comments; all other lines are commands for readline initialization. */
741 current_readline_init_lineno = 1;
742 line = buffer;
618 end = buffer + finfo.st_size;
743 end = buffer + file_size;
619 while (line < end)
620 {
621 /* Find the end of this line. */
622 for (i = 0; line + i != end && line[i] != '\n'; i++);
623
624 /* Mark end of line. */
625 line[i] = '\0';
626

--- 7 unchanged lines hidden (view full) ---

634 /* If the line is not a comment, then parse it. */
635 if (*line && *line != '#')
636 rl_parse_and_bind (line);
637
638 /* Move to the next line. */
639 line += i + 1;
640 current_readline_init_lineno++;
641 }
744 while (line < end)
745 {
746 /* Find the end of this line. */
747 for (i = 0; line + i != end && line[i] != '\n'; i++);
748
749 /* Mark end of line. */
750 line[i] = '\0';
751

--- 7 unchanged lines hidden (view full) ---

759 /* If the line is not a comment, then parse it. */
760 if (*line && *line != '#')
761 rl_parse_and_bind (line);
762
763 /* Move to the next line. */
764 line += i + 1;
765 current_readline_init_lineno++;
766 }
767
642 free (buffer);
643 return (0);
644}
645
646static void
647_rl_init_file_error (msg)
648 char *msg;
649{

--- 42 unchanged lines hidden (view full) ---

692 return 0;
693
694 /* Isolate first argument. */
695 for (i = 0; args[i] && !whitespace (args[i]); i++);
696
697 if (args[i])
698 args[i++] = '\0';
699
768 free (buffer);
769 return (0);
770}
771
772static void
773_rl_init_file_error (msg)
774 char *msg;
775{

--- 42 unchanged lines hidden (view full) ---

818 return 0;
819
820 /* Isolate first argument. */
821 for (i = 0; args[i] && !whitespace (args[i]); i++);
822
823 if (args[i])
824 args[i++] = '\0';
825
700 /* Handle "if term=foo" and "if mode=emacs" constructs. If this
826 /* Handle "$if term=foo" and "$if mode=emacs" constructs. If this
701 isn't term=foo, or mode=emacs, then check to see if the first
702 word in ARGS is the same as the value stored in rl_readline_name. */
703 if (rl_terminal_name && _rl_strnicmp (args, "term=", 5) == 0)
704 {
705 char *tem, *tname;
706
707 /* Terminals like "aaa-60" are equivalent to "aaa". */
708 tname = savestring (rl_terminal_name);

--- 35 unchanged lines hidden (view full) ---

744
745/* Invert the current parser state if there is anything on the stack. */
746static int
747parser_else (args)
748 char *args;
749{
750 register int i;
751
827 isn't term=foo, or mode=emacs, then check to see if the first
828 word in ARGS is the same as the value stored in rl_readline_name. */
829 if (rl_terminal_name && _rl_strnicmp (args, "term=", 5) == 0)
830 {
831 char *tem, *tname;
832
833 /* Terminals like "aaa-60" are equivalent to "aaa". */
834 tname = savestring (rl_terminal_name);

--- 35 unchanged lines hidden (view full) ---

870
871/* Invert the current parser state if there is anything on the stack. */
872static int
873parser_else (args)
874 char *args;
875{
876 register int i;
877
752 if (!if_stack_depth)
878 if (if_stack_depth == 0)
753 {
879 {
754 /* Error message? */
880 _rl_init_file_error ("$else found without matching $if");
755 return 0;
756 }
757
758 /* Check the previous (n - 1) levels of the stack to make sure that
759 we haven't previously turned off parsing. */
760 for (i = 0; i < if_stack_depth - 1; i++)
761 if (if_stack[i] == 1)
762 return 0;

--- 7 unchanged lines hidden (view full) ---

770 _rl_parsing_conditionalized_out from the stack. */
771static int
772parser_endif (args)
773 char *args;
774{
775 if (if_stack_depth)
776 _rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
777 else
881 return 0;
882 }
883
884 /* Check the previous (n - 1) levels of the stack to make sure that
885 we haven't previously turned off parsing. */
886 for (i = 0; i < if_stack_depth - 1; i++)
887 if (if_stack[i] == 1)
888 return 0;

--- 7 unchanged lines hidden (view full) ---

896 _rl_parsing_conditionalized_out from the stack. */
897static int
898parser_endif (args)
899 char *args;
900{
901 if (if_stack_depth)
902 _rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
903 else
778 {
779 /* *** What, no error message? *** */
780 }
904 _rl_init_file_error ("$endif without matching $if");
781 return 0;
782}
783
905 return 0;
906}
907
908static int
909parser_include (args)
910 char *args;
911{
912 char *old_init_file, *e;
913 int old_line_number, old_include_level, r;
914
915 if (_rl_parsing_conditionalized_out)
916 return (0);
917
918 old_init_file = current_readline_init_file;
919 old_line_number = current_readline_init_lineno;
920 old_include_level = current_readline_init_include_level;
921
922 e = strchr (args, '\n');
923 if (e)
924 *e = '\0';
925 r = _rl_read_init_file (args, old_include_level + 1);
926
927 current_readline_init_file = old_init_file;
928 current_readline_init_lineno = old_line_number;
929 current_readline_init_include_level = old_include_level;
930
931 return r;
932}
933
784/* Associate textual names with actual functions. */
785static struct {
786 char *name;
787 Function *function;
788} parser_directives [] = {
789 { "if", parser_if },
790 { "endif", parser_endif },
791 { "else", parser_else },
934/* Associate textual names with actual functions. */
935static struct {
936 char *name;
937 Function *function;
938} parser_directives [] = {
939 { "if", parser_if },
940 { "endif", parser_endif },
941 { "else", parser_else },
942 { "include", parser_include },
792 { (char *)0x0, (Function *)0x0 }
793};
794
795/* Handle a parser directive. STATEMENT is the line of the directive
796 without any leading `$'. */
797static int
798handle_parser_directive (statement)
799 char *statement;

--- 20 unchanged lines hidden (view full) ---

820 /* Lookup the command, and act on it. */
821 for (i = 0; parser_directives[i].name; i++)
822 if (_rl_stricmp (directive, parser_directives[i].name) == 0)
823 {
824 (*parser_directives[i].function) (args);
825 return (0);
826 }
827
943 { (char *)0x0, (Function *)0x0 }
944};
945
946/* Handle a parser directive. STATEMENT is the line of the directive
947 without any leading `$'. */
948static int
949handle_parser_directive (statement)
950 char *statement;

--- 20 unchanged lines hidden (view full) ---

971 /* Lookup the command, and act on it. */
972 for (i = 0; parser_directives[i].name; i++)
973 if (_rl_stricmp (directive, parser_directives[i].name) == 0)
974 {
975 (*parser_directives[i].function) (args);
976 return (0);
977 }
978
828 /* *** Should an error message be output? */
979 /* display an error message about the unknown parser directive */
980 _rl_init_file_error ("unknown parser directive");
829 return (1);
830}
831
832/* Read the binding command from STRING and perform it.
833 A key binding command looks like: Keyname: function-name\0,
834 a variable binding command looks like: set variable value.
835 A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */
836int

--- 98 unchanged lines hidden (view full) ---

935 to the matching delimiter. We allow the backslash to quote the
936 delimiter characters in the macro body. */
937 /* This code exists to allow whitespace in macro expansions, which
938 would otherwise be gobbled up by the next `for' loop.*/
939 /* XXX - it may be desirable to allow backslash quoting only if " is
940 the quoted string delimiter, like the shell. */
941 if (*funname == '\'' || *funname == '"')
942 {
981 return (1);
982}
983
984/* Read the binding command from STRING and perform it.
985 A key binding command looks like: Keyname: function-name\0,
986 a variable binding command looks like: set variable value.
987 A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */
988int

--- 98 unchanged lines hidden (view full) ---

1087 to the matching delimiter. We allow the backslash to quote the
1088 delimiter characters in the macro body. */
1089 /* This code exists to allow whitespace in macro expansions, which
1090 would otherwise be gobbled up by the next `for' loop.*/
1091 /* XXX - it may be desirable to allow backslash quoting only if " is
1092 the quoted string delimiter, like the shell. */
1093 if (*funname == '\'' || *funname == '"')
1094 {
943 int delimiter = string[i++];
944 int passc = 0;
1095 int delimiter = string[i++], passc;
945
1096
946 for (; c = string[i]; i++)
1097 for (passc = 0; c = string[i]; i++)
947 {
948 if (passc)
949 {
950 passc = 0;
951 continue;
952 }
953
954 if (c == '\\')

--- 21 unchanged lines hidden (view full) ---

976 {
977 return 0;
978 }
979
980 /* If this is a new-style key-binding, then do the binding with
981 rl_set_key (). Otherwise, let the older code deal with it. */
982 if (*string == '"')
983 {
1098 {
1099 if (passc)
1100 {
1101 passc = 0;
1102 continue;
1103 }
1104
1105 if (c == '\\')

--- 21 unchanged lines hidden (view full) ---

1127 {
1128 return 0;
1129 }
1130
1131 /* If this is a new-style key-binding, then do the binding with
1132 rl_set_key (). Otherwise, let the older code deal with it. */
1133 if (*string == '"')
1134 {
984 char *seq = xmalloc (1 + strlen (string));
985 register int j, k = 0;
986 int passc = 0;
1135 char *seq;
1136 register int j, k, passc;
987
1137
988 for (j = 1; string[j]; j++)
1138 seq = xmalloc (1 + strlen (string));
1139 for (j = 1, k = passc = 0; string[j]; j++)
989 {
990 /* Allow backslash to quote characters, but leave them in place.
991 This allows a string to end with a backslash quoting another
992 backslash, or with a backslash quoting a double quote. The
993 backslashes are left in place for rl_translate_keyseq (). */
994 if (passc || (string[j] == '\\'))
995 {
996 seq[k++] = string[j];

--- 76 unchanged lines hidden (view full) ---

1073
1074static struct {
1075 char *name;
1076 int *value;
1077} boolean_varlist [] = {
1078#if defined (PAREN_MATCHING)
1079 { "blink-matching-paren", &rl_blink_matching_paren },
1080#endif
1140 {
1141 /* Allow backslash to quote characters, but leave them in place.
1142 This allows a string to end with a backslash quoting another
1143 backslash, or with a backslash quoting a double quote. The
1144 backslashes are left in place for rl_translate_keyseq (). */
1145 if (passc || (string[j] == '\\'))
1146 {
1147 seq[k++] = string[j];

--- 76 unchanged lines hidden (view full) ---

1224
1225static struct {
1226 char *name;
1227 int *value;
1228} boolean_varlist [] = {
1229#if defined (PAREN_MATCHING)
1230 { "blink-matching-paren", &rl_blink_matching_paren },
1231#endif
1232 { "completion-ignore-case", &_rl_completion_case_fold },
1081 { "convert-meta", &_rl_convert_meta_chars_to_ascii },
1082 { "disable-completion", &rl_inhibit_completion },
1083 { "enable-keypad", &_rl_enable_keypad },
1084 { "expand-tilde", &rl_complete_with_tilde_expansion },
1085 { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode },
1086 { "input-meta", &_rl_meta_flag },
1087 { "mark-directories", &_rl_complete_mark_directories },
1088 { "mark-modified-lines", &_rl_mark_modified_lines },
1089 { "meta-flag", &_rl_meta_flag },
1090 { "output-meta", &_rl_output_meta_chars },
1233 { "convert-meta", &_rl_convert_meta_chars_to_ascii },
1234 { "disable-completion", &rl_inhibit_completion },
1235 { "enable-keypad", &_rl_enable_keypad },
1236 { "expand-tilde", &rl_complete_with_tilde_expansion },
1237 { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode },
1238 { "input-meta", &_rl_meta_flag },
1239 { "mark-directories", &_rl_complete_mark_directories },
1240 { "mark-modified-lines", &_rl_mark_modified_lines },
1241 { "meta-flag", &_rl_meta_flag },
1242 { "output-meta", &_rl_output_meta_chars },
1243 { "print-completions-horizontally", &_rl_print_completions_horizontally },
1091 { "show-all-if-ambiguous", &_rl_complete_show_all },
1092#if defined (VISIBLE_STATS)
1093 { "visible-stats", &rl_visible_stats },
1094#endif /* VISIBLE_STATS */
1095 { (char *)NULL, (int *)NULL }
1096};
1097
1098int

--- 82 unchanged lines hidden (view full) ---

1181 /* Backwards compatibility. */
1182 if (*value && (_rl_stricmp (value, "on") == 0 ||
1183 (*value == '1' && !value[1])))
1184 _rl_bell_preference = VISIBLE_BELL;
1185 else
1186 _rl_bell_preference = AUDIBLE_BELL;
1187 }
1188
1244 { "show-all-if-ambiguous", &_rl_complete_show_all },
1245#if defined (VISIBLE_STATS)
1246 { "visible-stats", &rl_visible_stats },
1247#endif /* VISIBLE_STATS */
1248 { (char *)NULL, (int *)NULL }
1249};
1250
1251int

--- 82 unchanged lines hidden (view full) ---

1334 /* Backwards compatibility. */
1335 if (*value && (_rl_stricmp (value, "on") == 0 ||
1336 (*value == '1' && !value[1])))
1337 _rl_bell_preference = VISIBLE_BELL;
1338 else
1339 _rl_bell_preference = AUDIBLE_BELL;
1340 }
1341
1342 /* For the time being, unknown variable names are simply ignored. */
1189 return 0;
1190}
1191
1192/* Return the character which matches NAME.
1193 For example, `Space' returns ' '. */
1194
1195typedef struct {
1196 char *name;

--- 136 unchanged lines hidden (view full) ---

1333 free (funmap_names);
1334}
1335
1336static char *
1337_rl_get_keyname (key)
1338 int key;
1339{
1340 char *keyname;
1343 return 0;
1344}
1345
1346/* Return the character which matches NAME.
1347 For example, `Space' returns ' '. */
1348
1349typedef struct {
1350 char *name;

--- 136 unchanged lines hidden (view full) ---

1487 free (funmap_names);
1488}
1489
1490static char *
1491_rl_get_keyname (key)
1492 int key;
1493{
1494 char *keyname;
1341 int i, c;
1495 int i, c, v;
1342
1343 keyname = (char *)xmalloc (8);
1344
1345 c = key;
1346 /* Since this is going to be used to write out keysequence-function
1347 pairs for possible inclusion in an inputrc file, we don't want to
1348 do any special meta processing on KEY. */
1349

--- 28 unchanged lines hidden (view full) ---

1378 if (CTRL_CHAR (c))
1379 {
1380 keyname[i++] = '\\';
1381 keyname[i++] = 'C';
1382 keyname[i++] = '-';
1383 c = _rl_to_lower (UNCTRL (c));
1384 }
1385
1496
1497 keyname = (char *)xmalloc (8);
1498
1499 c = key;
1500 /* Since this is going to be used to write out keysequence-function
1501 pairs for possible inclusion in an inputrc file, we don't want to
1502 do any special meta processing on KEY. */
1503

--- 28 unchanged lines hidden (view full) ---

1532 if (CTRL_CHAR (c))
1533 {
1534 keyname[i++] = '\\';
1535 keyname[i++] = 'C';
1536 keyname[i++] = '-';
1537 c = _rl_to_lower (UNCTRL (c));
1538 }
1539
1540 /* XXX experimental code. Turn the characters that are not ASCII or
1541 ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237).
1542 This changes C. */
1543 if (c >= 128 && c <= 159)
1544 {
1545 keyname[i++] = '\\';
1546 keyname[i++] = '2';
1547 c -= 128;
1548 keyname[i++] = (c / 8) + '0';
1549 c = (c % 8) + '0';
1550 }
1551
1386 /* Now, if the character needs to be quoted with a backslash, do that. */
1387 if (c == '\\' || c == '"')
1388 keyname[i++] = '\\';
1389
1390 /* Now add the key, terminate the string, and return it. */
1391 keyname[i++] = (char) c;
1392 keyname[i] = '\0';
1393

--- 293 unchanged lines hidden (view full) ---

1687 else
1688 fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name,
1689 *boolean_varlist[i].value ? "on" : "off");
1690 }
1691
1692 /* bell-style */
1693 switch (_rl_bell_preference)
1694 {
1552 /* Now, if the character needs to be quoted with a backslash, do that. */
1553 if (c == '\\' || c == '"')
1554 keyname[i++] = '\\';
1555
1556 /* Now add the key, terminate the string, and return it. */
1557 keyname[i++] = (char) c;
1558 keyname[i] = '\0';
1559

--- 293 unchanged lines hidden (view full) ---

1853 else
1854 fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name,
1855 *boolean_varlist[i].value ? "on" : "off");
1856 }
1857
1858 /* bell-style */
1859 switch (_rl_bell_preference)
1860 {
1695 case NO_BELL: kname = "none"; break;
1696 case VISIBLE_BELL: kname = "visible"; break;
1861 case NO_BELL:
1862 kname = "none"; break;
1863 case VISIBLE_BELL:
1864 kname = "visible"; break;
1697 case AUDIBLE_BELL:
1865 case AUDIBLE_BELL:
1698 default: kname = "audible"; break;
1866 default:
1867 kname = "audible"; break;
1699 }
1700 if (print_readably)
1701 fprintf (rl_outstream, "set bell-style %s\n", kname);
1702 else
1703 fprintf (rl_outstream, "bell-style is set to `%s'\n", kname);
1704
1705 /* comment-begin */
1706 if (print_readably)

--- 69 unchanged lines hidden ---
1868 }
1869 if (print_readably)
1870 fprintf (rl_outstream, "set bell-style %s\n", kname);
1871 else
1872 fprintf (rl_outstream, "bell-style is set to `%s'\n", kname);
1873
1874 /* comment-begin */
1875 if (print_readably)

--- 69 unchanged lines hidden ---