History log of /freebsd-current/usr.bin/head/head.c
Revision Date Author Comments
# 3abcc79c 19-Apr-2024 Martin Tournoij <martin@arp242.net>

head: use getline() instead of fgetln()

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


# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

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


# bdcbfde3 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Remove ancient SCCS tags.

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


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# a1b6427a 07-Jul-2023 Alfonso Gregory <gfunni234@gmail.com>

Mark usage function as __dead2 in programs where it does not return

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


# 643ac419 12-Jul-2022 Xin LI <delphij@FreeBSD.org>

Improve usability of head(1) and tail(1):

- 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


# 7ef518c0 05-Nov-2019 Mark Johnston <markj@FreeBSD.org>

fileargs_init() sets errno on failure.

Sponsored by: The FreeBSD Foundation


# d76eef34 17-Apr-2019 Ed Maste <emaste@FreeBSD.org>

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


# 3824f650 12-Nov-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

head: sandbox using capsicum

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D14409


# 509111af 12-Nov-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

head: fix style nits

No functional change intended.

Reviewed by: emaste
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D14498


# 79490b93 10-Apr-2018 Kyle Evans <kevans@FreeBSD.org>

head(1): Provide long options

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


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

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.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

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


# da52b4ca 11-Dec-2010 Joel Dahl <joel@FreeBSD.org>

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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 6137b0bd 11-Jan-2007 Brooks Davis <brooks@FreeBSD.org>

Fix build on architectures where off_t is signed by casting to uintmax_t
before comparing with a size_t.


# 6e8298db 11-Jan-2007 Brooks Davis <brooks@FreeBSD.org>

Fix head -c ### where ### is greater than 2^31. Unlike the submitted
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


# 58a8e6d2 23-Jul-2002 Juli Mallett <jmallett@FreeBSD.org>

Remove duplicate __FBSDID() - spotted by trying to build with a non-GNU
compiler.


# e026a48c 29-Jun-2002 David E. O'Brien <obrien@FreeBSD.org>

Consistently use FBSDID


# 1abf87a8 28-Apr-2002 Mark Murray <markm@FreeBSD.org>

Fix VCS tags; ANSIfy functions


# 4001504d 30-Mar-2002 David Malone <dwmalone@FreeBSD.org>

1) Staticise.
2) Remove registers.
3) Change some ints to size_t which are used with fread/fwrite.


# f1bb2cd2 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

remove __P


# ecca80bd 24-Jan-2002 David Malone <dwmalone@FreeBSD.org>

Make usage message and man page synopsis reflect the fact that -n
and -c are mutually exclusive.

PR: 34233
Submitted by: Gary W. Swearingen <swear@blarg.net>
MFC after: 3 days


# c7a2aa5d 02-Nov-2001 Alfred Perlstein <alfred@FreeBSD.org>

In order to perform faster when doing "head -n", use a pair of
fgetln/fwrite instead of getc/putchar, this seems about five times
faster.


# c16b5e4f 02-Nov-2001 Alfred Perlstein <alfred@FreeBSD.org>

change a global into a local, misc style fixes


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 710668ca 09-Oct-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

fread() returns 0 on eof or error, not EOF. This fixes the following
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>


# 73f3d053 11-Jul-1997 Philippe Charnier <charnier@FreeBSD.org>

Setting eval to 1 after calling warn was the original behaviour.


# c8510085 10-Jul-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3) instead of local redefinition.


# ef0e2ea4 05-Apr-1997 Alexander Langer <alex@FreeBSD.org>

Support for -c, byte count.


# 1c8af878 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# df3f5d9d 11-Mar-1997 Peter Wemm <peter@FreeBSD.org>

Merge from Lite2


# 0da30e9a 11-Mar-1997 Peter Wemm <peter@FreeBSD.org>

Import some parts of CSRG 4.4BSD-Lite2 usr.bin sources to fix tree build.


# 298f4291 26-Feb-1996 Wolfram Schneider <wosch@FreeBSD.org>

first check the count and then get
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>


# 8e502f11 15-Aug-1995 Joerg Wunsch <joerg@FreeBSD.org>

head(1) ignored EOFs (in certain cases).

Closes PR # bin/678: head(1) ignore EOF

Submitted by: wosch@cs.tu-berlin.de (Wolfram Schneider)


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources