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

Function wc_file

src/wc.c:695–723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695static bool
696wc_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

Callers 1

mainFunction · 0.85

Calls 1

wcFunction · 0.85

Tested by

no test coverage detected