Commit Graph

41 Commits

Author SHA1 Message Date
Ed Maste
d76eef3430 cap_fileargs: chase r346315, update fileargs_init in consumers
Reported by:	ci.freebsd.org (8 times so far)
MFC after:	3 weeks
MFC with:	r346315
Sponsored by:	The FreeBSD Foundation
2019-04-17 16:18:14 +00:00
Mariusz Zaborski
509e73d483 s/caph_enter_capser/caph_enter_casper/g
Reported by:	npn
2018-11-12 18:43:51 +00:00
Mariusz Zaborski
8e4febf012 s/caph_enter_with_casper/caph_enter_casper/
Reported by:	npn
2018-11-12 18:34:55 +00:00
Mariusz Zaborski
c71292ea35 wc: We should sandbox wc only if Capers is available. 2018-11-12 18:01:36 +00:00
Mariusz Zaborski
9e4c5144e6 wc: sandbox wc using capsicum
Reviewed by:	AllanJude, emaste
Differential Revision:	https://reviews.freebsd.org/D14409
2018-11-12 17:47:51 +00:00
Conrad Meyer
84b851c23f 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:	<amstrnad+bugzilla AT gmail.com>
Sponsored by:	Dell EMC Isilon
2018-08-02 23:45:14 +00:00
Conrad Meyer
0dc7c9e635 wc(1): Restore regular file char count fast path
fstat(2) is going to be a lot faster than reading all of the bytes in a
file, if we just need a character count for a regular file.  This fast path
was accidentally broken in r326736.

PR:		224160
Reported by:	bde
Sponsored by:	Dell EMC Isilon
2017-12-10 17:56:03 +00:00
Conrad Meyer
de1430411d wc(1): Extend non-controversial optimizations to '-c' mode
wc(1)'s slow path for counting words or multibyte characters requires
conversion of the 8-bit input stream to wide characters.  However, a faster
path can be used for counting only lines ('-l' -- newlines have the same
representation in all supported encodings) or bytes ('-c').

The existing line count optimization was not used if the input was the
implicit stdin.  Additionally, it wasn't used if only byte counting was
requested.  This change expands the fast path to both of these scenarios.

Expanding the buffer size from 64 kB helps reduce the number of read(2)
calls needed, but exactly what impact that change has and what size to
expand the buffer to are still under discussion.

PR:		224160
Tested by:	wosch (earlier version)
Sponsored by:	Dell EMC Isilon
2017-12-09 21:55:19 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Bryan Drewery
8ded906d2a Fix SIGINFO race causing final results to be lost to stderr.
If a SIGINFO comes in after the file is read then the 'siginfo' flag is set to
1 and the next call to show_cnt() (at exit) would print the data to stderr
rather than the expected stdout.

This was found with spamming Poudriere with SIGINFO which caused a 'wc -l'
execution to return no data rather than an expected number.

MFC after:	2 weeks
2015-04-16 21:44:35 +00:00
Marcel Moolenaar
399d34850f Close the file list before opening the container that holds the
totals, otherwise we end up emitting invalid JSON -- provided
libxo does not prevent us from doing that.

PR:		197499
Submitted by:	allanjude@
2015-02-11 17:56:24 +00:00
Marcel Moolenaar
985c93f0b4 Fix a SIGSEGV when emitting XML or JSON when reading stdin. In that
case the file variable is NULL.
2014-11-07 01:36:20 +00:00
Marcel Moolenaar
6711c4827a Convert to use libxo.
Obtained from:	Phil Shafer <phil@juniper.net>
Sponsored by:	Juniper Networks, Inc.
2014-11-05 04:02:25 +00:00
Ed Schouten
8df975a218 Add missing static keywords to wc(1) 2011-11-06 08:19:00 +00:00
Joel Dahl
da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Pawel Jakub Dawidek
c9a9640635 Use better type for siginfo (volatile sig_atomic_t instead of int).
Pointed out by:	jh
2010-05-17 19:13:49 +00:00
Pawel Jakub Dawidek
f09bc09332 On SIGINFO print current values on stderr. 2010-05-16 21:06:26 +00:00
Ed Schouten
0970727f4f Add missing `void' keyword for function without arguments. 2009-12-29 08:54:03 +00:00
Giorgos Keramidas
f45dd01002 Add a -L option to wc(1), for finger compatibility with the GNU
wc utility.  The -L option can be used to report the length of
the longest line wc has seen in one or more files.  It is
disabled by default, and wc uses the standard `-lwc'.

