| 455 | Return true if successful. */ |
| 456 | |
| 457 | static bool |
| 458 | nl_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 | |
| 497 | int |
| 498 | main (int argc, char **argv) |
no test coverage detected