aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/head/head.c
Commit message (Collapse)AuthorAgeFilesLines
* head: use getline() instead of fgetln()Martin Tournoij2024-04-191-4/+5
| | | | | | | | | | | | | | | | | | | | | | This replaces fgetln() with getline(). The main reason for this is portability, making things easier for people who want to compile these tools on non-FreeBSD systems. I appreciate that's probably not the top concern for FreeBSD base tools, but fgetln() is impossible to port to most platforms, as concurrent access is essentially impossible to implement fully correct without the line buffer on the FILE struct. Other than this, many generic FreeBSD tools compile fairly cleanly on Linux with a few small changes. Most uses of fgetln() pre-date getline() support (added in 2009 with 69099ba2ec8b), and there's been some previous patches (ee3ca711a898 8c98e6b1a7f3 1a2a4fc8ce1b) for other tools. Obtained from: https://github.com/dcantrell/bsdutils and https://github.com/chimera-linux/chimerautils Signed-off-by: Martin Tournoij <martin@arp242.net> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/893
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-9/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* usr.bin: Remove ancient SCCS tags.Warner Losh2023-11-271-3/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Mark usage function as __dead2 in programs where it does not returnAlfonso Gregory2023-07-071-1/+1
| | | | | | | | In most cases, usage does not return, so mark them as __dead2. For the cases where they do return, they have not been marked __dead2. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/735
* Improve usability of head(1) and tail(1):Xin LI2022-07-131-10/+23
| | | | | | | | | | | - Consistently support -q (quiet) and -v (verbose) - Allow specifying numbers with SI prefixes supported by expand_number(3) - Remove 2^31 limit on lines for head(1) MFC after: 2 weeks Reviewed by: lwhsu, pauamma, gbe Relnotes: yes Differential Revision: https://reviews.freebsd.org/D35720
* fileargs_init() sets errno on failure.Mark Johnston2019-11-061-1/+1
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=354368
* 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
* head: sandbox using capsicumMariusz Zaborski2018-11-121-1/+19
| | | | | | | | Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D14409 Notes: svn path=/head/; revision=340376
* head: fix style nitsMariusz Zaborski2018-11-121-8/+13
| | | | | | | | | | | No functional change intended. Reviewed by: emaste MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D14498 Notes: svn path=/head/; revision=340370
* head(1): Provide long optionsKyle Evans2018-04-101-1/+9
| | | | | | | | | | | | | Provide long options --bytes and --lines to match -c and -n respectively. This improves head(1)'s compatibility with its GNU counterpart in a sensible way. Reviewed by: eadler (previous version) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D14139 Notes: svn path=/head/; revision=332374
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | 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
* 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
* Fix build on architectures where off_t is signed by casting to uintmax_tBrooks Davis2007-01-111-1/+1
| | | | | | | before comparing with a size_t. Notes: svn path=/head/; revision=165955
* Fix head -c ### where ### is greater than 2^31. Unlike the submittedBrooks Davis2007-01-111-4/+6
| | | | | | | | | | | | | patch this uses off_t. WARNSify and add $FreeBSD$ to Makefile. PR: bin/107824 Submitted by: Brian Cornell <briancornell at earthlink dot net> MFC after: 3 days Notes: svn path=/head/; revision=165940
* Remove duplicate __FBSDID() - spotted by trying to build with a non-GNUJuli Mallett2002-07-231-3/+0
| | | | | | | compiler. Notes: svn path=/head/; revision=100575
* Consistently use FBSDIDDavid E. O'Brien2002-06-301-0/+2
| | | | Notes: svn path=/head/; revision=99112
* Fix VCS tags; ANSIfy functionsMark Murray2002-04-281-14/+8
| | | | Notes: svn path=/head/; revision=95652
* 1) Staticise.David Malone2002-03-301-13/+13
| | | | | | | | 2) Remove registers. 3) Change some ints to size_t which are used with fread/fwrite. Notes: svn path=/head/; revision=93441
* remove __PWarner Losh2002-03-221-4/+4
| | | | Notes: svn path=/head/; revision=92920
* Make usage message and man page synopsis reflect the fact that -nDavid Malone2002-01-241-1/+1
| | | | | | | | | | | and -c are mutually exclusive. PR: 34233 Submitted by: Gary W. Swearingen <swear@blarg.net> MFC after: 3 days Notes: svn path=/head/; revision=89767
* In order to perform faster when doing "head -n", use a pair ofAlfred Perlstein2001-11-021-7/+8
| | | | | | | | fgetln/fwrite instead of getc/putchar, this seems about five times faster. Notes: svn path=/head/; revision=85861
* change a global into a local, misc style fixesAlfred Perlstein2001-11-021-7/+5
| | | | Notes: svn path=/head/; revision=85859
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* fread() returns 0 on eof or error, not EOF. This fixes the followingDag-Erling Smørgrav1998-10-091-2/+2
| | | | | | | | | | | | | bug: "head -c <n>" never exit and loops forever (until it is killed), if the input stream has fewer bytes than specified (n). PR: bin/8225 Submitted-by: FUJIMOTO Kensaku <fujimoto@oscar.elec.waseda.ac.jp> Notes: svn path=/head/; revision=40114
* Setting eval to 1 after calling warn was the original behaviour.Philippe Charnier1997-07-111-1/+2
| | | | Notes: svn path=/head/; revision=27328
* Use err(3) instead of local redefinition.Philippe Charnier1997-07-101-42/+14
| | | | Notes: svn path=/head/; revision=27314
* Support for -c, byte count.Alexander Langer1997-04-061-7/+45
| | | | Notes: svn path=/head/; revision=24665
* compare return value from getopt against -1 rather than EOF, per the finalWarner Losh1997-03-291-1/+1
| | | | | | | posix standard on the topic. Notes: svn path=/head/; revision=24360
* Merge from Lite2Peter Wemm1997-03-111-3/+5
| | | | Notes: svn path=/head/; revision=23693
* first check the count and then getWolfram Schneider1996-02-261-1/+1
| | | | | | | | | | the next line of characters and not cause it to first get the characters even if the count (cnt) has become 0. Submitted by: R Bezuidenhout <rbezuide@mikom.csir.co.za> Notes: svn path=/head/; revision=14269
* head(1) ignored EOFs (in certain cases).Joerg Wunsch1995-08-151-3/+2
| | | | | | | | | Closes PR # bin/678: head(1) ignore EOF Submitted by: wosch@cs.tu-berlin.de (Wolfram Schneider) Notes: svn path=/head/; revision=10064
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+180
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590