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

cut: 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


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

sccs: Manual changes

For the uncommon items: Go through the tree and remove sccs tags that
didn't fit any nice pattern. If in the neighborhood, other SCM tags were
removed when they were detritis of long-ago CVS somehow in the early
mists of the project. Some adjacent copyrights stringswere removed (they
duplicated the copyright notices in the file). This also removed
non-standard formations of omission of SCCS tags (usually by adding an
extra #if 0 somewhere.

After this commit, a number of strings tagged with the 'what' @(#)
prefix remain, but they are primarily copyright notices.

Sponsored by: Netflix


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

Remove $FreeBSD$: one-line .c pattern

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


# 6872fd3c 23-May-2018 Eitan Adler <eadler@FreeBSD.org>

cut: Fix out of boundary write on illegal list argument

It is possible to trigger an out of boundary write in cut if an invalid
range with autostart has been supplied.

PR: 227330
Submitted by: tobias@stoeckmann.org


# 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


# bd9dd0c6 23-Nov-2012 Andrew Turner <andrew@FreeBSD.org>

The is_delim function works on wchar_t characters not ints, update the
function to take a wchar_t as it's argument.

This fixes the build when wchar_t is not an int, i.e. ARM EABI.


# 18ba28c8 19-Nov-2012 Eitan Adler <eadler@FreeBSD.org>

Add 'w' flag to:

Use whitespace (spaces and tabs) as the delimiter.
Consecutive spaces and tabs count as one single field
separator.

Reviewed by: swildner@dragonflybsd.org
Approved by: cperciva
Obtained from: DragonFlyBSD
MFC after: 1 week


# d334b286 10-Jun-2012 Kevin Lo <kevlo@FreeBSD.org>

- Consistenly mention columns and fields
- Add -b to short error messages

Obtained from: NetBSD


# 41b662c5 06-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Add missing static keywords to cut(1)


# 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.


# a2222839 05-Nov-2004 Tim J. Robbins <tjr@FreeBSD.org>

When the last line of a file is missing a newline in -f mode, pass a
length argument to mbrtowc() that accounts for the terminating newline
character we add automatically. Failing to do this caused the loop to
unexpectedly run out of characters and incorrectly signal an "Illegal byte
sequence" error.


# 3b90bf79 28-Jun-2004 Tim J. Robbins <tjr@FreeBSD.org>

Move some variable declarations to the top of the file.


# f0b4606f 27-Jun-2004 Tim J. Robbins <tjr@FreeBSD.org>

Silence a warning about an unused argument.


# a5c4bafc 27-Jun-2004 Tim J. Robbins <tjr@FreeBSD.org>

Handle multibyte characters when cutting out fields (-f and -d options.)


# 0dcb7b75 27-Jun-2004 Tim J. Robbins <tjr@FreeBSD.org>

Update a comment that compared the parser with an obsolete draft of
IEEE Std 1003.2-1992. Most of the "extensions" here were actually
required by the final version of the standard.


# 364d0a91 27-Jun-2004 Tim J. Robbins <tjr@FreeBSD.org>

Implement the -c option correctly in locales with multibyte characters
instead of treating it as a synonym for -b.


# d900c384 27-Jun-2004 Tim J. Robbins <tjr@FreeBSD.org>

Make the handling of invalid multibyte sequences more robust by using
mbrlen() instead of mblen().


# f4ac32de 04-Sep-2002 David Malone <dwmalone@FreeBSD.org>

ANSIify function definitions.
Add some constness to avoid some warnings.
Remove use register keyword.
Deal with missing/unneeded extern/prototypes.
Some minor type changes/casts to avoid warnings.

Reviewed by: md5


# 3a7fc8ce 18-Aug-2002 Juli Mallett <jmallett@FreeBSD.org>

Remove local prototypes for main().


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

Consistently use FBSDID


# 393cf508 08-Jun-2002 Tim J. Robbins <tjr@FreeBSD.org>

Don't split multibyte characters when the -n option is specified.


# 93738f50 07-Jun-2002 Tim J. Robbins <tjr@FreeBSD.org>

style(9): don't initialise variables in their declaration, remove space
after function name, use __unused on unused parameters instead of
initialising them to bogus values.


# f457179a 26-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

Initialise the `positions' array correctly before use.


# 204c78a1 24-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

When a file name of "-" is given, read from standard input (SUSv3)


# a8522a9b 24-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

Allow byte/character positions >_POSIX2_LINE_MAX to be specified by
dynamically growing the `positions' array.


# a6ea32c3 24-May-2002 Tim J. Robbins <tjr@FreeBSD.org>

If processing of one file fails, try to process the remaining files and
exit non-zero instead of immediately exiting. The traditional BSD
behaviour is explicitly forbidden by P1003.2.


# 41ff7633 06-Jun-2001 Dima Dorfman <dd@FreeBSD.org>

Silence the remaining warnings and clamp down with WARNS=2.

Not objected to by: -audit


# 1928e20e 24-Apr-2001 Dima Dorfman <dd@FreeBSD.org>

Teach cut(1) how to handle long lines: convert from fgets(3) to fgetln(3).

PR: 26810
Reviewed by: dwmalone


# 39e21a1b 06-Feb-2001 Philippe Charnier <charnier@FreeBSD.org>

Remove duplicate FreeBSD Id
Remoce unused #include
Use imperative mode to start flag description


# 99557a79 27-Jan-2001 Will Andrews <will@FreeBSD.org>

De-__P()-ify

Reviewed by: markm


# d8a3fbd5 27-Jan-2001 Will Andrews <will@FreeBSD.org>

BDECFLAGS: constify; use proper types. Add $FreeBSD$, clean up #ifndef lint.

Reviewed by: markm


# 2c39ae65 02-Feb-1999 Eivind Eklund <eivind@FreeBSD.org>

Merge from NetBSD: cut.1 rev 1.6 to 1.8
cut.c rev 1.9 to 1.13
* Man page internal cleanups
* 8-bit characters cast to unsigned for is*()
* Misc cleanups for egcs -Wall compatibility


# 5183fb53 02-Feb-1999 Eivind Eklund <eivind@FreeBSD.org>

Bring in use of strsep() to handle bad input better, and clean up
some text.

Obtained from: Merge from OpenBSD
(cut.1 up to OpenBSD rev 1.3, cut.c up to OpenBSD rev 1.6)


# d51c6625 02-Feb-1999 Eivind Eklund <eivind@FreeBSD.org>

Merge from NetBSD cut.1 rev 1.6 and cut.c rev 1.9, respectively. This
makes us conform to IEEE Std1003.2-1992 (``POSIX.2'').

Obtained from: NetBSD (but with slight modifications).


# fa146c53 06-Dec-1998 Archie Cobbs <archie@FreeBSD.org>

Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]).


# 812bff99 30-Jun-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3) instead of local redefinition. Change argument name in man
page to sync with usage string.


# 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.


# eaf92380 20-Mar-1995 Andrey A. Chernov <ache@FreeBSD.org>

Fix wrong separator output
Submitted by: julian
Obtained from: newsgroup?


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

BSD 4.4 Lite Usr.bin Sources