| 693 | } |
| 694 | |
| 695 | static bool |
| 696 | wc_file (char const *file, struct fstatus *fstatus) |
| 697 | { |
| 698 | if (! file || streq (file, "-")) |
| 699 | { |
| 700 | have_read_stdin = true; |
| 701 | xset_binary_mode (STDIN_FILENO, O_BINARY); |
| 702 | return wc (STDIN_FILENO, file, fstatus); |
| 703 | } |
| 704 | else |
| 705 | { |
| 706 | int fd = open (file, O_RDONLY | O_BINARY); |
| 707 | if (fd == -1) |
| 708 | { |
| 709 | error (0, errno, "%s", quotef (file)); |
| 710 | return false; |
| 711 | } |
| 712 | else |
| 713 | { |
| 714 | bool ok = wc (fd, file, fstatus); |
| 715 | if (close (fd) != 0) |
| 716 | { |
| 717 | error (0, errno, "%s", quotef (file)); |
| 718 | return false; |
| 719 | } |
| 720 | return ok; |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | /* Return the file status for the NFILES files addressed by FILE. |
| 726 | Optimize the case where only one number is printed, for just one |