OpenCoverage

history.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/lib/readline/history.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9static char *hist_inittime (void);-
10static HIST_ENTRY **the_history = (HIST_ENTRY **)-
11 ((void *)0)-
12 ;-
13-
14-
15-
16static int history_stifled;-
17-
18-
19static int history_size;-
20-
21-
22-
23int history_max_entries;-
24int max_input_history;-
25-
26-
27-
28int history_offset;-
29-
30-
31int history_length;-
32-
33-
34int history_base = 1;-
35-
36-
37HISTORY_STATE *-
38history_get_history_state (void)-
39{-
40 HISTORY_STATE *state;-
41-
42 state = (HISTORY_STATE *)xmalloc (sizeof (HISTORY_STATE));-
43 state->entries = the_history;-
44 state->offset = history_offset;-
45 state->length = history_length;-
46 state->size = history_size;-
47 state->flags = 0;-
48 if (history_stifled
history_stifledDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
49 state->flags |= 0x01;
never executed: state->flags |= 0x01;
0
50-
51 return
never executed: return (state);
(state);
never executed: return (state);
0
52}-
53-
54-
55void-
56history_set_history_state (HISTORY_STATE *state)-
57{-
58 the_history = state->entries;-
59 history_offset = state->offset;-
60 history_length = state->length;-
61 history_size = state->size;-
62 if (state->flags & 0x01
state->flags & 0x01Description
TRUEnever evaluated
FALSEnever evaluated
)
0
63 history_stifled = 1;
never executed: history_stifled = 1;
0
64}
never executed: end of block
0
65-
66-
67-
68void-
69using_history (void)-
70{-
71 history_offset = history_length;-
72}
executed 1028 times by 1 test: end of block
Executed by:
  • Self test
1028
73-
74-
75-
76-
77int-
78history_total_bytes (void)-
79{-
80 register int i, result;-
81-
82 for (i = result = 0; the_history
the_historyDescription
TRUEnever evaluated
FALSEnever evaluated
&& the_history[i]
the_history[i]Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
83 result += (strlen ((the_history[i])->line) + strlen ((the_history[i])->timestamp));
never executed: result += (strlen ((the_history[i])->line) + strlen ((the_history[i])->timestamp));
0
84-
85 return
never executed: return (result);
(result);
never executed: return (result);
0
86}-
87-
88-
89-
90int-
91where_history (void)-
92{-
93 return
executed 58 times by 1 test: return (history_offset);
Executed by:
  • Self test
(history_offset);
executed 58 times by 1 test: return (history_offset);
Executed by:
  • Self test
58
94}-
95-
96-
97-
98int-
99history_set_pos (int pos)-
100{-
101 if (pos > history_length
pos > history_lengthDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
|| pos < 0
pos < 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
|| !the_history
!the_historyDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
)
0-5
102 return
never executed: return (0);
(0);
never executed: return (0);
0
103 history_offset = pos;-
104 return
executed 5 times by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 5 times by 1 test: return (1);
Executed by:
  • Self test
5
105}-
106-
107-
108-
109-
110HIST_ENTRY **-
111history_list (void)-
112{-
113 return
executed 53 times by 1 test: return (the_history);
Executed by:
  • Self test
(the_history);
executed 53 times by 1 test: return (the_history);
Executed by:
  • Self test
53
114}-
115-
116-
117-
118HIST_ENTRY *-
119current_history (void)-
120{-
121 return
executed 11 times by 1 test: return ((history_offset == history_length) || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[history_offset];
Executed by:
  • Self test
((history_offset == history_length) || the_history == 0)
executed 11 times by 1 test: return ((history_offset == history_length) || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[history_offset];
Executed by:
  • Self test
11
122 ? (HIST_ENTRY *)
executed 11 times by 1 test: return ((history_offset == history_length) || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[history_offset];
Executed by:
  • Self test
11
123 ((void *)0)
executed 11 times by 1 test: return ((history_offset == history_length) || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[history_offset];
Executed by:
  • Self test
11
124
executed 11 times by 1 test: return ((history_offset == history_length) || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[history_offset];
Executed by:
  • Self test
11
125 : the_history[history_offset];
executed 11 times by 1 test: return ((history_offset == history_length) || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[history_offset];
Executed by:
  • Self test
11
126}-
127-
128-
129-
130-
131HIST_ENTRY *-
132previous_history (void)-
133{-
134 return
executed 295 times by 1 test: return history_offset ? the_history[--history_offset] : (HIST_ENTRY *) ((void *)0) ;
Executed by:
  • Self test
history_offset ? the_history[--history_offset] : (HIST_ENTRY *)
executed 295 times by 1 test: return history_offset ? the_history[--history_offset] : (HIST_ENTRY *) ((void *)0) ;
Executed by:
  • Self test
295
135 ((void *)0)
executed 295 times by 1 test: return history_offset ? the_history[--history_offset] : (HIST_ENTRY *) ((void *)0) ;
Executed by:
  • Self test
295
136 ;
executed 295 times by 1 test: return history_offset ? the_history[--history_offset] : (HIST_ENTRY *) ((void *)0) ;
Executed by:
  • Self test
295
137}-
138-
139-
140-
141-
142HIST_ENTRY *-
143next_history (void)-
144{-
145 return
never executed: return (history_offset == history_length) ? (HIST_ENTRY *) ((void *)0) : the_history[++history_offset];
(history_offset == history_length) ? (HIST_ENTRY *)
never executed: return (history_offset == history_length) ? (HIST_ENTRY *) ((void *)0) : the_history[++history_offset];
0
146 ((void *)0)
never executed: return (history_offset == history_length) ? (HIST_ENTRY *) ((void *)0) : the_history[++history_offset];
0
147 : the_history[++history_offset];
never executed: return (history_offset == history_length) ? (HIST_ENTRY *) ((void *)0) : the_history[++history_offset];
0
148}-
149-
150-
151-
152HIST_ENTRY *-
153history_get (int offset)-
154{-
155 int local_index;-
156-
157 local_index = offset - history_base;-
158 return
executed 126 times by 1 test: return (local_index >= history_length || local_index < 0 || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[local_index];
Executed by:
  • Self test
(local_index >= history_length || local_index < 0 || the_history == 0)
executed 126 times by 1 test: return (local_index >= history_length || local_index < 0 || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[local_index];
Executed by:
  • Self test
126
159 ? (HIST_ENTRY *)
executed 126 times by 1 test: return (local_index >= history_length || local_index < 0 || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[local_index];
Executed by:
  • Self test
126
160 ((void *)0)
executed 126 times by 1 test: return (local_index >= history_length || local_index < 0 || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[local_index];
Executed by:
  • Self test
126
161
executed 126 times by 1 test: return (local_index >= history_length || local_index < 0 || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[local_index];
Executed by:
  • Self test
126
162 : the_history[local_index];
executed 126 times by 1 test: return (local_index >= history_length || local_index < 0 || the_history == 0) ? (HIST_ENTRY *) ((void *)0) : the_history[local_index];
Executed by:
  • Self test
126
163}-
164-
165HIST_ENTRY *-
166alloc_history_entry (char *string, char *ts)-
167{-
168 HIST_ENTRY *temp;-
169-
170 temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));-
171-
172 temp->line = string
stringDescription
TRUEevaluated 447 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
? strcpy (xmalloc (1 + strlen (string)), (string)) : string;
0-447
173 temp->data = (char *)-
174 ((void *)0)-
175 ;-
176 temp->timestamp = ts;-
177-
178 return
executed 447 times by 1 test: return temp;
Executed by:
  • Self test
temp;
executed 447 times by 1 test: return temp;
Executed by:
  • Self test
447
179}-
180-
181time_t-
182history_get_time (HIST_ENTRY *hist)-
183{-
184 char *ts;-
185 time_t t;-
186-
187 if (hist == 0
hist == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| hist->timestamp == 0
hist->timestamp == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
188 return
never executed: return 0;
0;
never executed: return 0;
0
189 ts = hist->timestamp;-
190 if (ts[0] != history_comment_char
ts[0] != history_comment_charDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
191 return
never executed: return 0;
0;
never executed: return 0;
0
192 -
193 (*__errno_location ()) -
194 = 0;-
195 t = (time_t) strtol (ts + 1, (char **)-
196 ((void *)0)-
197 , 10);-
198 if (-
199 (*
(*__errno_location ()) == 34Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 34Description
TRUEnever evaluated
FALSEnever evaluated
0
200 ==
(*__errno_location ()) == 34Description
TRUEnever evaluated
FALSEnever evaluated
0
201 34
(*__errno_location ()) == 34Description
TRUEnever evaluated
FALSEnever evaluated
0
202 )-
203 return
never executed: return (time_t)0;
(time_t)0;
never executed: return (time_t)0;
0
204 return
never executed: return t;
t;
never executed: return t;
0
205}-
206-
207static char *-
208hist_inittime (void)-
209{-
210 time_t t;-
211 char ts[64], *ret;-
212-
213 t = (time_t) time ((time_t *)0);-
214-
215 snprintf (ts, sizeof (ts) - 1, "X%lu", (unsigned long) t);-
216-
217-
218-
219 ret = strcpy (xmalloc (1 + strlen (ts)), (ts));-
220 ret[0] = history_comment_char;-
221-
222 return
executed 447 times by 1 test: return ret;
Executed by:
  • Self test
ret;
executed 447 times by 1 test: return ret;
Executed by:
  • Self test
447
223}-
224-
225-
226-
227void-
228add_history (const char *string)-
229{-
230 HIST_ENTRY *temp;-
231 int new_length;-
232-
233 if (history_stifled
history_stifledDescription
TRUEevaluated 426 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
&& (
(history_lengt...y_max_entries)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 417 times by 1 test
Evaluated by:
  • Self test
history_length == history_max_entries)
(history_lengt...y_max_entries)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 417 times by 1 test
Evaluated by:
  • Self test
)
9-426
234 {-
235 register int i;-
236-
237-
238-
239 if (history_length == 0
history_length == 0Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
)
0-9
240 return;
never executed: return;
0
241-
242-
243 if (the_history[0]
the_history[0]Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-9
244 (
executed 9 times by 1 test: (void) free_history_entry (the_history[0]);
Executed by:
  • Self test
void) free_history_entry (the_history[0]);
executed 9 times by 1 test: (void) free_history_entry (the_history[0]);
Executed by:
  • Self test
9
245-
246-
247-
248 memmove (the_history, the_history + 1, history_length * sizeof (HIST_ENTRY *));-
249-
250 new_length = history_length;-
251 history_base++;-
252 }
executed 9 times by 1 test: end of block
Executed by:
  • Self test
9
253 else-
254 {-
255 if (history_size == 0
history_size == 0Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 405 times by 1 test
Evaluated by:
  • Self test
)
33-405
256 {-
257 if (history_stifled
history_stifledDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& history_max_entries > 0
history_max_entries > 0Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-33
258 history_size = (
(history_max_entries > 8192)Description
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
history_max_entries > 8192)
(history_max_entries > 8192)Description
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
executed 33 times by 1 test: history_size = (history_max_entries > 8192) ? 8192 : history_max_entries + 2;
Executed by:
  • Self test
0-33
259 ? 8192
executed 33 times by 1 test: history_size = (history_max_entries > 8192) ? 8192 : history_max_entries + 2;
Executed by:
  • Self test
33
260 : history_max_entries + 2;
executed 33 times by 1 test: history_size = (history_max_entries > 8192) ? 8192 : history_max_entries + 2;
Executed by:
  • Self test
33
261 else-
262 history_size = 502;
never executed: history_size = 502;
0
263 the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *));-
264 new_length = 1;-
265 }
executed 33 times by 1 test: end of block
Executed by:
  • Self test
33
266 else-
267 {-
268 if (history_length == (history_size - 1)
history_length...tory_size - 1)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 404 times by 1 test
Evaluated by:
  • Self test
)
1-404
269 {-
270 history_size += 50;-
271 the_history = (HIST_ENTRY **)-
272 xrealloc (the_history, history_size * sizeof (HIST_ENTRY *));-
273 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
274 new_length = history_length + 1;-
275 }
executed 405 times by 1 test: end of block
Executed by:
  • Self test
405
276 }-
277-
278 temp = alloc_history_entry ((char *)string, hist_inittime ());-
279-
280 the_history[new_length] = (HIST_ENTRY *)-
281 ((void *)0)-
282 ;-
283 the_history[new_length - 1] = temp;-
284 history_length = new_length;-
285}
executed 447 times by 1 test: end of block
Executed by:
  • Self test
447
286-
287-
288void-
289add_history_time (const char *string)-
290{-
291 HIST_ENTRY *hs;-
292-
293 if (string == 0
string == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| history_length < 1
history_length < 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
294 return;
never executed: return;
0
295 hs = the_history[history_length - 1];-
296 if (hs->timestamp
hs->timestampDescription
TRUEnever evaluated
FALSEnever evaluated
) free (hs->timestamp);
never executed: free (hs->timestamp);
0
297 hs->timestamp = strcpy (xmalloc (1 + strlen (string)), (string));-
298}
never executed: end of block
0
299-
300-
301-
302histdata_t-
303free_history_entry (HIST_ENTRY *hist)-
304{-
305 histdata_t x;-
306-
307 if (hist == 0
hist == 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
)
0-64
308 return
never executed: return ((histdata_t) 0);
((histdata_t) 0);
never executed: return ((histdata_t) 0);
0
309 if (hist->line
hist->lineDescription
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
) free (hist->line);
executed 64 times by 1 test: free (hist->line);
Executed by:
  • Self test
0-64
310 if (hist->timestamp
hist->timestampDescription
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
) free (hist->timestamp);
executed 64 times by 1 test: free (hist->timestamp);
Executed by:
  • Self test
0-64
311 x = hist->data;-
312 xfree (hist);-
313 return
executed 64 times by 1 test: return (x);
Executed by:
  • Self test
(x);
executed 64 times by 1 test: return (x);
Executed by:
  • Self test
64
314}-
315-
316HIST_ENTRY *-
317copy_history_entry (HIST_ENTRY *hist)-
318{-
319 HIST_ENTRY *ret;-
320 char *ts;-
321-
322 if (hist == 0
hist == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
323 return
never executed: return hist;
hist;
never executed: return hist;
0
324-
325 ret = alloc_history_entry (hist->line, (char *)-
326 ((void *)0)-
327 );-
328-
329 ts = hist->timestamp
hist->timestampDescription
TRUEnever evaluated
FALSEnever evaluated
? strcpy (xmalloc (1 + strlen (hist->timestamp)), (hist->timestamp)) : hist->timestamp;
0
330 ret->timestamp = ts;-
331-
332 ret->data = hist->data;-
333-
334 return
never executed: return ret;
ret;
never executed: return ret;
0
335}-
336-
337-
338-
339-
340HIST_ENTRY *-
341replace_history_entry (int which, const char *line, histdata_t data)-
342{-
343 HIST_ENTRY *temp, *old_value;-
344-
345 if (which < 0
which < 0Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
|| which >= history_length
which >= history_lengthDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
)
0-9
346 return
never executed: return ((HIST_ENTRY *) ((void *)0) );
((HIST_ENTRY *)
never executed: return ((HIST_ENTRY *) ((void *)0) );
0
347 ((void *)0)
never executed: return ((HIST_ENTRY *) ((void *)0) );
0
348 );
never executed: return ((HIST_ENTRY *) ((void *)0) );
0
349-
350 temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));-
351 old_value = the_history[which];-
352-
353 temp->line = strcpy (xmalloc (1 + strlen (line)), (line));-
354 temp->data = data;-
355 temp->timestamp = strcpy (xmalloc (1 + strlen (old_value->timestamp)), (old_value->timestamp));-
356 the_history[which] = temp;-
357-
358 return
executed 9 times by 1 test: return (old_value);
Executed by:
  • Self test
(old_value);
executed 9 times by 1 test: return (old_value);
Executed by:
  • Self test
9
359}-
360-
361-
362-
363-
364void-
365_hs_append_history_line (int which, const char *line)-
366{-
367 HIST_ENTRY *hent;-
368 size_t newlen, curlen, minlen;-
369 char *newline;-
370-
371 hent = the_history[which];-
372 curlen = strlen (hent->line);-
373 minlen = curlen + strlen (line) + 2;-
374 if (curlen > 256
curlen > 256Description
TRUEnever evaluated
FALSEnever evaluated
)
0
375 {-
376 newlen = 512;-
377-
378 while (newlen < minlen
newlen < minlenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
379 newlen <<= 1;
never executed: newlen <<= 1;
0
380 }
never executed: end of block
0
381 else-
382 newlen = minlen;
never executed: newlen = minlen;
0
383-
384-
385 newline = realloc (hent->line, newlen);-
386 if (newline
newlineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
387 {-
388 hent->line = newline;-
389 hent->line[curlen++] = '\n';-
390 strcpy (hent->line + curlen, line);-
391 }
never executed: end of block
0
392}
never executed: end of block
0
393-
394-
395-
396-
397-
398-
399-
400void-
401_hs_replace_history_data (int which, histdata_t *old, histdata_t *new)-
402{-
403 HIST_ENTRY *entry;-
404 register int i, last;-
405-
406 if (which < -2
which < -2Description
TRUEnever evaluated
FALSEnever evaluated
|| which >= history_length
which >= history_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
|| history_length == 0
history_length == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| the_history == 0
the_history == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
407 return;
never executed: return;
0
408-
409 if (which >= 0
which >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
410 {-
411 entry = the_history[which];-
412 if (entry
entryDescription
TRUEnever evaluated
FALSEnever evaluated
&& entry->data == old
entry->data == oldDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
413 entry->data = new;
never executed: entry->data = new;
0
414 return;
never executed: return;
0
415 }-
416-
417 last = -1;-
418 for (i = 0; i < history_length
i < history_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
419 {-
420 entry = the_history[i];-
421 if (entry == 0
entry == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
422 continue;
never executed: continue;
0
423 if (entry->data == old
entry->data == oldDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
424 {-
425 last = i;-
426 if (which == -1
which == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
427 entry->data = new;
never executed: entry->data = new;
0
428 }
never executed: end of block
0
429 }
never executed: end of block
0
430 if (which == -2
which == -2Description
TRUEnever evaluated
FALSEnever evaluated
&& last >= 0
last >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
431 {-
432 entry = the_history[last];-
433 entry->data = new;-
434 }
never executed: end of block
0
435}
never executed: end of block
0
436-
437-
438-
439-
440HIST_ENTRY *-
441remove_history (int which)-
442{-
443 HIST_ENTRY *return_value;-
444 register int i;-
445-
446 int nentries;-
447 HIST_ENTRY **start, **end;-
448-
449-
450 if (which < 0
which < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
|| which >= history_length
which >= history_lengthDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
|| history_length == 0
history_length == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
|| the_history == 0
the_history == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
0-3
451 return
never executed: return ((HIST_ENTRY *) ((void *)0) );
((HIST_ENTRY *)
never executed: return ((HIST_ENTRY *) ((void *)0) );
0
452 ((void *)0)
never executed: return ((HIST_ENTRY *) ((void *)0) );
0
453 );
never executed: return ((HIST_ENTRY *) ((void *)0) );
0
454-
455 return_value = the_history[which];-
456-
457-
458-
459-
460 nentries = history_length - which;-
461 start = the_history + which;-
462 end = start + 1;-
463 memmove (start, end, nentries * sizeof (HIST_ENTRY *));-
464-
465-
466-
467-
468-
469 history_length--;-
470-
471 return
executed 3 times by 1 test: return (return_value);
Executed by:
  • Self test
(return_value);
executed 3 times by 1 test: return (return_value);
Executed by:
  • Self test
3
472}-
473-
474HIST_ENTRY **-
475remove_history_range (int first, int last)-
476{-
477 HIST_ENTRY **return_value;-
478 register int i;-
479 int nentries;-
480 HIST_ENTRY **start, **end;-
481-
482 if (the_history == 0
the_history == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
|| history_length == 0
history_length == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
483 return
never executed: return ((HIST_ENTRY **) ((void *)0) );
((HIST_ENTRY **)
never executed: return ((HIST_ENTRY **) ((void *)0) );
0
484 ((void *)0)
never executed: return ((HIST_ENTRY **) ((void *)0) );
0
485 );
never executed: return ((HIST_ENTRY **) ((void *)0) );
0
486 if (first < 0
first < 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
|| first >= history_length
first >= history_lengthDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
|| last < 0
last < 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
|| last >= history_length
last >= history_lengthDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
487 return
never executed: return ((HIST_ENTRY **) ((void *)0) );
((HIST_ENTRY **)
never executed: return ((HIST_ENTRY **) ((void *)0) );
0
488 ((void *)0)
never executed: return ((HIST_ENTRY **) ((void *)0) );
0
489 );
never executed: return ((HIST_ENTRY **) ((void *)0) );
0
490 if (first > last
first > lastDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
491 return
never executed: return (HIST_ENTRY **) ((void *)0) ;
(HIST_ENTRY **)
never executed: return (HIST_ENTRY **) ((void *)0) ;
0
492 ((void *)0)
never executed: return (HIST_ENTRY **) ((void *)0) ;
0
493 ;
never executed: return (HIST_ENTRY **) ((void *)0) ;
0
494-
495 nentries = last - first + 1;-
496 return_value = (HIST_ENTRY **)malloc ((nentries + 1) * sizeof (HIST_ENTRY *));-
497 if (return_value == 0
return_value == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
498 return
never executed: return return_value;
return_value;
never executed: return return_value;
0
499-
500-
501 for (i = first ; i <= last
i <= lastDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
; i++)
2-8
502 return_value[i - first] = the_history[i];
executed 8 times by 1 test: return_value[i - first] = the_history[i];
Executed by:
  • Self test
8
503 return_value[i - first] = (HIST_ENTRY *)-
504 ((void *)0)-
505 ;-
506-
507-
508-
509 start = the_history + first;-
510 end = the_history + last + 1;-
511 memmove (start, end, (history_length - last) * sizeof (HIST_ENTRY *));-
512-
513 history_length -= nentries;-
514-
515 return
executed 2 times by 1 test: return (return_value);
Executed by:
  • Self test
(return_value);
executed 2 times by 1 test: return (return_value);
Executed by:
  • Self test
2
516}-
517-
518-
519void-
520stifle_history (int max)-
521{-
522 register int i, j;-
523-
524 if (max < 0
max < 0Description
TRUEnever evaluated
FALSEevaluated 39 times by 1 test
Evaluated by:
  • Self test
)
0-39
525 max = 0;
never executed: max = 0;
0
526-
527 if (history_length > max
history_length > maxDescription
TRUEnever evaluated
FALSEevaluated 39 times by 1 test
Evaluated by:
  • Self test
)
0-39
528 {-
529-
530 for (i = 0, j = history_length - max; i < j
i < jDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
531 free_history_entry (the_history[i]);
never executed: free_history_entry (the_history[i]);
0
532-
533 history_base = i;-
534 for (j = 0, i = history_length - max; j < max
j < maxDescription
TRUEnever evaluated
FALSEnever evaluated
; i++, j++)
0
535 the_history[j] = the_history[i];
never executed: the_history[j] = the_history[i];
0
536 the_history[j] = (HIST_ENTRY *)-
537 ((void *)0)-
538 ;-
539 history_length = j;-
540 }
never executed: end of block
0
541-
542 history_stifled = 1;-
543 max_input_history = history_max_entries = max;-
544}
executed 39 times by 1 test: end of block
Executed by:
  • Self test
39
545-
546-
547-
548-
549int-
550unstifle_history (void)-
551{-
552 if (history_stifled
history_stifledDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1
553 {-
554 history_stifled = 0;-
555 return
executed 1 time by 1 test: return (history_max_entries);
Executed by:
  • Self test
(history_max_entries);
executed 1 time by 1 test: return (history_max_entries);
Executed by:
  • Self test
1
556 }-
557 else-
558 return
executed 1 time by 1 test: return (-history_max_entries);
Executed by:
  • Self test
(-history_max_entries);
executed 1 time by 1 test: return (-history_max_entries);
Executed by:
  • Self test
1
559}-
560-
561int-
562history_is_stifled (void)-
563{-
564 return
never executed: return (history_stifled);
(history_stifled);
never executed: return (history_stifled);
0
565}-
566-
567void-
568clear_history (void)-
569{-
570 register int i;-
571-
572-
573 for (i = 0; i < history_length
i < history_lengthDescription
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
; i++)
6-35
574 {-
575 free_history_entry (the_history[i]);-
576 the_history[i] = (HIST_ENTRY *)-
577 ((void *)0)-
578 ;-
579 }
executed 35 times by 1 test: end of block
Executed by:
  • Self test
35
580-
581 history_offset = history_length = 0;-
582 history_base = 1;-
583}
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2