Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/lib/readline/macro.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||||||||
14 | - | |||||||||||||||||||||||||||||||
15 | - | |||||||||||||||||||||||||||||||
16 | - | |||||||||||||||||||||||||||||||
17 | char *rl_executing_macro = (char *) | - | ||||||||||||||||||||||||||||||
18 | ((void *)0) | - | ||||||||||||||||||||||||||||||
19 | ; | - | ||||||||||||||||||||||||||||||
20 | - | |||||||||||||||||||||||||||||||
21 | - | |||||||||||||||||||||||||||||||
22 | static int executing_macro_index; | - | ||||||||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||||||||
24 | - | |||||||||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||||||||
26 | static char *current_macro = (char *) | - | ||||||||||||||||||||||||||||||
27 | ((void *)0) | - | ||||||||||||||||||||||||||||||
28 | ; | - | ||||||||||||||||||||||||||||||
29 | - | |||||||||||||||||||||||||||||||
30 | - | |||||||||||||||||||||||||||||||
31 | static int current_macro_size; | - | ||||||||||||||||||||||||||||||
32 | - | |||||||||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||||||||
34 | static int current_macro_index; | - | ||||||||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||||||||
38 | struct saved_macro { | - | ||||||||||||||||||||||||||||||
39 | struct saved_macro *next; | - | ||||||||||||||||||||||||||||||
40 | char *string; | - | ||||||||||||||||||||||||||||||
41 | int sindex; | - | ||||||||||||||||||||||||||||||
42 | }; | - | ||||||||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||||||||
45 | static struct saved_macro *macro_list = (struct saved_macro *) | - | ||||||||||||||||||||||||||||||
46 | ((void *)0) | - | ||||||||||||||||||||||||||||||
47 | ; | - | ||||||||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||||||||
49 | static int macro_level = 0; | - | ||||||||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||||||||
53 | void | - | ||||||||||||||||||||||||||||||
54 | _rl_with_macro_input (char *string) | - | ||||||||||||||||||||||||||||||
55 | { | - | ||||||||||||||||||||||||||||||
56 | if (macro_level > 16
| 0 | ||||||||||||||||||||||||||||||
57 | { | - | ||||||||||||||||||||||||||||||
58 | _rl_errmsg ("maximum macro execution nesting level exceeded"); | - | ||||||||||||||||||||||||||||||
59 | _rl_abort_internal (); | - | ||||||||||||||||||||||||||||||
60 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
61 | } | - | ||||||||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||||||||
65 | - | |||||||||||||||||||||||||||||||
66 | _rl_push_executing_macro (); | - | ||||||||||||||||||||||||||||||
67 | rl_executing_macro = string; | - | ||||||||||||||||||||||||||||||
68 | executing_macro_index = 0; | - | ||||||||||||||||||||||||||||||
69 | (rl_readline_state |= (0x0000800)); | - | ||||||||||||||||||||||||||||||
70 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||||||||
74 | int | - | ||||||||||||||||||||||||||||||
75 | _rl_next_macro_key (void) | - | ||||||||||||||||||||||||||||||
76 | { | - | ||||||||||||||||||||||||||||||
77 | int c; | - | ||||||||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||||||||
79 | if (rl_executing_macro == 0
| 0 | ||||||||||||||||||||||||||||||
80 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||||||||
82 | if (rl_executing_macro[executing_macro_index] == 0
| 0 | ||||||||||||||||||||||||||||||
83 | { | - | ||||||||||||||||||||||||||||||
84 | _rl_pop_executing_macro (); | - | ||||||||||||||||||||||||||||||
85 | return never executed: (_rl_next_macro_key ());return (_rl_next_macro_key ()); never executed: return (_rl_next_macro_key ()); | 0 | ||||||||||||||||||||||||||||||
86 | } | - | ||||||||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||||||||
89 | c = rl_executing_macro[executing_macro_index++]; | - | ||||||||||||||||||||||||||||||
90 | if ((
| 0 | ||||||||||||||||||||||||||||||
91 | _rl_pop_executing_macro (); never executed: _rl_pop_executing_macro (); | 0 | ||||||||||||||||||||||||||||||
92 | return never executed: c;return c; never executed: return c; | 0 | ||||||||||||||||||||||||||||||
93 | - | |||||||||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||||||||
97 | - | |||||||||||||||||||||||||||||||
98 | } | - | ||||||||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||||||||
100 | int | - | ||||||||||||||||||||||||||||||
101 | _rl_peek_macro_key (void) | - | ||||||||||||||||||||||||||||||
102 | { | - | ||||||||||||||||||||||||||||||
103 | if (rl_executing_macro == 0
| 0 | ||||||||||||||||||||||||||||||
104 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
105 | if (rl_executing_macro[executing_macro_index] == 0
| 0 | ||||||||||||||||||||||||||||||
106 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
107 | if (rl_executing_macro[executing_macro_index] == 0
| 0 | ||||||||||||||||||||||||||||||
108 | return never executed: (macro_list->string[0]);return (macro_list->string[0]); never executed: return (macro_list->string[0]); | 0 | ||||||||||||||||||||||||||||||
109 | return never executed: (rl_executing_macro[executing_macro_index]);return (rl_executing_macro[executing_macro_index]); never executed: return (rl_executing_macro[executing_macro_index]); | 0 | ||||||||||||||||||||||||||||||
110 | } | - | ||||||||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||||||||
112 | int | - | ||||||||||||||||||||||||||||||
113 | _rl_prev_macro_key (void) | - | ||||||||||||||||||||||||||||||
114 | { | - | ||||||||||||||||||||||||||||||
115 | if (rl_executing_macro == 0
| 0 | ||||||||||||||||||||||||||||||
116 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||||||||
118 | if (executing_macro_index == 0
| 0 | ||||||||||||||||||||||||||||||
119 | return never executed: (0);return (0); never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||||||||
121 | executing_macro_index--; | - | ||||||||||||||||||||||||||||||
122 | return never executed: (rl_executing_macro[executing_macro_index]);return (rl_executing_macro[executing_macro_index]); never executed: return (rl_executing_macro[executing_macro_index]); | 0 | ||||||||||||||||||||||||||||||
123 | } | - | ||||||||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||||||||
126 | void | - | ||||||||||||||||||||||||||||||
127 | _rl_push_executing_macro (void) | - | ||||||||||||||||||||||||||||||
128 | { | - | ||||||||||||||||||||||||||||||
129 | struct saved_macro *saver; | - | ||||||||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||||||||
131 | saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro)); | - | ||||||||||||||||||||||||||||||
132 | saver->next = macro_list; | - | ||||||||||||||||||||||||||||||
133 | saver->sindex = executing_macro_index; | - | ||||||||||||||||||||||||||||||
134 | saver->string = rl_executing_macro; | - | ||||||||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||||||||
136 | macro_list = saver; | - | ||||||||||||||||||||||||||||||
137 | - | |||||||||||||||||||||||||||||||
138 | macro_level++; | - | ||||||||||||||||||||||||||||||
139 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||||||||
142 | - | |||||||||||||||||||||||||||||||
143 | void | - | ||||||||||||||||||||||||||||||
144 | _rl_pop_executing_macro (void) | - | ||||||||||||||||||||||||||||||
145 | { | - | ||||||||||||||||||||||||||||||
146 | struct saved_macro *macro; | - | ||||||||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||||||||
148 | if (rl_executing_macro
never executed: free (rl_executing_macro); | 0 | ||||||||||||||||||||||||||||||
149 | rl_executing_macro = (char *) | - | ||||||||||||||||||||||||||||||
150 | ((void *)0) | - | ||||||||||||||||||||||||||||||
151 | ; | - | ||||||||||||||||||||||||||||||
152 | executing_macro_index = 0; | - | ||||||||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||||||||
154 | if (macro_list
| 0 | ||||||||||||||||||||||||||||||
155 | { | - | ||||||||||||||||||||||||||||||
156 | macro = macro_list; | - | ||||||||||||||||||||||||||||||
157 | rl_executing_macro = macro_list->string; | - | ||||||||||||||||||||||||||||||
158 | executing_macro_index = macro_list->sindex; | - | ||||||||||||||||||||||||||||||
159 | macro_list = macro_list->next; | - | ||||||||||||||||||||||||||||||
160 | xfree (macro); | - | ||||||||||||||||||||||||||||||
161 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
162 | - | |||||||||||||||||||||||||||||||
163 | macro_level--; | - | ||||||||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||||||||
165 | if (rl_executing_macro == 0
| 0 | ||||||||||||||||||||||||||||||
166 | ( never executed: rl_readline_state &= ~(0x0000800));(rl_readline_state &= ~(0x0000800)); never executed: (rl_readline_state &= ~(0x0000800)); | 0 | ||||||||||||||||||||||||||||||
167 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||||||||
169 | - | |||||||||||||||||||||||||||||||
170 | void | - | ||||||||||||||||||||||||||||||
171 | _rl_add_macro_char (int c) | - | ||||||||||||||||||||||||||||||
172 | { | - | ||||||||||||||||||||||||||||||
173 | if (current_macro_index + 1 >= current_macro_size
| 0 | ||||||||||||||||||||||||||||||
174 | { | - | ||||||||||||||||||||||||||||||
175 | if (current_macro == 0
| 0 | ||||||||||||||||||||||||||||||
176 | current_macro = (char *)xmalloc (current_macro_size = 25); never executed: current_macro = (char *)xmalloc (current_macro_size = 25); | 0 | ||||||||||||||||||||||||||||||
177 | else | - | ||||||||||||||||||||||||||||||
178 | current_macro = (char *)xrealloc (current_macro, current_macro_size += 25); never executed: current_macro = (char *)xrealloc (current_macro, current_macro_size += 25); | 0 | ||||||||||||||||||||||||||||||
179 | } | - | ||||||||||||||||||||||||||||||
180 | - | |||||||||||||||||||||||||||||||
181 | current_macro[current_macro_index++] = c; | - | ||||||||||||||||||||||||||||||
182 | current_macro[current_macro_index] = '\0'; | - | ||||||||||||||||||||||||||||||
183 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
184 | - | |||||||||||||||||||||||||||||||
185 | void | - | ||||||||||||||||||||||||||||||
186 | _rl_kill_kbd_macro (void) | - | ||||||||||||||||||||||||||||||
187 | { | - | ||||||||||||||||||||||||||||||
188 | if (current_macro
| 0 | ||||||||||||||||||||||||||||||
189 | { | - | ||||||||||||||||||||||||||||||
190 | xfree (current_macro); | - | ||||||||||||||||||||||||||||||
191 | current_macro = (char *) | - | ||||||||||||||||||||||||||||||
192 | ((void *)0) | - | ||||||||||||||||||||||||||||||
193 | ; | - | ||||||||||||||||||||||||||||||
194 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
195 | current_macro_size = current_macro_index = 0; | - | ||||||||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||||||||
197 | if (rl_executing_macro
never executed: free (rl_executing_macro); | 0 | ||||||||||||||||||||||||||||||
198 | rl_executing_macro = (char *) | - | ||||||||||||||||||||||||||||||
199 | ((void *)0) | - | ||||||||||||||||||||||||||||||
200 | ; | - | ||||||||||||||||||||||||||||||
201 | executing_macro_index = 0; | - | ||||||||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||||||||
203 | (rl_readline_state &= ~(0x0001000)); | - | ||||||||||||||||||||||||||||||
204 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||||||||
207 | - | |||||||||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||||||||
209 | - | |||||||||||||||||||||||||||||||
210 | - | |||||||||||||||||||||||||||||||
211 | - | |||||||||||||||||||||||||||||||
212 | int | - | ||||||||||||||||||||||||||||||
213 | rl_start_kbd_macro (int ignore1, int ignore2) | - | ||||||||||||||||||||||||||||||
214 | { | - | ||||||||||||||||||||||||||||||
215 | if ((
| 0 | ||||||||||||||||||||||||||||||
216 | { | - | ||||||||||||||||||||||||||||||
217 | _rl_abort_internal (); | - | ||||||||||||||||||||||||||||||
218 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
219 | } | - | ||||||||||||||||||||||||||||||
220 | - | |||||||||||||||||||||||||||||||
221 | if (rl_explicit_arg
| 0 | ||||||||||||||||||||||||||||||
222 | { | - | ||||||||||||||||||||||||||||||
223 | if (current_macro
| 0 | ||||||||||||||||||||||||||||||
224 | _rl_with_macro_input (strcpy ((char *)xmalloc (1 + strlen (current_macro)), (current_macro))); never executed: _rl_with_macro_input (strcpy ((char *)xmalloc (1 + strlen (current_macro)), (current_macro))); | 0 | ||||||||||||||||||||||||||||||
225 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
226 | else | - | ||||||||||||||||||||||||||||||
227 | current_macro_index = 0; never executed: current_macro_index = 0; | 0 | ||||||||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||||||||
229 | (rl_readline_state |= (0x0001000)); | - | ||||||||||||||||||||||||||||||
230 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
231 | } | - | ||||||||||||||||||||||||||||||
232 | - | |||||||||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||||||||
236 | int | - | ||||||||||||||||||||||||||||||
237 | rl_end_kbd_macro (int count, int ignore) | - | ||||||||||||||||||||||||||||||
238 | { | - | ||||||||||||||||||||||||||||||
239 | if ((
| 0 | ||||||||||||||||||||||||||||||
240 | { | - | ||||||||||||||||||||||||||||||
241 | _rl_abort_internal (); | - | ||||||||||||||||||||||||||||||
242 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
243 | } | - | ||||||||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||||||||
245 | current_macro_index -= rl_key_sequence_length; | - | ||||||||||||||||||||||||||||||
246 | current_macro[current_macro_index] = '\0'; | - | ||||||||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||||||||
248 | (rl_readline_state &= ~(0x0001000)); | - | ||||||||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||||||||
250 | return never executed: (rl_call_last_kbd_macro (--count, 0));return (rl_call_last_kbd_macro (--count, 0)); never executed: return (rl_call_last_kbd_macro (--count, 0)); | 0 | ||||||||||||||||||||||||||||||
251 | } | - | ||||||||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||||||||
253 | - | |||||||||||||||||||||||||||||||
254 | - | |||||||||||||||||||||||||||||||
255 | int | - | ||||||||||||||||||||||||||||||
256 | rl_call_last_kbd_macro (int count, int ignore) | - | ||||||||||||||||||||||||||||||
257 | { | - | ||||||||||||||||||||||||||||||
258 | if (current_macro == 0
| 0 | ||||||||||||||||||||||||||||||
259 | _rl_abort_internal (); never executed: _rl_abort_internal (); | 0 | ||||||||||||||||||||||||||||||
260 | - | |||||||||||||||||||||||||||||||
261 | if ((
| 0 | ||||||||||||||||||||||||||||||
262 | { | - | ||||||||||||||||||||||||||||||
263 | rl_ding (); | - | ||||||||||||||||||||||||||||||
264 | current_macro[--current_macro_index] = '\0'; | - | ||||||||||||||||||||||||||||||
265 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
266 | } | - | ||||||||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||||||||
268 | while (count--
| 0 | ||||||||||||||||||||||||||||||
269 | _rl_with_macro_input (strcpy ((char *)xmalloc (1 + strlen (current_macro)), (current_macro))); never executed: _rl_with_macro_input (strcpy ((char *)xmalloc (1 + strlen (current_macro)), (current_macro))); | 0 | ||||||||||||||||||||||||||||||
270 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
271 | } | - | ||||||||||||||||||||||||||||||
272 | - | |||||||||||||||||||||||||||||||
273 | int | - | ||||||||||||||||||||||||||||||
274 | rl_print_last_kbd_macro (int count, int ignore) | - | ||||||||||||||||||||||||||||||
275 | { | - | ||||||||||||||||||||||||||||||
276 | char *m; | - | ||||||||||||||||||||||||||||||
277 | - | |||||||||||||||||||||||||||||||
278 | if (current_macro == 0
| 0 | ||||||||||||||||||||||||||||||
279 | { | - | ||||||||||||||||||||||||||||||
280 | rl_ding (); | - | ||||||||||||||||||||||||||||||
281 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
282 | } | - | ||||||||||||||||||||||||||||||
283 | m = _rl_untranslate_macro_value (current_macro, 1); | - | ||||||||||||||||||||||||||||||
284 | rl_crlf (); | - | ||||||||||||||||||||||||||||||
285 | printf ("%s", m); | - | ||||||||||||||||||||||||||||||
286 | fflush ( | - | ||||||||||||||||||||||||||||||
287 | stdout | - | ||||||||||||||||||||||||||||||
288 | ); | - | ||||||||||||||||||||||||||||||
289 | rl_crlf (); | - | ||||||||||||||||||||||||||||||
290 | if (m
never executed: free (m); | 0 | ||||||||||||||||||||||||||||||
291 | rl_forced_update_display (); | - | ||||||||||||||||||||||||||||||
292 | rl_display_fixed = 1; | - | ||||||||||||||||||||||||||||||
293 | - | |||||||||||||||||||||||||||||||
294 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
295 | } | - | ||||||||||||||||||||||||||||||
296 | - | |||||||||||||||||||||||||||||||
297 | void | - | ||||||||||||||||||||||||||||||
298 | rl_push_macro_input (char *macro) | - | ||||||||||||||||||||||||||||||
299 | { | - | ||||||||||||||||||||||||||||||
300 | _rl_with_macro_input (macro); | - | ||||||||||||||||||||||||||||||
301 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |