OpenCoverage

histfile.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/lib/readline/histfile.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
19-
20-
21-
22-
23-
24-
25-
26-
27-
28-
29extern void _hs_append_history_line (int, const char *);-
30-
31-
32int history_file_version = 1;-
33-
34-
35int history_write_timestamps = 0;-
36-
37-
38-
39-
40int history_multiline_entries = 0;-
41-
42-
43-
44-
45int history_lines_read_from_file = 0;-
46-
47-
48-
49-
50int history_lines_written_to_file = 0;-
51-
52-
53-
54-
55-
56static char *history_backupfile (const char *);-
57static char *history_tempfile (const char *);-
58static int histfile_backup (const char *, const char *);-
59static int histfile_restore (const char *, const char *);-
60-
61-
62-
63-
64static char *-
65history_filename (const char *filename)-
66{-
67 char *return_val;-
68 const char *home;-
69 int home_len;-
70-
71 return_val = filename
filenameDescription
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
? strcpy (xmalloc (1 + strlen (filename)), (filename)) : (char *)
15-35
72 ((void *)0)-
73 ;-
74-
75 if (return_val
return_valDescription
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
)
15-35
76 return
executed 35 times by 1 test: return (return_val);
Executed by:
  • Self test
(return_val);
executed 35 times by 1 test: return (return_val);
Executed by:
  • Self test
35
77-
78 home = sh_get_env_value ("HOME");-
79-
80-
81-
82-
83-
84 if (home == 0
home == 0Description
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
)
0-15
85 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
86 ((void *)0)
never executed: return ( ((void *)0) );
0
87 );
never executed: return ( ((void *)0) );
0
88 else-
89 home_len = strlen (home);
executed 15 times by 1 test: home_len = strlen (home);
Executed by:
  • Self test
15
90-
91 return_val = (char *)xmalloc (2 + home_len + 8);-
92 strcpy (return_val, home);-
93 return_val[home_len] = '/';-
94-
95-
96-
97 strcpy (return_val + home_len + 1, ".history");-
98-
99-
100 return
executed 15 times by 1 test: return (return_val);
Executed by:
  • Self test
(return_val);
executed 15 times by 1 test: return (return_val);
Executed by:
  • Self test
15
101}-
102-
103static char *-
104history_backupfile (const char *filename)-
105{-
106 const char *fn;-
107 char *ret, linkbuf[-
108 4096-
109 +1];-
110 size_t len;-
111 ssize_t n;-
112 struct stat fs;-
113-
114 fn = filename;-
115-
116-
117-
118 if ((
(n = readlink ...buf) - 1)) > 0Description
TRUEnever evaluated
FALSEnever evaluated
n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0
(n = readlink ...buf) - 1)) > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
119 {-
120 linkbuf[n] = '\0';-
121 fn = linkbuf;-
122 }
never executed: end of block
0
123-
124-
125 len = strlen (fn);-
126 ret = xmalloc (len + 2);-
127 strcpy (ret, fn);-
128 ret[len] = '-';-
129 ret[len+1] = '\0';-
130 return
never executed: return ret;
ret;
never executed: return ret;
0
131}-
132-
133static char *-
134history_tempfile (const char *filename)-
135{-
136 const char *fn;-
137 char *ret, linkbuf[-
138 4096-
139 +1];-
140 size_t len;-
141 ssize_t n;-
142 struct stat fs;-
143 int pid;-
144-
145 fn = filename;-
146-
147-
148-
149 if ((
(n = readlink ...buf) - 1)) > 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0
(n = readlink ...buf) - 1)) > 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
150 {-
151 linkbuf[n] = '\0';-
152 fn = linkbuf;-
153 }
never executed: end of block
0
154-
155-
156 len = strlen (fn);-
157 ret = xmalloc (len + 11);-
158 strcpy (ret, fn);-
159-
160 pid = (int)getpid ();-
161-
162-
163 ret[len] = '-';-
164 ret[len+1] = (pid / 10000 % 10) + '0';-
165 ret[len+2] = (pid / 1000 % 10) + '0';-
166 ret[len+3] = (pid / 100 % 10) + '0';-
167 ret[len+4] = (pid / 10 % 10) + '0';-
168 ret[len+5] = (pid % 10) + '0';-
169 strcpy (ret + len + 6, ".tmp");-
170-
171 return
executed 2 times by 1 test: return ret;
Executed by:
  • Self test
