From owner-svn-src-all@freebsd.org Thu Aug 2 23:45:15 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 975B91054C95; Thu, 2 Aug 2018 23:45:15 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D8D883FE4; Thu, 2 Aug 2018 23:45:15 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3012518B05; Thu, 2 Aug 2018 23:45:15 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w72NjFJL024208; Thu, 2 Aug 2018 23:45:15 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w72NjE8Q024206; Thu, 2 Aug 2018 23:45:14 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201808022345.w72NjE8Q024206@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Thu, 2 Aug 2018 23:45:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337203 - head/usr.bin/wc X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/usr.bin/wc X-SVN-Commit-Revision: 337203 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Aug 2018 23:45:15 -0000 Author: cem Date: Thu Aug 2 23:45:14 2018 New Revision: 337203 URL: https://svnweb.freebsd.org/changeset/base/337203 Log: wc(1): Fix 'wc -L' I inadvertently broke 'wc -L' in r326736. We must skip the fast path if -L was specified, in addition to the existing check for the -l option. Document long-standing -L behavior (count varies depending on whether wc(1) is run with the -m option or not) in wc.1. That behavior dates back to the introduction of the -L option, but was not documented. PR: 230300 Reported by: Sponsored by: Dell EMC Isilon Modified: head/usr.bin/wc/wc.1 head/usr.bin/wc/wc.c Modified: head/usr.bin/wc/wc.1 ============================================================================== --- head/usr.bin/wc/wc.1 Thu Aug 2 23:43:01 2018 (r337202) +++ head/usr.bin/wc/wc.1 Thu Aug 2 23:45:14 2018 (r337203) @@ -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 Modified: head/usr.bin/wc/wc.c ============================================================================== --- head/usr.bin/wc/wc.c Thu Aug 2 23:43:01 2018 (r337202) +++ head/usr.bin/wc/wc.c Thu Aug 2 23:45:14 2018 (r337203) @@ -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);