summaryrefslogtreecommitdiff
path: root/usr.bin/wc
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2024-09-11 03:57:15 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2024-09-11 03:57:15 +0000
commit10a0cbc06ef5b18f5008598e070baae40e926890 (patch)
tree940eb2d346a04142906aeda707d42a979c091adb /usr.bin/wc
parente5f7c5cbb7d3689ef721a309a17ccc6be57ecdf1 (diff)
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@
Diffstat (limited to 'usr.bin/wc')
-rw-r--r--usr.bin/wc/wc.16
-rw-r--r--usr.bin/wc/wc.c14
2 files changed, 8 insertions, 12 deletions
diff --git a/usr.bin/wc/wc.1 b/usr.bin/wc/wc.1
index dcbb3b61311..4714c88fb5f 100644
--- a/usr.bin/wc/wc.1
+++ b/usr.bin/wc/wc.1
@@ -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
diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c
index e6877f0cbec..a22188aff8e 100644
--- a/usr.bin/wc/wc.c
+++ b/usr.bin/wc/wc.c
@@ -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) {