OpenCoverage

printf.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/printf.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* printf - format and print data-
2 Copyright (C) 1990-2018 Free Software Foundation, Inc.-
3-
4 This program is free software: you can redistribute it and/or modify-
5 it under the terms of the GNU General Public License as published by-
6 the Free Software Foundation, either version 3 of the License, or-
7 (at your option) any later version.-
8-
9 This program is distributed in the hope that it will be useful,-
10 but WITHOUT ANY WARRANTY; without even the implied warranty of-
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
12 GNU General Public License for more details.-
13-
14 You should have received a copy of the GNU General Public License-
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */-
16-
17/* Usage: printf format [argument...]-
18-
19 A front end to the printf function that lets it be used from the shell.-
20-
21 Backslash escapes:-
22-
23 \" = double quote-
24 \\ = backslash-
25 \a = alert (bell)-
26 \b = backspace-
27 \c = produce no further output-
28 \e = escape-
29 \f = form feed-
30 \n = new line-
31 \r = carriage return-
32 \t = horizontal tab-
33 \v = vertical tab-
34 \ooo = octal number (ooo is 1 to 3 digits)-
35 \xhh = hexadecimal number (hhh is 1 to 2 digits)-
36 \uhhhh = 16-bit Unicode character (hhhh is 4 digits)-
37 \Uhhhhhhhh = 32-bit Unicode character (hhhhhhhh is 8 digits)-
38-
39 Additional directive:-
40-
41 %b = print an argument string, interpreting backslash escapes,-
42 except that octal escapes are of the form \0 or \0ooo.-
43-
44 %q = print an argument string in a format that can be-
45 reused as shell input. Escaped characters used the proposed-
46 POSIX $'' syntax supported by most shells.-
47-
48 The 'format' argument is re-used as many times as necessary-
49 to convert all of the given arguments.-
50-
51 David MacKenzie <djm@gnu.ai.mit.edu> */-
52-
53#include <config.h>-
54#include <stdio.h>-
55#include <sys/types.h>-
56-
57#include "system.h"-
58#include "c-strtod.h"-
59#include "die.h"-
60#include "error.h"-
61#include "quote.h"-
62#include "unicodeio.h"-
63#include "xprintf.h"-
64-
65/* The official name of this program (e.g., no 'g' prefix). */-
66#define PROGRAM_NAME "printf"-
67-
68#define AUTHORS proper_name ("David MacKenzie")-
69-
70#define isodigit(c) ((c) >= '0' && (c) <= '7')-
71#define hextobin(c) ((c) >= 'a' && (c) <= 'f' ? (c) - 'a' + 10 : \-
72 (c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 10 : (c) - '0')-
73#define octtobin(c) ((c) - '0')-
74-
75/* The value to return to the calling program. */-
76static int exit_status;-
77-
78/* True if the POSIXLY_CORRECT environment variable is set. */-
79static bool posixly_correct;-
80-
81/* This message appears in N_() here rather than just in _() below because-
82 the sole use would have been in a #define. */-
83static char const *const cfcc_msg =-
84 N_("warning: %s: character(s) following character constant have been ignored");-
85-
86void-
87usage (int status)-
88{-
89 if (status != EXIT_SUCCESS)
status != 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • printf
2
90 emit_try_help ();
executed 2 times by 1 test: end of block
Executed by:
  • printf
2
91 else-
92 {-
93 printf (_("\-
94Usage: %s FORMAT [ARGUMENT]...\n\-
95 or: %s OPTION\n\-
96"),-
97 program_name, program_name);-
98 fputs (_("\-
99Print ARGUMENT(s) according to FORMAT, or execute according to OPTION:\n\-
100\n\-
101"), stdout);-
102 fputs (HELP_OPTION_DESCRIPTION, stdout);-
103 fputs (VERSION_OPTION_DESCRIPTION, stdout);-
104 fputs (_("\-
105\n\-
106FORMAT controls the output as in C printf. Interpreted sequences are:\n\-
107\n\-
108 \\\" double quote\n\-
109"), stdout);-
110 fputs (_("\-
111 \\\\ backslash\n\-
112 \\a alert (BEL)\n\-
113 \\b backspace\n\-
114 \\c produce no further output\n\-
115 \\e escape\n\-
116 \\f form feed\n\-
117 \\n new line\n\-
118 \\r carriage return\n\-
119 \\t horizontal tab\n\-
120 \\v vertical tab\n\-
121"), stdout);-
122 fputs (_("\-
123 \\NNN byte with octal value NNN (1 to 3 digits)\n\-
124 \\xHH byte with hexadecimal value HH (1 to 2 digits)\n\-
125 \\uHHHH Unicode (ISO/IEC 10646) character with hex value HHHH (4 digits)\n\-
126 \\UHHHHHHHH Unicode character with hex value HHHHHHHH (8 digits)\n\-
127"), stdout);-
128 fputs (_("\-
129 %% a single %\n\-
130 %b ARGUMENT as a string with '\\' escapes interpreted,\n\-
131 except that octal escapes are of the form \\0 or \\0NNN\n\-
132 %q ARGUMENT is printed in a format that can be reused as shell input,\n\-
133 escaping non-printable characters with the proposed POSIX $'' syntax.\-
134\n\n\-
135and all C format specifications ending with one of diouxXfeEgGcs, with\n\-
136ARGUMENTs converted to proper type first. Variable widths are handled.\n\-
137"), stdout);-
138 printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);-
139 emit_ancillary_info (PROGRAM_NAME);-
140 }
executed 2 times by 1 test: end of block
Executed by:
  • printf
2
141 exit (status);
executed 4 times by 1 test: exit (status);
Executed by:
  • printf
4
142}-
143-
144static void-
145verify_numeric (const char *s, const char *end)-
146{-
147 if (errno)
(*__errno_location ())Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 318 times by 1 test
Evaluated by:
  • printf
1-318
148 {-
149 error (0, errno, "%s", quote (s));-
150 exit_status = EXIT_FAILURE;-
151 }
executed 1 time by 1 test: end of block
Executed by:
  • printf
1
152 else if (*end)
*endDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 314 times by 1 test
Evaluated by:
  • printf
4-314
153 {-
154 if (s == end)
s == endDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1-3
155 error (0, 0, _("%s: expected a numeric value"), quote (s));
executed 3 times by 1 test: error (0, 0, dcgettext (((void *)0), "%s: expected a numeric value" , 5) , quote (s));
Executed by:
  • printf
3
156 else-
157 error (0, 0, _("%s: value not completely converted"), quote (s));
executed 1 time by 1 test: error (0, 0, dcgettext (((void *)0), "%s: value not completely converted" , 5) , quote (s));
Executed by:
  • printf
1
158 exit_status = EXIT_FAILURE;-
159 }
executed 4 times by 1 test: end of block
Executed by:
  • printf
4
160}
executed 319 times by 1 test: end of block
Executed by:
  • printf
319
161-
162#define STRTOX(TYPE, FUNC_NAME, LIB_FUNC_EXPR) \-
163static TYPE \-
164FUNC_NAME (char const *s) \-
165{ \-
166 char *end; \-
167 TYPE val; \-
168 \-
169 if ((*s == '\"' || *s == '\'') && *(s + 1)) \-
170 { \-
171 unsigned char ch = *++s; \-
172 val = ch; \-
173 /* If POSIXLY_CORRECT is not set, then give a warning that there \-
174 are characters following the character constant and that GNU \-
175 printf is ignoring those characters. If POSIXLY_CORRECT *is* \-
176 set, then don't give the warning. */ \-
177 if (*++s != 0 && !posixly_correct) \-
178 error (0, 0, _(cfcc_msg), s); \-
179 } \-
180 else \-
181 { \-
182 errno = 0; \-
183 val = (LIB_FUNC_EXPR); \-
184 verify_numeric (s, end); \-
185 } \-
186 return val; \-
187} \-
188-
189STRTOX (intmax_t, vstrtoimax, strtoimax (s, &end, 0))
executed 1 time by 1 test: error (0, 0, dcgettext (((void *)0), cfcc_msg , 5) , s);
Executed by:
  • printf
executed 2 times by 1 test: end of block
Executed by:
  • printf
executed 43 times by 1 test: end of block
Executed by:
  • printf
executed 45 times by 1 test: return val;
Executed by:
  • printf
*s == '\"'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 42 times by 1 test
Evaluated by:
  • printf
*s == '\''Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • printf
*(s + 1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
*++s != 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
!posixly_correctDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
0-45
190STRTOX (uintmax_t, vstrtoumax, strtoumax (s, &end, 0))
never executed: error (0, 0, dcgettext (((void *)0), cfcc_msg , 5) , s);
never executed: end of block
executed 263 times by 1 test: end of block
Executed by:
  • printf
executed 263 times by 1 test: return val;
Executed by:
  • printf
*s == '\"'Description
TRUEnever evaluated
FALSEevaluated 263 times by 1 test
Evaluated by:
  • printf
*s == '\''Description
TRUEnever evaluated
FALSEevaluated 263 times by 1 test
Evaluated by:
  • printf
*(s + 1)Description
TRUEnever evaluated
FALSEnever evaluated
*++s != 0Description
TRUEnever evaluated
FALSEnever evaluated
!posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
0-263
191STRTOX (long double, vstrtold, c_strtold (s, &end))
never executed: error (0, 0, dcgettext (((void *)0), cfcc_msg , 5) , s);
never executed: end of block
executed 13 times by 1 test: end of block
Executed by:
  • printf
executed 13 times by 1 test: return val;
Executed by:
  • printf
*s == '\"'Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • printf
*s == '\''Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • printf
*(s + 1)Description
TRUEnever evaluated
FALSEnever evaluated
*++s != 0Description
TRUEnever evaluated
FALSEnever evaluated
!posixly_correctDescription
TRUEnever evaluated
FALSEnever evaluated
0-13
192-
193/* Output a single-character \ escape. */-
194-
195static void-
196print_esc_char (char c)-
197{-
198 switch (c)-
199 {-
200 case 'a': /* Alert. */
executed 1 time by 1 test: case 'a':
Executed by:
  • printf
1
201 putchar ('\a');-
202 break;
executed 1 time by 1 test: break;
Executed by:
  • printf
1
203 case 'b': /* Backspace. */
executed 1 time by 1 test: case 'b':
Executed by:
  • printf
1
204 putchar ('\b');-
205 break;
executed 1 time by 1 test: break;
Executed by:
  • printf
1
206 case 'c': /* Cancel the rest of the output. */
executed 1 time by 1 test: case 'c':
Executed by:
  • printf
1
207 exit (EXIT_SUCCESS);
executed 1 time by 1 test: exit ( 0 );
Executed by:
  • printf
1
208 break;
never executed: break;
0
209 case 'e': /* Escape. */
executed 1 time by 1 test: case 'e':
Executed by:
  • printf
1
210 putchar ('\x1B');-
211 break;
executed 1 time by 1 test: break;
Executed by:
  • printf
1
212 case 'f': /* Form feed. */
executed 1 time by 1 test: case 'f':
Executed by:
  • printf
1
213 putchar ('\f');-
214 break;
executed 1 time by 1 test: break;
Executed by:
  • printf
1
215 case 'n': /* New line. */
executed 94 times by 1 test: case 'n':
Executed by:
  • printf
94
216 putchar ('\n');-
217 break;
executed 94 times by 1 test: break;
Executed by:
  • printf
94
218 case 'r': /* Carriage return. */
executed 2 times by 1 test: case 'r':
Executed by:
  • printf
2
219 putchar ('\r');-
220 break;
executed 2 times by 1 test: break;
Executed by:
  • printf
2
221 case 't': /* Horizontal tab. */
executed 2 times by 1 test: case 't':
Executed by:
  • printf
2
222 putchar ('\t');-
223 break;
executed 2 times by 1 test: break;
Executed by:
  • printf
2
224 case 'v': /* Vertical tab. */
executed 1 time by 1 test: case 'v':
Executed by:
  • printf
1
225 putchar ('\v');-
226 break;
executed 1 time by 1 test: break;
Executed by:
  • printf
1
227 default:
executed 256 times by 1 test: default:
Executed by:
  • printf
256
228 putchar (c);-
229 break;
executed 256 times by 1 test: break;
Executed by:
  • printf
256
230 }-
231}-
232-
233/* Print a \ escape sequence starting at ESCSTART.-
234 Return the number of characters in the escape sequence-
235 besides the backslash.-
236 If OCTAL_0 is nonzero, octal escapes are of the form \0ooo, where o-
237 is an octal digit; otherwise they are of the form \ooo. */-
238-
239static int-
240print_esc (const char *escstart, bool octal_0)-
241{-
242 const char *p = escstart + 1;-
243 int esc_value = 0; /* Value of \nnn escape. */-
244 int esc_length; /* Length of \nnn escape. */-
245-
246 if (*p == 'x')
*p == 'x'Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 894 times by 1 test
Evaluated by:
  • printf
9-894
247 {-
248 /* A hexadecimal \xhh escape sequence must have 1 or 2 hex. digits. */-
249 for (esc_length = 0, ++p;-
250 esc_length < 2 && isxdigit (to_uchar (*p));
esc_length < 2Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 7 times by 1 test
Evaluated by:
  • printf
((*__ctype_b_l...nt) _ISxdigit)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • printf
2-16
251 ++esc_length, ++p)-
252 esc_value = esc_value * 16 + hextobin (*p);
executed 14 times by 1 test: esc_value = esc_value * 16 + ((*p) >= 'a' && (*p) <= 'f' ? (*p) - 'a' + 10 : (*p) >= 'A' && (*p) <= 'F' ? (*p) - 'A' + 10 : (*p) - '0');
Executed by:
  • printf
(*p) >= 'a'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 10 times by 1 test
Evaluated by:
  • printf
(*p) <= 'f'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
(*p) >= 'A'Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • printf
(*p) <= 'F'Description
TRUEnever evaluated
FALSEnever evaluated
0-14
253 if (esc_length == 0)
esc_length == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 7 times by 1 test
Evaluated by:
  • printf
2-7
254 die (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"missing hexadecimal number in escape\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "missing hexadecimal number in escape" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "missing hexadecimal number in escape" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • printf
2
255 putchar (esc_value);-
256 }
executed 7 times by 1 test: end of block
Executed by:
  • printf
7
257 else if (isodigit (*p))
(*p) >= '0'Description
TRUEevaluated 894 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
(*p) <= '7'Description
TRUEevaluated 531 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 363 times by 1 test
Evaluated by:
  • printf
0-894
258 {-
259 /* Parse \0ooo (if octal_0 && *p == '0') or \ooo (otherwise).-
260 Allow \ooo if octal_0 && *p != '0'; this is an undocumented-
261 extension to POSIX that is compatible with Bash 2.05b. */-
262 for (esc_length = 0, p += octal_0 && *p == '0';-
263 esc_length < 3 && isodigit (*p);
esc_length < 3Description
TRUEevaluated 1590 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 524 times by 1 test
Evaluated by:
  • printf
(*p) >= '0'Description
TRUEevaluated 1590 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
(*p) <= '7'Description
TRUEevaluated 1583 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 7 times by 1 test
Evaluated by:
  • printf
0-1590
264 ++esc_length, ++p)-
265 esc_value = esc_value * 8 + octtobin (*p);
executed 1583 times by 1 test: esc_value = esc_value * 8 + ((*p) - '0');
Executed by:
  • printf
1583
266 putchar (esc_value);-
267 }
executed 531 times by 1 test: end of block
Executed by:
  • printf
531
268 else if (*p && strchr ("\"\\abcefnrtv", *p))
*pDescription
TRUEevaluated 363 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
(__extension__...nrtv" , *p )))Description
TRUEevaluated 360 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 3 times by 1 test
Evaluated by:
  • printf
__builtin_constant_p ( *p )Description
TRUEnever evaluated
FALSEevaluated 363 times by 1 test
Evaluated by:
  • printf
!__builtin_con...\\abcefnrtv" )Description
TRUEnever evaluated
FALSEnever evaluated
( *p ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-363
269 print_esc_char (*p++);
executed 360 times by 1 test: print_esc_char (*p++);
Executed by:
  • printf
360
270 else if (*p == 'u' || *p == 'U')
*p == 'u'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
*p == 'U'Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
0-2
271 {-
272 char esc_char = *p;-
273 unsigned int uni_value;-
274-
275 uni_value = 0;-
276 for (esc_length = (esc_char == 'u' ? 4 : 8), ++p;-
277 esc_length > 0;
esc_length > 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1-5
278 --esc_length, ++p)-
279 {-
280 if (! isxdigit (to_uchar (*p)))
! ((*__ctype_b...nt) _ISxdigit)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 4 times by 1 test
Evaluated by:
  • printf
1-4
281 die (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"missing hexadecimal number in escape\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "missing hexadecimal number in escape" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "missing hexadecimal number in escape" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • printf
1
282 uni_value = uni_value * 16 + hextobin (*p);
(*p) >= 'a'Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • printf
(*p) <= 'f'Description
TRUEnever evaluated
FALSEnever evaluated
(*p) >= 'A'Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • printf
(*p) <= 'F'Description
TRUEnever evaluated
FALSEnever evaluated
0-4
283 }
executed 4 times by 1 test: end of block
Executed by:
  • printf
4
284-
285 /* A universal character name shall not specify a character short-
286 identifier in the range 00000000 through 00000020, 0000007F through-
287 0000009F, or 0000D800 through 0000DFFF inclusive. A universal-
288 character name shall not designate a character in the required-
289 character set. */-
290 if ((uni_value <= 0x9f
uni_value <= 0x9fDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
0-1
291 && uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60)
uni_value != 0x24Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
uni_value != 0x40Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
uni_value != 0x60Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
0-1
292 || (uni_value >= 0xd800 && uni_value <= 0xdfff))
uni_value >= 0xd800Description
TRUEnever evaluated
FALSEnever evaluated
uni_value <= 0xdfffDescription
TRUEnever evaluated
FALSEnever evaluated
0
293 die (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"),
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid universal character name \\\\%c%0*x\", 5), esc_char, (esc_char == 'u' ? 4 : 8), uni_value), assume (false))" ")"); int _gl_dummy; })) ? ((e..., uni_value), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid universal character name \\%c%0*x" , 5) , esc_char, (esc_char == 'u' ? 4 : 8), uni_value), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
1
294 esc_char, (esc_char == 'u' ? 4 : 8), uni_value);
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid universal character name \\\\%c%0*x\", 5), esc_char, (esc_char == 'u' ? 4 : 8), uni_value), assume (false))" ")"); int _gl_dummy; })) ? ((e..., uni_value), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid universal character name \\%c%0*x" , 5) , esc_char, (esc_char == 'u' ? 4 : 8), uni_value), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
1
295-
296 print_unicode_char (stdout, uni_value, 0);-
297 }
never executed: end of block
0
298 else-
299 {-
300 putchar ('\\');-
301 if (*p)
*pDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
0-1
302 {-
303 putchar (*p);-
304 p++;-
305 }
executed 1 time by 1 test: end of block
Executed by:
  • printf
1
306 }
executed 1 time by 1 test: end of block
Executed by:
  • printf
1
307 return p - escstart - 1;
executed 898 times by 1 test: return p - escstart - 1;
Executed by:
  • printf
898
308}-
309-
310/* Print string STR, evaluating \ escapes. */-
311-
312static void-
313print_esc_string (const char *str)-
314{-
315 for (; *str; str++)
*strDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printf
5-10
316 if (*str == '\\')
*str == '\\'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printf
5
317 str += print_esc (str, true);
executed 5 times by 1 test: str += print_esc (str, 1 );
Executed by:
  • printf
5
318 else-
319 putchar (*str);
executed 5 times by 1 test: putchar_unlocked (*str);
Executed by:
  • printf
5
320}
executed 5 times by 1 test: end of block
Executed by:
  • printf
5
321-
322/* Evaluate a printf conversion specification. START is the start of-
323 the directive, LENGTH is its length, and CONVERSION specifies the-
324 type of conversion. LENGTH does not include any length modifier or-
325 the conversion specifier itself. FIELD_WIDTH and PRECISION are the-
326 field width and precision for '*' values, if HAVE_FIELD_WIDTH and-
327 HAVE_PRECISION are true, respectively. ARGUMENT is the argument to-
328 be formatted. */-
329-
330static void-
331print_direc (const char *start, size_t length, char conversion,-
332 bool have_field_width, int field_width,-
333 bool have_precision, int precision,-
334 char const *argument)-
335{-
336 char *p; /* Null-terminated copy of % directive. */-
337-
338 /* Create a null-terminated copy of the % directive, with an-
339 intmax_t-wide length modifier substituted for any existing-
340 integer length modifier. */-
341 {-
342 char *q;-
343 char const *length_modifier;-
344 size_t length_modifier_len;-
345-
346 switch (conversion)-
347 {-
348 case 'd': case 'i': case 'o': case 'u': case 'x': case 'X':
executed 20 times by 1 test: case 'd':
Executed by:
  • printf
never executed: case 'i':
executed 256 times by 1 test: case 'o':
Executed by:
  • printf
never executed: case 'u':
never executed: case 'x':
executed 7 times by 1 test: case 'X':
Executed by:
  • printf
0-256
349 length_modifier = PRIdMAX;-
350 length_modifier_len = sizeof PRIdMAX - 2;-
351 break;
executed 283 times by 1 test: break;
Executed by:
  • printf
283
352-
353 case 'a': case 'e': case 'f': case 'g':
never executed: case 'a':
never executed: case 'e':
executed 5 times by 1 test: case 'f':
Executed by:
  • printf
never executed: case 'g':
0-5
354 case 'A': case 'E': case 'F': case 'G':
never executed: case 'A':
executed 2 times by 1 test: case 'E':
Executed by:
  • printf
executed 2 times by 1 test: case 'F':
Executed by:
  • printf
executed 4 times by 1 test: case 'G':
Executed by:
  • printf
0-4
355 length_modifier = "L";-
356 length_modifier_len = 1;-
357 break;
executed 13 times by 1 test: break;
Executed by:
  • printf
13
358-
359 default:
executed 10 times by 1 test: default:
Executed by:
  • printf
10
360 length_modifier = start; /* Any valid pointer will do. */-
361 length_modifier_len = 0;-
362 break;
executed 10 times by 1 test: break;
Executed by:
  • printf
10
363 }-
364-
365 p = xmalloc (length + length_modifier_len + 2);-
366 q = mempcpy (p, start, length);-
367 q = mempcpy (q, length_modifier, length_modifier_len);-
368 *q++ = conversion;-
369 *q = '\0';-
370 }-
371-
372 switch (conversion)-
373 {-
374 case 'd':
executed 20 times by 1 test: case 'd':
Executed by:
  • printf
20
375 case 'i':
never executed: case 'i':
0
376 {-
377 intmax_t arg = vstrtoimax (argument);-
378 if (!have_field_width)
!have_field_widthDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 3 times by 1 test
Evaluated by:
  • printf
3-17
379 {-
380 if (!have_precision)
!have_precisionDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 3 times by 1 test
Evaluated by:
  • printf
3-14
381 xprintf (p, arg);
executed 14 times by 1 test: xprintf (p, arg);
Executed by:
  • printf
14
382 else-
383 xprintf (p, precision, arg);
executed 3 times by 1 test: xprintf (p, precision, arg);
Executed by:
  • printf
3
384 }-
385 else-
386 {-
387 if (!have_precision)
!have_precisionDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1-2
388 xprintf (p, field_width, arg);
executed 2 times by 1 test: xprintf (p, field_width, arg);
Executed by:
  • printf
2
389 else-
390 xprintf (p, field_width, precision, arg);
executed 1 time by 1 test: xprintf (p, field_width, precision, arg);
Executed by:
  • printf
1
391 }-
392 }-
393 break;
executed 20 times by 1 test: break;
Executed by:
  • printf
20
394-
395 case 'o':
executed 256 times by 1 test: case 'o':
Executed by:
  • printf
256
396 case 'u':
never executed: case 'u':
0
397 case 'x':
never executed: case 'x':
0
398 case 'X':
executed 7 times by 1 test: case 'X':
Executed by:
  • printf
7
399 {-
400 uintmax_t arg = vstrtoumax (argument);-
401 if (!have_field_width)
!have_field_widthDescription
TRUEevaluated 261 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • printf
2-261
402 {-
403 if (!have_precision)
!have_precisionDescription
TRUEevaluated 260 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1-260
404 xprintf (p, arg);
executed 260 times by 1 test: xprintf (p, arg);
Executed by:
  • printf
260
405 else-
406 xprintf (p, precision, arg);
executed 1 time by 1 test: xprintf (p, precision, arg);
Executed by:
  • printf
1
407 }-
408 else-
409 {-
410 if (!have_precision)
!have_precisionDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1
411 xprintf (p, field_width, arg);
executed 1 time by 1 test: xprintf (p, field_width, arg);
Executed by:
  • printf
1
412 else-
413 xprintf (p, field_width, precision, arg);
executed 1 time by 1 test: xprintf (p, field_width, precision, arg);
Executed by:
  • printf
1
414 }-
415 }-
416 break;
executed 263 times by 1 test: break;
Executed by:
  • printf
263
417-
418 case 'a':
never executed: case 'a':
0
419 case 'A':
never executed: case 'A':
0
420 case 'e':
never executed: case 'e':
0
421 case 'E':
executed 2 times by 1 test: case 'E':
Executed by:
  • printf
2
422 case 'f':
executed 5 times by 1 test: case 'f':
Executed by:
  • printf
5
423 case 'F':
executed 2 times by 1 test: case 'F':
Executed by:
  • printf
2
424 case 'g':
never executed: case 'g':
0
425 case 'G':
executed 4 times by 1 test: case 'G':
Executed by:
  • printf
4
426 {-
427 long double arg = vstrtold (argument);-
428 if (!have_field_width)
!have_field_widthDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • printf
2-11
429 {-
430 if (!have_precision)
!have_precisionDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1-10
431 xprintf (p, arg);
executed 10 times by 1 test: xprintf (p, arg);
Executed by:
  • printf
10
432 else-
433 xprintf (p, precision, arg);
executed 1 time by 1 test: xprintf (p, precision, arg);
Executed by:
  • printf
1
434 }-
435 else-
436 {-
437 if (!have_precision)
!have_precisionDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1
438 xprintf (p, field_width, arg);
executed 1 time by 1 test: xprintf (p, field_width, arg);
Executed by:
  • printf
1
439 else-
440 xprintf (p, field_width, precision, arg);
executed 1 time by 1 test: xprintf (p, field_width, precision, arg);
Executed by:
  • printf
1
441 }-
442 }-
443 break;
executed 12 times by 1 test: break;
Executed by:
  • printf
12
444-
445 case 'c':
executed 3 times by 1 test: case 'c':
Executed by:
  • printf
3
446 if (!have_field_width)
!have_field_widthDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • printf
1-2
447 xprintf (p, *argument);
executed 1 time by 1 test: xprintf (p, *argument);
Executed by:
  • printf
1
448 else-
449 xprintf (p, field_width, *argument);
executed 2 times by 1 test: xprintf (p, field_width, *argument);
Executed by:
  • printf
2
450 break;
executed 3 times by 1 test: break;
Executed by:
  • printf
3
451-
452 case 's':
executed 7 times by 1 test: case 's':
Executed by:
  • printf
7
453 if (!have_field_width)
!have_field_widthDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 4 times by 1 test
Evaluated by:
  • printf
3-4
454 {-
455 if (!have_precision)
!have_precisionDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • printf
1-2
456 xprintf (p, argument);
executed 1 time by 1 test: xprintf (p, argument);
Executed by:
  • printf
1
457 else-
458 xprintf (p, precision, argument);
executed 2 times by 1 test: xprintf (p, precision, argument);
Executed by:
  • printf
2
459 }-
460 else-
461 {-
462 if (!have_precision)
!have_precisionDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1-3
463 xprintf (p, field_width, argument);
executed 3 times by 1 test: xprintf (p, field_width, argument);
Executed by:
  • printf
3
464 else-
465 xprintf (p, field_width, precision, argument);
executed 1 time by 1 test: xprintf (p, field_width, precision, argument);
Executed by:
  • printf
1
466 }-
467 break;
executed 7 times by 1 test: break;
Executed by:
  • printf
7
468 }-
469-
470 free (p);-
471}
executed 305 times by 1 test: end of block
Executed by:
  • printf
305
472-
473/* Print the text in FORMAT, using ARGV (with ARGC elements) for-
474 arguments to any '%' directives.-
475 Return the number of elements of ARGV used. */-
476-
477static int-
478print_formatted (const char *format, int argc, char **argv)-
479{-
480 int save_argc = argc; /* Preserve original value. */-
481 const char *f; /* Pointer into 'format'. */-
482 const char *direc_start; /* Start of % directive. */-
483 size_t direc_length; /* Length of % directive. */-
484 bool have_field_width; /* True if FIELD_WIDTH is valid. */-
485 int field_width = 0; /* Arg to first '*'. */-
486 bool have_precision; /* True if PRECISION is valid. */-
487 int precision = 0; /* Arg to second '*'. */-
488 char ok[UCHAR_MAX + 1]; /* ok['x'] is true if %x is allowed. */-
489-
490 for (f = format; *f; ++f)
*fDescription
TRUEevaluated 1290 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 332 times by 1 test
Evaluated by:
  • printf
332-1290
491 {-
492 switch (*f)-
493 {-
494 case '%':
executed 327 times by 1 test: case '%':
Executed by:
  • printf
327
495 direc_start = f++;-
496 direc_length = 1;-
497 have_field_width = have_precision = false;-
498 if (*f == '%')
*f == '%'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 326 times by 1 test
Evaluated by:
  • printf
1-326
499 {-
500 putchar ('%');-
501 break;
executed 1 time by 1 test: break;
Executed by:
  • printf
1
502 }-
503 if (*f == 'b')
*f == 'b'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 321 times by 1 test
Evaluated by:
  • printf
5-321
504 {-
505 /* FIXME: Field width and precision are not supported-
506 for %b, even though POSIX requires it. */-
507 if (argc > 0)
argc > 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
0-5
508 {-
509 print_esc_string (*argv);-
510 ++argv;-
511 --argc;-
512 }
executed 5 times by 1 test: end of block
Executed by:
  • printf
5
513 break;
executed 5 times by 1 test: break;
Executed by:
  • printf
5
514 }-
515-
516 if (*f == 'q')
*f == 'q'Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 314 times by 1 test
Evaluated by:
  • printf
7-314
517 {-
518 if (argc > 0)
argc > 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
0-7
519 {-
520 fputs (quotearg_style (shell_escape_quoting_style, *argv),-
521 stdout);-
522 ++argv;-
523 --argc;-
524 }
executed 7 times by 1 test: end of block
Executed by:
  • printf
7
525 break;
executed 7 times by 1 test: break;
Executed by:
  • printf
7
526 }-
527-
528 memset (ok, 0, sizeof ok);-
529 ok['a'] = ok['A'] = ok['c'] = ok['d'] = ok['e'] = ok['E'] =-
530 ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] =-
531 ok['s'] = ok['u'] = ok['x'] = ok['X'] = 1;-
532-
533 for (;; f++, direc_length++)-
534 switch (*f)-
535 {-
536#if (__GLIBC__ == 2 && 2 <= __GLIBC_MINOR__) || 3 <= __GLIBC__-
537 case 'I':
never executed: case 'I':
0
538#endif-
539 case '\'':
executed 2 times by 1 test: case '\'':
Executed by:
  • printf
2
540 ok['a'] = ok['A'] = ok['c'] = ok['e'] = ok['E'] =-
541 ok['o'] = ok['s'] = ok['x'] = ok['X'] = 0;-
542 break;
executed 2 times by 1 test: break;
Executed by:
  • printf
2
543 case '-': case '+': case ' ':
executed 1 time by 1 test: case '-':
Executed by:
  • printf
executed 2 times by 1 test: case '+':
Executed by:
  • printf
executed 2 times by 1 test: case ' ':
Executed by:
  • printf
1-2
544 break;
executed 5 times by 1 test: break;
Executed by:
  • printf
5
545 case '#':
executed 2 times by 1 test: case '#':
Executed by:
  • printf
2
546 ok['c'] = ok['d'] = ok['i'] = ok['s'] = ok['u'] = 0;-
547 break;
executed 2 times by 1 test: break;
Executed by:
  • printf
2
548 case '0':
executed 258 times by 1 test: case '0':
Executed by:
  • printf
258
549 ok['c'] = ok['s'] = 0;-
550 break;
executed 258 times by 1 test: break;
Executed by:
  • printf
258
551 default:
executed 314 times by 1 test: default:
Executed by:
  • printf
314
552 goto no_more_flag_characters;
executed 314 times by 1 test: goto no_more_flag_characters;
Executed by:
  • printf
314
553 }-
554 no_more_flag_characters:
code before this statement never executed: no_more_flag_characters:
0
555-
556 if (*f == '*')
*f == '*'Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 300 times by 1 test
Evaluated by:
  • printf
14-300
557 {-
558 ++f;-
559 ++direc_length;-
560 if (argc > 0)
argc > 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1-13
561 {-
562 intmax_t width = vstrtoimax (*argv);-
563 if (INT_MIN <= width && width <= INT_MAX)
(-0x7fffffff - 1) <= widthDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
width <= 0x7fffffffDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
0-13
564 field_width = width;
executed 12 times by 1 test: field_width = width;
Executed by:
  • printf
12
565 else-
566 die (EXIT_FAILURE, 0, _("invalid field width: %s"),
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid field width: %s\", 5), quote (*argv)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid field width: %s" , 5) , quote (*argv)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid field width: %s" , 5) , quote (*argv)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
1
567 quote (*argv));
executed 1 time by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid field width: %s\", 5), quote (*argv)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid field width: %s" , 5) , quote (*argv)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid field width: %s" , 5) , quote (*argv)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
1
568 ++argv;-
569 --argc;-
570 }
executed 12 times by 1 test: end of block
Executed by:
  • printf
12
571 else-
572 field_width = 0;
executed 1 time by 1 test: field_width = 0;
Executed by:
  • printf
1
573 have_field_width = true;-
574 }
executed 13 times by 1 test: end of block
Executed by:
  • printf
13
575 else-
576 while (ISDIGIT (*f))
((unsigned int...f) - '0' <= 9)Description
TRUEevaluated 277 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 300 times by 1 test
Evaluated by:
  • printf
277-300
577 {-
578 ++f;-
579 ++direc_length;-
580 }
executed 277 times by 1 test: end of block
Executed by:
  • printf
277
581 if (*f == '.')
*f == '.'Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 295 times by 1 test
Evaluated by:
  • printf
18-295
582 {-
583 ++f;-
584 ++direc_length;-
585 ok['c'] = 0;-
586 if (*f == '*')
*f == '*'Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printf
5-13
587 {-
588 ++f;-
589 ++direc_length;-
590 if (argc > 0)
argc > 0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
1-12
591 {-
592 intmax_t prec = vstrtoimax (*argv);-
593 if (prec < 0)
prec < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 10 times by 1 test
Evaluated by:
  • printf
2-10
594 {-
595 /* A negative precision is taken as if the-
596 precision were omitted, so -1 is safe-
597 here even if prec < INT_MIN. */-
598 precision = -1;-
599 }
executed 2 times by 1 test: end of block
Executed by:
  • printf
2
600 else if (INT_MAX < prec)
0x7fffffff < precDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 8 times by 1 test
Evaluated by:
  • printf
2-8
601 die (EXIT_FAILURE, 0, _("invalid precision: %s"),
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid precision: %s\", 5), quote (*argv)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid precision: %s" , 5) , quote (*argv)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid precision: %s" , 5) , quote (*argv)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
2
602 quote (*argv));
executed 2 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid precision: %s\", 5), quote (*argv)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid precision: %s" , 5) , quote (*argv)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid precision: %s" , 5) , quote (*argv)), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
2
603 else-
604 precision = prec;
executed 8 times by 1 test: precision = prec;
Executed by:
  • printf
8
605 ++argv;-
606 --argc;-
607 }
executed 10 times by 1 test: end of block
Executed by:
  • printf
10
608 else-
609 precision = 0;
executed 1 time by 1 test: precision = 0;
Executed by:
  • printf
1
610 have_precision = true;-
611 }
executed 11 times by 1 test: end of block
Executed by:
  • printf
11
612 else-
613 while (ISDIGIT (*f))
((unsigned int...f) - '0' <= 9)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 5 times by 1 test
Evaluated by:
  • printf
5
614 {-
615 ++f;-
616 ++direc_length;-
617 }
executed 5 times by 1 test: end of block
Executed by:
  • printf
5
618 }
executed 16 times by 1 test: end of block
Executed by:
  • printf
16
619-
620 while (*f == 'l' || *f == 'L' || *f == 'h'
*f == 'l'Description
TRUEnever evaluated
FALSEevaluated 313 times by 1 test
Evaluated by:
  • printf
*f == 'L'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 311 times by 1 test
Evaluated by:
  • printf
*f == 'h'Description
TRUEnever evaluated
FALSEevaluated 311 times by 1 test
Evaluated by:
  • printf
0-313
621 || *f == 'j' || *f == 't' || *f == 'z')
*f == 'j'Description
TRUEnever evaluated
FALSEevaluated 311 times by 1 test
Evaluated by:
  • printf
*f == 't'Description
TRUEnever evaluated
FALSEevaluated 311 times by 1 test
Evaluated by:
  • printf
*f == 'z'Description
TRUEnever evaluated
FALSEevaluated 311 times by 1 test
Evaluated by:
  • printf
0-311
622 ++f;
executed 2 times by 1 test: ++f;
Executed by:
  • printf
2
623-
624 {-
625 unsigned char conversion = *f;-
626 if (! ok[conversion])
! ok[conversion]Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 306 times by 1 test
Evaluated by:
  • printf
5-306
627 die (EXIT_FAILURE, 0,
executed 5 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"%.*s: invalid conversion specification\", 5), (int) (f + 1 - direc_start), direc_start), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , ..._start), direc_start), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "%.*s: invalid conversion specification" , 5) , (int) (f + 1 - direc_start), direc_start), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
5
628 _("%.*s: invalid conversion specification"),
executed 5 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"%.*s: invalid conversion specification\", 5), (int) (f + 1 - direc_start), direc_start), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , ..._start), direc_start), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "%.*s: invalid conversion specification" , 5) , (int) (f + 1 - direc_start), direc_start), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
5
629 (int) (f + 1 - direc_start), direc_start);
executed 5 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"%.*s: invalid conversion specification\", 5), (int) (f + 1 - direc_start), direc_start), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , ..._start), direc_start), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "%.*s: invalid conversion specification" , 5) , (int) (f + 1 - direc_start), direc_start), (( 0 ) ? (void) 0 : __builtin_unreachable ())))) ;
Executed by:
  • printf
5
630 }-
631-
632 print_direc (direc_start, direc_length, *f,-
633 have_field_width, field_width,-
634 have_precision, precision,-
635 (argc <= 0 ? "" : (argc--, *argv++)));-
636 break;
executed 305 times by 1 test: break;
Executed by:
  • printf
305
637-
638 case '\\':
executed 898 times by 1 test: case '\\':
Executed by:
  • printf
898
639 f += print_esc (f, false);-
640 break;
executed 893 times by 1 test: break;
Executed by:
  • printf
893
641-
642 default:
executed 65 times by 1 test: default:
Executed by:
  • printf
65
643 putchar (*f);-
644 }
executed 65 times by 1 test: end of block
Executed by:
  • printf
65
645 }-
646-
647 return save_argc - argc;
executed 332 times by 1 test: return save_argc - argc;
Executed by:
  • printf
332
648}-
649-
650int-
651main (int argc, char **argv)-
652{-
653 char *format;-
654 int args_used;-
655-
656 initialize_main (&argc, &argv);-
657 set_program_name (argv[0]);-
658 setlocale (LC_ALL, "");-
659 bindtextdomain (PACKAGE, LOCALEDIR);-
660 textdomain (PACKAGE);-
661-
662 atexit (close_stdout);-
663-
664 exit_status = EXIT_SUCCESS;-
665-
666 posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);-
667-
668 /* We directly parse options, rather than use parse_long_options, in-
669 order to avoid accepting abbreviations. */-
670 if (argc == 2)
argc == 2Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 63 times by 1 test
Evaluated by:
  • printf
37-63
671 {-
672 if (STREQ (argv[1], "--help"))
never executed: __result = (((const unsigned char *) (const char *) ( argv[1] ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "--help" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 35 times by 1 test
Evaluated by:
  • printf
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-35
673 usage (EXIT_SUCCESS);
executed 2 times by 1 test: usage ( 0 );
Executed by:
  • printf
2
674-
675 if (STREQ (argv[1], "--version"))
never executed: __result = (((const unsigned char *) (const char *) ( argv[1] ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "--version" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 24 times by 1 test
Evaluated by:
  • printf
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-24
676 {-
677 version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,-
678 (char *) NULL);-
679 return EXIT_SUCCESS;
executed 11 times by 1 test: return 0 ;
Executed by:
  • printf
11
680 }-
681 }
executed 24 times by 1 test: end of block
Executed by:
  • printf
24
682-
683 /* The above handles --help and --version.-
684 Since there is no other invocation of getopt, handle '--' here. */-
685 if (1 < argc && STREQ (argv[1], "--"))
never executed: __result = (((const unsigned char *) (const char *) ( argv[1] ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "--" ))[3] - __s2[3]);
executed 2 times by 1 test: end of block
Executed by:
  • printf
executed 3 times by 1 test: end of block
Executed by:
  • printf
1 < argcDescription
TRUEevaluated 86 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
( __extension_...)))); }) == 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 84 times by 1 test
Evaluated by:
  • printf
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
__result == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 83 times by 1 test
Evaluated by:
  • printf
__s2_len > 1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • printf
FALSEnever evaluated
__result == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 1 time by 1 test
Evaluated by:
  • printf
__s2_len > 2Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • printf
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-86
686 {-
687 --argc;-
688 ++argv;-
689 }
executed 2 times by 1 test: end of block
Executed by:
  • printf
2
690-
691 if (argc <= 1)
argc <= 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 85 times by 1 test
Evaluated by:
  • printf
2-85
692 {-
693 error (0, 0, _("missing operand"));-
694 usage (EXIT_FAILURE);-
695 }
never executed: end of block
0
696-
697 format = argv[1];-
698 argc -= 2;-
699 argv += 2;-
700-
701 do-
702 {-
703 args_used = print_formatted (format, argc, argv);-
704 argc -= args_used;-
705 argv += args_used;-
706 }
executed 332 times by 1 test: end of block
Executed by:
  • printf
332
707 while (args_used > 0 && argc > 0);
args_used > 0Description
TRUEevaluated 312 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 20 times by 1 test
Evaluated by:
  • printf
argc > 0Description
TRUEevaluated 261 times by 1 test
Evaluated by:
  • printf
FALSEevaluated 51 times by 1 test
Evaluated by:
  • printf
20-312
708-
709 if (argc > 0)
argc > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • printf
FALSEevaluated 70 times by 1 test
Evaluated by:
  • printf
1-70
710 error (0, 0,
executed 1 time by 1 test: error (0, 0, dcgettext (((void *)0), "warning: ignoring excess arguments, starting with %s" , 5) , quote (argv[0]));
Executed by:
  • printf
1
711 _("warning: ignoring excess arguments, starting with %s"),
executed 1 time by 1 test: error (0, 0, dcgettext (((void *)0), "warning: ignoring excess arguments, starting with %s" , 5) , quote (argv[0]));
Executed by:
  • printf
1
712 quote (argv[0]));
executed 1 time by 1 test: error (0, 0, dcgettext (((void *)0), "warning: ignoring excess arguments, starting with %s" , 5) , quote (argv[0]));
Executed by:
  • printf
1
713-
714 return exit_status;
executed 71 times by 1 test: return exit_status;
Executed by:
  • printf
71
715}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2