ret;
executed 2 times by 1 test: return ret;
Executed by:
  • Self test
2
172}-
173-
174-
175-
176-
177int-
178read_history (const char *filename)-
179{-
180 return
executed 4 times by 1 test: return (read_history_range (filename, 0, -1));
Executed by:
  • Self test
(read_history_range (filename, 0, -1));
executed 4 times by 1 test: return (read_history_range (filename, 0, -1));
Executed by:
  • Self test
4
181}-
182-
183-
184-
185-
186-
187-
188int-
189read_history_range (const char *filename, int from, int to)-
190{-
191 register char *line_start, *line_end, *p;-
192 char *input, *buffer, *bufend, *last_ts;-
193 int file, current_line, chars_read, has_timestamps, reset_comment_char;-
194 struct stat finfo;-
195 size_t file_size;-
196-
197 int overflow_errno = -
198 27-
199 ;-
200-
201-
202-
203-
204-
205-
206 history_lines_read_from_file = 0;-
207-
208 buffer = last_ts = (char *)-
209 ((void *)0)-
210 ;-
211 input = history_filename (filename);-
212 file = input
inputDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
? open (input,
0-5
213 00-
214 |0, 0666) : -1;-
215-
216 if ((
(file < 0)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
file < 0)
(file < 0)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
|| (
(fstat (file, &finfo) == -1)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
fstat (file, &finfo) == -1)
(fstat (file, &finfo) == -1)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
)
0-5
217 goto
never executed: goto error_and_exit;
error_and_exit;
never executed: goto error_and_exit;
0
218-
219 if (-
220 ((((
(((( finfo.st_...0100000)) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
2-3
221 finfo.st_mode
(((( finfo.st_...0100000)) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
2-3
222 )) & 0170000) == (0100000))
(((( finfo.st_...0100000)) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
2-3
223 == 0
(((( finfo.st_...0100000)) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
2-3
224 {-
225-
226-
227-
228 -
229 (*__errno_location ()) -
230 = -
231 22-
232 ;-
233-
234 goto
executed 2 times by 1 test: goto error_and_exit;
Executed by:
  • Self test
error_and_exit;
executed 2 times by 1 test: goto error_and_exit;
Executed by:
  • Self test
2
235 }-
236-
237 file_size = (size_t)finfo.st_size;-
238-
239-
240 if (file_size != finfo.st_size
file_size != finfo.st_sizeDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
|| file_size + 1 < file_size
file_size + 1 < file_sizeDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
0-3
241 {-
242 -
243 (*__errno_location ()) -
244 = overflow_errno;-
245 goto
never executed: goto error_and_exit;
error_and_exit;
never executed: goto error_and_exit;
0
246 }-
247-
248 if (file_size == 0
file_size == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
0-3
249 {-
250 free (input);-
251 return
never executed: return 0;
0;
never executed: return 0;
0
252 }-
253 buffer = (char *)malloc (file_size + 1);-
254 if (buffer == 0
buffer == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
0-3
255 {-
256 -
257 (*__errno_location ()) -
258 = overflow_errno;-
259 goto
never executed: goto error_and_exit;
error_and_exit;
never executed: goto error_and_exit;
0
260 }-
261-
262 chars_read = read (file, buffer, file_size);-
263-
264 if (chars_read < 0
chars_read < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
0-3
265 {-
266 error_and_exit:-
267 if (-
268 (*
(*__errno_location ()) != 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) != 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
269 != 0
(*__errno_location ()) != 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
270 chars_read =
executed 2 times by 1 test: chars_read = (*__errno_location ()) ;
Executed by:
  • Self test
2
271 (*__errno_location ())
executed 2 times by 1 test: chars_read = (*__errno_location ()) ;
Executed by:
  • Self test
2
272 ;
executed 2 times by 1 test: chars_read = (*__errno_location ()) ;
Executed by:
  • Self test
2
273 else-
274 chars_read =
never executed: chars_read = 5 ;
0
275 5
never executed: chars_read = 5 ;
0
276 ;
never executed: chars_read = 5 ;
0
277 if (file >= 0
file >= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
278 close (file);
executed 2 times by 1 test: close (file);
Executed by:
  • Self test
2
279-
280 if (input
inputDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
) free (input);
executed 2 times by 1 test: free (input);
Executed by:
  • Self test
0-2
281-
282 if (buffer
bufferDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
) free (buffer);
never executed: free (buffer);
0-2
283-
284-
285 return
executed 2 times by 1 test: return (chars_read);
Executed by:
  • Self test
(chars_read);
executed 2 times by 1 test: return (chars_read);
Executed by:
  • Self test
2
286 }-
287-
288 close (file);-
289-
290-
291 if (to < 0
to < 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-3
292 to = chars_read;
executed 3 times by 1 test: to = chars_read;
Executed by:
  • Self test
3
293-
294-
295 bufend = buffer + chars_read;-
296 *bufend = '\0';-
297 current_line = 0;-
298-
299-
300-
301-
302 reset_comment_char = 0;-
303 if (history_comment_char == '\0'
history_comment_char == '\0'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
&& buffer[0] == '#'
buffer[0] == '#'Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
&&
0-2
304 ((*
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
0
305 (unsigned char)buffer[1]
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
0
306 ))] & (unsigned short int) _ISdigit)
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
0
307 )-
308 {-
309 history_comment_char = '#';-
310 reset_comment_char = 1;-
311 }
never executed: end of block
0
312-
313 has_timestamps = (*(
*(buffer) == h...y_comment_charDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
buffer) == history_comment_char
*(buffer) == h...y_comment_charDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
&&
0-3
314 ((*
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
0
315 (unsigned char)(buffer)[1]
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
0
316 ))] & (unsigned short int) _ISdigit)
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
0
317 );-
318 history_multiline_entries += has_timestamps
has_timestampsDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
&& history_write_timestamps
history_write_timestampsDescription
TRUEnever evaluated
FALSEnever evaluated
;
0-3
319-
320-
321 for (line_start = line_end = buffer; line_end < bufend
line_end < bufendDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& current_line < from
current_line < fromDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
; line_end++)
0-3
322 if (*
*line_end == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
line_end == '\n'
*line_end == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
323 {-
324 p = line_end + 1;-
325-
326-
327 if ((*(
*(p) == history_comment_charDescription
TRUEnever evaluated
FALSEnever evaluated
p) == history_comment_char
*(p) == history_comment_charDescription
TRUEnever evaluated
FALSEnever evaluated
&&
(*(p) == histo...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
328 ((*
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(p) == histo...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
329 (unsigned char)(p)[1]
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(p) == histo...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
330 ))] & (unsigned short int) _ISdigit)
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(p) == histo...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
331 ) == 0
(*(p) == histo...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
332 current_line++;
never executed: current_line++;
0
333 line_start = p;-
334 }
never executed: end of block
0
335-
336-
337 for (line_end = line_start; line_end < bufend
line_end < bufendDescription
TRUEevaluated 360 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
; line_end++)
3-360
338 if (*
*line_end == '\n'Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 343 times by 1 test
Evaluated by:
  • Self test
line_end == '\n'
*line_end == '\n'Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 343 times by 1 test
Evaluated by:
  • Self test
)
17-343
339 {-
340-
341 if (line_end > line_start
line_end > line_startDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& line_end[-1] == '\r'
line_end[-1] == '\r'Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
)
0-17
342 line_end[-1] = '\0';
never executed: line_end[-1] = '\0';
0
343 else-
344 *
executed 17 times by 1 test: *line_end = '\0';
Executed by:
  • Self test
line_end = '\0';
executed 17 times by 1 test: *line_end = '\0';
Executed by:
  • Self test
17
345-
346 if (*
*line_startDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
line_start
*line_startDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-17
347 {-
348 if ((*(
*(line_start) ...y_comment_charDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
line_start) == history_comment_char
*(line_start) ...y_comment_charDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
&&
(*(line_start)...Sdigit) ) == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
349 ((*
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(line_start)...Sdigit) ) == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
350 (unsigned char)(line_start)[1]
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(line_start)...Sdigit) ) == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
351 ))] & (unsigned short int) _ISdigit)
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(line_start)...Sdigit) ) == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
352 ) == 0
(*(line_start)...Sdigit) ) == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-17
353 {-
354 if (last_ts ==
last_ts == ((void *)0)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
355 ((void *)0)
last_ts == ((void *)0)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
356 && history_multiline_entries
history_multiline_entriesDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
)
0-17
357 _hs_append_history_line (history_length - 1, line_start);
never executed: _hs_append_history_line (history_length - 1, line_start);
0
358 else-
359 add_history (line_start);
executed 17 times by 1 test: add_history (line_start);
Executed by:
  • Self test
17
360 if (last_ts
last_tsDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
)
0-17
361 {-
362 add_history_time (last_ts);-
363 last_ts = -
364 ((void *)0)-
365 ;-
366 }
never executed: end of block
0
367 }
executed 17 times by 1 test: end of block
Executed by:
  • Self test
17
368 else-
369 {-
370 last_ts = line_start;-
371 current_line--;-
372 }
never executed: end of block
0
373 }-
374-
375 current_line++;-
376-
377 if (current_line >= to
current_line >= toDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
)
0-17
378 break;
never executed: break;
0
379-
380 line_start = line_end + 1;-
381 }
executed 17 times by 1 test: end of block
Executed by:
  • Self test
17
382-
383 history_lines_read_from_file = current_line;-
384 if (reset_comment_char
reset_comment_charDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
)
0-3
385 history_comment_char = '\0';
never executed: history_comment_char = '\0';
0
386-
387 if (input
inputDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
) free (input);
executed 3 times by 1 test: free (input);
Executed by:
  • Self test
0-3
388-
389 if (buffer
bufferDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
) free (buffer);
executed 3 times by 1 test: free (buffer);
Executed by:
  • Self test
0-3
390-
391-
392-
393-
394 return
executed 3 times by 1 test: return (0);
Executed by:
  • Self test
(0);
executed 3 times by 1 test: return (0);
Executed by:
  • Self test
3
395}-
396-
397-
398-
399static int-
400histfile_backup (const char *filename, const char *back)-
401{-
402-
403 char linkbuf[-
404 4096-
405 +1];-
406 ssize_t n;-
407-
408-
409 if ((
(n = readlink ...buf) - 1)) > 0Description
TRUEnever evaluated
FALSEnever evaluated
n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0
(n = readlink ...buf) - 1)) > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
410 {-
411 linkbuf[n] = '\0';-
412 return
never executed: return (rename (linkbuf, back));
(rename (linkbuf, back));
never executed: return (rename (linkbuf, back));
0
413 }-
414-
415 return
never executed: return (rename (filename, back));
(rename (filename, back));
never executed: return (rename (filename, back));
0
416}-
417-
418-
419-
420static int-
421histfile_restore (const char *backup, const char *orig)-
422{-
423-
424 char linkbuf[-
425 4096-
426 +1];-
427 ssize_t n;-
428-
429-
430 if ((
(n = readlink ...buf) - 1)) > 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
n = readlink (orig, linkbuf, sizeof (linkbuf) - 1)) > 0
(n = readlink ...buf) - 1)) > 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
431 {-
432 linkbuf[n] = '\0';-
433 return
never executed: return (rename (backup, linkbuf));
(rename (backup, linkbuf));
never executed: return (rename (backup, linkbuf));
0
434 }-
435-
436 return
executed 2 times by 1 test: return (rename (backup, orig));
Executed by:
  • Self test
(rename (backup, orig));
executed 2 times by 1 test: return (rename (backup, orig));
Executed by:
  • Self test
2
437}-
438-
439-
440-
441-
442int-
443history_truncate_file (const char *fname, int lines)-
444{-
445 char *buffer, *filename, *tempname, *bp, *bp1;-
446 int file, chars_read, rv, orig_lines, exists, r;-
447 struct stat finfo;-
448 size_t file_size;-
449-
450 history_lines_written_to_file = 0;-
451-
452 buffer = (char *)-
453 ((void *)0)-
454 ;-
455 filename = history_filename (fname);-
456 tempname = 0;-
457 file = filename
filenameDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
? open (filename,
0-38
458 00-
459 |0, 0666) : -1;-
460 rv = exists = 0;-
461-
462-
463 if (file == -1
file == -1Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
|| fstat (file, &finfo) == -1
fstat (file, &finfo) == -1Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
)
0-30
464 {-
465 rv = -
466 (*__errno_location ())-
467 ;-
468 if (file != -1
file != -1Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
)
0-30
469 close (file);
never executed: close (file);
0
470 goto
executed 30 times by 1 test: goto truncate_exit;
Executed by:
  • Self test
truncate_exit;
executed 30 times by 1 test: goto truncate_exit;
Executed by:
  • Self test
30
471 }-
472 exists = 1;-
473-
474 if (-
475 ((((
(((( finfo.st_...0100000)) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
1-7
476 finfo.st_mode
(((( finfo.st_...0100000)) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
1-7
477 )) & 0170000) == (0100000))
(((( finfo.st_...0100000)) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
1-7
478 == 0
(((( finfo.st_...0100000)) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
1-7
479 {-
480 close (file);-
481-
482-
483-
484 rv = -
485 22-
486 ;-
487-
488 goto
executed 1 time by 1 test: goto truncate_exit;
Executed by:
  • Self test
truncate_exit;
executed 1 time by 1 test: goto truncate_exit;
Executed by:
  • Self test
1
489 }-
490-
491 file_size = (size_t)finfo.st_size;-
492-
493-
494 if (file_size != finfo.st_size
file_size != finfo.st_sizeDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
|| file_size + 1 < file_size
file_size + 1 < file_sizeDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-7
495 {-
496 close (file);-
497-
498 rv = -
499 (*__errno_location ()) -
500 = -
501 27-
502 ;-
503-
504-
505-
506-
507-
508 goto
never executed: goto truncate_exit;
truncate_exit;
never executed: goto truncate_exit;
0
509 }-
510-
511 buffer = (char *)malloc (file_size + 1);-
512 if (buffer == 0
buffer == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-7
513 {-
514 rv = -
515 (*__errno_location ())-
516 ;-
517 close (file);-
518 goto
never executed: goto truncate_exit;
truncate_exit;
never executed: goto truncate_exit;
0
519 }-
520-
521 chars_read = read (file, buffer, file_size);-
522 close (file);-
523-
524 if (chars_read <= 0
chars_read <= 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-7
525 {-
526 rv = (
(chars_read < 0)Description
TRUEnever evaluated
FALSEnever evaluated
chars_read < 0)
(chars_read < 0)Description
TRUEnever evaluated
FALSEnever evaluated
?
0
527 (*__errno_location ()) -
528 : 0;-
529 goto
never executed: goto truncate_exit;
truncate_exit;
never executed: goto truncate_exit;
0
530 }-
531-
532 orig_lines = lines;-
533-
534-
535-
536-
537 for (bp1 = bp = buffer + chars_read - 1; lines
linesDescription
TRUEevaluated 966 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& bp > buffer
bp > bufferDescription
TRUEevaluated 959 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
; bp--)
0-966
538 {-
539 if (*
*bp == '\n'Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 902 times by 1 test
Evaluated by:
  • Self test
bp == '\n'
*bp == '\n'Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 902 times by 1 test
Evaluated by:
  • Self test
&& (*(
*(bp1) == history_comment_charDescription
TRUEnever evaluated
FALSEevaluated 57 times by 1 test
Evaluated by:
  • Self test
bp1) == history_comment_char
*(bp1) == history_comment_charDescription
TRUEnever evaluated
FALSEevaluated 57 times by 1 test
Evaluated by:
  • Self test
&&
(*(bp1) == his...Sdigit) ) == 0Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-902
540 ((*
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(bp1) == his...Sdigit) ) == 0Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-57
541 (unsigned char)(bp1)[1]
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(bp1) == his...Sdigit) ) == 0Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-57
542 ))] & (unsigned short int) _ISdigit)
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(bp1) == his...Sdigit) ) == 0Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-57
543 ) == 0
(*(bp1) == his...Sdigit) ) == 0Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-57
544 lines--;
executed 57 times by 1 test: lines--;
Executed by:
  • Self test
57
545 bp1 = bp;-
546 }
executed 959 times by 1 test: end of block
Executed by:
  • Self test
959
547-
548-
549-
550-
551-
552-
553 for ( ; bp > buffer
bp > bufferDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
; bp--)
0-7
554 {-
555 if (*
*bp == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
bp == '\n'
*bp == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
&& (*(
*(bp1) == history_comment_charDescription
TRUEnever evaluated
FALSEnever evaluated
bp1) == history_comment_char
*(bp1) == history_comment_charDescription
TRUEnever evaluated
FALSEnever evaluated
&&
(*(bp1) == his...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
556 ((*
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(bp1) == his...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
557 (unsigned char)(bp1)[1]
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(bp1) == his...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
558 ))] & (unsigned short int) _ISdigit)
((*__ctype_b_l...int) _ISdigit)Description
TRUEnever evaluated
FALSEnever evaluated
(*(bp1) == his...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
559 ) == 0
(*(bp1) == his...Sdigit) ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
560 {-
561 bp++;-
562 break;
never executed: break;
0
563 }-
564 bp1 = bp;-
565 }
never executed: end of block
0
566-
567-
568-
569 if (bp <= buffer
bp <= bufferDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-7
570 {-
571 rv = 0;-
572-
573 history_lines_written_to_file = orig_lines - lines;-
574 goto
executed 7 times by 1 test: goto truncate_exit;
Executed by:
  • Self test
truncate_exit;
executed 7 times by 1 test: goto truncate_exit;
Executed by:
  • Self test
7
575 }-
576-
577 tempname = history_tempfile (filename);-
578-
579 if ((
(file = open (..., 0600)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
file = open (tempname,
(file = open (..., 0600)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
580 01
(file = open (..., 0600)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
581 |
(file = open (..., 0600)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
582 0100
(file = open (..., 0600)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
583 |
(file = open (..., 0600)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
584 01000
(file = open (..., 0600)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
585 |0, 0600)) != -1
(file = open (..., 0600)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
586 {-
587 if (write (file, bp, chars_read - (bp - buffer)) < 0
write (file, b...- buffer)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
588 rv =
never executed: rv = (*__errno_location ()) ;
0
589 (*__errno_location ())
never executed: rv = (*__errno_location ()) ;
0
590 ;
never executed: rv = (*__errno_location ()) ;
0
591-
592 if (close (file) < 0
close (file) < 0Description
TRUEnever evaluated
FALSEnever evaluated
&& rv == 0
rv == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
593 rv =
never executed: rv = (*__errno_location ()) ;
0
594 (*__errno_location ())
never executed: rv = (*__errno_location ()) ;
0
595 ;
never executed: rv = (*__errno_location ()) ;
0
596 }
never executed: end of block
0
597 else-
598 rv =
never executed: rv = (*__errno_location ()) ;
0
599 (*__errno_location ())
never executed: rv = (*__errno_location ()) ;
0
600 ;
never executed: rv = (*__errno_location ()) ;
0
601-
602 truncate_exit:
code before this statement never executed: truncate_exit:
0
603 if (buffer
bufferDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
) free (buffer);
executed 7 times by 1 test: free (buffer);
Executed by:
  • Self test
7-31
604-
605 history_lines_written_to_file = orig_lines - lines;-
606-
607 if (rv == 0
rv == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
&& filename
filenameDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& tempname
tempnameDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-31
608 rv = histfile_restore (tempname, filename);
never executed: rv = histfile_restore (tempname, filename);
0
609-
610 if (rv != 0
rv != 0Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
7-31
611 {-
612 if (tempname
tempnameDescription
TRUEnever evaluated
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
)
0-31
613 unlink (tempname);
never executed: unlink (tempname);
0
614 history_lines_written_to_file = 0;-
615 }
executed 31 times by 1 test: end of block
Executed by:
  • Self test
31
616-
617-
618-
619-
620-
621-
622 if (rv == 0
rv == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
&& exists
existsDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-31
623 r = chown (filename, finfo.st_uid, finfo.st_gid);
executed 7 times by 1 test: r = chown (filename, finfo.st_uid, finfo.st_gid);
Executed by:
  • Self test
7
624-
625-
626 xfree (filename);-
627 if (tempname
tempnameDescription
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
) free (tempname);
never executed: free (tempname);
0-38
628-
629 return
executed 38 times by 1 test: return rv;
Executed by:
  • Self test
rv;
executed 38 times by 1 test: return rv;
Executed by:
  • Self test
38
630}-
631-
632-
633-
634-
635static int-
636history_do_write (const char *filename, int nelements, int overwrite)-
637{-
638 register int i;-
639 char *output, *tempname, *histname;-
640 int file, mode, rv, exists;-
641 struct stat finfo;-
642-
643-
644-
645-
646-
647-
648-
649 mode = overwrite
overwriteDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
?
2-5
650 01-
651 |-
652 0100-
653 |-
654 01000-
655 |0 : -
656 01-
657 |-
658 02000-
659 |0;-
660-
661 histname = history_filename (filename);-
662 exists = histname
histnameDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
? (stat (histname, &finfo) == 0) : 0;
0-7
663-
664 tempname = (overwrite
overwriteDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
&& exists
existsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&&
0-5
665 ((((
(((( finfo.st_... == (0100000))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
666 finfo.st_mode
(((( finfo.st_... == (0100000))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
667 )) & 0170000) == (0100000))
(((( finfo.st_... == (0100000))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
668 ) ? history_tempfile (histname) : 0;-
669 output = tempname
tempnameDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
? tempname : histname;
2-5
670-
671 file = output
outputDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
? open (output, mode, 0600) : -1;
0-7
672 rv = 0;-
673-
674 if (file == -1
file == -1Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-7
675 {-
676 rv = -
677 (*__errno_location ())-
678 ;-
679 if (histname
histnameDescription
TRUEnever evaluated
FALSEnever evaluated
) free (histname);
never executed: free (histname);
0
680 if (tempname
tempnameDescription
TRUEnever evaluated
FALSEnever evaluated
) free (tempname);
never executed: free (tempname);
0
681 return
never executed: return (rv);
(rv);
never executed: return (rv);
0
682 }-
683-
684-
685-
686-
687-
688 if (nelements > history_length
nelements > history_lengthDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-7
689 nelements = history_length;
never executed: nelements = history_length;
0
690-
691-
692-
693 {-
694 HIST_ENTRY **the_history;-
695 register int j;-
696 int buffer_size;-
697 char *buffer;-
698-
699 the_history = history_list ();-
700-
701 for (buffer_size = 0, i = history_length - nelements; i < history_length
i < history_lengthDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
; i++)
7-27
702-
703-
704-
705 {-
706 if (history_write_timestamps
history_write_timestampsDescription
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
&& the_history[i]->timestamp
the_history[i]->timestampDescription
TRUEnever evaluated
FALSEnever evaluated
&& the_history[i]->timestamp[0]
the_history[i]->timestamp[0]Description
TRUEnever evaluated
FALSEnever evaluated
)
0-27
707 buffer_size += strlen (the_history[i]->timestamp) + 1;
never executed: buffer_size += strlen (the_history[i]->timestamp) + 1;
0
708 buffer_size += strlen (the_history[i]->line) + 1;-
709 }
executed 27 times by 1 test: end of block
Executed by:
  • Self test
27
710 buffer = (char *)malloc (buffer_size);-
711 if (buffer == 0
buffer == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-7
712 {-
713 rv = -
714 (*__errno_location ())-
715 ;-
716 close (file);-
717 if (tempname
tempnameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
718 unlink (tempname);
never executed: unlink (tempname);
0
719 if (histname
histnameDescription
TRUEnever evaluated
FALSEnever evaluated
) free (histname);
never executed: free (histname);
0
720 if (tempname
tempnameDescription
TRUEnever evaluated
FALSEnever evaluated
) free (tempname);
never executed: free (tempname);
0
721 return
never executed: return rv;
rv;
never executed: return rv;
0
722 }-
723-
724-
725 for (j = 0, i = history_length - nelements; i < history_length
i < history_lengthDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
; i++)
7-27
726 {-
727 if (history_write_timestamps
history_write_timestampsDescription
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
&& the_history[i]->timestamp
the_history[i]->timestampDescription
TRUEnever evaluated
FALSEnever evaluated
&& the_history[i]->timestamp[0]
the_history[i]->timestamp[0]Description
TRUEnever evaluated
FALSEnever evaluated
)
0-27
728 {-
729 strcpy (buffer + j, the_history[i]->timestamp);-
730 j += strlen (the_history[i]->timestamp);-
731 buffer[j++] = '\n';-
732 }
never executed: end of block
0
733 strcpy (buffer + j, the_history[i]->line);-
734 j += strlen (the_history[i]->line);-
735 buffer[j++] = '\n';-
736 }
executed 27 times by 1 test: end of block
Executed by:
  • Self test
27
737-
738-
739-
740-
741-
742 if (write (file, buffer, buffer_size) < 0
write (file, b...ffer_size) < 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-7
743 rv =
never executed: rv = (*__errno_location ()) ;
0
744 (*__errno_location ())
never executed: rv = (*__errno_location ()) ;
0
745 ;
never executed: rv = (*__errno_location ()) ;
0
746 xfree (buffer);-
747-
748 }-
749-
750 history_lines_written_to_file = nelements;-
751-
752 if (close (file) < 0
close (file) < 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
&& rv == 0
rv == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0-7
753 rv =
never executed: rv = (*__errno_location ()) ;
0
754 (*__errno_location ())
never executed: rv = (*__errno_location ()) ;
0
755 ;
never executed: rv = (*__errno_location ()) ;
0
756-
757 if (rv == 0
rv == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& histname
histnameDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& tempname
tempnameDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
)
0-7
758 rv = histfile_restore (tempname, histname);
executed 2 times by 1 test: rv = histfile_restore (tempname, histname);
Executed by:
  • Self test
2
759-
760 if (rv != 0
rv != 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
0-7
761 {-
762 if (tempname
tempnameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
763 unlink (tempname);
never executed: unlink (tempname);
0
764 history_lines_written_to_file = 0;-
765 }
never executed: end of block
0
766-
767-
768-
769-
770-
771-
772 if (rv == 0
rv == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& exists
existsDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-7
773 mode = chown (histname, finfo.st_uid, finfo.st_gid);
executed 7 times by 1 test: mode = chown (histname, finfo.st_uid, finfo.st_gid);
Executed by:
  • Self test
7
774-
775-
776 if (histname
histnameDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
) free (histname);
executed 7 times by 1 test: free (histname);
Executed by:
  • Self test
0-7
777 if (tempname
tempnameDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
) free (tempname);
executed 2 times by 1 test: free (tempname);
Executed by:
  • Self test
2-5
778-
779 return
executed 7 times by 1 test: return (rv);
Executed by:
  • Self test
(rv);
executed 7 times by 1 test: return (rv);
Executed by:
  • Self test
7
780}-
781-
782-
783-
784int-
785append_history (int nelements, const char *filename)-
786{-
787 return
executed 5 times by 1 test: return (history_do_write (filename, nelements, 0));
Executed by:
  • Self test
(history_do_write (filename, nelements, 0));
executed 5 times by 1 test: return (history_do_write (filename, nelements, 0));
Executed by:
  • Self test
5
788}-
789-
790-
791-
792-
793int-
794write_history (const char *filename)-
795{-
796 return
executed 2 times by 1 test: return (history_do_write (filename, history_length, 1));
Executed by:
  • Self test
(history_do_write (filename, history_length, 1));
executed 2 times by 1 test: return (history_do_write (filename, history_length, 1));
Executed by:
  • Self test
2
797}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2