OpenCoverage

head.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/head.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5static -
6 _Bool -
7 presume_input_pipe;-
8-
9-
10static -
11 _Bool -
12 print_headers;-
13-
14-
15static char line_end;-
16-
17-
18enum header_mode-
19{-
20 multiple_files, always, never-
21};-
22-
23-
24static -
25 _Bool -
26 have_read_stdin;-
27-
28enum Copy_fd_status-
29 {-
30 COPY_FD_OK = 0,-
31 COPY_FD_READ_ERROR,-
32 COPY_FD_UNEXPECTED_EOF-
33 };-
34-
35-
36-
37enum-
38{-
39 PRESUME_INPUT_PIPE_OPTION = 0x7f + 1-
40};-
41-
42static struct option const long_options[] =-
43{-
44 {"bytes", -
45 1-
46 , -
47 ((void *)0)-
48 , 'c'},-
49 {"lines", -
50 1-
51 , -
52 ((void *)0)-
53 , 'n'},-
54 {"-presume-input-pipe", -
55 0-
56 , -
57 ((void *)0)-
58 ,-
59 PRESUME_INPUT_PIPE_OPTION},-
60 {"quiet", -
61 0-
62 , -
63 ((void *)0)-
64 , 'q'},-
65 {"silent", -
66 0-
67 , -
68 ((void *)0)-
69 , 'q'},-
70 {"verbose", -
71 0-
72 , -
73 ((void *)0)-
74 , 'v'},-
75 {"zero-terminated", -
76 0-
77 , -
78 ((void *)0)-
79 , 'z'},-
80 {"help", -
81 0-
82 , -
83 ((void *)0)-
84 , GETOPT_HELP_CHAR},-
85 {"version", -
86 0-
87 , -
88 ((void *)0)-
89 , GETOPT_VERSION_CHAR},-
90 {-
91 ((void *)0)-
92 , 0, -
93 ((void *)0)-
94 , 0}-
95};-
96-
97void-
98usage (int status)-
99{-
100 if (status !=
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • head
FALSEevaluated 10 times by 1 test
Evaluated by:
  • head
3-10
101 0
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • head
FALSEevaluated 10 times by 1 test
Evaluated by:
  • head
3-10
102 )-
103 do { fprintf (-
104 stderr-
105 , -
106 dcgettext (((void *)0), -
107 "Try '%s --help' for more information.\n"-
108 , 5)-
109 , program_name); }
executed 3 times by 1 test: end of block
Executed by:
  • head
while (0);
3
110 else-
111 {-
112 printf (-
113 dcgettext (((void *)0), -
114 "Usage: %s [OPTION]... [FILE]...\n"-
115 , 5)-
116-
117 -
118 ,-
119 program_name);-
120 printf (-
121 dcgettext (((void *)0), -
122 "Print the first %d lines of each FILE to standard output.\nWith more than one FILE, precede each with a header giving the file name.\n"-
123 , 5)-
124-
125-
126 -
127 , 10);-
128-
129 emit_stdin_note ();-
130 emit_mandatory_arg_note ();-
131-
132 printf (-
133 dcgettext (((void *)0), -
134 " -c, --bytes=[-]NUM print the first NUM bytes of each file;\n with the leading '-', print all but the last\n NUM bytes of each file\n -n, --lines=[-]NUM print the first NUM lines instead of the first %d;\n with the leading '-', print all but the last\n NUM lines of each file\n"-
135 , 5)-
136-
137-
138-
139-
140-
141-
142 -
143 , 10);-
144 fputs_unlocked (-
145 dcgettext (((void *)0), -
146 " -q, --quiet, --silent never print headers giving file names\n -v, --verbose always print headers giving file names\n"-
147 , 5)-
148 ,-
149 stdout-
150 )-
151-
152-
153 ;-
154 fputs_unlocked (-
155 dcgettext (((void *)0), -
156 " -z, --zero-terminated line delimiter is NUL, not newline\n"-
157 , 5)-
158 ,-
159 stdout-
160 )-
161-
162 ;-
163 fputs_unlocked (-
164 dcgettext (((void *)0), -
165 " --help display this help and exit\n"-
166 , 5)-
167 ,-
168 stdout-
169 );-
170 fputs_unlocked (-
171 dcgettext (((void *)0), -
172 " --version output version information and exit\n"-
173 , 5)-
174 ,-
175 stdout-
176 );-
177 fputs_unlocked (-
178 dcgettext (((void *)0), -
179 "\nNUM may have a multiplier suffix:\nb 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,\nGB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\n"-
180 , 5)-
181 ,-
182 stdout-
183 )-
184-
185-
186-
187-
188 ;-
189 emit_ancillary_info ("head");-
190 }
executed 10 times by 1 test: end of block
Executed by:
  • head
10
191 exit (status);
executed 13 times by 1 test: exit (status);
Executed by:
  • head
13
192}-
193-
194static void-
195diagnose_copy_fd_failure (enum Copy_fd_status err, char const *filename)-
196{-
197 switch (err)-
198 {-
199 case
never executed: case COPY_FD_READ_ERROR:
COPY_FD_READ_ERROR:
never executed: case COPY_FD_READ_ERROR:
0
200 error (0, -
201 (*__errno_location ())-
202 , -
203 dcgettext (((void *)0), -
204 "error reading %s"-
205 , 5)-
206 , quotearg_style (shell_escape_always_quoting_style, filename));-
207 break;
never executed: break;
0
208 case
never executed: case COPY_FD_UNEXPECTED_EOF:
COPY_FD_UNEXPECTED_EOF:
never executed: case COPY_FD_UNEXPECTED_EOF:
0
209 error (0, -
210 (*__errno_location ())-
211 , -
212 dcgettext (((void *)0), -
213 "%s: file has shrunk too much"-
214 , 5)-
215 , quotearg_n_style_colon (0, shell_escape_quoting_style, filename));-
216 break;
never executed: break;
0
217 default
never executed: default:
:
never executed: default:
0
218 abort ();
never executed: abort ();
0
219 }-
220}-
221-
222static void-
223write_header (const char *filename)-
224{-
225 static -
226 _Bool -
227 first_file = -
228 1-
229 ;-
230-
231 printf ("%s==> %s <==\n", (first_file ? "" : "\n"), filename);-
232 first_file = -
233 0-
234 ;-
235}
never executed: end of block
0
236-
237-
238-
239-
240static void-
241xwrite_stdout (char const *buffer, size_t n_bytes)-
242{-
243 if (n_bytes > 0
n_bytes > 0Description
TRUEevaluated 3748 times by 1 test
Evaluated by:
  • head
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
&&
1-3748
244 (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
__extension__ ((__builtin_constant_p (
__builtin_constant_p ( 1 )Description
TRUEevaluated 3748 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
245 1
__builtin_constant_p ( 1 )Description
TRUEevaluated 3748 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
246 )
__builtin_constant_p ( 1 )Description
TRUEevaluated 3748 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
&& __builtin_constant_p (
__builtin_cons..._p ( n_bytes )Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
247 n_bytes
__builtin_cons..._p ( n_bytes )Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
248 )
__builtin_cons..._p ( n_bytes )Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
&& (
(size_t) ( 1 )...n_bytes ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
size_t) (
(size_t) ( 1 )...n_bytes ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
249 1
(size_t) ( 1 )...n_bytes ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
250 ) * (size_t) (
(size_t) ( 1 )...n_bytes ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
251 n_bytes
(size_t) ( 1 )...n_bytes ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
252 ) <= 8
(size_t) ( 1 )...n_bytes ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(size_t) ( 1 ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
size_t) (
(size_t) ( 1 ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
253 1
(size_t) ( 1 ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
254 ) != 0
(size_t) ( 1 ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
) ? ({ const char *__ptr = (const char *) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
255 buffer
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
256 ); FILE *__stream = (stdout); size_t __cnt; for (__cnt = (size_t) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
257 1
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
258 ) * (size_t) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
259 n_bytes
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
260 ); __cnt > 0
__cnt > 0Description
TRUEnever evaluated
FALSEnever evaluated
; --__cnt) if ((
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0)
__builtin_expe...write_end), 0)Description
TRUEnever evaluated
FALSEnever evaluated
? __overflow (__stream, (unsigned char) (*__ptr++)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (*__ptr++))) == (-1)
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEnever evaluated
) break;
never executed: break;
((size_t) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
261 1
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
262 ) * (size_t) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
263 n_bytes
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
264 ) - __cnt) / (size_t) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
265 1
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
266 ); }) : (((__builtin_constant_p (
__builtin_constant_p ( 1 )Description
TRUEevaluated 3748 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
267 1
__builtin_constant_p ( 1 )Description
TRUEevaluated 3748 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
268 )
__builtin_constant_p ( 1 )Description
TRUEevaluated 3748 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
&& (
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
size_t) (
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
269 1
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
270 ) == 0
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
) || (__builtin_constant_p (
__builtin_cons..._p ( n_bytes )Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
271 n_bytes
__builtin_cons..._p ( n_bytes )Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
272 )
__builtin_cons..._p ( n_bytes )Description
TRUEnever evaluated
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • head
&& (
(size_t) ( n_bytes ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
size_t) (
(size_t) ( n_bytes ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3748
273 n_bytes
(size_t) ( n_bytes ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
274 ) == 0
(size_t) ( n_bytes ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)) ? ((void) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
0-3740
275 buffer
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
276 ), (void) (stdout), (void) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
277 1
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
278 ), (void) (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
279 n_bytes
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
280 ), (size_t) 0) : fwrite_unlocked (
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
281 buffer
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
282 ,
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
283 1
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
284 ,
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
285 n_bytes
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
286 , stdout))))
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
8-3740
287 < n_bytes
(__extension__...)))) < n_bytesDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3740 times by 1 test
Evaluated by:
  • head
)
8-3740
288 {-
289 clearerr_unlocked (-
290 stdout-
291 );-
292 ((!!sizeof (struct { _Static_assert (-
293 1-
294 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"error writing %s\", 5), quotearg_style (shell_escape_always_quoting_style, \"standard output\")), assume (false))" ")"); int _gl_dummy; })) ? ((error (-
295 1-
296 , -
297 (*__errno_location ())-
298 , -
299 dcgettext (((void *)0), -
300 "error writing %s"-
301 , 5)-
302 , quotearg_style (shell_escape_always_quoting_style, "standard output")), ((-
303 0-
304 ) ? (void) 0 : __builtin_unreachable ()))) : ((error (-
305 1-
306 , -
307 (*__errno_location ())-
308 , -
309 dcgettext (((void *)0), -
310 "error writing %s"-
311 , 5)-
312 , quotearg_style (shell_escape_always_quoting_style, "standard output")), ((-
313 0-
314 ) ? (void) 0 : __builtin_unreachable ()))))-
315 ;-
316 }
never executed: end of block
0
317}
executed 3741 times by 1 test: end of block
Executed by:
  • head
