Commit graph

94 commits

Author SHA1 Message Date
Martin Tournoij b05785953e 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
69099ba2ec), and there's been some previous patches (ee3ca711a8
8c98e6b1a7 1a2a4fc8ce) 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
2024-04-19 15:52:21 -06:00
Warner Losh 5b31cc94b1 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
2023-11-26 22:23:58 -07:00
Warner Losh bdcbfde31e 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
2023-11-26 22:23:30 -07:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Gordon Bergling 9bdb5158d6 Update HISTORY and AUTHORS sections for cut(1) and paste(1)
In an e-mail Brian Walden wrote that:

"GWRL stands for Gottfried W. R. Luderer, the author of cut(1) and
paste(1), probably around 1978. Those came either from PWB or USG,
as he worked with, or for, Berkley Tague. Thus they made their way
into AT&T commercial UNIX, first into System III and the into System
V, and that's why they are missing from early BSD releases as they
didn't get into Research UNIX until the 8th Edition."

So update the HISTORY and AUTHORS sections for cut(1) and paste(1).

[1] https://minnie.tuhs.org/pipermail/tuhs/2020-January/019955.html

Reviewed by:	pauamma, imp
Obtained from:	OpenBSD (in partial)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36048
2022-11-07 11:23:33 +01:00
Eitan Adler 6872fd3c94 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
2018-05-23 09:16:20 +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
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Enji Cooper f2381beb2c MFhead@r322021 2017-08-03 17:43:26 +00:00
Sevan Janiyan 079f5b9b7b Document -w flag is an extension to POSIX.
PR:		201937
Submitted by:	<fullermd AT over-yonder DOT net>
Approved by:	bcr (mentor)
Differential Revision:	https://reviews.freebsd.org/D11842
2017-08-03 14:35:02 +00:00
Enji Cooper d511b20a69 Add HAS_TESTS to all Makefiles that are currently using the
`SUBDIR.${MK_TESTS}+= tests` idiom.

This is a follow up to r321912.
2017-08-02 08:50:42 +00:00
Enji Cooper 4b330699f8 Convert traditional ${MK_TESTS} conditional idiom for including test
directories to SUBDIR.${MK_TESTS} idiom

This is being done to pave the way for future work (and homogenity) in
^/projects/make-check-sandbox .

No functional change intended.

MFC after:	1 weeks
2017-08-02 08:35:51 +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
Enji Cooper acdd2b1ca3 Add some basic -s flag testcases for cut(1)
The remaining functionality seems to be covered in one form or
another via the NetBSD ATF testcase.

MFC after:	3 weeks
Sponsored by:	Dell EMC Isilon
2017-01-20 08:00:36 +00:00
Enji Cooper 430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Glen Barber 7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery 15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Glen Barber 43faedc133 First pass to fix the 'tests' packages.
Sponsored by:	The FreeBSD Foundation
2016-02-02 22:26:49 +00:00
Enji Cooper b2d48be1bc Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and
netbsd-tests.test.mk (r289151)

- Eliminate explicit OBJTOP/SRCTOP setting
- Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk
- Remove unnecessary TESTSDIR setting
- Use SRCTOP where possible for clarity

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Divison
2015-10-12 08:16:03 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty 9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Enji Cooper 48e0fbc3f9 Integrate usr.bin/cut/tests from NetBSD into atf/kyua
Sponsored by: EMC / Isilon Storage Division
2014-10-09 01:46:31 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty 76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Andrew Turner bd9dd0c6c9 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.
2012-11-24 04:15:25 +00:00
Eitan Adler 18ba28c82c 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
2012-11-20 01:57:21 +00:00
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Marcel Moolenaar 7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Kevin Lo 0087e1818e Fix typo 2012-06-11 03:10:15 +00:00
Kevin Lo d334b28625 - Consistenly mention columns and fields
- Add -b to short error messages

Obtained from:	NetBSD
2012-06-11 03:02:40 +00:00
Ed Schouten 41b662c583 Add missing static keywords to cut(1) 2011-11-06 08:14:51 +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
Tom Rhodes 6abf213ba4 Fix punctuation.
PR:		132834
Submitted by:	"Alan R. S. Bueno" <alan.bsd@gmail.com>
2009-04-01 08:33:54 +00:00
Ruslan Ermilov 081fa92f3b - Adopt the short description from POSIX as it better matches the
utility name.

- Fix a bug in description: the range preceded by a dash selects
  up to the last number, not first.
2007-02-28 10:13:32 +00:00
Ruslan Ermilov 6c7216df78 Sort sections. 2005-01-18 13:43:56 +00:00
Ruslan Ermilov a866e17077 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
Tim J. Robbins a2222839a5 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.
2004-11-05 10:45:23 +00:00
Ruslan Ermilov 2410103c1d mdoc(7) fixes. 2004-07-07 19:57:16 +00:00
Tim J. Robbins ea8348d4e4 Describe the algorithm used by the -n option. 2004-06-28 06:20:28 +00:00
Tim J. Robbins 3b90bf797f Move some variable declarations to the top of the file. 2004-06-28 06:05:36 +00:00
Tim J. Robbins f0b4606f3f Silence a warning about an unused argument. 2004-06-27 16:58:56 +00:00
Tim J. Robbins 8180b4573c Correct the description of the -f option: input and output fields are
separated by the field delimiter character, which is not necessarily
the tab character.
2004-06-27 16:55:25 +00:00
Tim J. Robbins a5c4bafcd1 Handle multibyte characters when cutting out fields (-f and -d options.) 2004-06-27 16:42:33 +00:00