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

Function nl_file

src/nl.c:457–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455 Return true if successful. */
456
457static bool
458nl_file (char const *file)
459{
460 FILE *stream;
461
462 if (streq (file, "-"))
463 {
464 have_read_stdin = true;
465 stream = stdin;
466 assume (stream); /* Pacify GCC bug#109613. */
467 }
468 else
469 {
470 stream = fopen (file, "r");
471 if (stream == NULL)
472 {
473 error (0, errno, "%s", quotef (file));
474 return false;
475 }
476 }
477
478 fadvise (stream, FADVISE_SEQUENTIAL);
479
480 process_file (stream);
481
482 int err = errno;
483 if (!ferror (stream))
484 err = 0;
485 if (streq (file, "-"))
486 clearerr (stream); /* Also clear EOF. */
487 else if (fclose (stream) != 0 && !err)
488 err = errno;
489 if (err)
490 {
491 error (0, err, "%s", quotef (file));
492 return false;
493 }
494 return true;
495}
496
497int
498main (int argc, char **argv)

Callers 1

mainFunction · 0.85

Calls 2

fadviseFunction · 0.85
process_fileFunction · 0.70

Tested by

no test coverage detected