3741
318-
319-
320-
321-
322static enum Copy_fd_status-
323copy_fd (int src_fd, uintmax_t n_bytes)-
324{-
325 char buf[-
326 8192-
327 ];-
328 const size_t buf_size = sizeof (buf);-
329-
330-
331 while (0 < n_bytes
0 < n_bytesDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
)
3-20
332 {-
333 size_t n_to_read = -
334 (((
(( buf_size )<( n_bytes ))Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
3-17
335 buf_size
(( buf_size )<( n_bytes ))Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
3-17
336 )<(
(( buf_size )<( n_bytes ))Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
3-17
337 n_bytes
(( buf_size )<( n_bytes ))Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
3-17
338 ))
(( buf_size )<( n_bytes ))Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
?(
3-17
339 buf_size-
340 ):(-
341 n_bytes-
342 ))-
343 ;-
344 size_t n_read = safe_read (src_fd, buf, n_to_read);-
345 if (n_read == ((size_t) -1)
n_read == ((size_t) -1)Description
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • head
)
0-20
346 return
never executed: return COPY_FD_READ_ERROR;
COPY_FD_READ_ERROR;
never executed: return COPY_FD_READ_ERROR;
0
347-
348 n_bytes -= n_read;-
349-
350 if (n_read == 0
n_read == 0Description
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • head
&& n_bytes != 0
n_bytes != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0-20
351 return
never executed: return COPY_FD_UNEXPECTED_EOF;
COPY_FD_UNEXPECTED_EOF;
never executed: return COPY_FD_UNEXPECTED_EOF;
0
352-
353 xwrite_stdout (buf, n_read);-
354 }
executed 16 times by 1 test: end of block
Executed by:
  • head
16
355-
356 return
executed 3 times by 1 test: return COPY_FD_OK;
Executed by:
  • head
COPY_FD_OK;
executed 3 times by 1 test: return COPY_FD_OK;
Executed by:
  • head
3
357}-
358-
359-
360-
361-
362-
363-
364static off_t-
365elseek (int fd, off_t offset, int whence, char const *filename)-
366{-
367 off_t new_offset = lseek (fd, offset, whence);-
368 char buf[((((((sizeof (offset) * 8) - (! ((__typeof__ (offset)) 0 < (__typeof__ (offset)) -1))) * 146 + 484) / 485) + (! ((__typeof__ (offset)) 0 < (__typeof__ (offset)) -1))) + 1)];-
369-
370 if (new_offset < 0
new_offset < 0Description
TRUEnever evaluated
FALSEevaluated 2052 times by 1 test
Evaluated by:
  • head
)
0-2052
371 error (0,
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
372 (*__errno_location ())
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
373 ,
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
374
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
375 dcgettext (((void *)0),
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
376 whence ==
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
377 0
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
378 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s"
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
379 , 5)
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
3800
381
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
382 ,
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
383 quotearg_n_style_colon (0, shell_escape_quoting_style, filename),
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
384 offtostr (offset, buf));
never executed: error (0, (*__errno_location ()) , dcgettext (((void *)0), whence == 0 ? "%s: cannot seek to offset %s" : "%s: cannot seek to relative offset %s" , 5) , quotearg_n_style_colon (0, shell_escape_quoting_style, filename), offtostr (offset, buf));
0
385-
386 return
executed 2052 times by 1 test: return new_offset;
Executed by:
  • head
new_offset;
executed 2052 times by 1 test: return new_offset;
Executed by:
  • head
2052
387}-
388static -
389 _Bool-
390-
391elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0,-
392 off_t current_pos)-
393{-
394 size_t n_elide = n_elide_0;-
395 uintmax_t desired_pos = current_pos;-
396 -
397 _Bool -
398 ok = -
399 1-
400 ;-
401 if (-
402 (
(1844674407370...elide_0 + 8192Description
TRUEnever evaluated
FALSEevaluated 955 times by 1 test
Evaluated by:
  • head
18446744073709551615UL)
(1844674407370...elide_0 + 8192Description
TRUEnever evaluated
FALSEevaluated 955 times by 1 test
Evaluated by:
  • head
0-955
403 < n_elide_0 +
(1844674407370...elide_0 + 8192Description
TRUEnever evaluated
FALSEevaluated 955 times by 1 test
Evaluated by:
  • head
0-955
404 8192
(1844674407370...elide_0 + 8192Description
TRUEnever evaluated
FALSEevaluated 955 times by 1 test
Evaluated by:
  • head
0-955
405 )-
406 {-
407 char umax_buf[((((((sizeof (n_elide_0) * 8) - (! ((__typeof__ (n_elide_0)) 0 < (__typeof__ (n_elide_0)) -1))) * 146 + 484) / 485) + (! ((__typeof__ (n_elide_0)) 0 < (__typeof__ (n_elide_0)) -1))) + 1)];-
408 ((!!sizeof (struct { _Static_assert (-
409 1-
410 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"%s: number of bytes is too large\", 5), umaxtostr (n_elide_0, umax_buf)), assume (false))" ")"); int _gl_dummy; })) ? ((error (-
411 1-
412 , 0, -
413 dcgettext (((void *)0), -
414 "%s: number of bytes is too large"-
415 , 5)-
416 , umaxtostr (n_elide_0, umax_buf)), ((-
417 0-
418 ) ? (void) 0 : __builtin_unreachable ()))) : ((error (-
419 1-
420 , 0, -
421 dcgettext (((void *)0), -
422 "%s: number of bytes is too large"-
423 , 5)-
424 , umaxtostr (n_elide_0, umax_buf)), ((-
425 0-
426 ) ? (void) 0 : __builtin_unreachable ()))))-
427 ;-
428 }
never executed: end of block
0
429 if (n_elide <= 1024 * 1024
n_elide <= 1024 * 1024Description
TRUEevaluated 954 times by 1 test
Evaluated by:
  • head
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
)
1-954
430 {-
431 -
432 _Bool -
433 first = -
434 1-
435 ;-
436 -
437 _Bool -
438 eof = -
439 0-
440 ;-
441 size_t n_to_read = -
442 8192 -
443 + n_elide;-
444 -
445 _Bool -
446 i;-
447 char *b[2];-
448 b[0] = xnmalloc (2, n_to_read);-
449 b[1] = b[0] + n_to_read;-
450-
451 for (i = -
452 0-
453 ; ! eof
! eofDescription
TRUEevaluated 954 times by 1 test
Evaluated by:
  • head
FALSEevaluated 952 times by 1 test
Evaluated by:
  • head
; i = !i)
952-954
454 {-
455 size_t n_read = full_read (fd, b[i], n_to_read);-
456 size_t delta = 0;-
457 if (n_read < n_to_read
n_read < n_to_readDescription
TRUEevaluated 952 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2 times by 1 test
Evaluated by:
  • head
)
2-952
458 {-
459 if (-
460 (*
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEevaluated 952 times by 1 test
Evaluated by:
  • head
__errno_location ())
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEevaluated 952 times by 1 test
Evaluated by:
  • head
0-952
461 != 0
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEevaluated 952 times by 1 test
Evaluated by:
  • head
)
0-952
462 {-
463 error (0, -
464 (*__errno_location ())-
465 , -
466 dcgettext (((void *)0), -
467 "error reading %s"-
468 , 5)-
469 , quotearg_style (shell_escape_always_quoting_style, filename));-
470 ok = -
471 0-
472 ;-
473 break;
never executed: break;
0
474 }-
475-
476-
477 if (n_read <= n_elide
n_read <= n_elideDescription
TRUEevaluated 464 times by 1 test
Evaluated by:
  • head
FALSEevaluated 488 times by 1 test
Evaluated by:
  • head
)
464-488
478 {-
479 if (first
firstDescription
TRUEevaluated 464 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-464
480 {-
481-
482-
483-
484 }
executed 464 times by 1 test: end of block
Executed by:
  • head
464
485 else-
486 {-
487 delta = n_elide - n_read;-
488 }
never executed: end of block
0
489 }-
490 eof = -
491 1-
492 ;-
493 }
executed 952 times by 1 test: end of block
Executed by:
  • head
952
494-
495-
496-
497 if (! first
! firstDescription
TRUEnever evaluated
FALSEevaluated 954 times by 1 test
Evaluated by:
  • head
)
0-954
498 {-
499 desired_pos += n_elide - delta;-
500 xwrite_stdout (b[!i] + -
501 8192-
502 , n_elide - delta);-
503 }
never executed: end of block
0
504 first = -
505 0-
506 ;-
507-
508 if (n_elide < n_read
n_elide < n_readDescription
TRUEevaluated 490 times by 1 test
Evaluated by:
  • head
FALSEevaluated 464 times by 1 test
Evaluated by:
  • head
)
464-490
509 {-
510 desired_pos += n_read - n_elide;-
511 xwrite_stdout (b[i], n_read - n_elide);-
512 }
executed 488 times by 1 test: end of block
Executed by:
  • head
488
513 }
executed 952 times by 1 test: end of block
Executed by:
  • head
952
514-
515 free (b[0]);-
516 }
executed 952 times by 1 test: end of block
Executed by:
  • head
952
517 else-
518 {-
519-
520-
521-
522 -
523 _Bool -
524 eof = -
525 0-
526 ;-
527 size_t n_read;-
528 -
529 _Bool -
530 buffered_enough;-
531 size_t i, i_next;-
532 char **b = -
533 ((void *)0)-
534 ;-
535-
536 size_t rem = -
537 8192 -
538 - (n_elide % -
539 8192-
540 );-
541 size_t n_elide_round = n_elide + rem;-
542 size_t n_bufs = n_elide_round / -
543 8192 -
544 + 1;-
545 size_t n_alloc = 0;-
546 size_t n_array_alloc = 0;-
547-
548 buffered_enough = -
549 0-
550 ;-
551 for (i = 0, i_next = 1; !eof
!eofDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
; i = i_next, i_next = (i_next + 1) % n_bufs)
1
552 {-
553 if (n_array_alloc == i
n_array_alloc == iDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-1
554 {-
555-
556 if (n_array_alloc == 0
n_array_alloc == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-1
557 n_array_alloc =
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
1
558 (((
(( n_bufs )<( 16 ))Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
0-1
559 n_bufs
(( n_bufs )<( 16 ))Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
0-1
560 )<(
(( n_bufs )<( 16 ))Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
0-1
561 16
(( n_bufs )<( 16 ))Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
0-1
562 ))
(( n_bufs )<( 16 ))Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
?(
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
0-1
563 n_bufs
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
1
564 ):(
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
1
565 16
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
1
566 ))
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
1
567 ;
executed 1 time by 1 test: n_array_alloc = ((( n_bufs )<( 16 ))?( n_bufs ):( 16 )) ;
Executed by:
  • head
1
568 else if (n_array_alloc <= n_bufs / 2
n_array_alloc <= n_bufs / 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
569 n_array_alloc *= 2;
never executed: n_array_alloc *= 2;
0
570 else-
571 n_array_alloc = n_bufs;
never executed: n_array_alloc = n_bufs;
0
572 b = xnrealloc (b, n_array_alloc, sizeof *b);-
573 }
executed 1 time by 1 test: end of block
Executed by:
  • head
1
574-
575 if (! buffered_enough
! buffered_enoughDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-1
576 {-
577 b[i] = xmalloc (-
578 8192-
579 );-
580 n_alloc = i + 1;-
581 }
executed 1 time by 1 test: end of block
Executed by:
  • head
1
582 n_read = full_read (fd, b[i], -
583 8192-
584 );-
585 if (n_read <
n_read < 8192Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEnever evaluated
0-1
586 8192
n_read < 8192Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEnever evaluated
0-1
587 )-
588 {-
589 if (-
590 (*
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
__errno_location ())
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
0-1
591 != 0
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
)
0-1
592 {-
593 error (0, -
594 (*__errno_location ())-
595 , -
596 dcgettext (((void *)0), -
597 "error reading %s"-
598 , 5)-
599 , quotearg_style (shell_escape_always_quoting_style, filename));-
600 ok = -
601 0-
602 ;-
603 goto
never executed: goto free_mem;
free_mem;
never executed: goto free_mem;
0
604 }-
605 eof = -
606 1-
607 ;-
608 }
executed 1 time by 1 test: end of block
Executed by:
  • head
1
609-
610 if (i + 1 == n_bufs
i + 1 == n_bufsDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
)
0-1
611 buffered_enough =
never executed: buffered_enough = 1 ;
0
612 1
never executed: buffered_enough = 1 ;
0
613 ;
never executed: buffered_enough = 1 ;
0
614-
615 if (buffered_enough
buffered_enoughDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
)
0-1
616 {-
617 desired_pos += n_read;-
618 xwrite_stdout (b[i_next], n_read);-
619 }
never executed: end of block
0
620 }
executed 1 time by 1 test: end of block
Executed by:
  • head
1
621-
622-
623 if (rem
remDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-1
624 {-
625 if (buffered_enough
buffered_enoughDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
)
0-1
626 {-
627 size_t n_bytes_left_in_b_i = -
628 8192 -
629 - n_read;-
630 desired_pos += rem;-
631 if (rem < n_bytes_left_in_b_i
rem < n_bytes_left_in_b_iDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
632 {-
633 xwrite_stdout (b[i] + n_read, rem);-
634 }
never executed: end of block
0
635 else-
636 {-
637 xwrite_stdout (b[i] + n_read, n_bytes_left_in_b_i);-
638 xwrite_stdout (b[i_next], rem - n_bytes_left_in_b_i);-
639 }
never executed: end of block
0
640 }-
641 else if (i + 1 == n_bufs
i + 1 == n_bufsDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
)
0-1
642 {-
643 size_t y = -
644 8192 -
645 - rem;-
646 size_t x = n_read - y;-
647 desired_pos += x;-
648 xwrite_stdout (b[i_next], x);-
649 }
never executed: end of block
0
650 }
executed 1 time by 1 test: end of block
Executed by:
  • head
1
651-
652 free_mem:
code before this statement executed 1 time by 1 test: free_mem:
Executed by:
  • head
1
653 for (i = 0; i < n_alloc
i < n_allocDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
; i++)
1
654 free (b[i]);
executed 1 time by 1 test: free (b[i]);
Executed by:
  • head
1
655 free (b);-
656 }
executed 1 time by 1 test: end of block
Executed by:
  • head
1
657-
658 if (0 <= current_pos
0 <= current_posDescription
TRUEevaluated 509 times by 1 test
Evaluated by:
  • head
FALSEevaluated 444 times by 1 test
Evaluated by:
  • head
&& elseek (fd, desired_pos,
elseek (fd, de... filename) < 0Description
TRUEnever evaluated
FALSEevaluated 509 times by 1 test
Evaluated by:
  • head
0-509
659 0
elseek (fd, de... filename) < 0Description
TRUEnever evaluated
FALSEevaluated 509 times by 1 test
Evaluated by:
  • head
0-509
660 , filename) < 0
elseek (fd, de... filename) < 0Description
TRUEnever evaluated
FALSEevaluated 509 times by 1 test
Evaluated by:
  • head
)
0-509
661 ok =
never executed: ok = 0 ;
0
662 0
never executed: ok = 0 ;
0
663 ;
never executed: ok = 0 ;
0
664 return
executed 953 times by 1 test: return ok;
Executed by:
  • head
ok;
executed 953 times by 1 test: return ok;
Executed by:
  • head
953
665}-
666static -
667 _Bool-
668-
669elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide,-
670 struct stat const *st, off_t current_pos)-
671{-
672 off_t size = st->st_size;-
673 if (presume_input_pipe
presume_input_pipeDescription
TRUEevaluated 441 times by 1 test
Evaluated by:
  • head
FALSEevaluated 518 times by 1 test
Evaluated by:
  • head
|| current_pos < 0
current_pos < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • head
FALSEevaluated 513 times by 1 test
Evaluated by:
  • head
|| size <= ((0 < (*st).st_blksize
0 < (*st).st_blksizeDescription
TRUEevaluated 513 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
&& (*
(*st).st_blksi..._t)-1) / 8 + 1Description
TRUEevaluated 513 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
st).st_blksize <= ((size_t)-1) / 8 + 1
(*st).st_blksi..._t)-1) / 8 + 1Description
TRUEevaluated 513 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
) ? (*st).st_blksize :
size <= ((0 < ...lksize : 512 )Description
TRUEevaluated 509 times by 1 test
Evaluated by:
  • head
FALSEevaluated 4 times by 1 test
Evaluated by:
  • head
0-518
674 512
size <= ((0 < ...lksize : 512 )Description
TRUEevaluated 509 times by 1 test
Evaluated by:
  • head
FALSEevaluated 4 times by 1 test
Evaluated by:
  • head
4-509
675 )
size <= ((0 < ...lksize : 512 )Description
TRUEevaluated 509 times by 1 test
Evaluated by:
  • head
FALSEevaluated 4 times by 1 test
Evaluated by:
  • head
)
4-509
676 return
executed 955 times by 1 test: return elide_tail_bytes_pipe (filename, fd, n_elide, current_pos);
Executed by:
  • head
elide_tail_bytes_pipe (filename, fd, n_elide, current_pos);
executed 955 times by 1 test: return elide_tail_bytes_pipe (filename, fd, n_elide, current_pos);
Executed by:
  • head
955
677 else-
678 {-
679-
680-
681 off_t diff = size - current_pos;-
682 off_t bytes_remaining = diff < 0
diff < 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • head
? 0 : diff;
0-4
683-
684 if (bytes_remaining <= n_elide
bytes_remaining <= n_elideDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • head
)
0-4
685 return
never executed: return 1 ;
never executed: return 1 ;
0
686 1
never executed: return 1 ;
0
687 ;
never executed: return 1 ;
0
688-
689 enum Copy_fd_status err = copy_fd (fd, bytes_remaining - n_elide);-
690 if (err == COPY_FD_OK
err == COPY_FD_OKDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-2
691 return
executed 2 times by 1 test: return 1 ;
Executed by:
  • head
executed 2 times by 1 test: return 1 ;
Executed by:
  • head
2
692 1
executed 2 times by 1 test: return 1 ;
Executed by:
  • head
2
693 ;
executed 2 times by 1 test: return 1 ;
Executed by:
  • head
2
694-
695 diagnose_copy_fd_failure (err, filename);-
696 return
never executed: return 0 ;
never executed: return 0 ;
0
697 0
never executed: return 0 ;
0
698 ;
never executed: return 0 ;
0
699 }-
700}-
701static -
702 _Bool-
703-
704elide_tail_lines_pipe (const char *filename, int fd, uintmax_t n_elide,-
705 off_t current_pos)-
706{-
707 struct linebuffer-
708 {-
709 char buffer[-
710 8192-
711 ];-
712 size_t nbytes;-
713 size_t nlines;-
714 struct linebuffer *next;-
715 };-
716 uintmax_t desired_pos = current_pos;-
717 typedef struct linebuffer LBUFFER;-
718 LBUFFER *first, *last, *tmp;-
719 size_t total_lines = 0;-
720 -
721 _Bool -
722 ok = -
723 1-
724 ;-
725 size_t n_read;-
726-
727 first = last = xmalloc (sizeof (LBUFFER));-
728 first->nbytes = first->nlines = 0;-
729 first->next = -
730 ((void *)0)-
731 ;-
732 tmp = xmalloc (sizeof (LBUFFER));-
733-
734-
735-
736-
737 while (1)-
738 {-
739 n_read = safe_read (fd, tmp->buffer, -
740 8192-
741 );-
742 if (n_read == 0
n_read == 0Description
TRUEevaluated 976 times by 1 test
Evaluated by:
  • head
FALSEevaluated 934 times by 1 test
Evaluated by:
  • head
|| n_read == ((size_t) -1)
n_read == ((size_t) -1)Description
TRUEnever evaluated
FALSEevaluated 934 times by 1 test
Evaluated by:
  • head
)
0-976
743 break;
executed 976 times by 1 test: break;
Executed by:
  • head
976
744-
745 if (! n_elide
! n_elideDescription
TRUEevaluated 45 times by 1 test
Evaluated by:
  • head
FALSEevaluated 889 times by 1 test
Evaluated by:
  • head
)
45-889
746 {-
747 desired_pos += n_read;-
748 xwrite_stdout (tmp->buffer, n_read);-
749 continue;
executed 44 times by 1 test: continue;
Executed by:
  • head
44
750 }-
751-
752 tmp->nbytes = n_read;-
753 tmp->nlines = 0;-
754 tmp->next = -
755 ((void *)0)-
756 ;-
757-
758-
759 {-
760 char const *buffer_end = tmp->buffer + n_read;-
761 char const *p = tmp->buffer;-
762 while ((
(p = memchr (p...ffer_end - p))Description
TRUEevaluated 17858 times by 1 test
Evaluated by:
  • head
FALSEevaluated 889 times by 1 test
Evaluated by:
  • head
p = memchr (p, line_end, buffer_end - p))
(p = memchr (p...ffer_end - p))Description
TRUEevaluated 17858 times by 1 test
Evaluated by:
  • head
FALSEevaluated 889 times by 1 test
Evaluated by:
  • head
)
889-17858
763 {-
764 ++p;-
765 ++tmp->nlines;-
766 }
executed 17858 times by 1 test: end of block
Executed by:
  • head
17858
767 }-
768 total_lines += tmp->nlines;-
769-
770-
771-
772-
773 if (tmp->nbytes + last->nbytes <
tmp->nbytes + ...>nbytes < 8192Description
TRUEevaluated 887 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2 times by 1 test
Evaluated by:
  • head
2-887
774 8192
tmp->nbytes + ...>nbytes < 8192Description
TRUEevaluated 887 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2 times by 1 test
Evaluated by:
  • head
2-887
775 )-
776 {-
777 memcpy (&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes);-
778 last->nbytes += tmp->nbytes;-
779 last->nlines += tmp->nlines;-
780 }
executed 887 times by 1 test: end of block
Executed by:
  • head
887
781 else-
782 {-
783-
784-
785-
786-
787-
788 last = last->next = tmp;-
789 if (n_elide < total_lines - first->nlines
n_elide < tota... first->nlinesDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-2
790 {-
791 desired_pos += first->nbytes;-
792 xwrite_stdout (first->buffer, first->nbytes);-
793 tmp = first;-
794 total_lines -= first->nlines;-
795 first = first->next;-
796 }
executed 1 time by 1 test: end of block
Executed by:
  • head
1
797 else-
798 tmp = xmalloc (sizeof (LBUFFER));
never executed: tmp = xmalloc (sizeof (LBUFFER));
0
799 }-
800 }-
801-
802 free (tmp);-
803-
804 if (n_read == ((size_t) -1)
n_read == ((size_t) -1)Description
TRUEnever evaluated
FALSEevaluated 976 times by 1 test
Evaluated by:
  • head
)
0-976
805 {-
806 error (0, -
807 (*__errno_location ())-
808 , -
809 dcgettext (((void *)0), -
810 "error reading %s"-
811 , 5)-
812 , quotearg_style (shell_escape_always_quoting_style, filename));-
813 ok = -
814 0-
815 ;-
816 goto
never executed: goto free_lbuffers;
free_lbuffers;
never executed: goto free_lbuffers;
0
817 }-
818-
819-
820-
821 if (last->nbytes
last->nbytesDescription
TRUEevaluated 887 times by 1 test
Evaluated by:
  • head
FALSEevaluated 89 times by 1 test
Evaluated by:
  • head
&& last->buffer[last->nbytes - 1] != line_end
last->buffer[l...1] != line_endDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • head
FALSEevaluated 843 times by 1 test
Evaluated by:
  • head
)
44-887
822 {-
823 ++last->nlines;-
824 ++total_lines;-
825 }
executed 44 times by 1 test: end of block
Executed by:
  • head
44
826-
827 for (tmp = first; n_elide < total_lines - tmp->nlines
n_elide < tota... - tmp->nlinesDescription
TRUEnever evaluated
FALSEevaluated 976 times by 1 test
Evaluated by:
  • head
; tmp = tmp->next)
0-976
828 {-
829 desired_pos += tmp->nbytes;-
830 xwrite_stdout (tmp->buffer, tmp->nbytes);-
831 total_lines -= tmp->nlines;-
832 }
never executed: end of block
0
833-
834-
835 if (n_elide < total_lines
n_elide < total_linesDescription
TRUEevaluated 423 times by 1 test
Evaluated by:
  • head
FALSEevaluated 553 times by 1 test
Evaluated by:
  • head
)
423-553
836 {-
837 size_t n = total_lines - n_elide;-
838 char const *buffer_end = tmp->buffer + tmp->nbytes;-
839 char const *p = tmp->buffer;-
840 while (n
nDescription
TRUEevaluated 3083 times by 1 test
Evaluated by:
  • head
FALSEevaluated 423 times by 1 test
Evaluated by:
  • head
&& (
(p = memchr (p...ffer_end - p))Description
TRUEevaluated 3083 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
p = memchr (p, line_end, buffer_end - p))
(p = memchr (p...ffer_end - p))Description
TRUEevaluated 3083 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-3083
841 {-
842 ++p;-
843 ++tmp->nlines;-
844 --n;-
845 }
executed 3083 times by 1 test: end of block
Executed by:
  • head
3083
846 desired_pos += p - tmp->buffer;-
847 xwrite_stdout (tmp->buffer, p - tmp->buffer);-
848 }
executed 423 times by 1 test: end of block
Executed by:
  • head
423
849-
850free_lbuffers:
code before this statement executed 976 times by 1 test: free_lbuffers:
Executed by:
  • head
976
851 while (first
firstDescription
TRUEevaluated 976 times by 1 test
Evaluated by:
  • head
FALSEevaluated 976 times by 1 test
Evaluated by:
  • head
)
976
852 {-
853 tmp = first->next;-
854 free (first);-
855 first = tmp;-
856 }
executed 976 times by 1 test: end of block
Executed by:
  • head
976
857-
858 if (0 <= current_pos
0 <= current_posDescription
TRUEevaluated 492 times by 1 test
Evaluated by:
  • head
FALSEevaluated 484 times by 1 test
Evaluated by:
  • head
&& elseek (fd, desired_pos,
elseek (fd, de... filename) < 0Description
TRUEnever evaluated
FALSEevaluated 492 times by 1 test
Evaluated by:
  • head
0-492
859 0
elseek (fd, de... filename) < 0Description
TRUEnever evaluated
FALSEevaluated 492 times by 1 test
Evaluated by:
  • head
0-492
860 , filename) < 0
elseek (fd, de... filename) < 0Description
TRUEnever evaluated
FALSEevaluated 492 times by 1 test
Evaluated by:
  • head
)
0-492
861 ok =
never executed: ok = 0 ;
0
862 0
never executed: ok = 0 ;
0
863 ;
never executed: ok = 0 ;
0
864 return
executed 976 times by 1 test: return ok;
Executed by:
  • head
ok;
executed 976 times by 1 test: return ok;
Executed by:
  • head
976
865}-
866static -
867 _Bool-
868-
869elide_tail_lines_seekable (const char *pretty_filename, int fd,-
870 uintmax_t n_lines,-
871 off_t start_pos, off_t size)-
872{-
873 char buffer[-
874 8192-
875 ];-
876 size_t bytes_read;-
877 off_t pos = size;-
878-
879-
880-
881 bytes_read = (pos - start_pos) % -
882 8192-
883 ;-
884 if (bytes_read == 0
bytes_read == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • head
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
)
1-2
885 bytes_read =
executed 2 times by 1 test: bytes_read = 8192 ;
Executed by:
  • head
2
886 8192
executed 2 times by 1 test: bytes_read = 8192 ;
Executed by:
  • head
2
887 ;
executed 2 times by 1 test: bytes_read = 8192 ;
Executed by:
  • head
2
888-
889-
890 pos -= bytes_read;-
891 if (elseek (fd, pos,
elseek (fd, po..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
0-3
892 0
elseek (fd, po..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
0-3
893 , pretty_filename) < 0
elseek (fd, po..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
)
0-3
894 return
never executed: return 0 ;
never executed: return 0 ;
0
895 0
never executed: return 0 ;
0
896 ;
never executed: return 0 ;
0
897 bytes_read = safe_read (fd, buffer, bytes_read);-
898 if (bytes_read == ((size_t) -1)
bytes_read == ((size_t) -1)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
)
0-3
899 {-
900 error (0, -
901 (*__errno_location ())-
902 , -
903 dcgettext (((void *)0), -
904 "error reading %s"-
905 , 5)-
906 , quotearg_style (shell_escape_always_quoting_style, pretty_filename));-
907 return
never executed: return 0 ;
never executed: return 0 ;
0
908 0
never executed: return 0 ;
0
909 ;
never executed: return 0 ;
0
910 }-
911-
912-
913 const -
914 _Bool -
915 all_lines = !n_lines;-
916-
917-
918 if (n_lines
n_linesDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • head
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
&& bytes_read
bytes_readDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
&& buffer[bytes_read - 1] != line_end
buffer[bytes_r...1] != line_endDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • head
)
0-2
919 --
never executed: --n_lines;
n_lines;
never executed: --n_lines;
0
920-
921 while (1)-
922 {-
923-
924-
925 size_t n = bytes_read;-
926 while (n
nDescription
TRUEevaluated 50040 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-50040
927 {-
928 if (all_lines
all_linesDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • head
FALSEevaluated 50039 times by 1 test
Evaluated by:
  • head
)
1-50039
929 n -= 1;
executed 1 time by 1 test: n -= 1;
Executed by:
  • head
1
930 else-
931 {-
932 char const *nl;-
933 nl = memrchr (buffer, line_end, n);-
934 if (nl ==
nl == ((void *)0)Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • head
FALSEevaluated 50003 times by 1 test
Evaluated by:
  • head
36-50003
935 ((void *)0)
nl == ((void *)0)Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • head
FALSEevaluated 50003 times by 1 test
Evaluated by:
  • head
36-50003
936 )-
937 break;
executed 36 times by 1 test: break;
Executed by:
  • head
36
938 n = nl - buffer;-
939 }
executed 50003 times by 1 test: end of block
Executed by:
  • head
50003
940 if (n_lines-- == 0
n_lines-- == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • head
FALSEevaluated 50001 times by 1 test
Evaluated by:
  • head
)
3-50001
941 {-
942-
943-
944-
945 if (start_pos < pos
start_pos < posDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
)
0-3
946 {-
947 enum Copy_fd_status err;-
948 if (elseek (fd, start_pos,
elseek (fd, st..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
0-3
949 0
elseek (fd, st..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
0-3
950 , pretty_filename) < 0
elseek (fd, st..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
)
0-3
951 return
never executed: return 0 ;
never executed: return 0 ;
0
952 0
never executed: return 0 ;
0
953 ;
never executed: return 0 ;
0
954-
955 err = copy_fd (fd, pos - start_pos);-
956 if (err != COPY_FD_OK
err != COPY_FD_OKDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • head
)
0-1
957 {-
958 diagnose_copy_fd_failure (err, pretty_filename);-
959 return
never executed: return 0 ;
never executed: return 0 ;
0
960 0
never executed: return 0 ;
0
961 ;
never executed: return 0 ;
0
962 }-
963 }
executed 1 time by 1 test: end of block
Executed by:
  • head
1
964-
965-
966-
967 xwrite_stdout (buffer, n + 1);-
968-
969-
970 return
executed 1 time by 1 test: return 0 <= elseek (fd, pos + n + 1, 0 , pretty_filename);
Executed by:
  • head
0 <= elseek (fd, pos + n + 1,
executed 1 time by 1 test: return 0 <= elseek (fd, pos + n + 1, 0 , pretty_filename);
Executed by:
  • head
1
971 0
executed 1 time by 1 test: return 0 <= elseek (fd, pos + n + 1, 0 , pretty_filename);
Executed by:
  • head
1
972 , pretty_filename);
executed 1 time by 1 test: return 0 <= elseek (fd, pos + n + 1, 0 , pretty_filename);
Executed by:
  • head
1
973 }-
974 }
executed 50001 times by 1 test: end of block
Executed by:
  • head
50001
975-
976-
977 if (pos == start_pos
pos == start_posDescription
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • head
)
0-36
978 {-
979-
980 return
never executed: return 1 ;
never executed: return 1 ;
0
981 1
never executed: return 1 ;
0
982 ;
never executed: return 1 ;
0
983 }-
984 pos -= -
985 8192-
986 ;-
987 if (elseek (fd, pos,
elseek (fd, po..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • head
0-36
988 0
elseek (fd, po..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • head
0-36
989 , pretty_filename) < 0
elseek (fd, po..._filename) < 0Description
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • head
)
0-36
990 return
never executed: return 0 ;
never executed: return 0 ;
0
991 0
never executed: return 0 ;
0
992 ;
never executed: return 0 ;
0
993-
994 bytes_read = safe_read (fd, buffer, -
995 8192-
996 );-
997 if (bytes_read == ((size_t) -1)
bytes_read == ((size_t) -1)Description
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • head
)
0-36
998 {-
999 error (0, -
1000 (*__errno_location ())-
1001 , -
1002 dcgettext (((void *)0), -
1003 "error reading %s"-
1004 , 5)-
1005 , quotearg_style (shell_escape_always_quoting_style, pretty_filename));-
1006 return
never executed: return 0 ;
never executed: return 0 ;
0
1007 0
never executed: return 0 ;
0
1008 ;
never executed: return 0 ;
0
1009 }-
1010-
1011-
1012-
1013 if (bytes_read == 0
bytes_read == 0Description
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • head
)
0-36
1014 return
never executed: return 1 ;
never executed: return 1 ;
0
1015 1
never executed: return 1 ;
0
1016 ;
never executed: return 1 ;
0
1017 }
executed 36 times by 1 test: end of block
Executed by:
  • head
36
1018}
never executed: end of block
0
1019-
1020-
1021-
1022-
1023-
1024-
1025static -
1026 _Bool-
1027-
1028elide_tail_lines_file (const char *filename, int fd, uintmax_t n_elide,-
1029 struct stat const *st, off_t current_pos)-
1030{-
1031 off_t size = st->st_size;-
1032 if (presume_input_pipe
presume_input_pipeDescription
TRUEevaluated 484 times by 1 test
Evaluated by:
  • head
FALSEevaluated 497 times by 1 test
Evaluated by:
  • head
|| current_pos < 0
current_pos < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • head
FALSEevaluated 495 times by 1 test
Evaluated by:
  • head
|| size <= ((0 < (*st).st_blksize
0 < (*st).st_blksizeDescription
TRUEevaluated 495 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
&& (*
(*st).st_blksi..._t)-1) / 8 + 1Description
TRUEevaluated 495 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
st).st_blksize <= ((size_t)-1) / 8 + 1
(*st).st_blksi..._t)-1) / 8 + 1Description
TRUEevaluated 495 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
) ? (*st).st_blksize :
size <= ((0 < ...lksize : 512 )Description
TRUEevaluated 492 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
0-497
1033 512
size <= ((0 < ...lksize : 512 )Description
TRUEevaluated 492 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
3-492
1034 )
size <= ((0 < ...lksize : 512 )Description
TRUEevaluated 492 times by 1 test
Evaluated by:
  • head
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
)
3-492
1035 return
executed 978 times by 1 test: return elide_tail_lines_pipe (filename, fd, n_elide, current_pos);
Executed by:
  • head
elide_tail_lines_pipe (filename, fd, n_elide, current_pos);
executed 978 times by 1 test: return elide_tail_lines_pipe (filename, fd, n_elide, current_pos);
Executed by:
  • head
978
1036 else-
1037 {-
1038-
1039-
1040-
1041-
1042-
1043 return
executed 3 times by 1 test: return (size <= current_pos || elide_tail_lines_seekable (filename, fd, n_elide, current_pos, size));
Executed by:
  • head
(size <= current_pos
executed 3 times by 1 test: return (size <= current_pos || elide_tail_lines_seekable (filename, fd, n_elide, current_pos, size));
Executed by:
  • head
3
1044 || elide_tail_lines_seekable (filename, fd, n_elide,
executed 3 times by 1 test: return (size <= current_pos || elide_tail_lines_seekable (filename, fd, n_elide, current_pos, size));
Executed by:
  • head
3
1045 current_pos, size));
executed 3 times by 1 test: return (size <= current_pos || elide_tail_lines_seekable (filename, fd, n_elide, current_pos, size));
Executed by:
  • head
3
1046 }-
1047}-
1048-
1049static -
1050 _Bool-
1051-
1052head_bytes (const char *filename, int fd, uintmax_t bytes_to_write)-
1053{-
1054 char buffer[-
1055 8192-
1056 ];-
1057 size_t bytes_to_read = -
1058 8192-
1059 ;-
1060-
1061 while (bytes_to_write
bytes_to_writeDescription
TRUEevaluated 1577 times by 1 test
Evaluated by:
  • head
FALSEevaluated 140 times by 1 test
Evaluated by:
  • head
)
140-1577
1062 {-
1063 size_t bytes_read;-
1064 if (bytes_to_write < bytes_to_read
bytes_to_write < bytes_to_readDescription
TRUEevaluated 147 times by 1 test
Evaluated by:
  • head
FALSEevaluated 1430 times by 1 test
Evaluated by:
  • head
)
147-1430
1065 bytes_to_read = bytes_to_write;
executed 147 times by 1 test: bytes_to_read = bytes_to_write;
Executed by:
  • head
147
1066 bytes_read = safe_read (fd, buffer, bytes_to_read);-
1067 if (bytes_read == ((size_t) -1)
bytes_read == ((size_t) -1)Description
TRUEnever evaluated
FALSEevaluated 1577 times by 1 test
Evaluated by:
  • head
)
0-1577
1068 {-
1069 error (0, -
1070 (*__errno_location ())-
1071 , -
1072 dcgettext (((void *)0), -
1073 "error reading %s"-
1074 , 5)-
1075 , quotearg_style (shell_escape_always_quoting_style, filename));-
1076 return
never executed: return 0 ;
never executed: return 0 ;
0
1077 0
never executed: return 0 ;
0
1078 ;
never executed: return 0 ;
0
1079 }-
1080 if (bytes_read == 0
bytes_read == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • head
FALSEevaluated 1569 times by 1 test
Evaluated by:
  • head
)
8-1569
1081 break;
executed 8 times by 1 test: break;
Executed by:
  • head
8
1082 xwrite_stdout (buffer, bytes_read);-
1083 bytes_to_write -= bytes_read;-
1084 }
executed 1569 times by 1 test: end of block
Executed by:
  • head
1569
1085 return
executed 148 times by 1 test: return 1 ;
Executed by:
  • head
executed 148 times by 1 test: return 1 ;
Executed by:
  • head
148
1086 1
executed 148 times by 1 test: return 1 ;
Executed by:
  • head
148
1087 ;
executed 148 times by 1 test: return 1 ;
Executed by:
  • head
148
1088}-
1089-
1090static -
1091 _Bool-
1092-
1093head_lines (const char *filename, int fd, uintmax_t lines_to_write)-
1094{-
1095 char buffer[-
1096 8192-
1097 ];-
1098-
1099 while (lines_to_write
lines_to_writeDescription
TRUEevaluated 1225 times by 1 test
Evaluated by:
  • head
FALSEevaluated 502 times by 1 test
Evaluated by:
  • head
)
502-1225
1100 {-
1101 size_t bytes_read = safe_read (fd, buffer, -
1102 8192-
1103 );-
1104 size_t bytes_to_write = 0;-
1105-
1106 if (bytes_read == ((size_t) -1)
bytes_read == ((size_t) -1)Description
TRUEnever evaluated
FALSEevaluated 1225 times by 1 test
Evaluated by:
  • head
)
0-1225
1107 {-
1108 error (0, -
1109 (*__errno_location ())-
1110 , -
1111 dcgettext (((void *)0), -
1112 "error reading %s"-
1113 , 5)-
1114 , quotearg_style (shell_escape_always_quoting_style, filename));-
1115 return
never executed: return 0 ;
never executed: return 0 ;
0
1116 0
never executed: return 0 ;
0
1117 ;
never executed: return 0 ;
0
1118 }-
1119 if (bytes_read == 0
bytes_read == 0Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • head
FALSEevaluated 1199 times by 1 test
Evaluated by:
  • head
)
26-1199
1120 break;
executed 26 times by 1 test: break;
Executed by:
  • head
26
1121 while (bytes_to_write < bytes_read
bytes_to_write < bytes_readDescription
TRUEevaluated 5611464 times by 1 test
Evaluated by:
  • head
FALSEevaluated 697 times by 1 test
Evaluated by:
  • head
)
697-5611464
1122 if (buffer[bytes_to_write++] == line_end
buffer[bytes_t...+] == line_endDescription
TRUEevaluated 2709035 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2902429 times by 1 test
Evaluated by:
  • head
&& --
--lines_to_write == 0Description
TRUEevaluated 502 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2708533 times by 1 test
Evaluated by:
  • head
lines_to_write == 0
--lines_to_write == 0Description
TRUEevaluated 502 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2708533 times by 1 test
Evaluated by:
  • head
)
502-2902429
1123 {-
1124 off_t n_bytes_past_EOL = bytes_read - bytes_to_write;-
1125-
1126-
1127-
1128 if (lseek (fd, -n_bytes_past_EOL,
lseek (fd, -n_...t_EOL, 1 ) < 0Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • head
FALSEevaluated 458 times by 1 test
Evaluated by:
  • head
44-458
1129 1
lseek (fd, -n_...t_EOL, 1 ) < 0Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • head
FALSEevaluated 458 times by 1 test
Evaluated by:
  • head
44-458
1130 ) < 0
lseek (fd, -n_...t_EOL, 1 ) < 0Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • head
FALSEevaluated 458 times by 1 test
Evaluated by:
  • head
)
44-458
1131 {-
1132 struct stat st;-
1133 if (fstat (fd, &st) != 0
fstat (fd, &st) != 0Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • head
||
0-44
1134 ((((
(((( st.st_mod... == (0100000))Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • head
0-44
1135 st.st_mode
(((( st.st_mod... == (0100000))Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • head
0-44
1136 )) & 0170000) == (0100000))
(((( st.st_mod... == (0100000))Description
TRUEnever evaluated
FALSEevaluated 44 times by 1 test
Evaluated by:
  • head
0-44
1137 )-
1138 elseek (fd, -n_bytes_past_EOL,
never executed: elseek (fd, -n_bytes_past_EOL, 1 , filename);
0
1139 1
never executed: elseek (fd, -n_bytes_past_EOL, 1 , filename);
0
1140 , filename);
never executed: elseek (fd, -n_bytes_past_EOL, 1 , filename);
0
1141 }
executed 44 times by 1 test: end of block
Executed by:
  • head
44
1142 break;
executed 502 times by 1 test: break;
Executed by:
  • head
502
1143 }-
1144 xwrite_stdout (buffer, bytes_to_write);-
1145 }
executed 1199 times by 1 test: end of block
Executed by:
  • head
1199
1146 return
executed 528 times by 1 test: return 1 ;
Executed by:
  • head
executed 528 times by 1 test: return 1 ;
Executed by:
  • head
528
1147 1
executed 528 times by 1 test: return 1 ;
Executed by:
  • head
528
1148 ;
executed 528 times by 1 test: return 1 ;
Executed by:
  • head
528
1149}-
1150-
1151static -
1152 _Bool-
1153-
1154head (const char *filename, int fd, uintmax_t n_units, -
1155 _Bool -
1156 count_lines,-
1157 -
1158 _Bool -
1159 elide_from_end)-
1160{-
1161 if (print_headers
print_headersDescription
TRUEnever evaluated
FALSEevaluated 2616 times by 1 test
Evaluated by:
  • head
)
0-2616
1162 write_header (filename);
never executed: write_header (filename);
0
1163-
1164 if (elide_from_end
elide_from_endDescription
TRUEevaluated 1940 times by 1 test
Evaluated by:
  • head
FALSEevaluated 676 times by 1 test
Evaluated by:
  • head
)
676-1940
1165 {-
1166 off_t current_pos = -1;-
1167 struct stat st;-
1168 if (fstat (fd, &st) != 0
fstat (fd, &st) != 0Description
TRUEnever evaluated
FALSEevaluated 1940 times by 1 test
Evaluated by:
  • head
)
0-1940
1169 {-
1170 error (0, -
1171 (*__errno_location ())-
1172 , -
1173 dcgettext (((void *)0), -
1174 "cannot fstat %s"-
1175 , 5)-
1176 ,-
1177 quotearg_style (shell_escape_always_quoting_style, filename));-
1178 return
never executed: return 0 ;
never executed: return 0 ;
0
1179 0
never executed: return 0 ;
0
1180 ;
never executed: return 0 ;
0
1181 }-
1182 if (! presume_input_pipe
! presume_input_pipeDescription
TRUEevaluated 1015 times by 1 test
Evaluated by:
  • head
FALSEevaluated 925 times by 1 test
Evaluated by:
  • head
&& usable_st_size (&st)
usable_st_size (&st)Description
TRUEevaluated 1008 times by 1 test
Evaluated by:
  • head
FALSEevaluated 7 times by 1 test
Evaluated by:
  • head
)
7-1015
1183 {-
1184 current_pos = elseek (fd, 0, -
1185 1-
1186 , filename);-
1187 if (current_pos < 0
current_pos < 0Description
TRUEnever evaluated
FALSEevaluated 1008 times by 1 test
Evaluated by:
  • head
)
0-1008
1188 return
never executed: return 0 ;
never executed: return 0 ;
0
1189 0
never executed: return 0 ;
0
1190 ;
never executed: return 0 ;
0
1191 }
executed 1008 times by 1 test: end of block
Executed by:
  • head
1008
1192 if (count_lines
count_linesDescription
TRUEevaluated 981 times by 1 test
Evaluated by:
  • head
FALSEevaluated 959 times by 1 test
Evaluated by:
  • head
)
959-981
1193 return
executed 981 times by 1 test: return elide_tail_lines_file (filename, fd, n_units, &st, current_pos);
Executed by:
  • head
elide_tail_lines_file (filename, fd, n_units, &st, current_pos);
executed 981 times by 1 test: return elide_tail_lines_file (filename, fd, n_units, &st, current_pos);
Executed by:
  • head
981
1194 else-
1195 return
executed 959 times by 1 test: return elide_tail_bytes_file (filename, fd, n_units, &st, current_pos);
Executed by:
  • head
elide_tail_bytes_file (filename, fd, n_units, &st, current_pos);
executed 959 times by 1 test: return elide_tail_bytes_file (filename, fd, n_units, &st, current_pos);
Executed by:
  • head
959
1196 }-
1197 if (count_lines
count_linesDescription
TRUEevaluated 528 times by 1 test
Evaluated by:
  • head
FALSEevaluated 148 times by 1 test
Evaluated by:
  • head
)
148-528
1198 return
executed 528 times by 1 test: return head_lines (filename, fd, n_units);
Executed by:
  • head
head_lines (filename, fd, n_units);
executed 528 times by 1 test: return head_lines (filename, fd, n_units);
Executed by:
  • head
528
1199 else-
1200 return
executed 148 times by 1 test: return head_bytes (filename, fd, n_units);
Executed by:
  • head
head_bytes (filename, fd, n_units);
executed 148 times by 1 test: return head_bytes (filename, fd, n_units);
Executed by:
  • head
148
1201}-
1202-
1203static -
1204 _Bool-
1205-
1206head_file (const char *filename, uintmax_t n_units, -
1207 _Bool -
1208 count_lines,-
1209 -
1210 _Bool -
1211 elide_from_end)-
1212{-
1213 int fd;-
1214 -
1215 _Bool -
1216 ok;-
1217 -
1218 _Bool -
1219 is_stdin = (-
1220 __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (-
1221 filename-
1222 ) && __builtin_constant_p (-
1223 "-"-
1224 ) && (__s1_len = __builtin_strlen (-
1225 filename-
1226 ), __s2_len = __builtin_strlen (-
1227 "-"-
1228 ), (!((size_t)(const void *)((-
1229 filename-
1230 ) + 1) - (size_t)(const void *)(-
1231 filename-
1232 ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((-
1233 "-"-
1234 ) + 1) - (size_t)(const void *)(-
1235 "-"-
1236 ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (-
1237 filename-
1238 , -
1239 "-"-
1240 ) : (__builtin_constant_p (-
1241 filename-
1242 ) && ((size_t)(const void *)((-
1243 filename-
1244 ) + 1) - (size_t)(const void *)(-
1245 filename-
1246 ) == 1) && (__s1_len = __builtin_strlen (-
1247 filename-
1248 ), __s1_len < 4) ? (__builtin_constant_p (-
1249 "-"-
1250 ) && ((size_t)(const void *)((-
1251 "-"-
1252 ) + 1) - (size_t)(const void *)(-
1253 "-"-
1254 ) == 1) ? __builtin_strcmp (-
1255 filename-
1256 , -
1257 "-"-
1258 ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (-
1259 "-"-
1260 ); int __result = (((const unsigned char *) (const char *) (-
1261 filename-
1262 ))[0] - __s2[0]); if (__s1_len > 0
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) { __result = (((const unsigned char *) (const char *) (
0
1263 filename-
1264 ))[1] - __s2[1]); if (__s1_len > 1
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) { __result = (((const unsigned char *) (const char *) (
0
1265 filename-
1266 ))[2] - __s2[2]); if (__s1_len > 2
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) __result = (((const unsigned char *) (const char *) (
never executed: __result = (((const unsigned char *) (const char *) ( filename ))[3] - __s2[3]);
0
1267 filename
never executed: __result = (((const unsigned char *) (const char *) ( filename ))[3] - __s2[3]);
0
1268 ))[3] - __s2[3]);
never executed: __result = (((const unsigned char *) (const char *) ( filename ))[3] - __s2[3]);
}
never executed: end of block
}
never executed: end of block
__result; }))) : (__builtin_constant_p (
0
1269 "-"-
1270 ) && ((size_t)(const void *)((-
1271 "-"-
1272 ) + 1) - (size_t)(const void *)(-
1273 "-"-
1274 ) == 1) && (__s2_len = __builtin_strlen (-
1275 "-"-
1276 ), __s2_len < 4) ? (__builtin_constant_p (-
1277 filename-
1278 ) && ((size_t)(const void *)((-
1279 filename-
1280 ) + 1) - (size_t)(const void *)(-
1281 filename-
1282 ) == 1) ? __builtin_strcmp (-
1283 filename-
1284 , -
1285 "-"-
1286 ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (-
1287 filename-
1288 ); int __result = (((const unsigned char *) (const char *) (-
1289 "-"-
1290 ))[0] - __s2[0]); if (__s2_len > 0
__s2_len > 0Description
TRUEevaluated 2616 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEevaluated 276 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2340 times by 1 test
Evaluated by:
  • head
) { __result = (((const unsigned char *) (const char *) (
0-2616
1291 "-"-
1292 ))[1] - __s2[1]); if (__s2_len > 1
__s2_len > 1Description
TRUEnever evaluated
FALSEevaluated 276 times by 1 test
Evaluated by:
  • head
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) { __result = (((const unsigned char *) (const char *) (
0-276
1293 "-"-
1294 ))[2] - __s2[2]); if (__s2_len > 2
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) __result = (((const unsigned char *) (const char *) (
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]);
0
1295 "-"
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]);
0
1296 ))[3] - __s2[3]);
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]);
}
never executed: end of block
}
executed 276 times by 1 test: end of block
Executed by:
  • head
__result; }))) : __builtin_strcmp (
0-276
1297 filename-
1298 , -
1299 "-"-
1300 )))); }) -
1301 == 0);-
1302-
1303 if (is_stdin
is_stdinDescription
TRUEevaluated 276 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2340 times by 1 test
Evaluated by:
  • head
)
276-2340
1304 {-
1305 have_read_stdin = -
1306 1-
1307 ;-
1308 fd = -
1309 0-
1310 ;-
1311 filename = -
1312 dcgettext (((void *)0), -
1313 "standard input"-
1314 , 5)-
1315 ;-
1316 xset_binary_mode (-
1317 0-
1318 , -
1319 0-
1320 );-
1321 }
executed 276 times by 1 test: end of block
Executed by:
  • head
276
1322 else-
1323 {-
1324 fd = open (filename, -
1325 00 -
1326 | -
1327 0-
1328 );-
1329 if (fd < 0
fd < 0Description
TRUEnever evaluated
FALSEevaluated 2340 times by 1 test
Evaluated by:
  • head
)
0-2340
1330 {-
1331 error (0, -
1332 (*__errno_location ())-
1333 , -
1334 dcgettext (((void *)0), -
1335 "cannot open %s for reading"-
1336 , 5)-
1337 , quotearg_style (shell_escape_always_quoting_style, filename));-
1338 return
never executed: return 0 ;
never executed: return 0 ;
0
1339 0
never executed: return 0 ;
0
1340 ;
never executed: return 0 ;
0
1341 }-
1342 }
executed 2340 times by 1 test: end of block
Executed by:
  • head
2340
1343-
1344 ok = head (filename, fd, n_units, count_lines, elide_from_end);-
1345 if (!is_stdin
!is_stdinDescription
TRUEevaluated 2336 times by 1 test
Evaluated by:
  • head
FALSEevaluated 272 times by 1 test
Evaluated by:
  • head
&& close (fd) != 0
close (fd) != 0Description
TRUEnever evaluated
FALSEevaluated 2336 times by 1 test
Evaluated by:
  • head
)
0-2336
1346 {-
1347 error (0, -
1348 (*__errno_location ())-
1349 , -
1350 dcgettext (((void *)0), -
1351 "failed to close %s"-
1352 , 5)-
1353 , quotearg_style (shell_escape_always_quoting_style, filename));-
1354 return
never executed: return 0 ;
never executed: return 0 ;
0
1355 0
never executed: return 0 ;
0
1356 ;
never executed: return 0 ;
0
1357 }-
1358 return
executed 2608 times by 1 test: return ok;
Executed by:
  • head
ok;
executed 2608 times by 1 test: return ok;
Executed by:
  • head
2608
1359}-
1360-
1361-
1362-
1363-
1364-
1365-
1366-
1367static uintmax_t-
1368string_to_integer (-
1369 _Bool -
1370 count_lines, const char *n_string)-
1371{-
1372 return
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
xdectoumax (n_string, 0,
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1373 (18446744073709551615UL)
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1374 , "bkKmMGTPEZY0",
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1375 count_lines ?
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1376 dcgettext (((void *)0),
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1377 "invalid number of lines"
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1378 , 5)
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1379
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1380 :
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1381 dcgettext (((void *)0),
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1382 "invalid number of bytes"
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1383 , 5)
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1384 , 0);
executed 2594 times by 1 test: return xdectoumax (n_string, 0, (18446744073709551615UL) , "bkKmMGTPEZY0", count_lines ? dcgettext (((void *)0), "invalid number of lines" , 5) : dcgettext (((void *)0), "invalid number of bytes" , 5) , 0);
Executed by:
  • head
2594
1385}-
1386-
1387int-
1388main (int argc, char **argv)-
1389{-
1390 enum header_mode header_mode = multiple_files;-
1391 -
1392 _Bool -
1393 ok = -
1394 1-
1395 ;-
1396 int c;-
1397 size_t i;-
1398-
1399-
1400 uintmax_t n_units = 10;-
1401-
1402-
1403-
1404 -
1405 _Bool -
1406 count_lines = -
1407 1-
1408 ;-
1409-
1410-
1411-
1412 -
1413 _Bool -
1414 elide_from_end = -
1415 0-
1416 ;-
1417-
1418-
1419-
1420 static char const *const default_file_list[] = {"-", -
1421 ((void *)0)-
1422 };-
1423 char const *const *file_list;-
1424-
1425 ;-
1426 set_program_name (argv[0]);-
1427 setlocale (-
1428 6-
1429 , "");-
1430 bindtextdomain ("coreutils", "/usr/local/share/locale");-
1431 textdomain ("coreutils");-
1432-
1433 atexit (close_stdout);-
1434-
1435 have_read_stdin = -
1436 0-
1437 ;-
1438-
1439 print_headers = -
1440 0-
1441 ;-
1442-
1443 line_end = '\n';-
1444-
1445 if (1 < argc
1 < argcDescription
TRUEevaluated 2623 times by 1 test
Evaluated by:
  • head
FALSEevaluated 18 times by 1 test
Evaluated by:
  • head
&& argv[1][0] == '-'
argv[1][0] == '-'Description
TRUEevaluated 2615 times by 1 test
Evaluated by:
  • head
FALSEevaluated 8 times by 1 test
Evaluated by:
  • head
&& ((
((unsigned int...]) - '0' <= 9)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2591 times by 1 test
Evaluated by:
  • head
unsigned int) (argv[1][1]) - '0' <= 9)
((unsigned int...]) - '0' <= 9)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2591 times by 1 test
Evaluated by:
  • head
)
8-2623
1446 {-
1447 char *a = argv[1];-
1448 char *n_string = ++a;-
1449 char *end_n_string;-
1450 char multiplier_char = 0;-
1451-
1452-
1453-
1454 do ++
executed 36 times by 1 test: ++a;
Executed by:
  • head
a;
executed 36 times by 1 test: ++a;
Executed by:
  • head
36
1455 while (((
((unsigned int...a) - '0' <= 9)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • head
FALSEevaluated 24 times by 1 test
Evaluated by:
  • head
unsigned int) (*a) - '0' <= 9)
((unsigned int...a) - '0' <= 9)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • head
FALSEevaluated 24 times by 1 test
Evaluated by:
  • head
);
12-24
1456-
1457-
1458 end_n_string = a;-
1459-
1460-
1461 for (; *
*aDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • head
FALSEevaluated 24 times by 1 test
Evaluated by:
  • head
a
*aDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • head
FALSEevaluated 24 times by 1 test
Evaluated by:
  • head
; a++)
15-24
1462 {-
1463 switch (*a)-
1464 {-
1465 case
executed 9 times by 1 test: case 'c':
Executed by:
  • head
'c':
executed 9 times by 1 test: case 'c':
Executed by:
  • head
9
1466 count_lines = -
1467 0-
1468 ;-
1469 multiplier_char = 0;-
1470 break;
executed 9 times by 1 test: break;
Executed by:
  • head
9
1471-
1472 case
executed 3 times by 1 test: case 'b':
Executed by:
  • head
'b':
executed 3 times by 1 test: case 'b':
Executed by:
  • head
3
1473 case
executed 3 times by 1 test: case 'k':
Executed by:
  • head
'k':
executed 3 times by 1 test: case 'k':
Executed by:
  • head
3
1474 case
never executed: case 'm':
'm':
never executed: case 'm':
0
1475 count_lines = -
1476 0-
1477 ;-
1478 multiplier_char = *a;-
1479 break;
executed 6 times by 1 test: break;
Executed by:
  • head
6
1480-
1481 case
never executed: case 'l':
'l':
never executed: case 'l':
0
1482 count_lines = -
1483 1-
1484 ;-
1485 break;
never executed: break;
0
1486-
1487 case
never executed: case 'q':
'q':
never executed: case 'q':
0
1488 header_mode = never;-
1489 break;
never executed: break;
0
1490-
1491 case
never executed: case 'v':
'v':
never executed: case 'v':
0
1492 header_mode = always;-
1493 break;
never executed: break;
0
1494-
1495 case
never executed: case 'z':
'z':
never executed: case 'z':
0
1496 line_end = '\0';-
1497 break;
never executed: break;
0
1498-
1499 default
never executed: default:
:
never executed: default:
0
1500 error (0, 0, -
1501 dcgettext (((void *)0), -
1502 "invalid trailing option -- %c"-
1503 , 5)-
1504 , *a);-
1505 usage (-
1506 1-
1507 );-
1508 }
never executed: end of block
0
1509 }-
1510-
1511-
1512-
1513 *end_n_string = multiplier_char;-
1514 if (multiplier_char
multiplier_charDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • head
FALSEevaluated 18 times by 1 test
Evaluated by:
  • head
)
6-18
1515 *(++
executed 6 times by 1 test: *(++end_n_string) = 0;
Executed by:
  • head
end_n_string) = 0;
executed 6 times by 1 test: *(++end_n_string) = 0;
Executed by:
  • head
6
1516-
1517 n_units = string_to_integer (count_lines, n_string);-
1518-
1519-
1520 argv[1] = argv[0];-
1521 argv++;-
1522 argc--;-
1523 }
executed 24 times by 1 test: end of block
Executed by:
  • head
24
1524-
1525 while ((
(c = getopt_lo... *)0) )) != -1Description
TRUEevaluated 3529 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2616 times by 1 test
Evaluated by:
  • head
c = getopt_long (argc, argv, "c:n:qvz0123456789", long_options,
(c = getopt_lo... *)0) )) != -1Description
TRUEevaluated 3529 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2616 times by 1 test
Evaluated by:
  • head
2616-3529
1526 ((void *)0)
(c = getopt_lo... *)0) )) != -1Description
TRUEevaluated 3529 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2616 times by 1 test
Evaluated by:
  • head
2616-3529
1527 ))
(c = getopt_lo... *)0) )) != -1Description
TRUEevaluated 3529 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2616 times by 1 test
Evaluated by:
  • head
2616-3529
1528 != -1
(c = getopt_lo... *)0) )) != -1Description
TRUEevaluated 3529 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2616 times by 1 test
Evaluated by:
  • head
)
2616-3529
1529 {-
1530 switch (c)-
1531 {-
1532 case
executed 925 times by 1 test: case PRESUME_INPUT_PIPE_OPTION:
Executed by:
  • head
PRESUME_INPUT_PIPE_OPTION:
executed 925 times by 1 test: case PRESUME_INPUT_PIPE_OPTION:
Executed by:
  • head
925
1533 presume_input_pipe = -
1534 1-
1535 ;-
1536 break;
executed 925 times by 1 test: break;
Executed by:
  • head
925
1537-
1538 case
executed 1094 times by 1 test: case 'c':
Executed by:
  • head
'c':
executed 1094 times by 1 test: case 'c':
Executed by:
  • head
1094
1539 count_lines = -
1540 0-
1541 ;-
1542 elide_from_end = (*optarg == '-');-
1543 if (elide_from_end
elide_from_endDescription
TRUEevaluated 961 times by 1 test
Evaluated by:
  • head
FALSEevaluated 133 times by 1 test
Evaluated by:
  • head
)
133-961
1544 ++
executed 961 times by 1 test: ++optarg;
Executed by:
  • head
optarg;
executed 961 times by 1 test: ++optarg;
Executed by:
  • head
961
1545 n_units = string_to_integer (count_lines, optarg);-
1546 break;
executed 1092 times by 1 test: break;
Executed by:
  • head
1092
1547-
1548 case
executed 1476 times by 1 test: case 'n':
Executed by:
  • head
'n':
executed 1476 times by 1 test: case 'n':
Executed by:
  • head
1476
1549 count_lines = -
1550 1-
1551 ;-
1552 elide_from_end = (*optarg == '-');-
1553 if (elide_from_end
elide_from_endDescription
TRUEevaluated 983 times by 1 test
Evaluated by:
  • head
FALSEevaluated 493 times by 1 test
Evaluated by:
  • head
)
493-983
1554 ++
executed 983 times by 1 test: ++optarg;
Executed by:
  • head
optarg;
executed 983 times by 1 test: ++optarg;
Executed by:
  • head
983
1555 n_units = string_to_integer (count_lines, optarg);-
1556 break;
executed 1474 times by 1 test: break;
Executed by:
  • head
1474
1557-
1558 case
executed 3 times by 1 test: case 'q':
Executed by:
  • head
'q':
executed 3 times by 1 test: case 'q':
Executed by:
  • head
3
1559 header_mode = never;-
1560 break;
executed 3 times by 1 test: break;
Executed by:
  • head
3
1561-
1562 case
executed 2 times by 1 test: case 'v':
Executed by:
  • head
'v':
executed 2 times by 1 test: case 'v':
Executed by:
  • head
2
1563 header_mode = always;-
1564 break;
executed 2 times by 1 test: break;
Executed by:
  • head
2
1565-
1566 case
executed 8 times by 1 test: case 'z':
Executed by:
  • head
'z':
executed 8 times by 1 test: case 'z':
Executed by:
  • head
8
1567 line_end = '\0';-
1568 break;
executed 8 times by 1 test: break;
Executed by:
  • head
8
1569-
1570 case
executed 10 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • head
GETOPT_HELP_CHAR:
executed 10 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • head
usage (
10
1571 0-
1572 ); break;
never executed: break;
;
0
1573-
1574 case
executed 8 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • head
GETOPT_VERSION_CHAR:
executed 8 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • head
version_etc (
8
1575 stdout-
1576 , "head", "GNU coreutils", Version, ("David MacKenzie"), ("Jim Meyering"), (char *) -
1577 ((void *)0)-
1578 ); exit (
executed 8 times by 1 test: exit ( 0 );
Executed by:
  • head
8
1579 0
executed 8 times by 1 test: exit ( 0 );
Executed by:
  • head
8
1580 );
executed 8 times by 1 test: exit ( 0 );
Executed by:
  • head
break;
never executed: break;
;
0-8
1581-
1582 default
executed 3 times by 1 test: default:
Executed by:
  • head
:
executed 3 times by 1 test: default:
Executed by:
  • head
3
1583 if (((
((unsigned int...c) - '0' <= 9)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
unsigned int) (c) - '0' <= 9)
((unsigned int...c) - '0' <= 9)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • head
)
0-3
1584 error (0, 0,
never executed: error (0, 0, dcgettext (((void *)0), "invalid trailing option -- %c" , 5) , c);
0
1585 dcgettext (((void *)0),
never executed: error (0, 0, dcgettext (((void *)0), "invalid trailing option -- %c" , 5) , c);
0
1586 "invalid trailing option -- %c"
never executed: error (0, 0, dcgettext (((void *)0), "invalid trailing option -- %c" , 5) , c);
0
1587 , 5)
never executed: error (0, 0, dcgettext (((void *)0), "invalid trailing option -- %c" , 5) , c);
0
1588 , c);
never executed: error (0, 0, dcgettext (((void *)0), "invalid trailing option -- %c" , 5) , c);
0
1589 usage (-
1590 1-
1591 );-
1592 }
never executed: end of block
0
1593 }-
1594-
1595 if (header_mode == always
header_mode == alwaysDescription
TRUEnever evaluated
FALSEevaluated 2616 times by 1 test
Evaluated by:
  • head
0-2616
1596 || (header_mode == multiple_files
header_mode == multiple_filesDescription
TRUEevaluated 2616 times by 1 test
Evaluated by:
  • head
FALSEnever evaluated
&& optind < argc - 1
optind < argc - 1Description
TRUEnever evaluated
FALSEevaluated 2616 times by 1 test
Evaluated by:
  • head
))
0-2616
1597 print_headers =
never executed: print_headers = 1 ;
0
1598 1
never executed: print_headers = 1 ;
0
1599 ;
never executed: print_headers = 1 ;
0
1600-
1601 if ( ! count_lines
! count_linesDescription
TRUEevaluated 1107 times by 1 test
Evaluated by:
  • head
FALSEevaluated 1509 times by 1 test
Evaluated by:
  • head
&& elide_from_end
elide_from_endDescription
TRUEevaluated 959 times by 1 test
Evaluated by:
  • head
FALSEevaluated 148 times by 1 test
Evaluated by:
  • head
&& ((
((off_t) (! (!...1))) < n_unitsDescription
TRUEnever evaluated
FALSEevaluated 959 times by 1 test
Evaluated by:
  • head
off_t) (! (! ((off_t) 0 < (off_t) -1)) ? (off_t) -1 : ((((off_t) 1 << ((sizeof (off_t) * 8) - 2)) - 1) * 2 + 1))) < n_units
((off_t) (! (!...1))) < n_unitsDescription
TRUEnever evaluated
FALSEevaluated 959 times by 1 test
Evaluated by:
  • head
)
0-1509
1602 {-
1603 char umax_buf[((((((sizeof (n_units) * 8) - (! ((__typeof__ (n_units)) 0 < (__typeof__ (n_units)) -1))) * 146 + 484) / 485) + (! ((__typeof__ (n_units)) 0 < (__typeof__ (n_units)) -1))) + 1)];-
1604 ((!!sizeof (struct { _Static_assert (-
1605 1-
1606 , "verify_expr (" "1" ", " "(error (1, 75, \"%s: %s\", dcgettext (((void *)0), \"invalid number of bytes\", 5), quote (umaxtostr (n_units, umax_buf))), assume (false))" ")"); int _gl_dummy; })) ? ((error (-
1607 1-
1608 , -
1609 75-
1610 , "%s: %s", -
1611 dcgettext (((void *)0), -
1612 "invalid number of bytes"-
1613 , 5)-
1614 , quote (umaxtostr (n_units, umax_buf))), ((-
1615 0-
1616 ) ? (void) 0 : __builtin_unreachable ()))) : ((error (-
1617 1-
1618 , -
1619 75-
1620 , "%s: %s", -
1621 dcgettext (((void *)0), -
1622 "invalid number of bytes"-
1623 , 5)-
1624 , quote (umaxtostr (n_units, umax_buf))), ((-
1625 0-
1626 ) ? (void) 0 : __builtin_unreachable ()))))-
1627 ;-
1628 }
never executed: end of block
0
1629-
1630 file_list = (optind < argc
optind < argcDescription
TRUEevaluated 2340 times by 1 test
Evaluated by:
  • head
FALSEevaluated 276 times by 1 test
Evaluated by:
  • head
276-2340
1631 ? (char const *const *) &argv[optind]-
1632 : default_file_list);-
1633-
1634 xset_binary_mode (-
1635 1-
1636 , -
1637 0-
1638 );-
1639-
1640 for (i = 0; file_list[i]
file_list[i]Description
TRUEevaluated 2616 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2608 times by 1 test
Evaluated by:
  • head
; ++i)
2608-2616
1641 ok &= head_file (file_list[i], n_units, count_lines, elide_from_end);
executed 2616 times by 1 test: ok &= head_file (file_list[i], n_units, count_lines, elide_from_end);
Executed by:
  • head
2616
1642-
1643 if (have_read_stdin
have_read_stdinDescription
TRUEevaluated 272 times by 1 test
Evaluated by:
  • head
FALSEevaluated 2336 times by 1 test
Evaluated by:
  • head
&& close (
close ( 0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 272 times by 1 test
Evaluated by:
  • head
0-2336
1644 0
close ( 0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 272 times by 1 test
Evaluated by:
  • head
0-272
1645 ) < 0
close ( 0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 272 times by 1 test
Evaluated by:
  • head
)
0-272
1646 ((
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
!!sizeof (struct { _Static_assert (
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1647 1
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1648 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error (
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1649 1
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1650 ,
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1651 (*__errno_location ())
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1652 , "-"), ((
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1653 0
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1654 ) ? (void) 0 : __builtin_unreachable ()))) : ((error (
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1655 1
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1656 ,
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1657 (*__errno_location ())
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1658 , "-"), ((
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1659 0
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1660 ) ? (void) 0 : __builtin_unreachable ()))));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"-\"), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "-"), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
1661-
1662 return
executed 2608 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • head
ok ?
executed 2608 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • head
2608
1663 0
executed 2608 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • head
2608
1664 :
executed 2608 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • head
2608
1665 1
executed 2608 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • head
2608
1666 ;
executed 2608 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • head
2608
1667}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2