OpenCoverage

print_cmd.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/print_cmd.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* print_command -- A way to make readable commands from a command tree. */-
2-
3/* Copyright (C) 1989-2017 Free Software Foundation, Inc.-
4-
5 This file is part of GNU Bash, the Bourne Again SHell.-
6-
7 Bash is free software: you can redistribute it and/or modify-
8 it under the terms of the GNU General Public License as published by-
9 the Free Software Foundation, either version 3 of the License, or-
10 (at your option) any later version.-
11-
12 Bash is distributed in the hope that it will be useful,-
13 but WITHOUT ANY WARRANTY; without even the implied warranty of-
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
15 GNU General Public License for more details.-
16-
17 You should have received a copy of the GNU General Public License-
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.-
19*/-
20-
21#include "config.h"-
22-
23#include <stdio.h>-
24-
25#if defined (HAVE_UNISTD_H)-
26# ifdef _MINIX-
27# include <sys/types.h>-
28# endif-
29# include <unistd.h>-
30#endif-
31-
32#if defined (PREFER_STDARG)-
33# include <stdarg.h>-
34#else-
35# include <varargs.h>-
36#endif-
37-
38#include "bashansi.h"-
39#include "bashintl.h"-
40-
41#include "shell.h"-
42#include "flags.h"-
43#include <y.tab.h> /* use <...> so we pick it up from the build directory */-
44#include "input.h"-
45-
46#include "shmbutil.h"-
47-
48#include "builtins/common.h"-
49-
50#if !HAVE_DECL_PRINTF-
51extern int printf __P((const char *, ...)); /* Yuck. Double yuck. */-
52#endif-
53-
54static int indentation;-
55static int indentation_amount = 4;-
56-
57#if defined (PREFER_STDARG)-
58typedef void PFUNC __P((const char *, ...));-
59-
60static void cprintf __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));-
61static void xprintf __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));-
62#else-
63#define PFUNC VFunction-
64static void cprintf ();-
65static void xprintf ();-
66#endif-
67-
68static void reset_locals __P((void));-
69static void newline __P((char *));-
70static void indent __P((int));-
71static void semicolon __P((void));-
72static void the_printed_command_resize __P((int));-
73-
74static void make_command_string_internal __P((COMMAND *));-
75static void _print_word_list __P((WORD_LIST *, char *, PFUNC *));-
76static void command_print_word_list __P((WORD_LIST *, char *));-
77static void print_case_clauses __P((PATTERN_LIST *));-
78static void print_redirection_list __P((REDIRECT *));-
79static void print_redirection __P((REDIRECT *));-
80static void print_heredoc_header __P((REDIRECT *));-
81static void print_heredoc_body __P((REDIRECT *));-
82static void print_heredocs __P((REDIRECT *));-
83static void print_heredoc_bodies __P((REDIRECT *));-
84static void print_deferred_heredocs __P((const char *));-
85-
86static void print_for_command __P((FOR_COM *));-
87#if defined (ARITH_FOR_COMMAND)-
88static void print_arith_for_command __P((ARITH_FOR_COM *));-
89#endif-
90#if defined (SELECT_COMMAND)-
91static void print_select_command __P((SELECT_COM *));-
92#endif-
93static void print_group_command __P((GROUP_COM *));-
94static void print_case_command __P((CASE_COM *));-
95static void print_while_command __P((WHILE_COM *));-
96static void print_until_command __P((WHILE_COM *));-
97static void print_until_or_while __P((WHILE_COM *, char *));-
98static void print_if_command __P((IF_COM *));-
99#if defined (COND_COMMAND)-
100static void print_cond_node __P((COND_COM *));-
101#endif-
102static void print_function_def __P((FUNCTION_DEF *));-
103-
104#define PRINTED_COMMAND_INITIAL_SIZE 64-
105#define PRINTED_COMMAND_GROW_SIZE 128-
106-
107char *the_printed_command = (char *)NULL;-
108int the_printed_command_size = 0;-
109int command_string_index = 0;-
110-
111int xtrace_fd = -1;-
112FILE *xtrace_fp = 0;-
113-
114#define CHECK_XTRACE_FP xtrace_fp = (xtrace_fp ? xtrace_fp : stderr)-
115-
116/* shell expansion characters: used in print_redirection_list */-
117#define EXPCHAR(c) ((c) == '{' || (c) == '~' || (c) == '$' || (c) == '`')-
118-
119#define PRINT_DEFERRED_HEREDOCS(x) \-
120 do { \-
121 if (deferred_heredocs) \-
122 print_deferred_heredocs (x); \-
123 } while (0)-
124-
125/* Non-zero means the stuff being printed is inside of a function def. */-
126static int inside_function_def;-
127static int skip_this_indent;-
128static int was_heredoc;-
129static int printing_connection;-
130static REDIRECT *deferred_heredocs;-
131-
132/* The depth of the group commands that we are currently printing. This-
133 includes the group command that is a function body. */-
134static int group_command_nesting;-
135-
136/* A buffer to indicate the indirection level (PS4) when set -x is enabled. */-
137static char *indirection_string = 0;-
138static int indirection_stringsiz = 0;-
139-
140/* Print COMMAND (a command tree) on standard output. */-
141void-
142print_command (command)-
143 COMMAND *command;-
144{-
145 command_string_index = 0;-
146 printf ("%s", make_command_string (command));-
147}
never executed: end of block
0
148-
149/* Make a string which is the printed representation of the command-
150 tree in COMMAND. We return this string. However, the string is-
151 not consed, so you have to do that yourself if you want it to-
152 remain around. */-
153char *-
154make_command_string (command)-
155 COMMAND *command;-
156{-
157 command_string_index = was_heredoc = 0;-
158 deferred_heredocs = 0;-
159 make_command_string_internal (command);-
160 return (the_printed_command);
executed 5886 times by 1 test: return (the_printed_command);
Executed by:
  • Self test
5886
161}-
162-
163/* The internal function. This is the real workhorse. */-
164static void-
165make_command_string_internal (command)-
166 COMMAND *command;-
167{-
168 char s[3];-
169-
170 if (command == 0)
command == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30519 times by 1 test
Evaluated by:
  • Self test
6-30519
171 cprintf ("");
executed 6 times by 1 test: cprintf ("");
Executed by:
  • Self test
6
172 else-
173 {-
174 if (skip_this_indent)
skip_this_indentDescription
TRUEevaluated 19560 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10959 times by 1 test
Evaluated by:
  • Self test
10959-19560
175 skip_this_indent--;
executed 19560 times by 1 test: skip_this_indent--;
Executed by:
  • Self test
19560
176 else-
177 indent (indentation);
executed 10959 times by 1 test: indent (indentation);
Executed by:
  • Self test
10959
178-
179 if (command->flags & CMD_TIME_PIPELINE)
command->flags & 0x80Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30513 times by 1 test
Evaluated by:
  • Self test
6-30513
180 {-
181 cprintf ("time ");-
182 if (command->flags & CMD_TIME_POSIX)
command->flags & 0x100Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-5
183 cprintf ("-p ");
executed 5 times by 1 test: cprintf ("-p ");
Executed by:
  • Self test
5
184 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
185-
186 if (command->flags & CMD_INVERT_RETURN)
command->flags & 0x04Description
TRUEevaluated 149 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30370 times by 1 test
Evaluated by:
  • Self test
149-30370
187 cprintf ("! ");
executed 149 times by 1 test: cprintf ("! ");
Executed by:
  • Self test
149
188-
189 switch (command->type)-
190 {-
191 case cm_for:
executed 19 times by 1 test: case cm_for:
Executed by:
  • Self test
19
192 print_for_command (command->value.For);-
193 break;
executed 19 times by 1 test: break;
Executed by:
  • Self test
19
194-
195#if defined (ARITH_FOR_COMMAND)-
196 case cm_arith_for:
executed 1119 times by 1 test: case cm_arith_for:
Executed by:
  • Self test
1119
197 print_arith_for_command (command->value.ArithFor);-
198 break;
executed 1119 times by 1 test: break;
Executed by:
  • Self test
1119
199#endif-
200-
201#if defined (SELECT_COMMAND)-
202 case cm_select:
never executed: case cm_select:
0
203 print_select_command (command->value.Select);-
204 break;
never executed: break;
0
205#endif-
206-
207 case cm_case:
executed 7 times by 1 test: case cm_case:
Executed by:
  • Self test
7
208 print_case_command (command->value.Case);-
209 break;
executed 7 times by 1 test: break;
Executed by:
  • Self test
7
210-
211 case cm_while:
executed 23 times by 1 test: case cm_while:
Executed by:
  • Self test
23
212 print_while_command (command->value.While);-
213 break;
executed 23 times by 1 test: break;
Executed by:
  • Self test
23
214-
215 case cm_until:
executed 5 times by 1 test: case cm_until:
Executed by:
  • Self test
5
216 print_until_command (command->value.While);-
217 break;
executed 5 times by 1 test: break;
Executed by:
  • Self test
5
218-
219 case cm_if:
executed 626 times by 1 test: case cm_if:
Executed by:
  • Self test
626
220 print_if_command (command->value.If);-
221 break;
executed 626 times by 1 test: break;
Executed by:
  • Self test
626
222-
223#if defined (DPAREN_ARITHMETIC)-
224 case cm_arith:
executed 1222 times by 1 test: case cm_arith:
Executed by:
  • Self test
1222
225 print_arith_command (command->value.Arith->exp);-
226 break;
executed 1222 times by 1 test: break;
Executed by:
  • Self test
1222
227#endif-
228-
229#if defined (COND_COMMAND)-
230 case cm_cond:
executed 10 times by 1 test: case cm_cond:
Executed by:
  • Self test
10
231 print_cond_command (command->value.Cond);-
232 break;
executed 10 times by 1 test: break;
Executed by:
  • Self test
10
233#endif-
234-
235 case cm_simple:
executed 13606 times by 1 test: case cm_simple:
Executed by:
  • Self test
13606
236 print_simple_command (command->value.Simple);-
237 break;
executed 13606 times by 1 test: break;
Executed by:
  • Self test
13606
238-
239 case cm_connection:
executed 7914 times by 1 test: case cm_connection:
Executed by:
  • Self test
7914
240-
241 skip_this_indent++;-
242 printing_connection++;-
243 make_command_string_internal (command->value.Connection->first);-
244-
245 switch (command->value.Connection->connector)-
246 {-
247 case '&':
executed 100 times by 1 test: case '&':
Executed by:
  • Self test
100
248 case '|':
executed 39 times by 1 test: case '|':
Executed by:
  • Self test
39
249 {-
250 char c = command->value.Connection->connector;-
251-
252 s[0] = ' ';-
253 s[1] = c;-
254 s[2] = '\0';-
255 -
256 print_deferred_heredocs (s);-
257-
258 if (c != '&' || command->value.Connection->second)
c != '&'Description
TRUEevaluated 39 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 100 times by 1 test
Evaluated by:
  • Self test
command->value...ection->secondDescription
TRUEevaluated 94 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-100
259 {-
260 cprintf (" ");-
261 skip_this_indent++;-
262 }
executed 133 times by 1 test: end of block
Executed by:
  • Self test
133
263 }-
264 break;
executed 139 times by 1 test: break;
Executed by:
  • Self test
139
265-
266 case AND_AND:
executed 17 times by 1 test: case 288:
Executed by:
  • Self test
17
267 print_deferred_heredocs (" && ");-
268 if (command->value.Connection->second)
command->value...ection->secondDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
269 skip_this_indent++;
executed 17 times by 1 test: skip_this_indent++;
Executed by:
  • Self test
17
270 break;
executed 17 times by 1 test: break;
Executed by:
  • Self test
17
271-
272 case OR_OR:
executed 10 times by 1 test: case 289:
Executed by:
  • Self test
10
273 print_deferred_heredocs (" || ");-
274 if (command->value.Connection->second)
command->value...ection->secondDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
275 skip_this_indent++;
executed 10 times by 1 test: skip_this_indent++;
Executed by:
  • Self test
10
276 break;
executed 10 times by 1 test: break;
Executed by:
  • Self test
10
277-
278 case ';':
executed 7748 times by 1 test: case ';':
Executed by:
  • Self test
7748
279 if (deferred_heredocs == 0)
deferred_heredocs == 0Description
TRUEevaluated 7735 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
13-7735
280 {-
281 if (was_heredoc == 0)
was_heredoc == 0Description
TRUEevaluated 7722 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
13-7722
282 cprintf (";");
executed 7722 times by 1 test: cprintf (";");
Executed by:
  • Self test
7722
283 else-
284 was_heredoc = 0;
executed 13 times by 1 test: was_heredoc = 0;
Executed by:
  • Self test
13
285 }-
286 else-
287 print_deferred_heredocs (inside_function_def ? "" : ";");
executed 13 times by 1 test: print_deferred_heredocs (inside_function_def ? "" : ";");
Executed by:
  • Self test
13
288-
289 if (inside_function_def)
inside_function_defDescription
TRUEevaluated 2857 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4891 times by 1 test
Evaluated by:
  • Self test
2857-4891
290 cprintf ("\n");
executed 2857 times by 1 test: cprintf ("\n");
Executed by:
  • Self test
2857
291 else-
292 {-
293 cprintf (" ");-
294 if (command->value.Connection->second)
command->value...ection->secondDescription
TRUEevaluated 4891 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4891
295 skip_this_indent++;
executed 4891 times by 1 test: skip_this_indent++;
Executed by:
  • Self test
4891
296 }
executed 4891 times by 1 test: end of block
Executed by:
  • Self test
4891
297 break;
executed 7748 times by 1 test: break;
Executed by:
  • Self test
7748
298-
299 default:
never executed: default:
0
300 cprintf (_("print_command: bad connector `%d'"),-
301 command->value.Connection->connector);-
302 break;
never executed: break;
0
303 }-
304-
305 make_command_string_internal (command->value.Connection->second);-
306 PRINT_DEFERRED_HEREDOCS ("");
executed 16 times by 1 test: print_deferred_heredocs ("");
Executed by:
  • Self test
deferred_heredocsDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7898 times by 1 test
Evaluated by:
  • Self test
16-7898
307 printing_connection--; -
308 break;
executed 7914 times by 1 test: break;
Executed by:
  • Self test
7914
309-
310 case cm_function_def:
executed 11 times by 1 test: case cm_function_def:
Executed by:
  • Self test
11
311 print_function_def (command->value.Function_def);-
312 break;
executed 11 times by 1 test: break;
Executed by:
  • Self test
11
313-
314 case cm_group:
executed 734 times by 1 test: case cm_group:
Executed by:
  • Self test
734
315 print_group_command (command->value.Group);-
316 break;
executed 734 times by 1 test: break;
Executed by:
  • Self test
734
317-
318 case cm_subshell:
executed 5190 times by 1 test: case cm_subshell:
Executed by:
  • Self test
5190
319 cprintf ("( ");-
320 skip_this_indent++;-
321 make_command_string_internal (command->value.Subshell->command);-
322 PRINT_DEFERRED_HEREDOCS ("");
executed 2 times by 1 test: print_deferred_heredocs ("");
Executed by:
  • Self test
deferred_heredocsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5188 times by 1 test
Evaluated by:
  • Self test
2-5188
323 cprintf (" )");-
324 break;
executed 5190 times by 1 test: break;
Executed by:
  • Self test
5190
325-
326 case cm_coproc:
executed 33 times by 1 test: case cm_coproc:
Executed by:
  • Self test
33
327 cprintf ("coproc %s ", command->value.Coproc->name);-
328 skip_this_indent++;-
329 make_command_string_internal (command->value.Coproc->command);-
330 break;
executed 33 times by 1 test: break;
Executed by:
  • Self test
33
331-
332 default:
never executed: default:
0
333 command_error ("print_command", CMDERR_BADTYPE, command->type, 0);-
334 break;
never executed: break;
0
335 }-
336-
337-
338 if (command->redirects)
command->redirectsDescription
TRUEevaluated 1672 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28847 times by 1 test
Evaluated by:
  • Self test
1672-28847
339 {-
340 cprintf (" ");-
341 print_redirection_list (command->redirects);-
342 }
executed 1672 times by 1 test: end of block
Executed by:
  • Self test
1672
343 }
executed 30519 times by 1 test: end of block
Executed by:
  • Self test
30519
344}-
345-
346static void-
347_print_word_list (list, separator, pfunc)-
348 WORD_LIST *list;-
349 char *separator;-
350 PFUNC *pfunc;-
351{-
352 WORD_LIST *w;-
353-
354 for (w = list; w; w = w->next)
wDescription
TRUEevaluated 113345661 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76740485 times by 1 test
Evaluated by:
  • Self test
76740485-113345661
355 (*pfunc) ("%s%s", w->word->word, w->next ? separator : "");
executed 113345661 times by 1 test: (*pfunc) ("%s%s", w->word->word, w->next ? separator : "");
Executed by:
  • Self test
113345661
356}
executed 76740485 times by 1 test: end of block
Executed by:
  • Self test
76740485
357-
358void-
359print_word_list (list, separator)-
360 WORD_LIST *list;-
361 char *separator;-
362{-
363 _print_word_list (list, separator, xprintf);-
364}
never executed: end of block
0
365-
366void-
367xtrace_set (fd, fp)-
368 int fd;-
369 FILE *fp;-
370{-
371 if (fd >= 0 && sh_validfd (fd) == 0)
fd >= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5432 times by 1 test
Evaluated by:
  • Self test
sh_validfd (fd) == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-5432
372 {-
373 internal_error (_("xtrace_set: %d: invalid file descriptor"), fd);-
374 return;
never executed: return;
0
375 }-
376 if (fp == 0)
fp == 0Description
TRUEnever evaluated
FALSEevaluated 5433 times by 1 test
Evaluated by:
  • Self test
0-5433
377 {-
378 internal_error (_("xtrace_set: NULL file pointer"));-
379 return;
never executed: return;
0
380 }-
381 if (fd >= 0 && fileno (fp) != fd)
fd >= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5432 times by 1 test
Evaluated by:
  • Self test
fileno (fp) != fdDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-5432
382 internal_warning (_("xtrace fd (%d) != fileno xtrace fp (%d)"), fd, fileno (fp));
never executed: internal_warning ( dcgettext (((void *)0), "xtrace fd (%d) != fileno xtrace fp (%d)" , 5) , fd, fileno (fp));
0
383 -
384 xtrace_fd = fd;-
385 xtrace_fp = fp;-
386}
executed 5433 times by 1 test: end of block
Executed by:
  • Self test
5433
387-
388void-
389xtrace_init ()-
390{-
391 xtrace_set (-1, stderr);-
392}
executed 5432 times by 1 test: end of block
Executed by:
  • Self test
5432
393-
394void-
395xtrace_reset ()-
396{-
397 if (xtrace_fd >= 0 && xtrace_fp)
xtrace_fd >= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
xtrace_fpDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
398 {-
399 fflush (xtrace_fp);-
400 fclose (xtrace_fp);-
401 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
402 else if (xtrace_fd >= 0)
xtrace_fd >= 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
403 close (xtrace_fd);
never executed: close (xtrace_fd);
0
404-
405 xtrace_fd = -1;-
406 xtrace_fp = stderr;-
407}
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
408-
409void-
410xtrace_fdchk (fd)-
411 int fd;-
412{-
413 if (fd == xtrace_fd)
fd == xtrace_fdDescription
TRUEnever evaluated
FALSEevaluated 666440 times by 1 test
Evaluated by:
  • Self test
0-666440
414 xtrace_reset ();
never executed: xtrace_reset ();
0
415}
executed 666440 times by 1 test: end of block
Executed by:
  • Self test
666440
416-
417/* Return a string denoting what our indirection level is. */-
418-
419char *-
420indirection_level_string ()-
421{-
422 register int i, j;-
423 char *ps4;-
424 char ps4_firstc[MB_LEN_MAX+1];-
425 int ps4_firstc_len, ps4_len, ineed, old;-
426-
427 ps4 = get_string_value ("PS4");-
428 if (indirection_string == 0)
indirection_string == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53 times by 1 test
Evaluated by:
  • Self test
6-53
429 indirection_string = xmalloc (indirection_stringsiz = 100);
executed 6 times by 1 test: indirection_string = sh_xmalloc((indirection_stringsiz = 100), "print_cmd.c", 429);
Executed by:
  • Self test
6
430 indirection_string[0] = '\0';-
431-
432 if (ps4 == 0 || *ps4 == '\0')
ps4 == 0Description
TRUEnever evaluated
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
*ps4 == '\0'Description
TRUEnever evaluated
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
0-59
433 return (indirection_string);
never executed: return (indirection_string);
0
434-
435 old = change_flag ('x', FLAG_OFF);-
436 ps4 = decode_prompt_string (ps4);-
437 if (old)
oldDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-59
438 change_flag ('x', FLAG_ON);
executed 59 times by 1 test: change_flag ('x', '-');
Executed by:
  • Self test
59
439-
440 if (ps4 == 0 || *ps4 == '\0')
ps4 == 0Description
TRUEnever evaluated
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
*ps4 == '\0'Description
TRUEnever evaluated
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
0-59
441 return (indirection_string);
never executed: return (indirection_string);
0
442-
443#if defined (HANDLE_MULTIBYTE)-
444 ps4_len = strnlen (ps4, MB_CUR_MAX);-
445 ps4_firstc_len = MBLEN (ps4, ps4_len);
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-59
446 if (ps4_firstc_len == 1 || ps4_firstc_len == 0 || ps4_firstc_len < 0)
ps4_firstc_len == 1Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ps4_firstc_len == 0Description
TRUEnever evaluated
FALSEnever evaluated
ps4_firstc_len < 0Description
TRUEnever evaluated
FALSEnever evaluated
0-59
447 {-
448 ps4_firstc[0] = ps4[0];-
449 ps4_firstc[ps4_firstc_len = 1] = '\0';-
450 }
executed 59 times by 1 test: end of block
Executed by:
  • Self test
59
451 else-
452 memcpy (ps4_firstc, ps4, ps4_firstc_len);
never executed: memcpy (ps4_firstc, ps4, ps4_firstc_len);
0
453#else-
454 ps4_firstc[0] = ps4[0];-
455 ps4_firstc[ps4_firstc_len = 1] = '\0';-
456#endif-
457-
458 /* Dynamically resize indirection_string so we have room for everything-
459 and we don't have to truncate ps4 */-
460 ineed = (ps4_firstc_len * indirection_level) + strlen (ps4);-
461 if (ineed > indirection_stringsiz - 1)
ineed > indire..._stringsiz - 1Description
TRUEnever evaluated
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
0-59
462 {-
463 indirection_stringsiz = ineed + 1;-
464 indirection_string = xrealloc (indirection_string, indirection_stringsiz);-
465 }
never executed: end of block
0
466-
467 for (i = j = 0; ps4_firstc[0] && j < indirection_level && i < indirection_stringsiz - 1; i += ps4_firstc_len, j++)
ps4_firstc[0]Description
TRUEevaluated 119 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
j < indirection_levelDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
i < indirection_stringsiz - 1Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-119
468 {-
469 if (ps4_firstc_len == 1)
ps4_firstc_len == 1Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-60
470 indirection_string[i] = ps4_firstc[0];
executed 60 times by 1 test: indirection_string[i] = ps4_firstc[0];
Executed by:
  • Self test
60
471 else-
472 memcpy (indirection_string+i, ps4_firstc, ps4_firstc_len);
never executed: memcpy (indirection_string+i, ps4_firstc, ps4_firstc_len);
0
473 } -
474-
475 for (j = ps4_firstc_len; *ps4 && ps4[j] && i < indirection_stringsiz - 1; i++, j++)
*ps4Description
TRUEevaluated 148 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ps4[j]Description
TRUEevaluated 89 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
i < indirection_stringsiz - 1Description
TRUEevaluated 89 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-148
476 indirection_string[i] = ps4[j];
executed 89 times by 1 test: indirection_string[i] = ps4[j];
Executed by:
  • Self test
89
477-
478 indirection_string[i] = '\0';-
479 free (ps4);-
480 return (indirection_string);
executed 59 times by 1 test: return (indirection_string);
Executed by:
  • Self test
59
481}-
482-
483void-
484xtrace_print_assignment (name, value, assign_list, xflags)-
485 char *name, *value;-
486 int assign_list, xflags;-
487{-
488 char *nval;-
489-
490 CHECK_XTRACE_FP;
xtrace_fpDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-12
491-
492 if (xflags)
xflagsDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-12
493 fprintf (xtrace_fp, "%s", indirection_level_string ());
executed 12 times by 1 test: fprintf (xtrace_fp, "%s", indirection_level_string ());
Executed by:
  • Self test
12
494-
495 /* VALUE should not be NULL when this is called. */-
496 if (*value == '\0' || assign_list)
*value == '\0'Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
assign_listDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-12
497 nval = value;
never executed: nval = value;
0
498 else if (sh_contains_shell_metas (value))
sh_contains_sh..._metas (value)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-12
499 nval = sh_single_quote (value);
never executed: nval = sh_single_quote (value);
0
500 else if (ansic_shouldquote (value))
ansic_shouldquote (value)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-12
501 nval = ansic_quote (value, 0, (int *)0);
never executed: nval = ansic_quote (value, 0, (int *)0);
0
502 else-
503 nval = value;
executed 12 times by 1 test: nval = value;
Executed by:
  • Self test
12
504-
505 if (assign_list)
assign_listDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-12
506 fprintf (xtrace_fp, "%s=(%s)\n", name, nval);
never executed: fprintf (xtrace_fp, "%s=(%s)\n", name, nval);
0
507 else-
508 fprintf (xtrace_fp, "%s=%s\n", name, nval);
executed 12 times by 1 test: fprintf (xtrace_fp, "%s=%s\n", name, nval);
Executed by:
  • Self test
12
509-
510 if (nval != value)
nval != valueDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-12
511 FREE (nval);
never executed: sh_xfree((nval), "print_cmd.c", 511);
never executed: end of block
nvalDescription
TRUEnever evaluated
FALSEnever evaluated
0
512-
513 fflush (xtrace_fp);-
514}
executed 12 times by 1 test: end of block
Executed by:
  • Self test
12
515-
516/* A function to print the words of a simple command when set -x is on. Also used to-
517 print the word list in a for or select command header; in that case, we suppress-
518 quoting the words because they haven't been expanded yet. XTFLAGS&1 means to-
519 print $PS4; XTFLAGS&2 means to suppress quoting the words in LIST. */-
520void-
521xtrace_print_word_list (list, xtflags)-
522 WORD_LIST *list;-
523 int xtflags;-
524{-
525 WORD_LIST *w;-
526 char *t, *x;-
527-
528 CHECK_XTRACE_FP;
xtrace_fpDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-32
529-
530 if (xtflags&1)
xtflags&1Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
8-24
531 fprintf (xtrace_fp, "%s", indirection_level_string ());
executed 24 times by 1 test: fprintf (xtrace_fp, "%s", indirection_level_string ());
Executed by:
  • Self test
24
532-
533 for (w = list; w; w = w->next)
wDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
32-82
534 {-
535 t = w->word->word;-
536 if (t == 0 || *t == '\0')
t == 0Description
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
*t == '\0'Description
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
0-82
537 fprintf (xtrace_fp, "''%s", w->next ? " " : "");
never executed: fprintf (xtrace_fp, "''%s", w->next ? " " : "");
0
538 else if (xtflags & 2)
xtflags & 2Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test
34-48
539 fprintf (xtrace_fp, "%s%s", t, w->next ? " " : "");
executed 34 times by 1 test: fprintf (xtrace_fp, "%s%s", t, w->next ? " " : "");
Executed by:
  • Self test
34
540 else if (sh_contains_shell_metas (t))
sh_contains_shell_metas (t)Description
TRUEnever evaluated
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test
0-48
541 {-
542 x = sh_single_quote (t);-
543 fprintf (xtrace_fp, "%s%s", x, w->next ? " " : "");-
544 free (x);-
545 }
never executed: end of block
0
546 else if (ansic_shouldquote (t))
ansic_shouldquote (t)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47 times by 1 test
Evaluated by:
  • Self test
1-47
547 {-
548 x = ansic_quote (t, 0, (int *)0);-
549 fprintf (xtrace_fp, "%s%s", x, w->next ? " " : "");-
550 free (x);-
551 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
552 else-
553 fprintf (xtrace_fp, "%s%s", t, w->next ? " " : "");
executed 47 times by 1 test: fprintf (xtrace_fp, "%s%s", t, w->next ? " " : "");
Executed by:
  • Self test
47
554 }-
555 fprintf (xtrace_fp, "\n");-
556 fflush (xtrace_fp);-
557}
executed 32 times by 1 test: end of block
Executed by:
  • Self test
32
558-
559static void-
560command_print_word_list (list, separator)-
561 WORD_LIST *list;-
562 char *separator;-
563{-
564 _print_word_list (list, separator, cprintf);-
565}
executed 76740485 times by 1 test: end of block
Executed by:
  • Self test
76740485
566-
567void-
568print_for_command_head (for_command)-
569 FOR_COM *for_command;-
570{-
571 cprintf ("for %s in ", for_command->name->word);-
572 command_print_word_list (for_command->map_list, " ");-
573}
executed 5456701 times by 1 test: end of block
Executed by:
  • Self test
5456701
574-
575void-
576xtrace_print_for_command_head (for_command)-
577 FOR_COM *for_command;-
578{-
579 CHECK_XTRACE_FP;
xtrace_fpDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-8
580 fprintf (xtrace_fp, "%s", indirection_level_string ());-
581 fprintf (xtrace_fp, "for %s in ", for_command->name->word);-
582 xtrace_print_word_list (for_command->map_list, 2);-
583}
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
584-
585static void-
586print_for_command (for_command)-
587 FOR_COM *for_command;-
588{-
589 print_for_command_head (for_command);-
590 cprintf (";");-
591 newline ("do\n");-
592-
593 indentation += indentation_amount;-
594 make_command_string_internal (for_command->action);-
595 PRINT_DEFERRED_HEREDOCS ("");
executed 1 time by 1 test: print_deferred_heredocs ("");
Executed by:
  • Self test
deferred_heredocsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
1-18
596 semicolon ();-
597 indentation -= indentation_amount;-
598-
599 newline ("done");-
600}
executed 19 times by 1 test: end of block
Executed by:
  • Self test
19
601-
602#if defined (ARITH_FOR_COMMAND)-
603static void-
604print_arith_for_command (arith_for_command)-
605 ARITH_FOR_COM *arith_for_command;-
606{-
607 cprintf ("for ((");-
608 command_print_word_list (arith_for_command->init, " ");-
609 cprintf ("; ");-
610 command_print_word_list (arith_for_command->test, " ");-
611 cprintf ("; ");-
612 command_print_word_list (arith_for_command->step, " ");-
613 cprintf ("))");-
614 newline ("do\n");-
615 indentation += indentation_amount;-
616 make_command_string_internal (arith_for_command->action);-
617 PRINT_DEFERRED_HEREDOCS ("");
never executed: print_deferred_heredocs ("");
deferred_heredocsDescription
TRUEnever evaluated
FALSEevaluated 1119 times by 1 test
Evaluated by:
  • Self test
0-1119
618 semicolon ();-
619 indentation -= indentation_amount;-
620 newline ("done");-
621}
executed 1119 times by 1 test: end of block
Executed by:
  • Self test
1119
622#endif /* ARITH_FOR_COMMAND */-
623-
624#if defined (SELECT_COMMAND)-
625void-
626print_select_command_head (select_command)-
627 SELECT_COM *select_command;-
628{-
629 cprintf ("select %s in ", select_command->name->word);-
630 command_print_word_list (select_command->map_list, " ");-
631}
executed 9 times by 1 test: end of block
Executed by:
  • Self test
9
632-
633void-
634xtrace_print_select_command_head (select_command)-
635 SELECT_COM *select_command;-
636{-
637 CHECK_XTRACE_FP;
xtrace_fpDescription
TRUEnever evaluated
FALSEnever evaluated
0
638 fprintf (xtrace_fp, "%s", indirection_level_string ());-
639 fprintf (xtrace_fp, "select %s in ", select_command->name->word);-
640 xtrace_print_word_list (select_command->map_list, 2);-
641}
never executed: end of block
0
642-
643static void-
644print_select_command (select_command)-
645 SELECT_COM *select_command;-
646{-
647 print_select_command_head (select_command);-
648-
649 cprintf (";");-
650 newline ("do\n");-
651 indentation += indentation_amount;-
652 make_command_string_internal (select_command->action);-
653 PRINT_DEFERRED_HEREDOCS ("");
never executed: print_deferred_heredocs ("");
deferred_heredocsDescription
TRUEnever evaluated
FALSEnever evaluated
0
654 semicolon ();-
655 indentation -= indentation_amount;-
656 newline ("done");-
657}
never executed: end of block
0
658#endif /* SELECT_COMMAND */-
659-
660static void-
661print_group_command (group_command)-
662 GROUP_COM *group_command;-
663{-
664 group_command_nesting++;-
665 cprintf ("{ ");-
666-
667 if (inside_function_def == 0)
inside_function_def == 0Description
TRUEevaluated 718 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
16-718
668 skip_this_indent++;
executed 718 times by 1 test: skip_this_indent++;
Executed by:
  • Self test
718
669 else-
670 {-
671 /* This is a group command { ... } inside of a function-
672 definition, and should be printed as a multiline group-
673 command, using the current indentation. */-
674 cprintf ("\n");-
675 indentation += indentation_amount;-
676 }
executed 16 times by 1 test: end of block
Executed by:
  • Self test
16
677-
678 make_command_string_internal (group_command->command);-
679 PRINT_DEFERRED_HEREDOCS ("");
executed 2 times by 1 test: print_deferred_heredocs ("");
Executed by:
  • Self test
deferred_heredocsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 732 times by 1 test
Evaluated by:
  • Self test
2-732
680-
681 if (inside_function_def)
inside_function_defDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 718 times by 1 test
Evaluated by:
  • Self test
16-718
682 {-
683 cprintf ("\n");-
684 indentation -= indentation_amount;-
685 indent (indentation);-
686 }
executed 16 times by 1 test: end of block
Executed by:
  • Self test
16
687 else-
688 {-
689 semicolon ();-
690 cprintf (" ");-
691 }
executed 718 times by 1 test: end of block
Executed by:
  • Self test
718
692-
693 cprintf ("}");-
694-
695 group_command_nesting--;-
696}
executed 734 times by 1 test: end of block
Executed by:
  • Self test
734
697-
698void-
699print_case_command_head (case_command)-
700 CASE_COM *case_command;-
701{-
702 cprintf ("case %s in ", case_command->word->word);-
703}
executed 36947178 times by 1 test: end of block
Executed by:
  • Self test
36947178
704-
705void-
706xtrace_print_case_command_head (case_command)-
707 CASE_COM *case_command;-
708{-
709 CHECK_XTRACE_FP;
xtrace_fpDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
710 fprintf (xtrace_fp, "%s", indirection_level_string ());-
711 fprintf (xtrace_fp, "case %s in\n", case_command->word->word);-
712}
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
713-
714static void-
715print_case_command (case_command)-
716 CASE_COM *case_command;-
717{-
718 print_case_command_head (case_command);-
719-
720 if (case_command->clauses)
case_command->clausesDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
721 print_case_clauses (case_command->clauses);
executed 7 times by 1 test: print_case_clauses (case_command->clauses);
Executed by:
  • Self test
7
722 newline ("esac");-
723}
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
724-
725static void-
726print_case_clauses (clauses)-
727 PATTERN_LIST *clauses;-
728{-
729 indentation += indentation_amount;-
730 while (clauses)
clausesDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
7-14
731 {-
732 newline ("");-
733 command_print_word_list (clauses->patterns, " | ");-
734 cprintf (")\n");-
735 indentation += indentation_amount;-
736 make_command_string_internal (clauses->action);-
737 indentation -= indentation_amount;-
738 PRINT_DEFERRED_HEREDOCS ("");
never executed: print_deferred_heredocs ("");
deferred_heredocsDescription
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
0-14
739 if (clauses->flags & CASEPAT_FALLTHROUGH)
clauses->flags & 0x01Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
0-14
740 newline (";&");
never executed: newline (";&");
0
741 else if (clauses->flags & CASEPAT_TESTNEXT)
clauses->flags & 0x02Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
0-14
742 newline (";;&");
never executed: newline (";;&");
0
743 else-
744 newline (";;");
executed 14 times by 1 test: newline (";;");
Executed by:
  • Self test
14
745 clauses = clauses->next;-
746 }
executed 14 times by 1 test: end of block
Executed by:
  • Self test
14
747 indentation -= indentation_amount;-
748}
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
749-
750static void-
751print_while_command (while_command)-
752 WHILE_COM *while_command;-
753{-
754 print_until_or_while (while_command, "while");-
755}
executed 23 times by 1 test: end of block
Executed by:
  • Self test
23
756-
757static void-
758print_until_command (while_command)-
759 WHILE_COM *while_command;-
760{-
761 print_until_or_while (while_command, "until");-
762}
executed 5 times by 1 test: end of block
Executed by:
  • Self test
5
763-
764static void-
765print_until_or_while (while_command, which)-
766 WHILE_COM *while_command;-
767 char *which;-
768{-
769 cprintf ("%s ", which);-
770 skip_this_indent++;-
771 make_command_string_internal (while_command->test);-
772 PRINT_DEFERRED_HEREDOCS ("");
never executed: print_deferred_heredocs ("");
deferred_heredocsDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
0-28
773 semicolon ();-
774 cprintf (" do\n"); /* was newline ("do\n"); */-
775 indentation += indentation_amount;-
776 make_command_string_internal (while_command->action);-
777 PRINT_DEFERRED_HEREDOCS ("");
never executed: print_deferred_heredocs ("");
deferred_heredocsDescription
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
0-28
778 indentation -= indentation_amount;-
779 semicolon ();-
780 newline ("done");-
781}
executed 28 times by 1 test: end of block
Executed by:
  • Self test
28
782-
783static void-
784print_if_command (if_command)-
785 IF_COM *if_command;-
786{-
787 cprintf ("if ");-
788 skip_this_indent++;-
789 make_command_string_internal (if_command->test);-
790 semicolon ();-
791 cprintf (" then\n");-
792 indentation += indentation_amount;-
793 make_command_string_internal (if_command->true_case);-
794 PRINT_DEFERRED_HEREDOCS ("");
never executed: print_deferred_heredocs ("");
deferred_heredocsDescription
TRUEnever evaluated
FALSEevaluated 626 times by 1 test
Evaluated by:
  • Self test
0-626
795 indentation -= indentation_amount;-
796-
797 if (if_command->false_case)
if_command->false_caseDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 616 times by 1 test
Evaluated by:
  • Self test
10-616
798 {-
799 semicolon ();-
800 newline ("else\n");-
801 indentation += indentation_amount;-
802 make_command_string_internal (if_command->false_case);-
803 PRINT_DEFERRED_HEREDOCS ("");
never executed: print_deferred_heredocs ("");
deferred_heredocsDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
804 indentation -= indentation_amount;-
805 }
executed 10 times by 1 test: end of block
Executed by:
  • Self test
10
806 semicolon ();-
807 newline ("fi");-
808}
executed 626 times by 1 test: end of block
Executed by:
  • Self test
626
809-
810#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)-
811void-
812print_arith_command (arith_cmd_list)-
813 WORD_LIST *arith_cmd_list;-
814{-
815 cprintf ("((");-
816 command_print_word_list (arith_cmd_list, " ");-
817 cprintf ("))");-
818}
executed 6556553 times by 1 test: end of block
Executed by:
  • Self test
6556553
819#endif-
820-
821#if defined (COND_COMMAND)-
822static void-
823print_cond_node (cond)-
824 COND_COM *cond;-
825{-
826 if (cond->flags & CMD_INVERT_RETURN)
cond->flags & 0x04Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2900 times by 1 test
Evaluated by:
  • Self test
2-2900
827 cprintf ("! ");
executed 2 times by 1 test: cprintf ("! ");
Executed by:
  • Self test
2
828-
829 if (cond->type == COND_EXPR)
cond->type == 6Description
TRUEevaluated 141 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2761 times by 1 test
Evaluated by:
  • Self test
141-2761
830 {-
831 cprintf ("( ");-
832 print_cond_node (cond->left);-
833 cprintf (" )");-
834 }
executed 141 times by 1 test: end of block
Executed by:
  • Self test
141
835 else if (cond->type == COND_AND)
cond->type == 1Description
TRUEevaluated 169 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2592 times by 1 test
Evaluated by:
  • Self test
169-2592
836 {-
837 print_cond_node (cond->left);-
838 cprintf (" && ");-
839 print_cond_node (cond->right);-
840 }
executed 169 times by 1 test: end of block
Executed by:
  • Self test
169
841 else if (cond->type == COND_OR)
cond->type == 2Description
TRUEevaluated 77 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2515 times by 1 test
Evaluated by:
  • Self test
77-2515
842 {-
843 print_cond_node (cond->left);-
844 cprintf (" || ");-
845 print_cond_node (cond->right);-
846 }
executed 77 times by 1 test: end of block
Executed by:
  • Self test
77
847 else if (cond->type == COND_UNARY)
cond->type == 3Description
TRUEevaluated 143 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2372 times by 1 test
Evaluated by:
  • Self test
143-2372
848 {-
849 cprintf ("%s", cond->op->word);-
850 cprintf (" ");-
851 print_cond_node (cond->left);-
852 }
executed 143 times by 1 test: end of block
Executed by:
  • Self test
143
853 else if (cond->type == COND_BINARY)
cond->type == 4Description
TRUEevaluated 743 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1629 times by 1 test
Evaluated by:
  • Self test
743-1629
854 {-
855 print_cond_node (cond->left);-
856 cprintf (" ");-
857 cprintf ("%s", cond->op->word);-
858 cprintf (" ");-
859 print_cond_node (cond->right);-
860 }
executed 743 times by 1 test: end of block
Executed by:
  • Self test
743
861 else if (cond->type == COND_TERM)
cond->type == 5Description
TRUEevaluated 1629 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1629
862 {-
863 cprintf ("%s", cond->op->word); /* need to add quoting here */-
864 }
executed 1629 times by 1 test: end of block
Executed by:
  • Self test
1629
865}
executed 2902 times by 1 test: end of block
Executed by:
  • Self test
2902
866-
867void-
868print_cond_command (cond)-
869 COND_COM *cond;-
870{-
871 cprintf ("[[ ");-
872 print_cond_node (cond);-
873 cprintf (" ]]");-
874}
executed 640 times by 1 test: end of block
Executed by:
  • Self test
640
875-
876#ifdef DEBUG-
877void-
878debug_print_word_list (s, list, sep)-
879 char *s;-
880 WORD_LIST *list;-
881 char *sep;-
882{-
883 WORD_LIST *w;-
884-
885 if (s)
sDescription
TRUEnever evaluated
FALSEnever evaluated
0
886 fprintf (stderr, "%s: ", s);
never executed: fprintf ( stderr , "%s: ", s);
0
887 for (w = list; w; w = w->next)
wDescription
TRUEnever evaluated
FALSEnever evaluated
0
888 fprintf (stderr, "%s%s", w->word->word, w->next ? sep : "");
never executed: fprintf ( stderr , "%s%s", w->word->word, w->next ? sep : "");
0
889 fprintf (stderr, "\n");-
890}
never executed: end of block
0
891-
892void-
893debug_print_cond_command (cond)-
894 COND_COM *cond;-
895{-
896 fprintf (stderr, "DEBUG: ");-
897 command_string_index = 0;-
898 print_cond_command (cond);-
899 fprintf (stderr, "%s\n", the_printed_command);-
900}
never executed: end of block
0
901#endif-
902-
903void-
904xtrace_print_cond_term (type, invert, op, arg1, arg2)-
905 int type, invert;-
906 WORD_DESC *op;-
907 char *arg1, *arg2;-
908{-
909 CHECK_XTRACE_FP;
xtrace_fpDescription
TRUEnever evaluated
FALSEnever evaluated
0
910 command_string_index = 0;-
911 fprintf (xtrace_fp, "%s", indirection_level_string ());-
912 fprintf (xtrace_fp, "[[ ");-
913 if (invert)
invertDescription
TRUEnever evaluated
FALSEnever evaluated
0
914 fprintf (xtrace_fp, "! ");
never executed: fprintf (xtrace_fp, "! ");
0
915-
916 if (type == COND_UNARY)
type == 3Description
TRUEnever evaluated
FALSEnever evaluated
0
917 {-
918 fprintf (xtrace_fp, "%s ", op->word);-
919 fprintf (xtrace_fp, "%s", (arg1 && *arg1) ? arg1 : "''");-
920 }
never executed: end of block
0
921 else if (type == COND_BINARY)
type == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
922 {-
923 fprintf (xtrace_fp, "%s", (arg1 && *arg1) ? arg1 : "''");-
924 fprintf (xtrace_fp, " %s ", op->word);-
925 fprintf (xtrace_fp, "%s", (arg2 && *arg2) ? arg2 : "''");-
926 }
never executed: end of block
0
927-
928 fprintf (xtrace_fp, " ]]\n");-
929-
930 fflush (xtrace_fp);-
931}
never executed: end of block
never executed: end of block
0
932#endif /* COND_COMMAND */-
933-
934#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)-
935/* A function to print the words of an arithmetic command when set -x is on. */-
936void-
937xtrace_print_arith_cmd (list)-
938 WORD_LIST *list;-
939{-
940 WORD_LIST *w;-
941-
942 CHECK_XTRACE_FP;
xtrace_fpDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-14
943 fprintf (xtrace_fp, "%s", indirection_level_string ());-
944 fprintf (xtrace_fp, "(( ");-
945 for (w = list; w; w = w->next)
wDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
14
946 fprintf (xtrace_fp, "%s%s", w->word->word, w->next ? " " : "");
executed 14 times by 1 test: fprintf (xtrace_fp, "%s%s", w->word->word, w->next ? " " : "");
Executed by:
  • Self test
14
947 fprintf (xtrace_fp, " ))\n");-
948-
949 fflush (xtrace_fp);-
950}
executed 14 times by 1 test: end of block
Executed by:
  • Self test
14
951#endif-
952-
953void-
954print_simple_command (simple_command)-
955 SIMPLE_COM *simple_command;-
956{-
957 command_print_word_list (simple_command->words, " ");-
958-
959 if (simple_command->redirects)
simple_command->redirectsDescription
TRUEevaluated 14550 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64709301 times by 1 test
Evaluated by:
  • Self test
14550-64709301
960 {-
961 cprintf (" ");-
962 print_redirection_list (simple_command->redirects);-
963 }
executed 14550 times by 1 test: end of block
Executed by:
  • Self test
14550
964}
executed 64723851 times by 1 test: end of block
Executed by:
  • Self test
64723851
965-
966static void-
967print_heredocs (heredocs)-
968 REDIRECT *heredocs;-
969{-
970 REDIRECT *hdtail;-
971-
972 cprintf (" "); -
973 for (hdtail = heredocs; hdtail; hdtail = hdtail->next)
hdtailDescription
TRUEnever evaluated
FALSEnever evaluated
0
974 {-
975 print_redirection (hdtail);-
976 cprintf ("\n");-
977 }
never executed: end of block
0
978 was_heredoc = 1;-
979}
never executed: end of block
0
980-
981static void-
982print_heredoc_bodies (heredocs)-
983 REDIRECT *heredocs;-
984{-
985 REDIRECT *hdtail;-
986-
987 cprintf ("\n"); -
988 for (hdtail = heredocs; hdtail; hdtail = hdtail->next)
hdtailDescription
TRUEevaluated 1342 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1340 times by 1 test
Evaluated by:
  • Self test
1340-1342
989 {-
990 print_heredoc_body (hdtail);-
991 cprintf ("\n");-
992 }
executed 1342 times by 1 test: end of block
Executed by:
  • Self test
1342
993 was_heredoc = 1;-
994}
executed 1340 times by 1 test: end of block
Executed by:
  • Self test
1340
995-
996/* Print heredocs that are attached to the command before the connector-
997 represented by CSTRING. The parsing semantics require us to print the-
998 here-doc delimiters, then the connector (CSTRING), then the here-doc-
999 bodies. We print the here-doc delimiters in print_redirection_list-
1000 and print the connector and the bodies here. We don't print the connector-
1001 if it's a `;', but we use it to note not to print an extra space after the-
1002 last heredoc body and newline. */-
1003static void-
1004print_deferred_heredocs (cstring)-
1005 const char *cstring;-
1006{-
1007 /* We now print the heredoc headers in print_redirection_list */-
1008 if (cstring && cstring[0] && (cstring[0] != ';' || cstring[1]))
cstringDescription
TRUEevaluated 200 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
cstring[0]Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
cstring[0] != ';'Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
cstring[1]Description
TRUEnever evaluated
FALSEnever evaluated
0-200
1009 cprintf ("%s", cstring);
executed 166 times by 1 test: cprintf ("%s", cstring);
Executed by:
  • Self test
166
1010 if (deferred_heredocs)
deferred_heredocsDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 166 times by 1 test
Evaluated by:
  • Self test
34-166
1011 {-
1012 print_heredoc_bodies (deferred_heredocs);-
1013 if (cstring && cstring[0] && (cstring[0] != ';' || cstring[1]))
cstringDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
cstring[0]Description
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
cstring[0] != ';'Description
TRUEnever evaluated
FALSEnever evaluated
cstring[1]Description
TRUEnever evaluated
FALSEnever evaluated
0-34
1014 cprintf (" "); /* make sure there's at least one space */
never executed: cprintf (" ");
0
1015 dispose_redirects (deferred_heredocs);-
1016 was_heredoc = 1;-
1017 }
executed 34 times by 1 test: end of block
Executed by:
  • Self test
34
1018 deferred_heredocs = (REDIRECT *)NULL;-
1019}
executed 200 times by 1 test: end of block
Executed by:
  • Self test
200
1020 -
1021static void-
1022print_redirection_list (redirects)-
1023 REDIRECT *redirects;-
1024{-
1025 REDIRECT *heredocs, *hdtail, *newredir;-
1026 char *rw;-
1027-
1028 heredocs = (REDIRECT *)NULL;-
1029 hdtail = heredocs;-
1030-
1031 was_heredoc = 0;-
1032 while (redirects)
redirectsDescription
TRUEevaluated 17606 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16246 times by 1 test
Evaluated by:
  • Self test
16246-17606
1033 {-
1034 /* Defer printing the here document bodiess until we've printed the rest of the-
1035 redirections, but print the headers in the order they're given. */-
1036 if (redirects->instruction == r_reading_until || redirects->instruction == r_deblank_reading_until)
redirects->ins..._reading_untilDescription
TRUEevaluated 1334 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16272 times by 1 test
Evaluated by:
  • Self test
redirects->ins..._reading_untilDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16264 times by 1 test
Evaluated by:
  • Self test
8-16272
1037 {-
1038 newredir = copy_redirect (redirects);-
1039 newredir->next = (REDIRECT *)NULL;-
1040-
1041 print_heredoc_header (newredir);-
1042-
1043 if (heredocs)
heredocsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1340 times by 1 test
Evaluated by:
  • Self test
2-1340
1044 {-
1045 hdtail->next = newredir;-
1046 hdtail = newredir;-
1047 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
1048 else-
1049 hdtail = heredocs = newredir;
executed 1340 times by 1 test: hdtail = heredocs = newredir;
Executed by:
  • Self test
1340
1050 }-
1051 else if (redirects->instruction == r_duplicating_output_word && (redirects->flags & REDIR_VARASSIGN) == 0 && redirects->redirector.dest == 1)
redirects->ins...ng_output_wordDescription
TRUEevaluated 113 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16151 times by 1 test
Evaluated by:
  • Self test
(redirects->flags & 0x01) == 0Description
TRUEevaluated 113 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
redirects->red...ctor.dest == 1Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-16151
1052 {-
1053 /* Temporarily translate it as the execution code does. */-
1054 rw = redirects->redirectee.filename->word;-
1055 if (rw && *rw != '-' && DIGIT (*rw) == 0 && EXPCHAR (*rw) == 0)
rwDescription
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*rw != '-'Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((*rw) >= '0' ...) <= '9') == 0Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(*rw) >= '0'Description
TRUEnever evaluated
FALSEevaluated 108 times by 1 test
Evaluated by:
  • Self test
(*rw) <= '9'Description
TRUEnever evaluated
FALSEnever evaluated
((*rw) == '{' ...) == '`') == 0Description
TRUEnever evaluated
FALSEevaluated 108 times by 1 test
Evaluated by:
  • Self test
(*rw) == '{'Description
TRUEnever evaluated
FALSEevaluated 108 times by 1 test
Evaluated by:
  • Self test
(*rw) == '~'Description
TRUEnever evaluated
FALSEevaluated 108 times by 1 test
Evaluated by:
  • Self test
(*rw) == '$'Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(*rw) == '`'Description
TRUEnever evaluated
FALSEnever evaluated
0-108
1056 redirects->instruction = r_err_and_out;
never executed: redirects->instruction = r_err_and_out;
0
1057 print_redirection (redirects);-
1058 redirects->instruction = r_duplicating_output_word;-
1059 }
executed 108 times by 1 test: end of block
Executed by:
  • Self test
108
1060 else-
1061 print_redirection (redirects);
executed 16156 times by 1 test: print_redirection (redirects);
Executed by:
  • Self test
16156
1062-
1063 redirects = redirects->next;-
1064 if (redirects)
redirectsDescription
TRUEevaluated 1360 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16246 times by 1 test
Evaluated by:
  • Self test
1360-16246
1065 cprintf (" ");
executed 1360 times by 1 test: cprintf (" ");
Executed by:
  • Self test
1360
1066 }
executed 17606 times by 1 test: end of block
Executed by:
  • Self test
17606
1067-
1068 /* Now that we've printed all the other redirections (on one line),-
1069 print the here documents. If we're printing a connection, we wait until-
1070 we print the connector symbol, then we print the here document bodies */-
1071 if (heredocs && printing_connection)
heredocsDescription
TRUEevaluated 1340 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14906 times by 1 test
Evaluated by:
  • Self test
printing_connectionDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1306 times by 1 test
Evaluated by:
  • Self test
34-14906
1072 deferred_heredocs = heredocs;
executed 34 times by 1 test: deferred_heredocs = heredocs;
Executed by:
  • Self test
34
1073 else if (heredocs)
heredocsDescription
TRUEevaluated 1306 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14906 times by 1 test
Evaluated by:
  • Self test
1306-14906
1074 {-
1075 print_heredoc_bodies (heredocs);-
1076 dispose_redirects (heredocs);-
1077 }
executed 1306 times by 1 test: end of block
Executed by:
  • Self test
1306
1078}
executed 16246 times by 1 test: end of block
Executed by:
  • Self test
16246
1079-
1080static void-
1081print_heredoc_header (redirect)-
1082 REDIRECT *redirect;-
1083{-
1084 int kill_leading;-
1085 char *x;-
1086-
1087 kill_leading = redirect->instruction == r_deblank_reading_until;-
1088-
1089 /* Here doc header */-
1090 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1340 times by 1 test
Evaluated by:
  • Self test
2-1340
1091 cprintf ("{%s}", redirect->redirector.filename->word);
executed 2 times by 1 test: cprintf ("{%s}", redirect->redirector.filename->word);
Executed by:
  • Self test
2
1092 else if (redirect->redirector.dest != 0)
redirect->redirector.dest != 0Description
TRUEnever evaluated
FALSEevaluated 1340 times by 1 test
Evaluated by:
  • Self test
0-1340
1093 cprintf ("%d", redirect->redirector.dest);
never executed: cprintf ("%d", redirect->redirector.dest);
0
1094-
1095 /* If the here document delimiter is quoted, single-quote it. */-
1096 if (redirect->redirectee.filename->flags & W_QUOTED)
redirect->redi...ags & 0x000002Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1285 times by 1 test
Evaluated by:
  • Self test
57-1285
1097 {-
1098 x = sh_single_quote (redirect->here_doc_eof);-
1099 cprintf ("<<%s%s", kill_leading ? "-" : "", x);-
1100 free (x);-
1101 }
executed 57 times by 1 test: end of block
Executed by:
  • Self test
57
1102 else-
1103 cprintf ("<<%s%s", kill_leading ? "-" : "", redirect->here_doc_eof);
executed 1285 times by 1 test: cprintf ("<<%s%s", kill_leading ? "-" : "", redirect->here_doc_eof);
Executed by:
  • Self test
1285
1104}-
1105-
1106static void-
1107print_heredoc_body (redirect)-
1108 REDIRECT *redirect;-
1109{-
1110 /* Here doc body */-
1111 cprintf ("%s%s", redirect->redirectee.filename->word, redirect->here_doc_eof);-
1112}
executed 1342 times by 1 test: end of block
Executed by:
  • Self test
1342
1113-
1114static void-
1115print_redirection (redirect)-
1116 REDIRECT *redirect;-
1117{-
1118 int redirector, redir_fd;-
1119 WORD_DESC *redirectee, *redir_word;-
1120-
1121 redirectee = redirect->redirectee.filename;-
1122 redir_fd = redirect->redirectee.dest;-
1123-
1124 redir_word = redirect->redirector.filename;-
1125 redirector = redirect->redirector.dest;-
1126-
1127 switch (redirect->instruction)-
1128 {-
1129 case r_input_direction:
executed 1457 times by 1 test: case r_input_direction:
Executed by:
  • Self test
1457
1130 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1452 times by 1 test
Evaluated by:
  • Self test
5-1452
1131 cprintf ("{%s}", redir_word->word);
executed 5 times by 1 test: cprintf ("{%s}", redir_word->word);
Executed by:
  • Self test
5
1132 else if (redirector != 0)
redirector != 0Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1405 times by 1 test
Evaluated by:
  • Self test
47-1405
1133 cprintf ("%d", redirector);
executed 47 times by 1 test: cprintf ("%d", redirector);
Executed by:
  • Self test
47
1134 cprintf ("< %s", redirectee->word);-
1135 break;
executed 1457 times by 1 test: break;
Executed by:
  • Self test
1457
1136-
1137 case r_output_direction:
executed 12607 times by 1 test: case r_output_direction:
Executed by:
  • Self test
12607
1138 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12597 times by 1 test
Evaluated by:
  • Self test
10-12597
1139 cprintf ("{%s}", redir_word->word);
executed 10 times by 1 test: cprintf ("{%s}", redir_word->word);
Executed by:
  • Self test
10
1140 else if (redirector != 1)
redirector != 1Description
TRUEevaluated 4036 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8561 times by 1 test
Evaluated by:
  • Self test
4036-8561
1141 cprintf ("%d", redirector);
executed 4036 times by 1 test: cprintf ("%d", redirector);
Executed by:
  • Self test
4036
1142 cprintf ("> %s", redirectee->word);-
1143 break;
executed 12607 times by 1 test: break;
Executed by:
  • Self test
12607
1144-
1145 case r_inputa_direction: /* Redirection created by the shell. */
never executed: case r_inputa_direction:
0
1146 cprintf ("&");-
1147 break;
never executed: break;
0
1148-
1149 case r_output_force:
executed 19 times by 1 test: case r_output_force:
Executed by:
  • Self test
19
1150 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
0-19
1151 cprintf ("{%s}", redir_word->word);
never executed: cprintf ("{%s}", redir_word->word);
0
1152 else if (redirector != 1)
redirector != 1Description
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
0-19
1153 cprintf ("%d", redirector);
never executed: cprintf ("%d", redirector);
0
1154 cprintf (">| %s", redirectee->word);-
1155 break;
executed 19 times by 1 test: break;
Executed by:
  • Self test
19
1156-
1157 case r_appending_to:
executed 40 times by 1 test: case r_appending_to:
Executed by:
  • Self test
40
1158 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • Self test
0-40
1159 cprintf ("{%s}", redir_word->word);
never executed: cprintf ("{%s}", redir_word->word);
0
1160 else if (redirector != 1)
redirector != 1Description
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • Self test
0-40
1161 cprintf ("%d", redirector);
never executed: cprintf ("%d", redirector);
0
1162 cprintf (">> %s", redirectee->word);-
1163 break;
executed 40 times by 1 test: break;
Executed by:
  • Self test
40
1164-
1165 case r_input_output:
executed 18 times by 1 test: case r_input_output:
Executed by:
  • Self test
18
1166 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
0-18
1167 cprintf ("{%s}", redir_word->word);
never executed: cprintf ("{%s}", redir_word->word);
0
1168 else if (redirector != 1)
redirector != 1Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-18
1169 cprintf ("%d", redirector);
executed 18 times by 1 test: cprintf ("%d", redirector);
Executed by:
  • Self test
18
1170 cprintf ("<> %s", redirectee->word);-
1171 break;
executed 18 times by 1 test: break;
Executed by:
  • Self test
18
1172-
1173 case r_deblank_reading_until:
never executed: case r_deblank_reading_until:
0
1174 case r_reading_until:
never executed: case r_reading_until:
0
1175 print_heredoc_header (redirect);-
1176 cprintf ("\n");-
1177 print_heredoc_body (redirect);-
1178 break;
never executed: break;
0
1179-
1180 case r_reading_string:
executed 56 times by 1 test: case r_reading_string:
Executed by:
  • Self test
56
1181 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEnever evaluated
FALSEevaluated 56 times by 1 test
Evaluated by:
  • Self test
0-56
1182 cprintf ("{%s}", redir_word->word);
never executed: cprintf ("{%s}", redir_word->word);
0
1183 else if (redirector != 0)
redirector != 0Description
TRUEnever evaluated
FALSEevaluated 56 times by 1 test
Evaluated by:
  • Self test
0-56
1184 cprintf ("%d", redirector);
never executed: cprintf ("%d", redirector);
0
1185#if 0-
1186 /* Don't need to check whether or not to requote, since original quotes-
1187 are still intact. The only thing that has happened is that $'...'-
1188 has been replaced with 'expanded ...'. */-
1189 if (ansic_shouldquote (redirect->redirectee.filename->word))-
1190 {-
1191 char *x;-
1192 x = ansic_quote (redirect->redirectee.filename->word, 0, (int *)0);-
1193 cprintf ("<<< %s", x);-
1194 free (x);-
1195 }-
1196 else-
1197#endif-
1198 cprintf ("<<< %s", redirect->redirectee.filename->word);-
1199 break;
executed 56 times by 1 test: break;
Executed by:
  • Self test
56
1200-
1201 case r_duplicating_input:
executed 35 times by 1 test: case r_duplicating_input:
Executed by:
  • Self test
35
1202 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
4-31
1203 cprintf ("{%s}<&%d", redir_word->word, redir_fd);
executed 4 times by 1 test: cprintf ("{%s}<&%d", redir_word->word, redir_fd);
Executed by:
  • Self test
4
1204 else-
1205 cprintf ("%d<&%d", redirector, redir_fd);
executed 31 times by 1 test: cprintf ("%d<&%d", redirector, redir_fd);
Executed by:
  • Self test
31
1206 break;
executed 35 times by 1 test: break;
Executed by:
  • Self test
35
1207-
1208 case r_duplicating_output:
executed 811 times by 1 test: case r_duplicating_output:
Executed by:
  • Self test
811
1209 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 806 times by 1 test
Evaluated by:
  • Self test
5-806
1210 cprintf ("{%s}>&%d", redir_word->word, redir_fd);
executed 5 times by 1 test: cprintf ("{%s}>&%d", redir_word->word, redir_fd);
Executed by:
  • Self test
5
1211 else-
1212 cprintf ("%d>&%d", redirector, redir_fd);
executed 806 times by 1 test: cprintf ("%d>&%d", redirector, redir_fd);
Executed by:
  • Self test
806
1213 break;
executed 811 times by 1 test: break;
Executed by:
  • Self test
811
1214-
1215 case r_duplicating_input_word:
executed 22 times by 1 test: case r_duplicating_input_word:
Executed by:
  • Self test
22
1216 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
2-20
1217 cprintf ("{%s}<&%s", redir_word->word, redirectee->word);
executed 2 times by 1 test: cprintf ("{%s}<&%s", redir_word->word, redirectee->word);
Executed by:
  • Self test
2
1218 else-
1219 cprintf ("%d<&%s", redirector, redirectee->word);
executed 20 times by 1 test: cprintf ("%d<&%s", redirector, redirectee->word);
Executed by:
  • Self test
20
1220 break;
executed 22 times by 1 test: break;
Executed by:
  • Self test
22
1221-
1222 case r_duplicating_output_word:
executed 113 times by 1 test: case r_duplicating_output_word:
Executed by:
  • Self test
113
1223 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 111 times by 1 test
Evaluated by:
  • Self test
2-111
1224 cprintf ("{%s}>&%s", redir_word->word, redirectee->word);
executed 2 times by 1 test: cprintf ("{%s}>&%s", redir_word->word, redirectee->word);
Executed by:
  • Self test
2
1225 else-
1226 cprintf ("%d>&%s", redirector, redirectee->word);
executed 111 times by 1 test: cprintf ("%d>&%s", redirector, redirectee->word);
Executed by:
  • Self test
111
1227 break;
executed 113 times by 1 test: break;
Executed by:
  • Self test
113
1228-
1229 case r_move_input:
executed 3 times by 1 test: case r_move_input:
Executed by:
  • Self test
3
1230 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
1231 cprintf ("{%s}<&%d-", redir_word->word, redir_fd);
never executed: cprintf ("{%s}<&%d-", redir_word->word, redir_fd);
0
1232 else-
1233 cprintf ("%d<&%d-", redirector, redir_fd);
executed 3 times by 1 test: cprintf ("%d<&%d-", redirector, redir_fd);
Executed by:
  • Self test
3
1234 break;
executed 3 times by 1 test: break;
Executed by:
  • Self test
3
1235-
1236 case r_move_output:
never executed: case r_move_output:
0
1237 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEnever evaluated
FALSEnever evaluated
0
1238 cprintf ("{%s}>&%d-", redir_word->word, redir_fd);
never executed: cprintf ("{%s}>&%d-", redir_word->word, redir_fd);
0
1239 else-
1240 cprintf ("%d>&%d-", redirector, redir_fd);
never executed: cprintf ("%d>&%d-", redirector, redir_fd);
0
1241 break;
never executed: break;
0
1242-
1243 case r_move_input_word:
executed 5 times by 1 test: case r_move_input_word:
Executed by:
  • Self test
5
1244 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-4
1245 cprintf ("{%s}<&%s-", redir_word->word, redirectee->word);
executed 4 times by 1 test: cprintf ("{%s}<&%s-", redir_word->word, redirectee->word);
Executed by:
  • Self test
4
1246 else-
1247 cprintf ("%d<&%s-", redirector, redirectee->word);
executed 1 time by 1 test: cprintf ("%d<&%s-", redirector, redirectee->word);
Executed by:
  • Self test
1
1248 break;
executed 5 times by 1 test: break;
Executed by:
  • Self test
5
1249-
1250 case r_move_output_word:
executed 5 times by 1 test: case r_move_output_word:
Executed by:
  • Self test
5
1251 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-4
1252 cprintf ("{%s}>&%s-", redir_word->word, redirectee->word);
executed 4 times by 1 test: cprintf ("{%s}>&%s-", redir_word->word, redirectee->word);
Executed by:
  • Self test
4
1253 else-
1254 cprintf ("%d>&%s-", redirector, redirectee->word);
executed 1 time by 1 test: cprintf ("%d>&%s-", redirector, redirectee->word);
Executed by:
  • Self test
1
1255 break;
executed 5 times by 1 test: break;
Executed by:
  • Self test
5
1256-
1257 case r_close_this:
executed 1054 times by 1 test: case r_close_this:
Executed by:
  • Self test
1054
1258 if (redirect->rflags & REDIR_VARASSIGN)
redirect->rflags & 0x01Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1047 times by 1 test
Evaluated by:
  • Self test
7-1047
1259 cprintf ("{%s}>&-", redir_word->word);
executed 7 times by 1 test: cprintf ("{%s}>&-", redir_word->word);
Executed by:
  • Self test
7
1260 else-
1261 cprintf ("%d>&-", redirector);
executed 1047 times by 1 test: cprintf ("%d>&-", redirector);
Executed by:
  • Self test
1047
1262 break;
executed 1054 times by 1 test: break;
Executed by:
  • Self test
1054
1263-
1264 case r_err_and_out:
executed 15 times by 1 test: case r_err_and_out:
Executed by:
  • Self test
15
1265 cprintf ("&> %s", redirectee->word);-
1266 break;
executed 15 times by 1 test: break;
Executed by:
  • Self test
15
1267-
1268 case r_append_err_and_out:
executed 4 times by 1 test: case r_append_err_and_out:
Executed by:
  • Self test
4
1269 cprintf ("&>> %s", redirectee->word);-
1270 break;
executed 4 times by 1 test: break;
Executed by:
  • Self test
4
1271 }-
1272}
executed 16264 times by 1 test: end of block
Executed by:
  • Self test
16264
1273-
1274static void-
1275reset_locals ()-
1276{-
1277 inside_function_def = 0;-
1278 indentation = 0;-
1279 printing_connection = 0;-
1280 deferred_heredocs = 0;-
1281}
never executed: end of block
0
1282-
1283static void-
1284print_function_def (func)-
1285 FUNCTION_DEF *func;-
1286{-
1287 COMMAND *cmdcopy;-
1288 REDIRECT *func_redirects;-
1289-
1290 func_redirects = NULL;-
1291 /* When in posix mode, print functions as posix specifies them. */-
1292 if (posixly_correct == 0)
posixly_correct == 0Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11
1293 cprintf ("function %s () \n", func->name->word);
executed 11 times by 1 test: cprintf ("function %s () \n", func->name->word);
Executed by:
  • Self test
11
1294 else-
1295 cprintf ("%s () \n", func->name->word);
never executed: cprintf ("%s () \n", func->name->word);
0
1296 add_unwind_protect (reset_locals, 0);-
1297-
1298 indent (indentation);-
1299 cprintf ("{ \n");-
1300-
1301 inside_function_def++;-
1302 indentation += indentation_amount;-
1303-
1304 cmdcopy = copy_command (func->command);-
1305 if (cmdcopy->type == cm_group)
cmdcopy->type == cm_groupDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11
1306 {-
1307 func_redirects = cmdcopy->redirects;-
1308 cmdcopy->redirects = (REDIRECT *)NULL;-
1309 }
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
1310 make_command_string_internal (cmdcopy->type == cm_group-
1311 ? cmdcopy->value.Group->command-
1312 : cmdcopy);-
1313 /* XXX - PRINT_DEFERRED_HEREDOCS (""); ? */-
1314-
1315 remove_unwind_protect ();-
1316 indentation -= indentation_amount;-
1317 inside_function_def--;-
1318-
1319 if (func_redirects)
func_redirectsDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11
1320 { /* { */-
1321 newline ("} ");-
1322 print_redirection_list (func_redirects);-
1323 cmdcopy->redirects = func_redirects;-
1324 }
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
1325 else-
1326 newline ("}");
never executed: newline ("}");
0
1327-
1328 dispose_command (cmdcopy);-
1329}
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
1330-
1331/* Return the string representation of the named function.-
1332 NAME is the name of the function.-
1333 COMMAND is the function body. It should be a GROUP_COM.-
1334 flags&FUNC_MULTILINE is non-zero to pretty-print, or zero for all on one line.-
1335 flags&FUNC_EXTERNAL means convert from internal to external form-
1336 */-
1337char *-
1338named_function_string (name, command, flags)-
1339 char *name;-
1340 COMMAND *command;-
1341 int flags;-
1342{-
1343 char *result;-
1344 int old_indent, old_amount;-
1345 COMMAND *cmdcopy;-
1346 REDIRECT *func_redirects;-
1347-
1348 old_indent = indentation;-
1349 old_amount = indentation_amount;-
1350 command_string_index = was_heredoc = 0;-
1351 deferred_heredocs = 0;-
1352-
1353 if (name && *name)
nameDescription
TRUEevaluated 304 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69 times by 1 test
Evaluated by:
  • Self test
*nameDescription
TRUEevaluated 304 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-304
1354 {-
1355 if (find_reserved_word (name) >= 0)
find_reserved_word (name) >= 0Description
TRUEnever evaluated
FALSEevaluated 304 times by 1 test
Evaluated by:
  • Self test
0-304
1356 cprintf ("function ");
never executed: cprintf ("function ");
0
1357 cprintf ("%s ", name);-
1358 }
executed 304 times by 1 test: end of block
Executed by:
  • Self test
304
1359-
1360 cprintf ("() ");-
1361-
1362 if ((flags & FUNC_MULTILINE) == 0)
(flags & 0x01) == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 312 times by 1 test
Evaluated by:
  • Self test
61-312
1363 {-
1364 indentation = 1;-
1365 indentation_amount = 0;-
1366 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
1367 else-
1368 {-
1369 cprintf ("\n");-
1370 indentation += indentation_amount;-
1371 }
executed 312 times by 1 test: end of block
Executed by:
  • Self test
312
1372-
1373 inside_function_def++;-
1374-
1375 cprintf ((flags & FUNC_MULTILINE) ? "{ \n" : "{ ");-
1376-
1377 cmdcopy = copy_command (command);-
1378 /* Take any redirections specified in the function definition (which should-
1379 apply to the function as a whole) and save them for printing later. */-
1380 func_redirects = (REDIRECT *)NULL;-
1381 if (cmdcopy->type == cm_group)
cmdcopy->type == cm_groupDescription
TRUEevaluated 361 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
12-361
1382 {-
1383 func_redirects = cmdcopy->redirects;-
1384 cmdcopy->redirects = (REDIRECT *)NULL;-
1385 }
executed 361 times by 1 test: end of block
Executed by:
  • Self test
361
1386 make_command_string_internal (cmdcopy->type == cm_group-
1387 ? cmdcopy->value.Group->command-
1388 : cmdcopy);-
1389 /* XXX - PRINT_DEFERRED_HEREDOCS (""); ? */-
1390-
1391 indentation = old_indent;-
1392 indentation_amount = old_amount;-
1393 inside_function_def--;-
1394-
1395 if (func_redirects)
func_redirectsDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 360 times by 1 test
Evaluated by:
  • Self test
13-360
1396 { /* { */-
1397 newline ("} ");-
1398 print_redirection_list (func_redirects);-
1399 cmdcopy->redirects = func_redirects;-
1400 }
executed 13 times by 1 test: end of block
Executed by:
  • Self test
13
1401 else-
1402 newline ("}");
executed 360 times by 1 test: newline ("}");
Executed by:
  • Self test
360
1403-
1404 result = the_printed_command;-
1405-
1406 if ((flags & FUNC_MULTILINE) == 0)
(flags & 0x01) == 0Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 312 times by 1 test
Evaluated by:
  • Self test
61-312
1407 {-
1408#if 0-
1409 register int i;-
1410 for (i = 0; result[i]; i++)-
1411 if (result[i] == '\n')-
1412 {-
1413 strcpy (result + i, result + i + 1);-
1414 --i;-
1415 }-
1416#else-
1417 if (result[2] == '\n') /* XXX -- experimental */
result[2] == '\n'Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
0-61
1418 memmove (result + 2, result + 3, strlen (result) - 2);
never executed: memmove (result + 2, result + 3, strlen (result) - 2);
0
1419#endif-
1420 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
1421-
1422 dispose_command (cmdcopy);-
1423-
1424 if (flags & FUNC_EXTERNAL)
flags & 0x02Description
TRUEevaluated 312 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
61-312
1425 result = remove_quoted_escapes (result);
executed 312 times by 1 test: result = remove_quoted_escapes (result);
Executed by:
  • Self test
312
1426-
1427 return (result);
executed 373 times by 1 test: return (result);
Executed by:
  • Self test
373
1428}-
1429-
1430static void-
1431newline (string)-
1432 char *string;-
1433{-
1434 cprintf ("\n");-
1435 indent (indentation);-
1436 if (string && *string)
stringDescription
TRUEevaluated 3359 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*stringDescription
TRUEevaluated 3345 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
0-3359
1437 cprintf ("%s", string);
executed 3345 times by 1 test: cprintf ("%s", string);
Executed by:
  • Self test
3345
1438}
executed 3359 times by 1 test: end of block
Executed by:
  • Self test
3359
1439-
1440static char *indentation_string;-
1441static int indentation_size;-
1442-
1443static void-
1444indent (amount)-
1445 int amount;-
1446{-
1447 register int i;-
1448-
1449 RESIZE_MALLOCED_BUFFER (indentation_string, 0, amount, indentation_size, 16);
executed 3520 times by 1 test: indentation_size += (16);
Executed by:
  • Self test
executed 3520 times by 1 test: end of block
Executed by:
  • Self test
(0) + (amount)...dentation_sizeDescription
TRUEevaluated 3520 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10825 times by 1 test
Evaluated by:
  • Self test
(0) + (amount)...dentation_sizeDescription
TRUEevaluated 3520 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3520 times by 1 test
Evaluated by:
  • Self test
3520-10825
1450-
1451 for (i = 0; amount > 0; amount--)
amount > 0Description
TRUEevaluated 47659 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14345 times by 1 test
Evaluated by:
  • Self test
14345-47659
1452 indentation_string[i++] = ' ';
executed 47659 times by 1 test: indentation_string[i++] = ' ';
Executed by:
  • Self test
47659
1453 indentation_string[i] = '\0';-
1454 cprintf ("%s", indentation_string);-
1455}
executed 14345 times by 1 test: end of block
Executed by:
  • Self test
14345
1456-
1457static void-
1458semicolon ()-
1459{-
1460 if (command_string_index > 0 &&
command_string_index > 0Description
TRUEevaluated 3174 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3174
1461 (the_printed_command[command_string_index - 1] == '&' ||
the_printed_co...ex - 1] == '&'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3172 times by 1 test
Evaluated by:
  • Self test
2-3172
1462 the_printed_command[command_string_index - 1] == '\n'))
the_printed_co...x - 1] == '\n'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3171 times by 1 test
Evaluated by:
  • Self test
1-3171
1463 return;
executed 3 times by 1 test: return;
Executed by:
  • Self test
3
1464 cprintf (";");-
1465}
executed 3171 times by 1 test: end of block
Executed by:
  • Self test
3171
1466-
1467/* How to make the string. */-
1468static void-
1469#if defined (PREFER_STDARG)-
1470cprintf (const char *control, ...)-
1471#else-
1472cprintf (control, va_alist)-
1473 const char *control;-
1474 va_dcl-
1475#endif-
1476{-
1477 register const char *s;-
1478 char char_arg[2], *argp, intbuf[INT_STRLEN_BOUND (int) + 1];-
1479 int digit_arg, arg_len, c;-
1480 va_list args;-
1481-
1482 SH_VA_START (args, control);-
1483-
1484 arg_len = strlen (control);-
1485 the_printed_command_resize (arg_len + 1);-
1486-
1487 char_arg[1] = '\0';-
1488 s = control;-
1489 while (s && *s)
sDescription
TRUEevaluated 840651695 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*sDescription
TRUEevaluated 671679769 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 168971926 times by 1 test
Evaluated by:
  • Self test
0-840651695
1490 {-
1491 c = *s++;-
1492 argp = (char *)NULL;-
1493 if (c != '%' || !*s)
c != '%'Description
TRUEevaluated 402537068 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 269142701 times by 1 test
Evaluated by:
  • Self test
!*sDescription
TRUEnever evaluated
FALSEevaluated 269142701 times by 1 test
Evaluated by:
  • Self test
0-402537068
1494 {-
1495 char_arg[0] = c;-
1496 argp = char_arg;-
1497 arg_len = 1;-
1498 }
executed 402537068 times by 1 test: end of block
Executed by:
  • Self test
402537068
1499 else-
1500 {-
1501 c = *s++;-
1502 switch (c)-
1503 {-
1504 case '%':
never executed: case '%':
0
1505 char_arg[0] = c;-
1506 argp = char_arg;-
1507 arg_len = 1;-
1508 break;
never executed: break;
0
1509-
1510 case 's':
executed 269135731 times by 1 test: case 's':
Executed by:
  • Self test
269135731
1511 argp = va_arg (args, char *);-
1512 arg_len = strlen (argp);-
1513 break;
executed 269135731 times by 1 test: break;
Executed by:
  • Self test
269135731
1514-
1515 case 'd':
executed 6970 times by 1 test: case 'd':
Executed by:
  • Self test
6970
1516 /* Represent an out-of-range file descriptor with an out-of-range-
1517 integer value. We can do this because the only use of `%d' in-
1518 the calls to cprintf is to output a file descriptor number for-
1519 a redirection. */-
1520 digit_arg = va_arg (args, int);-
1521 if (digit_arg < 0)
digit_arg < 0Description
TRUEnever evaluated
FALSEevaluated 6970 times by 1 test
Evaluated by:
  • Self test
0-6970
1522 {-
1523 sprintf (intbuf, "%u", (unsigned)-1);-
1524 argp = intbuf;-
1525 }
never executed: end of block
0
1526 else-
1527 argp = inttostr (digit_arg, intbuf, sizeof (intbuf));
executed 6970 times by 1 test: argp = inttostr (digit_arg, intbuf, sizeof (intbuf));
Executed by:
  • Self test
6970
1528 arg_len = strlen (argp);-
1529 break;
executed 6970 times by 1 test: break;
Executed by:
  • Self test
6970
1530-
1531 case 'c':
never executed: case 'c':
0
1532 char_arg[0] = va_arg (args, int);-
1533 argp = char_arg;-
1534 arg_len = 1;-
1535 break;
never executed: break;
0
1536-
1537 default:
never executed: default:
0
1538 programming_error (_("cprintf: `%c': invalid format character"), c);-
1539 /*NOTREACHED*/-
1540 }
never executed: end of block
0
1541 }-
1542-
1543 if (argp && arg_len)
argpDescription
TRUEevaluated 671679769 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
arg_lenDescription
TRUEevaluated 594931490 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76748279 times by 1 test
Evaluated by:
  • Self test
0-671679769
1544 {-
1545 the_printed_command_resize (arg_len + 1);-
1546 FASTCOPY (argp, the_printed_command + command_string_index, arg_len);-
1547 command_string_index += arg_len;-
1548 }
executed 594931490 times by 1 test: end of block
Executed by:
  • Self test
594931490
1549 }
executed 671679769 times by 1 test: end of block
Executed by:
  • Self test
671679769
1550-
1551 va_end (args);-
1552-
1553 the_printed_command[command_string_index] = '\0';-
1554}
executed 168971926 times by 1 test: end of block
Executed by:
  • Self test
168971926
1555-
1556/* Ensure that there is enough space to stuff LENGTH characters into-
1557 THE_PRINTED_COMMAND. */-
1558static void-
1559the_printed_command_resize (length)-
1560 int length;-
1561{-
1562 if (the_printed_command == 0)
the_printed_command == 0Description
TRUEevaluated 5419 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 763897997 times by 1 test
Evaluated by:
  • Self test
5419-763897997
1563 {-
1564 the_printed_command_size = (length + PRINTED_COMMAND_INITIAL_SIZE - 1) & ~(PRINTED_COMMAND_INITIAL_SIZE - 1);-
1565 the_printed_command = (char *)xmalloc (the_printed_command_size);-
1566 command_string_index = 0;-
1567 }
executed 5419 times by 1 test: end of block
Executed by:
  • Self test
5419
1568 else if ((command_string_index + length) >= the_printed_command_size)
(command_strin...d_command_sizeDescription
TRUEevaluated 4307 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 763893690 times by 1 test
Evaluated by:
  • Self test
4307-763893690
1569 {-
1570 int new;-
1571 new = command_string_index + length + 1;-
1572-
1573 /* Round up to the next multiple of PRINTED_COMMAND_GROW_SIZE. */-
1574 new = (new + PRINTED_COMMAND_GROW_SIZE - 1) & ~(PRINTED_COMMAND_GROW_SIZE - 1);-
1575 the_printed_command_size = new;-
1576-
1577 the_printed_command = (char *)xrealloc (the_printed_command, the_printed_command_size);-
1578 }
executed 4307 times by 1 test: end of block
Executed by:
  • Self test
4307
1579}
executed 763903416 times by 1 test: end of block
Executed by:
  • Self test
763903416
1580-
1581#if defined (HAVE_VPRINTF)-
1582/* ``If vprintf is available, you may assume that vfprintf and vsprintf are-
1583 also available.'' */-
1584-
1585static void-
1586#if defined (PREFER_STDARG)-
1587xprintf (const char *format, ...)-
1588#else-
1589xprintf (format, va_alist)-
1590 const char *format;-
1591 va_dcl-
1592#endif-
1593{-
1594 va_list args;-
1595-
1596 SH_VA_START (args, format);-
1597-
1598 vfprintf (stdout, format, args);-
1599 va_end (args);-
1600}
never executed: end of block
0
1601-
1602#else-
1603-
1604static void-
1605xprintf (format, arg1, arg2, arg3, arg4, arg5)-
1606 const char *format;-
1607{-
1608 printf (format, arg1, arg2, arg3, arg4, arg5);-
1609}-
1610-
1611#endif /* !HAVE_VPRINTF */-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2