mirror of
https://github.com/openbsd/src.git
synced 2024-12-21 23:18:00 -08:00
fstat(2) can't return an S_IFLNK, so delete that test.
Also, switch to S_IS*() tests and update the manpage to reflect that POSIX-2024 has no substantive changes for wc(1) ok op@ millert@
This commit is contained in:
parent
4c8569653c
commit
e291b8af02
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: wc.1,v 1.27 2016/10/24 13:46:58 schwarze Exp $
|
||||
.\" $OpenBSD: wc.1,v 1.28 2024/09/11 03:57:14 guenther Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
.\"
|
||||
.\" from: @(#)wc.1 8.2 (Berkeley) 4/19/94
|
||||
.\"
|
||||
.Dd $Mdocdate: October 24 2016 $
|
||||
.Dd $Mdocdate: September 11 2024 $
|
||||
.Dt WC 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -125,7 +125,7 @@ has the same effect as
|
||||
The
|
||||
.Nm
|
||||
utility is compliant with the
|
||||
.St -p1003.1-2008
|
||||
.St -p1003.1-2024
|
||||
specification.
|
||||
.Pp
|
||||
The flag
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: wc.c,v 1.31 2022/12/04 23:50:50 cheloha Exp $ */
|
||||
/* $OpenBSD: wc.c,v 1.32 2024/09/11 03:57:14 guenther Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1987, 1991, 1993
|
||||
@ -193,23 +193,19 @@ cnt(const char *path)
|
||||
}
|
||||
/*
|
||||
* If all we need is the number of characters and
|
||||
* it's a directory or a regular or linked file, just
|
||||
* stat the puppy. We avoid testing for it not being
|
||||
* it's a directory or a regular file, just stat
|
||||
* our handle. We avoid testing for it not being
|
||||
* a special device in case someone adds a new type
|
||||
* of inode.
|
||||
*/
|
||||
else if (dochar) {
|
||||
mode_t ifmt;
|
||||
|
||||
if (fstat(fd, &sbuf)) {
|
||||
warn("%s", file);
|
||||
rval = 1;
|
||||
} else {
|
||||
ifmt = sbuf.st_mode & S_IFMT;
|
||||
if (ifmt == S_IFREG || ifmt == S_IFLNK
|
||||
|| ifmt == S_IFDIR) {
|
||||
if (S_ISREG(sbuf.st_mode) || S_ISDIR(sbuf.st_mode))
|
||||
charct = sbuf.st_size;
|
||||
} else {
|
||||
else {
|
||||
while ((len = read(fd, buf, _MAXBSIZE)) > 0)
|
||||
charct += len;
|
||||
if (len == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user