OpenCoverage

flags.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/flags.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9extern int set_job_control (int);-
10int mark_modified_vars = 0;-
11-
12-
13-
14int asynchronous_notification = 0;-
15-
16-
17-
18-
19int errexit_flag = 0;-
20int exit_immediately_on_error = 0;-
21-
22-
23int disallow_filename_globbing = 0;-
24-
25-
26-
27-
28int place_keywords_in_env = 0;-
29-
30-
31-
32-
33int read_but_dont_execute = 0;-
34-
35-
36int just_one_command = 0;-
37-
38-
39int noclobber = 0;-
40-
41-
42-
43int unbound_vars_is_error = 0;-
44-
45-
46int echo_input_at_read = 0;-
47int verbose_flag = 0;-
48-
49-
50-
51int echo_command_at_execute = 0;-
52-
53-
54int jobs_m_flag = 0;-
55-
56-
57-
58int forced_interactive = 0;-
59-
60-
61-
62-
63-
64-
65int no_symbolic_links = 0;-
66int no_invisible_vars = 0;-
67-
68-
69int hashing_enabled = 1;-
70-
71-
72-
73-
74int history_expansion = 1;-
75int histexp_flag = 0;-
76-
77-
78-
79int interactive_comments = 1;-
80-
81-
82-
83-
84-
85-
86int restricted = 0;-
87int restricted_shell = 0;-
88-
89-
90-
91-
92-
93-
94int privileged_mode = 0;-
95-
96-
97-
98int brace_expansion = 1;-
99-
100-
101-
102int function_trace_mode = 0;-
103-
104-
105int error_trace_mode = 0;-
106-
107-
108-
109-
110int pipefail_opt = 0;-
111-
112-
113-
114-
115-
116-
117-
118const struct flags_alist shell_flags[] = {-
119-
120 { 'a', &mark_modified_vars },-
121-
122 { 'b', &asynchronous_notification },-
123-
124 { 'e', &errexit_flag },-
125 { 'f', &disallow_filename_globbing },-
126 { 'h', &hashing_enabled },-
127 { 'i', &forced_interactive },-
128 { 'k', &place_keywords_in_env },-
129-
130 { 'm', &jobs_m_flag },-
131-
132 { 'n', &read_but_dont_execute },-
133 { 'p', &privileged_mode },-
134-
135 { 'r', &restricted },-
136-
137 { 't', &just_one_command },-
138 { 'u', &unbound_vars_is_error },-
139 { 'v', &verbose_flag },-
140 { 'x', &echo_command_at_execute },-
141-
142-
143-
144-
145-
146-
147 { 'B', &brace_expansion },-
148-
149 { 'C', &noclobber },-
150 { 'E', &error_trace_mode },-
151-
152 { 'H', &histexp_flag },-
153-
154 { 'I', &no_invisible_vars },-
155 { 'P', &no_symbolic_links },-
156 { 'T', &function_trace_mode },-
157 {0, (int *)-
158 ((void *)0)-
159 }-
160};-
161-
162-
163-
164char optflags[(sizeof (shell_flags) / sizeof (struct flags_alist))+4] = { '+' };-
165-
166int *-
167find_flag (name)-
168 int name;-
169{-
170 int i;-
171 for (i = 0; shell_flags[i].name
shell_flags[i].nameDescription
TRUEevaluated 2238050 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
; i++)
0-2238050
172 {-
173 if (shell_flags[i].name == name
shell_flags[i].name == nameDescription
TRUEevaluated 199955 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2038095 times by 1 test
Evaluated by:
  • Self test
)
199955-2038095
174 return
executed 199955 times by 1 test: return (shell_flags[i].value);
Executed by:
  • Self test
(shell_flags[i].value);
executed 199955 times by 1 test: return (shell_flags[i].value);
Executed by:
  • Self test
199955
175 }
executed 2038095 times by 1 test: end of block
Executed by:
  • Self test
2038095
176 return
never executed: return ((int *)0);
((int *)0);
never executed: return ((int *)0);
0
177}-
178-
179-
180-
181-
182int-
183change_flag (flag, on_or_off)-
184 int flag;-
185 int on_or_off;-
186{-
187 int *value, old_value;-
188-
189-
190-
191 if (restricted
restrictedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13715 times by 1 test
Evaluated by:
  • Self test
&& flag == 'r'
flag == 'r'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& on_or_off == '+'
on_or_off == '+'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-13715
192 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
193-
194-
195 value = find_flag (flag);-
196-
197 if ((
(value == (int *)(int *)0)Description
TRUEnever evaluated
FALSEevaluated 13715 times by 1 test
Evaluated by:
  • Self test
value == (int *)(int *)0)
(value == (int *)(int *)0)Description
TRUEnever evaluated
FALSEevaluated 13715 times by 1 test
Evaluated by:
  • Self test
|| (on_or_off != '-'
on_or_off != '-'Description
TRUEevaluated 12963 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 752 times by 1 test
Evaluated by:
  • Self test
&& on_or_off != '+'
on_or_off != '+'Description
TRUEnever evaluated
FALSEevaluated 12963 times by 1 test
Evaluated by:
  • Self test
))
0-13715
198 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
199-
200 old_value = *value;-
201 *value = (
(on_or_off == '-')Description
TRUEevaluated 752 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12963 times by 1 test
Evaluated by:
  • Self test
on_or_off == '-')
(on_or_off == '-')Description
TRUEevaluated 752 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12963 times by 1 test
Evaluated by:
  • Self test
? 1 : 0;
752-12963
202-
203-
204 switch (flag)-
205 {-
206-
207 case
executed 30 times by 1 test: case 'H':
Executed by:
  • Self test
'H':
executed 30 times by 1 test: case 'H':
Executed by:
  • Self test
30
208 history_expansion = histexp_flag;-
209 if (on_or_off == '-'
on_or_off == '-'Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-30
210 bash_initialize_history ();
executed 30 times by 1 test: bash_initialize_history ();
Executed by:
  • Self test
30
211 break;
executed 30 times by 1 test: break;
Executed by:
  • Self test
30
212-
213-
214-
215 case
executed 5462 times by 1 test: case 'm':
Executed by:
  • Self test
'm':
executed 5462 times by 1 test: case 'm':
Executed by:
  • Self test
5462
216 set_job_control (on_or_off == '-');-
217 break;
executed 5462 times by 1 test: break;
Executed by:
  • Self test
5462
218-
219-
220 case
executed 3347 times by 1 test: case 'e':
Executed by:
  • Self test
'e':
executed 3347 times by 1 test: case 'e':
Executed by:
  • Self test
3347
221 if (builtin_ignoring_errexit == 0
builtin_ignoring_errexit == 0Description
TRUEevaluated 3346 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1-3346
222 exit_immediately_on_error = errexit_flag;
executed 3346 times by 1 test: exit_immediately_on_error = errexit_flag;
Executed by:
  • Self test
3346
223 break;
executed 3347 times by 1 test: break;
Executed by:
  • Self test
3347
224-
225 case
executed 2 times by 1 test: case 'n':
Executed by:
  • Self test
'n':
executed 2 times by 1 test: case 'n':
Executed by:
  • Self test
2
226 if (interactive_shell
interactive_shellDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
)
0-2
227 read_but_dont_execute = 0;
never executed: read_but_dont_execute = 0;
0
228 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
229-
230 case
executed 11 times by 1 test: case 'p':
Executed by:
  • Self test
'p':
executed 11 times by 1 test: case 'p':
Executed by:
  • Self test
11
231 if (on_or_off == '+'
on_or_off == '+'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
)
1-10
232 disable_priv_mode ();
executed 10 times by 1 test: disable_priv_mode ();
Executed by:
  • Self test
10
233 break;
executed 11 times by 1 test: break;
Executed by:
  • Self test
11
234-
235-
236 case
executed 1 time by 1 test: case 'r':
Executed by:
  • Self test
'r':
executed 1 time by 1 test: case 'r':
Executed by:
  • Self test
1
237 if (on_or_off == '-'
on_or_off == '-'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& shell_initialized
shell_initializedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-1
238 maybe_make_restricted (shell_name);
executed 1 time by 1 test: maybe_make_restricted (shell_name);
Executed by:
  • Self test
1
239 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
240-
241-
242 case
executed 4340 times by 1 test: case 'v':
Executed by:
  • Self test
'v':
executed 4340 times by 1 test: case 'v':
Executed by:
  • Self test
4340
243 echo_input_at_read = verbose_flag;-
244 break;
executed 4340 times by 1 test: break;
Executed by:
  • Self test
4340
245 }-
246-
247 return
executed 13715 times by 1 test: return (old_value);
Executed by:
  • Self test
(old_value);
executed 13715 times by 1 test: return (old_value);
Executed by:
  • Self test
13715
248}-
249-
250-
251-
252char *-
253which_set_flags ()-
254{-
255 char *temp;-
256 int i, string_index;-
257-
258 temp = (char *)sh_xmalloc((1 + (sizeof (shell_flags) / sizeof (struct flags_alist)) + read_from_stdin + want_pending_command), "flags.c", 306);-
259 for (i = string_index = 0; shell_flags[i].name
shell_flags[i].nameDescription
TRUEevaluated 1672 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
; i++)
76-1672
260 if (*(
*(shell_flags[i].value)Description
TRUEevaluated 161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1511 times by 1 test
Evaluated by:
  • Self test
shell_flags[i].value)
*(shell_flags[i].value)Description
TRUEevaluated 161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1511 times by 1 test
Evaluated by:
  • Self test
)
161-1511
261 temp[string_index++] = shell_flags[i].name;
executed 161 times by 1 test: temp[string_index++] = shell_flags[i].name;
Executed by:
  • Self test
161
262-
263 if (want_pending_command
want_pending_commandDescription
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
)
0-76
264 temp[string_index++] = 'c';
never executed: temp[string_index++] = 'c';
0
265 if (read_from_stdin
read_from_stdinDescription
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
)
0-76
266 temp[string_index++] = 's';
never executed: temp[string_index++] = 's';
0
267-
268 temp[string_index] = '\0';-
269 return
executed 76 times by 1 test: return (temp);
Executed by:
  • Self test
(temp);
executed 76 times by 1 test: return (temp);
Executed by:
  • Self test
76
270}-
271-
272char *-
273get_current_flags ()-
274{-
275 char *temp;-
276 int i;-
277-
278 temp = (char *)sh_xmalloc((1 + (sizeof (shell_flags) / sizeof (struct flags_alist))), "flags.c", 326);-
279 for (i = 0; shell_flags[i].name
shell_flags[i].nameDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
280 temp[i] = *(shell_flags[i].value);
never executed: temp[i] = *(shell_flags[i].value);
0
281 temp[i] = '\0';-
282 return
never executed: return (temp);
(temp);
never executed: return (temp);
0
283}-
284-
285void-
286set_current_flags (bitmap)-
287 const char *bitmap;-
288{-
289 int i;-
290-
291 if (bitmap == 0
bitmap == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
292 return;
never executed: return;
0
293 for (i = 0; shell_flags[i].name
shell_flags[i].nameDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
294 *(
never executed: *(shell_flags[i].value) = bitmap[i];
shell_flags[i].value) = bitmap[i];
never executed: *(shell_flags[i].value) = bitmap[i];
0
295}
never executed: end of block
0
296-
297void-
298reset_shell_flags ()-
299{-
300 mark_modified_vars = disallow_filename_globbing = 0;-
301 place_keywords_in_env = read_but_dont_execute = just_one_command = 0;-
302 noclobber = unbound_vars_is_error = 0;-
303 echo_command_at_execute = jobs_m_flag = forced_interactive = 0;-
304 no_symbolic_links = no_invisible_vars = 0;-
305 privileged_mode = pipefail_opt = 0;-
306-
307 error_trace_mode = function_trace_mode = 0;-
308-
309 exit_immediately_on_error = errexit_flag = 0;-
310 echo_input_at_read = verbose_flag = 0;-
311-
312 hashing_enabled = interactive_comments = 1;-
313-
314-
315 asynchronous_notification = 0;-
316-
317-
318-
319-
320-
321-
322 history_expansion = 1;-
323-
324-
325-
326-
327 brace_expansion = 1;-
328-
329-
330-
331 restricted = 0;-
332-
333}
executed 15 times by 1 test: end of block
Executed by:
  • Self test
15
334-
335void-
336initialize_flags ()-
337{-
338 register int i;-
339-
340 for (i = 0; shell_flags[i].name
shell_flags[i].nameDescription
TRUEevaluated 119834 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5447 times by 1 test
Evaluated by:
  • Self test
; i++)
5447-119834
341 optflags[i+1] = shell_flags[i].name;
executed 119834 times by 1 test: optflags[i+1] = shell_flags[i].name;
Executed by:
  • Self test
119834
342 optflags[++i] = 'o';-
343 optflags[++i] = ';';-
344 optflags[i+1] = '\0';-
345}
executed 5447 times by 1 test: end of block
Executed by:
  • Self test
5447
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2