summaryrefslogtreecommitdiff
path: root/usr.bin/wc/wc.c
Commit message (Collapse)AuthorAgeFilesLines
* wc(1): account for possibility of file == NULLKyle Evans2020-02-051-2/+2
| | | | | | | | | | | | file could reasonably be NULL here if we we're using stdin. Albeit less likely in normal usage, one could actually hit either of these warnings on stdin. ubmitted by: sigsys@gmail.com MFC after: 3 days Notes: svn path=/head/; revision=357572
* cap_fileargs: chase r346315, update fileargs_init in consumersEd Maste2019-04-171-1/+1
| | | | | | | | | | Reported by: ci.freebsd.org (8 times so far) MFC after: 3 weeks MFC with: r346315 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=346316
* s/caph_enter_capser/caph_enter_casper/gMariusz Zaborski2018-11-121-1/+1
| | | | | | | Reported by: npn Notes: svn path=/head/; revision=340382
* s/caph_enter_with_casper/caph_enter_casper/Mariusz Zaborski2018-11-121-1/+1
| | | | | | | Reported by: npn Notes: svn path=/head/; revision=340380
* wc: We should sandbox wc only if Capers is available.Mariusz Zaborski2018-11-121-1/+1
| | | | Notes: svn path=/head/; revision=340377
* wc: sandbox wc using capsicumMariusz Zaborski2018-11-121-1/+29
| | | | | | | | Reviewed by: AllanJude, emaste Differential Revision: https://reviews.freebsd.org/D14409 Notes: svn path=/head/; revision=340374
* wc(1): Fix 'wc -L'Conrad Meyer2018-08-021-10/+6
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=337203
* wc(1): Restore regular file char count fast pathConrad Meyer2017-12-101-44/+41
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=326749
* wc(1): Extend non-controversial optimizations to '-c' modeConrad Meyer2017-12-091-50/+51
| | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=326736
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326025
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=314436
* Fix SIGINFO race causing final results to be lost to stderr.Bryan Drewery2015-04-161-0/+11
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=281617
* Close the file list before opening the container that holds theMarcel Moolenaar2015-02-111-1/+3
| | | | | | | | | | | totals, otherwise we end up emitting invalid JSON -- provided libxo does not prevent us from doing that. PR: 197499 Submitted by: allanjude@ Notes: svn path=/head/; revision=278590
* Fix a SIGSEGV when emitting XML or JSON when reading stdin. In thatMarcel Moolenaar2014-11-071-3/+1
| | | | | | | case the file variable is NULL. Notes: svn path=/head/; revision=274210
* Convert to use libxo.Marcel Moolenaar2014-11-051-17/+39
| | | | | | | | Obtained from: Phil Shafer <phil@juniper.net> Sponsored by: Juniper Networks, Inc. Notes: svn path=/head/; revision=274125
* Add missing static keywords to wc(1)Ed Schouten2011-11-061-2/+2
| | | | Notes: svn path=/head/; revision=227201
* Remove the advertising clause from UCB copyrighted files in usr.bin. ThisJoel Dahl2010-12-111-4/+0
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=216370
* Use better type for siginfo (volatile sig_atomic_t instead of int).Pawel Jakub Dawidek2010-05-171-1/+2
| | | | | | | Pointed out by: jh Notes: svn path=/head/; revision=208210
* On SIGINFO print current values on stderr.Pawel Jakub Dawidek2010-05-161-44/+68
| | | | Notes: svn path=/head/; revision=208170
* Add missing `void' keyword for function without arguments.Ed Schouten2009-12-291-1/+1
| | | | Notes: svn path=/head/; revision=201181
* Add a -L option to wc(1), for finger compatibility with the GNUGiorgos Keramidas2008-12-061-9/+35
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=185714
* Remove warnings and make wc WARNS=6 clean.Josef El-Rayes2004-12-271-5/+2
| | | | | | | | | Add FreeBSD Id to Makefile. Approved by: ssouhlal Notes: svn path=/head/; revision=139364
* Improve robustness of multibyte character handling (-m option), andTim J. Robbins2004-04-091-19/+23
| | | | | | | | simplify the read buffering now that we can feed partial multibyte characters to mbrtowc(). Notes: svn path=/head/; revision=128049
* Use the iswspace(3) function now that it's been implemented.Tim J. Robbins2002-08-111-2/+2
| | | | Notes: svn path=/head/; revision=101670
* When counting words, check the correct character variable to see whether it'sTim J. Robbins2002-06-161-2/+2
| | | | | | | | | a space or not. Noticed by: bde Notes: svn path=/head/; revision=98291
* fstat() returns information about the target of any symbolic link thatTim J. Robbins2002-06-151-2/+2
| | | | | | | was opened, not the link itself. Remove dead code. Notes: svn path=/head/; revision=98245
* Add the -m option, which counts characters (as opposed to -c, whichTim J. Robbins2002-06-131-20/+47
| | | | | | | | | | 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. Notes: svn path=/head/; revision=98165
* remove __PWarner Losh2002-03-221-2/+2
| | | | Notes: svn path=/head/; revision=92922
* Leave the `copyright' variable exposed, since the main purpose of itMike Barcroft2002-03-071-2/+2
| | | | | | | | | is to put a copyright in the object file. Submitted by: bde Notes: svn path=/head/; revision=91792
* Fix vendor ID (mostly obtained from rev 1.1).Mike Barcroft2002-02-281-21/+23
| | | | | | | | | Make use of `static' storage-class for local functions. Replace uses of `u_quad_t' with `uintmax_t'. Notes: svn path=/head/; revision=91481
* WARNS=2 fix, use __FBSDID().Mark Murray2001-12-111-8/+7
| | | | | | | Not added to Makefgile as WARNS=2 will be made default. Notes: svn path=/head/; revision=87676
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Correct style issues with the previous commit.Sheldon Hearn1999-08-131-19/+16
| | | | | | | Requested by: bde Notes: svn path=/head/; revision=49685
* Fix integer overflow for files containing more than 4GB by usingSheldon Hearn1999-08-061-15/+16
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=49461
* Sync usage string according to man page. Silent -Wall.Philippe Charnier1997-08-251-4/+4
| | | | Notes: svn path=/head/; revision=28696
* compare return value from getopt against -1 rather than EOF, per the finalWarner Losh1997-03-291-2/+2
| | | | | | | posix standard on the topic. Notes: svn path=/head/; revision=24360
* Revert $FreeBSD$ to $Id$Peter Wemm1997-02-221-1/+1
| | | | Notes: svn path=/head/; revision=23012
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=21673
* Changed all per-file errors to warnings. Exit with a nonzero status ofBruce Evans1996-04-131-55/+48
| | | | | | | | | | 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 Notes: svn path=/head/; revision=15233
* Do not exit if a file is not readable. This is a short hackWolfram Schneider1996-04-101-2/+4
| | | | | | | until someone rewrite wc(1). Notes: svn path=/head/; revision=15179
* Localize it.Andrey A. Chernov1996-01-101-2/+5
| | | | Notes: svn path=/head/; revision=13380
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+243
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590