Submitted by:	Sheldon Givens, sheldon at sigsegv.ca
Reviewed by:	kib
MFC after:	1 week
2008-12-06 19:21:56 +00:00
Josef El-Rayes
806abfccac Remove warnings and make wc WARNS=6 clean.
Add FreeBSD Id to Makefile.

Approved by:	ssouhlal
2004-12-27 22:27:56 +00:00
Tim J. Robbins
149a123b34 Improve robustness of multibyte character handling (-m option), and
simplify the read buffering now that we can feed partial multibyte
characters to mbrtowc().
2004-04-09 11:17:29 +00:00
Tim J. Robbins
e58245f7dc Use the iswspace(3) function now that it's been implemented. 2002-08-11 10:52:13 +00:00
Tim J. Robbins
abd0c85dcd When counting words, check the correct character variable to see whether it's
a space or not.

Noticed by: bde
2002-06-16 06:04:43 +00:00
Tim J. Robbins
a1a27143bd fstat() returns information about the target of any symbolic link that
was opened, not the link itself. Remove dead code.
2002-06-15 08:31:19 +00:00
Tim J. Robbins
ebb42aee31 Add the -m option, which counts characters (as opposed to -c, which
counts bytes). In locales that don't have multibyte characters, -m
is effectively an alias for -c.

This brings wc(1) up to P1003.1-2001 conformance.
2002-06-13 12:48:50 +00:00
Warner Losh
3f330d7d1a remove __P 2002-03-22 01:42:45 +00:00
Mike Barcroft
064692095c Leave the `copyright' variable exposed, since the main purpose of it
is to put a copyright in the object file.

Submitted by:	bde
2002-03-07 10:06:00 +00:00
Mike Barcroft
a821e36e41 Fix vendor ID (mostly obtained from rev 1.1).
Make use of `static' storage-class for local functions.

Replace uses of `u_quad_t' with `uintmax_t'.
2002-02-28 11:02:49 +00:00
Mark Murray
7a8fb588c7 WARNS=2 fix, use __FBSDID().
Not added to Makefgile as WARNS=2 will be made default.
2001-12-11 22:23:53 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Sheldon Hearn
a0cf59e65e Correct style issues with the previous commit.
Requested by:	bde
1999-08-13 12:56:35 +00:00
Sheldon Hearn
af86fc21d6 Fix integer overflow for files containing more than 4GB by using
u_quad_int instead of u_long for counters. (NetBSD's rev 1.15 - 1.18)

Deprecate register. (NetBSD's rev 1.13)

The diffs from NetBSD were not applied verbatim, because we don't care
about NO_QUAD right now.

PR:	12959
Reported by:	Nicholas Barnes <nb@ravenbrook.com>
Obtained from:	NetBSD
1999-08-06 14:37:13 +00:00
Philippe Charnier
8c85cce77a Sync usage string according to man page. Silent -Wall. 1997-08-25 06:44:59 +00:00
Warner Losh
1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Peter Wemm
c115df18cd Revert $FreeBSD$ to $Id$ 1997-02-22 19:58:13 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Bruce Evans
2c51e5ed8d Changed all per-file errors to warnings. Exit with a nonzero status of
if there was a per-file error.  My test case of `wc /proc/curproc/*'
works reasonably now (much like `size /proc/curproc/*'.

Reviewed by:	wosch
1996-04-13 11:35:54 +00:00
Wolfram Schneider
a0d038a406 Do not exit if a file is not readable. This is a short hack
until someone rewrite wc(1).
1996-04-10 22:21:01 +00:00
Andrey A. Chernov
ae6fa8ae08 Localize it. 1996-01-10 21:42:14 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00