aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/wc
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2018-08-02 23:45:14 +0000
committerConrad Meyer <cem@FreeBSD.org>2018-08-02 23:45:14 +0000
commit84b851c23fecf26c88f1407b8a06282785c6bffd (patch)
treecbcb9a76d29af7ad656e35f99d8811e7c22a390d /usr.bin/wc
parent050b16aea8bb014827936006e350012319e431ad (diff)
Notes
Diffstat (limited to 'usr.bin/wc')
-rw-r--r--usr.bin/wc/wc.19
-rw-r--r--usr.bin/wc/wc.c16
2 files changed, 12 insertions, 13 deletions
diff --git a/usr.bin/wc/wc.1 b/usr.bin/wc/wc.1
index 63cbe4ccfb769..c31bb865385ea 100644
--- a/usr.bin/wc/wc.1
+++ b/usr.bin/wc/wc.1
@@ -31,7 +31,7 @@
.\" @(#)wc.1 8.2 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd December 1, 2015
+.Dd August 2, 2018
.Dt WC 1
.Os
.Sh NAME
@@ -76,8 +76,11 @@ See
.Xr xo_parse_args 3
for details on command line arguments.
.It Fl L
-The number of characters in the longest input line
-is written to the standard output.
+Write the length of the line containing the most bytes (default) or characters
+(when
+.Fl m
+is provided)
+to standard output.
When more than one
.Ar file
argument is specified, the longest input line of
diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c
index 67d6f51092d4f..c2990035c0c7e 100644
--- a/usr.bin/wc/wc.c
+++ b/usr.bin/wc/wc.c
@@ -216,7 +216,7 @@ cnt(const char *file)
* If all we need is the number of characters and it's a regular file,
* just stat it.
*/
- if (doline == 0) {
+ if (doline == 0 && dolongline == 0) {
if (fstat(fd, &sb)) {
xo_warn("%s: fstat", file);
(void)close(fd);
@@ -246,7 +246,7 @@ cnt(const char *file)
if (siginfo)
show_cnt(file, linect, wordct, charct, llct);
charct += len;
- if (doline) {
+ if (doline || dolongline) {
for (p = buf; len--; ++p)
if (*p == '\n') {
if (tmpll > llct)
@@ -262,10 +262,8 @@ cnt(const char *file)
tlinect += linect;
if (dochar)
tcharct += charct;
- if (dolongline) {
- if (llct > tlongline)
- tlongline = llct;
- }
+ if (dolongline && llct > tlongline)
+ tlongline = llct;
show_cnt(file, linect, wordct, charct, llct);
(void)close(fd);
return (0);
@@ -331,10 +329,8 @@ word: gotsp = 1;
twordct += wordct;
if (dochar || domulti)
tcharct += charct;
- if (dolongline) {
- if (llct > tlongline)
- tlongline = llct;
- }
+ if (dolongline && llct > tlongline)
+ tlongline = llct;
show_cnt(file, linect, wordct, charct, llct);
(void)close(fd);
return (0);