OpenCoverage

history.def

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/history.def
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15static char *histtime (HIST_ENTRY *, const char *);-
16static int display_history (WORD_LIST *);-
17static void push_history (WORD_LIST *);-
18static int expand_and_print_history (WORD_LIST *);-
19int-
20history_builtin (list)-
21 WORD_LIST *list;-
22{-
23 int flags, opt, result, old_history_lines, obase, ind;-
24 char *filename, *delete_arg, *range;-
25 intmax_t delete_offset;-
26-
27 flags = 0;-
28 reset_internal_getopt ();-
29 while ((
(opt = interna...npsrw")) != -1Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
opt = internal_getopt (list, "acd:npsrw")) != -1
(opt = interna...npsrw")) != -1Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
)
32-45
30 {-
31 switch (opt)-
32 {-
33 case
executed 2 times by 1 test: case 'a':
Executed by:
  • Self test
'a':
executed 2 times by 1 test: case 'a':
Executed by:
  • Self test
2
34 flags |= 0x01;-
35 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
36 case
executed 6 times by 1 test: case 'c':
Executed by:
  • Self test
'c':
executed 6 times by 1 test: case 'c':
Executed by:
  • Self test
6
37 flags |= 0x40;-
38 break;
executed 6 times by 1 test: break;
Executed by:
  • Self test
6
39 case
executed 1 time by 1 test: case 'n':
Executed by:
  • Self test
'n':
executed 1 time by 1 test: case 'n':
Executed by:
  • Self test
1
40 flags |= 0x08;-
41 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
42 case
executed 2 times by 1 test: case 'r':
Executed by:
  • Self test
'r':
executed 2 times by 1 test: case 'r':
Executed by:
  • Self test
2
43 flags |= 0x02;-
44 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
45 case
executed 3 times by 1 test: case 'w':
Executed by:
  • Self test
'w':
executed 3 times by 1 test: case 'w':
Executed by:
  • Self test
3
46 flags |= 0x04;-
47 break;
executed 3 times by 1 test: break;
Executed by:
  • Self test
3
48 case
executed 3 times by 1 test: case 's':
Executed by:
  • Self test
's':
executed 3 times by 1 test: case 's':
Executed by:
  • Self test
3
49 flags |= 0x10;-
50 break;
executed 3 times by 1 test: break;
Executed by:
  • Self test
3
51 case
executed 7 times by 1 test: case 'd':
Executed by:
  • Self test
'd':
executed 7 times by 1 test: case 'd':
Executed by:
  • Self test
7
52 flags |= 0x80;-
53 delete_arg = list_optarg;-
54 break;
executed 7 times by 1 test: break;
Executed by:
  • Self test
7
55 case
executed 7 times by 1 test: case 'p':
Executed by:
  • Self test
'p':
executed 7 times by 1 test: case 'p':
Executed by:
  • Self test
7
56-
57 flags |= 0x20;-
58-
59 break;
executed 7 times by 1 test: break;
Executed by:
  • Self test
7
60 case
never executed: case -99:
-99:
never executed: case -99:
builtin_help (); return
never executed: return (258);
(258);
never executed: return (258);
0
61 default
executed 1 time by 1 test: default:
Executed by:
  • Self test
:
executed 1 time by 1 test: default:
Executed by:
  • Self test
1
62 builtin_usage ();-
63 return
executed 1 time by 1 test: return (258);
Executed by:
  • Self test
(258);
executed 1 time by 1 test: return (258);
Executed by:
  • Self test
1
64 }-
65 }-
66 list = loptend;-
67-
68 opt = flags & (0x01|0x02|0x04|0x08);-
69 if (opt
optDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
&& opt != 0x01
opt != 0x01Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
&& opt != 0x02
opt != 0x02Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
&& opt != 0x04
opt != 0x04Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
&& opt != 0x08
opt != 0x08Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1-38
70 {-
71 builtin_error (-
72 dcgettext (((void *)0), -
73 "cannot use more than one of -anrw"-
74 , 5)-
75 );-
76 return
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
1
77 }-
78-
79-
80 if (flags & 0x40
flags & 0x40Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
)
6-38
81 {-
82 bash_clear_history ();-
83 if (list == 0
list == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-6
84 return
executed 6 times by 1 test: return (0);
Executed by:
  • Self test
(0);
executed 6 times by 1 test: return (0);
Executed by:
  • Self test
6
85 }
never executed: end of block
0
86-
87 if (flags & 0x10
flags & 0x10Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35 times by 1 test
Evaluated by:
  • Self test
)
3-35
88 {-
89 if (list
listDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-3
90 push_history (list);
executed 3 times by 1 test: push_history (list);
Executed by:
  • Self test
3
91 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
92 }-
93-
94 else if (flags & 0x20
flags & 0x20Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
)
7-28
95 {-
96 if (list
listDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-7
97 return
executed 7 times by 1 test: return (expand_and_print_history (list));
Executed by:
  • Self test
(expand_and_print_history (list));
executed 7 times by 1 test: return (expand_and_print_history (list));
Executed by:
  • Self test
7
98 return
never executed: return (sh_chkwrite (0));
(sh_chkwrite (0));
never executed: return (sh_chkwrite (0));
0
99 }-
100-
101 else if ((
(flags & 0x80)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
flags & 0x80)
(flags & 0x80)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
&& (
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
range =
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-21
102 (__extension__ (__builtin_constant_p (
__builtin_constant_p ( '-' )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
103 '-'
__builtin_constant_p ( '-' )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
104 )
__builtin_constant_p ( '-' )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& !__builtin_constant_p (
!__builtin_con...: delete_arg )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
105 (delete_arg[0] == '-') ? delete_arg + 1 : delete_arg
!__builtin_con...: delete_arg )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
106 )
!__builtin_con...: delete_arg )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& (
( '-' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
107 '-'
( '-' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
108 ) == '\0'
( '-' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
? (char *) __rawmemchr (
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
109 (delete_arg[0] == '-') ? delete_arg + 1 : delete_arg
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
110 ,
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
111 '-'
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
112 ) : __builtin_strchr (
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
113 (delete_arg[0] == '-') ? delete_arg + 1 : delete_arg
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
114 ,
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
115 '-'
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
116 )))
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
117 )
(range = (__ex...rg , '-' ))) )Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-7
118 {-
119 intmax_t delete_start, delete_end;-
120 *range++ = '\0';-
121 if (legal_number (delete_arg, &delete_start) == 0
legal_number (...te_start) == 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
|| legal_number (range, &delete_end) == 0
legal_number (...lete_end) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
0-7
122 {-
123 range[-1] = '-';-
124 sh_erange (delete_arg, -
125 dcgettext (((void *)0), -
126 "history position"-
127 , 5)-
128 );-
129 return
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
1
130 }-
131 if (delete_arg[0] == '-'
delete_arg[0] == '-'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
&& delete_start < 0
delete_start < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-5
132 {-
133-
134 delete_start += history_length;-
135 if (delete_start < history_base
delete_start < history_baseDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-1
136 {-
137start_error:-
138 sh_erange (delete_arg, -
139 dcgettext (((void *)0), -
140 "history position"-
141 , 5)-
142 );-
143 return
executed 2 times by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 2 times by 1 test: return (1);
Executed by:
  • Self test
2
144 }-
145 }
never executed: end of block
0
146-
147 else if (delete_start > 0
delete_start > 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-5
148 delete_start -= history_base;
executed 5 times by 1 test: delete_start -= history_base;
Executed by:
  • Self test
5
149 if (delete_start < 0
delete_start < 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
|| delete_start >= history_length
delete_start >= history_lengthDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
)
0-5
150 goto
executed 1 time by 1 test: goto start_error;
Executed by:
  • Self test
start_error;
executed 1 time by 1 test: goto start_error;
Executed by:
  • Self test
1
151 if (range[0] == '-'
range[0] == '-'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
&& delete_end < 0
delete_end < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
152 {-
153 delete_end += history_length;-
154 if (delete_end < history_base
delete_end < history_baseDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1
155 {-
156range_error:-
157 sh_erange (range, -
158 dcgettext (((void *)0), -
159 "history position"-
160 , 5)-
161 );-
162 return
executed 2 times by 1 test: return (1);
Executed by:
  • Self test
(1);
executed 2 times by 1 test: return (1);
Executed by:
  • Self test
2
163 }-
164 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
165 else if (delete_end > 0
delete_end > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
166 delete_end -= history_base;
executed 2 times by 1 test: delete_end -= history_base;
Executed by:
  • Self test
2
167 if (delete_end < 0
delete_end < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
|| delete_end >= history_length
delete_end >= history_lengthDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-3
168 goto
executed 1 time by 1 test: goto range_error;
Executed by:
  • Self test
range_error;
executed 1 time by 1 test: goto range_error;
Executed by:
  • Self test
1
169 result = bash_delete_history_range (delete_start, delete_end);-
170 if (where_history () > history_length
where_history ...history_lengthDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-2
171 history_set_pos (history_length);
executed 2 times by 1 test: history_set_pos (history_length);
Executed by:
  • Self test
2
172 return
executed 2 times by 1 test: return (result ? 0 : 1);
Executed by:
  • Self test
(result ? 0 : 1);
executed 2 times by 1 test: return (result ? 0 : 1);
Executed by:
  • Self test
2
173 }-
174 else if (flags & 0x80
flags & 0x80Description
TRUEnever evaluated
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
)
0-21
175 {-
176 if (legal_number (delete_arg, &delete_offset) == 0
legal_number (...e_offset) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
177 {-
178 sh_erange (delete_arg, -
179 dcgettext (((void *)0), -
180 "history position"-
181 , 5)-
182 );-
183 return
never executed: return (1);
(1);
never executed: return (1);
0
184 }-
185-
186 if (delete_arg[0] == '-'
delete_arg[0] == '-'Description
TRUEnever evaluated
FALSEnever evaluated
&& delete_offset < 0
delete_offset < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
187 {-
188-
189-
190-
191 ind = history_length + delete_offset;-
192 if (ind < history_base
ind < history_baseDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
193 {-
194 sh_erange (delete_arg, -
195 dcgettext (((void *)0), -
196 "history position"-
197 , 5)-
198 );-
199 return
never executed: return (1);
(1);
never executed: return (1);
0
200 }-
201 opt = ind + history_base;-
202 }
never executed: end of block
0
203 else if ((
(delete_offset < history_base)Description
TRUEnever evaluated
FALSEnever evaluated
delete_offset < history_base)
(delete_offset < history_base)Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(delete_offset...story_length))Description
TRUEnever evaluated
FALSEnever evaluated
delete_offset > (history_base + history_length))
(delete_offset...story_length))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
204 {-
205 sh_erange (delete_arg, -
206 dcgettext (((void *)0), -
207 "history position"-
208 , 5)-
209 );-
210 return
never executed: return (1);
(1);
never executed: return (1);
0
211 }-
212 else-
213 opt = delete_offset;
never executed: opt = delete_offset;
0
214-
215-
216-
217 result = bash_delete_histent (opt - history_base);-
218-
219-
220 if (where_history () > history_length
where_history ...history_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
221 history_set_pos (history_length);
never executed: history_set_pos (history_length);
0
222 return
never executed: return (result ? 0 : 1);
(result ? 0 : 1);
never executed: return (result ? 0 : 1);
0
223 }-
224 else if ((
(flags & (0x01...04|0x40)) == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
flags & (0x01|0x02|0x08|0x04|0x40)) == 0
(flags & (0x01...04|0x40)) == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
6-15
225 {-
226 result = display_history (list);-
227 return
executed 15 times by 1 test: return (sh_chkwrite (result));
Executed by:
  • Self test
(sh_chkwrite (result));
executed 15 times by 1 test: return (sh_chkwrite (result));
Executed by:
  • Self test
15
228 }-
229-
230 filename = list
listDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
? list->word->word : get_string_value ("HISTFILE");
2-4
231 result = 0;-
232-
233 if (flags & 0x01
flags & 0x01Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
)
2-4
234 result = maybe_append_history (filename);
executed 2 times by 1 test: result = maybe_append_history (filename);
Executed by:
  • Self test
2
235 else if (flags & 0x04
flags & 0x04Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
2
236 result = write_history (filename);
executed 2 times by 1 test: result = write_history (filename);
Executed by:
  • Self test
2
237 else if (flags & 0x02
flags & 0x02Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1
238 {-
239 result = read_history (filename);-
240 history_lines_in_file = history_lines_read_from_file;-
241-
242 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
243 else if (flags & 0x08
flags & 0x08Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-1
244 {-
245-
246 old_history_lines = history_lines_in_file;-
247 obase = history_base;-
248-
249 using_history ();-
250 result = read_history_range (filename, history_lines_in_file, -1);-
251 using_history ();-
252-
253 history_lines_in_file = history_lines_read_from_file;-
254 if (force_append_history == 0
force_append_history == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-1
255 history_lines_this_session += history_lines_in_file - old_history_lines +
executed 1 time by 1 test: history_lines_this_session += history_lines_in_file - old_history_lines + history_base - obase;
Executed by:
  • Self test
1
256 history_base - obase;
executed 1 time by 1 test: history_lines_this_session += history_lines_in_file - old_history_lines + history_base - obase;
Executed by:
  • Self test
1
257 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
258-
259 return
executed 6 times by 1 test: return (result ? 1 : 0);
Executed by:
  • Self test
(result ? 1 : 0);
executed 6 times by 1 test: return (result ? 1 : 0);
Executed by:
  • Self test
6
260}-
261-
262-
263-
264-
265-
266static char *-
267histtime (hlist, histtimefmt)-
268 HIST_ENTRY *hlist;-
269 const char *histtimefmt;-
270{-
271 static char timestr[128];-
272 time_t t;-
273 struct tm *tm;-
274-
275 t = history_get_time (hlist);-
276 tm = t
tDescription
TRUEnever evaluated
FALSEnever evaluated
? localtime (&t) : 0;
0
277 if (t
tDescription
TRUEnever evaluated
FALSEnever evaluated
&& tm
tmDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
278 strftime (timestr, sizeof (timestr), histtimefmt, tm);
never executed: strftime (timestr, sizeof (timestr), histtimefmt, tm);
0
279 else if (hlist->timestamp
hlist->timestampDescription
TRUEnever evaluated
FALSEnever evaluated
&& hlist->timestamp[0]
hlist->timestamp[0]Description
TRUEnever evaluated
FALSEnever evaluated
)
0
280 snprintf (timestr, sizeof (timestr),
never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
0
281 dcgettext (((void *)0),
never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
0
282 "%s: invalid timestamp"
never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
0
283 , 5)
never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
0
284 ,
never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
0
285 (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
never executed: snprintf (timestr, sizeof (timestr), dcgettext (((void *)0), "%s: invalid timestamp" , 5) , (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
0
286 else-
287 strcpy (timestr, "??");
never executed: strcpy (timestr, "??");
0
288 return
never executed: return timestr;
timestr;
never executed: return timestr;
0
289}-
290-
291static int-
292display_history (list)-
293 WORD_LIST *list;-
294{-
295 register int i;-
296 intmax_t limit;-
297 HIST_ENTRY **hlist;-
298 char *histtimefmt, *timestr;-
299-
300 if (list
listDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
)
1-14
301 {-
302 if (get_numeric_arg (list, 0, &limit) == 0
get_numeric_ar..., &limit) == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
0-1
303 return
never executed: return (1);
(1);
never executed: return (1);
0
304-
305 if (limit < 0
limit < 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
0-1
306 limit = -limit;
never executed: limit = -limit;
0
307 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
308 else-
309 limit = -1;
executed 14 times by 1 test: limit = -1;
Executed by:
  • Self test
14
310-
311 hlist = history_list ();-
312-
313 if (hlist
hlistDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-15
314 {-
315 for (i = 0; hlist[i]
hlist[i]Description
TRUEevaluated 135 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
; i++)
15-135
316 ;
executed 135 times by 1 test: ;
Executed by:
  • Self test
135
317-
318 if (0 <= limit
0 <= limitDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
&& limit < i
limit < iDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-14
319 i -= limit;
executed 1 time by 1 test: i -= limit;
Executed by:
  • Self test
1
320 else-
321 i = 0;
executed 14 times by 1 test: i = 0;
Executed by:
  • Self test
14
322-
323 histtimefmt = get_string_value ("HISTTIMEFORMAT");-
324-
325 while (hlist[i]
hlist[i]Description
TRUEevaluated 122 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
)
15-122
326 {-
327 do { if (terminating_signal
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 122 times by 1 test
Evaluated by:
  • Self test
) termsig_handler (terminating_signal);
never executed: termsig_handler (terminating_signal);
if (interrupt_state
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 122 times by 1 test
Evaluated by:
  • Self test
) throw_to_top_level ();
never executed: throw_to_top_level ();
} while (0);
0-122
328-
329 timestr = (histtimefmt
histtimefmtDescription
TRUEnever evaluated
FALSEevaluated 122 times by 1 test
Evaluated by:
  • Self test
&& *
*histtimefmtDescription
TRUEnever evaluated
FALSEnever evaluated
histtimefmt
*histtimefmtDescription
TRUEnever evaluated
FALSEnever evaluated
) ? histtime (hlist[i], histtimefmt) : (char *)
0-122
330 ((void *)0)-
331 ;-
332 printf ("%5d%c %s%s\n", i + history_base,-
333 (hlist[(i)]->data) ? '*' : ' ',-
334 ((timestr && *timestr) ? timestr : ""),-
335 (hlist[(i)]->line));-
336 i++;-
337 }
executed 122 times by 1 test: end of block
Executed by:
  • Self test
122
338 }
executed 15 times by 1 test: end of block
Executed by:
  • Self test
15
339-
340 return
executed 15 times by 1 test: return (0);
Executed by:
  • Self test
(0);
executed 15 times by 1 test: return (0);
Executed by:
  • Self test
15
341}-
342-
343-
344-
345static void-
346push_history (list)-
347 WORD_LIST *list;-
348{-
349 char *s;-
350 if (remember_on_history
remember_on_historyDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& hist_last_line_pushed == 0
hist_last_line_pushed == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&&
0-3
351 (hist_last_line_added
hist_last_line_addedDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
||
0-3
352 (current_command_line_count > 0
current_command_line_count > 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& current_command_first_line_saved
current_comman...rst_line_savedDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
&& command_oriented_history
command_oriented_historyDescription
TRUEnever evaluated
FALSEnever evaluated
))
0-3
353 && bash_delete_last_history () == 0
bash_delete_la...istory () == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
354-
355 return;
never executed: return;
0
356-
357 s = string_list (list);-
358-
359-
360-
361-
362-
363-
364 check_add_history (s, 1);-
365-
366 hist_last_line_pushed = 1;-
367 sh_xfree((s), "./history.def", 423);-
368}
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
369-
370-
371static int-
372expand_and_print_history (list)-
373 WORD_LIST *list;-
374{-
375 char *s;-
376 int r, result;-
377-
378 if (hist_last_line_pushed == 0
hist_last_line_pushed == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
&& hist_last_line_added
hist_last_line_addedDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
&& bash_delete_last_history () == 0
bash_delete_la...istory () == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0-5
379 return
never executed: return 1;
1;
never executed: return 1;
0
380 result = 0;-
381 while (list
listDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
)
7
382 {-
383 r = history_expand (list->word->word, &s);-
384 if (r < 0
r < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
)
1-6
385 {-
386 builtin_error (-
387 dcgettext (((void *)0), -
388 "%s: history expansion failed"-
389 , 5)-
390 , list->word->word);-
391 result = 1;-
392 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
393 else-
394 {-
395 fputs (s, -
396 stdout-
397 );-
398 putchar ('\n');-
399 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
400 do { if (s
sDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
) sh_xfree((s), "./history.def", 450);
executed 7 times by 1 test: sh_xfree((s), "./history.def", 450);
Executed by:
  • Self test
} while (0);
0-7
401 list = list->next;-
402 }
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
403 fflush (-
404 stdout-
405 );-
406 return
executed 7 times by 1 test: return result;
Executed by:
  • Self test
result;
executed 7 times by 1 test: return result;
Executed by:
  • Self test
7
407}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2