MCPcopy Create free account
hub / github.com/coreutils/coreutils / write_counts

Function write_counts

src/wc.c:260–301  ·  view source on GitHub ↗

FILE is the name of the file (or null for standard input) associated with the specified counters. */

Source from the content-addressed store, hash-verified

258/* FILE is the name of the file (or null for standard input)
259 associated with the specified counters. */
260static void
261write_counts (uintmax_t lines,
262 uintmax_t words,
263 uintmax_t chars,
264 uintmax_t bytes,
265 intmax_t linelength,
266 char const *file)
267{
268 static char const format_sp_int[] = " %*s";
269 char const *format_int = format_sp_int + 1;
270 char buf[MAX (INT_BUFSIZE_BOUND (intmax_t),
271 INT_BUFSIZE_BOUND (uintmax_t))];
272
273 if (print_lines)
274 {
275 printf (format_int, number_width, umaxtostr (lines, buf));
276 format_int = format_sp_int;
277 }
278 if (print_words)
279 {
280 printf (format_int, number_width, umaxtostr (words, buf));
281 format_int = format_sp_int;
282 }
283 if (print_chars)
284 {
285 printf (format_int, number_width, umaxtostr (chars, buf));
286 format_int = format_sp_int;
287 }
288 if (print_bytes)
289 {
290 printf (format_int, number_width, umaxtostr (bytes, buf));
291 format_int = format_sp_int;
292 }
293 if (print_linelength)
294 printf (format_int, number_width, imaxtostr (linelength, buf));
295 if (file)
296 printf (" %s", strchr (file, '\n') ? quotef (file) : file);
297 putchar ('\n');
298
299 if (ferror (stdout))
300 write_error ();
301}
302
303/* Read FD and return a summary. */
304static struct wc_lines

Callers 2

wcFunction · 0.85
mainFunction · 0.85

Calls 1

write_errorFunction · 0.85

Tested by

no test coverage detected