Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/lib/readline/keymaps.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* keymaps.c -- Functions and keymaps for the GNU Readline library. */ | - | ||||||||||||
2 | - | |||||||||||||
3 | /* Copyright (C) 1988,1989-2009,2017 Free Software Foundation, Inc. | - | ||||||||||||
4 | - | |||||||||||||
5 | This file is part of the GNU Readline Library (Readline), a library | - | ||||||||||||
6 | for reading lines of text with interactive input and history editing. | - | ||||||||||||
7 | - | |||||||||||||
8 | Readline is free software: you can redistribute it and/or modify | - | ||||||||||||
9 | it under the terms of the GNU General Public License as published by | - | ||||||||||||
10 | the Free Software Foundation, either version 3 of the License, or | - | ||||||||||||
11 | (at your option) any later version. | - | ||||||||||||
12 | - | |||||||||||||
13 | Readline is distributed in the hope that it will be useful, | - | ||||||||||||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | ||||||||||||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | ||||||||||||
16 | GNU General Public License for more details. | - | ||||||||||||
17 | - | |||||||||||||
18 | You should have received a copy of the GNU General Public License | - | ||||||||||||
19 | along with Readline. If not, see <http://www.gnu.org/licenses/>. | - | ||||||||||||
20 | */ | - | ||||||||||||
21 | - | |||||||||||||
22 | #define READLINE_LIBRARY | - | ||||||||||||
23 | - | |||||||||||||
24 | #if defined (HAVE_CONFIG_H) | - | ||||||||||||
25 | # include <config.h> | - | ||||||||||||
26 | #endif | - | ||||||||||||
27 | - | |||||||||||||
28 | #if defined (HAVE_STDLIB_H) | - | ||||||||||||
29 | # include <stdlib.h> | - | ||||||||||||
30 | #else | - | ||||||||||||
31 | # include "ansi_stdlib.h" | - | ||||||||||||
32 | #endif /* HAVE_STDLIB_H */ | - | ||||||||||||
33 | - | |||||||||||||
34 | #include <stdio.h> /* for FILE * definition for readline.h */ | - | ||||||||||||
35 | - | |||||||||||||
36 | #include "readline.h" | - | ||||||||||||
37 | #include "rlconf.h" | - | ||||||||||||
38 | - | |||||||||||||
39 | #include "emacs_keymap.c" | - | ||||||||||||
40 | - | |||||||||||||
41 | #if defined (VI_MODE) | - | ||||||||||||
42 | #include "vi_keymap.c" | - | ||||||||||||
43 | #endif | - | ||||||||||||
44 | - | |||||||||||||
45 | #include "xmalloc.h" | - | ||||||||||||
46 | - | |||||||||||||
47 | /* **************************************************************** */ | - | ||||||||||||
48 | /* */ | - | ||||||||||||
49 | /* Functions for manipulating Keymaps. */ | - | ||||||||||||
50 | /* */ | - | ||||||||||||
51 | /* **************************************************************** */ | - | ||||||||||||
52 | - | |||||||||||||
53 | - | |||||||||||||
54 | /* Return a new, empty keymap. | - | ||||||||||||
55 | Free it with free() when you are done. */ | - | ||||||||||||
56 | Keymap | - | ||||||||||||
57 | rl_make_bare_keymap (void) | - | ||||||||||||
58 | { | - | ||||||||||||
59 | register int i; | - | ||||||||||||
60 | Keymap keymap; | - | ||||||||||||
61 | - | |||||||||||||
62 | keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY)); | - | ||||||||||||
63 | for (i = 0; i < KEYMAP_SIZE; i++)
| 0 | ||||||||||||
64 | { | - | ||||||||||||
65 | keymap[i].type = ISFUNC; | - | ||||||||||||
66 | keymap[i].function = (rl_command_func_t *)NULL; | - | ||||||||||||
67 | } never executed: end of block | 0 | ||||||||||||
68 | - | |||||||||||||
69 | #if 0 | - | ||||||||||||
70 | for (i = 'A'; i < ('Z' + 1); i++) | - | ||||||||||||
71 | { | - | ||||||||||||
72 | keymap[i].type = ISFUNC; | - | ||||||||||||
73 | keymap[i].function = rl_do_lowercase_version; | - | ||||||||||||
74 | } | - | ||||||||||||
75 | #endif | - | ||||||||||||
76 | - | |||||||||||||
77 | return (keymap); never executed: return (keymap); | 0 | ||||||||||||
78 | } | - | ||||||||||||
79 | - | |||||||||||||
80 | /* A convenience function that returns 1 if there are no keys bound to | - | ||||||||||||
81 | functions in KEYMAP */ | - | ||||||||||||
82 | int | - | ||||||||||||
83 | rl_empty_keymap (Keymap keymap) | - | ||||||||||||
84 | { | - | ||||||||||||
85 | int i; | - | ||||||||||||
86 | - | |||||||||||||
87 | for (i = 0; i < ANYOTHERKEY; i++)
| 0 | ||||||||||||
88 | { | - | ||||||||||||
89 | if (keymap[i].type != ISFUNC || keymap[i].function)
| 0 | ||||||||||||
90 | return 0; never executed: return 0; | 0 | ||||||||||||
91 | } never executed: end of block | 0 | ||||||||||||
92 | return 1; never executed: return 1; | 0 | ||||||||||||
93 | } | - | ||||||||||||
94 | - | |||||||||||||
95 | /* Return a new keymap which is a copy of MAP. Just copies pointers, does | - | ||||||||||||
96 | not copy text of macros or descend into child keymaps. */ | - | ||||||||||||
97 | Keymap | - | ||||||||||||
98 | rl_copy_keymap (Keymap map) | - | ||||||||||||
99 | { | - | ||||||||||||
100 | register int i; | - | ||||||||||||
101 | Keymap temp; | - | ||||||||||||
102 | - | |||||||||||||
103 | temp = rl_make_bare_keymap (); | - | ||||||||||||
104 | for (i = 0; i < KEYMAP_SIZE; i++)
| 0 | ||||||||||||
105 | { | - | ||||||||||||
106 | temp[i].type = map[i].type; | - | ||||||||||||
107 | temp[i].function = map[i].function; | - | ||||||||||||
108 | } never executed: end of block | 0 | ||||||||||||
109 | return (temp); never executed: return (temp); | 0 | ||||||||||||
110 | } | - | ||||||||||||
111 | - | |||||||||||||
112 | /* Return a new keymap with the printing characters bound to rl_insert, | - | ||||||||||||
113 | the uppercase Meta characters bound to run their lowercase equivalents, | - | ||||||||||||
114 | and the Meta digits bound to produce numeric arguments. */ | - | ||||||||||||
115 | Keymap | - | ||||||||||||
116 | rl_make_keymap (void) | - | ||||||||||||
117 | { | - | ||||||||||||
118 | register int i; | - | ||||||||||||
119 | Keymap newmap; | - | ||||||||||||
120 | - | |||||||||||||
121 | newmap = rl_make_bare_keymap (); | - | ||||||||||||
122 | - | |||||||||||||
123 | /* All ASCII printing characters are self-inserting. */ | - | ||||||||||||
124 | for (i = ' '; i < 127; i++)
| 0 | ||||||||||||
125 | newmap[i].function = rl_insert; never executed: newmap[i].function = rl_insert; | 0 | ||||||||||||
126 | - | |||||||||||||
127 | newmap[TAB].function = rl_insert; | - | ||||||||||||
128 | newmap[RUBOUT].function = rl_rubout; /* RUBOUT == 127 */ | - | ||||||||||||
129 | newmap[CTRL('H')].function = rl_rubout; | - | ||||||||||||
130 | - | |||||||||||||
131 | #if KEYMAP_SIZE > 128 | - | ||||||||||||
132 | /* Printing characters in ISO Latin-1 and some 8-bit character sets. */ | - | ||||||||||||
133 | for (i = 128; i < 256; i++)
| 0 | ||||||||||||
134 | newmap[i].function = rl_insert; never executed: newmap[i].function = rl_insert; | 0 | ||||||||||||
135 | #endif /* KEYMAP_SIZE > 128 */ | - | ||||||||||||
136 | - | |||||||||||||
137 | return (newmap); never executed: return (newmap); | 0 | ||||||||||||
138 | } | - | ||||||||||||
139 | - | |||||||||||||
140 | /* Free the storage associated with MAP. */ | - | ||||||||||||
141 | void | - | ||||||||||||
142 | rl_discard_keymap (Keymap map) | - | ||||||||||||
143 | { | - | ||||||||||||
144 | int i; | - | ||||||||||||
145 | - | |||||||||||||
146 | if (map == 0)
| 0 | ||||||||||||
147 | return; never executed: return; | 0 | ||||||||||||
148 | - | |||||||||||||
149 | for (i = 0; i < KEYMAP_SIZE; i++)
| 0 | ||||||||||||
150 | { | - | ||||||||||||
151 | switch (map[i].type) | - | ||||||||||||
152 | { | - | ||||||||||||
153 | case ISFUNC: never executed: case 0: | 0 | ||||||||||||
154 | break; never executed: break; | 0 | ||||||||||||
155 | - | |||||||||||||
156 | case ISKMAP: never executed: case 1: | 0 | ||||||||||||
157 | rl_discard_keymap ((Keymap)map[i].function); | - | ||||||||||||
158 | xfree ((char *)map[i].function); | - | ||||||||||||
159 | break; never executed: break; | 0 | ||||||||||||
160 | - | |||||||||||||
161 | case ISMACR: never executed: case 2: | 0 | ||||||||||||
162 | xfree ((char *)map[i].function); | - | ||||||||||||
163 | break; never executed: break; | 0 | ||||||||||||
164 | } | - | ||||||||||||
165 | } never executed: end of block | 0 | ||||||||||||
166 | } never executed: end of block | 0 | ||||||||||||
167 | - | |||||||||||||
168 | /* Convenience function that discards, then frees, MAP. */ | - | ||||||||||||
169 | void | - | ||||||||||||
170 | rl_free_keymap (Keymap map) | - | ||||||||||||
171 | { | - | ||||||||||||
172 | rl_discard_keymap (map); | - | ||||||||||||
173 | xfree ((char *)map); | - | ||||||||||||
174 | } never executed: end of block | 0 | ||||||||||||
Source code | Switch to Preprocessed file |