Commit Graph

67 Commits

Author SHA1 Message Date
Math Ieu
172be8642d split: reset errno prior to getline()
Something else may have set errno, breaking the post-getline() logic
that tries to detect the getline() error.  This was initially noted in
a jail on a system that has HPET, in a jail that does not expose
/dev/hpet0 -- we see an earlier error in libc's vdso bits.

Fixes:	5c053aa3c5 ("split: switch to getline() [...]")
2022-10-27 12:17:59 -05:00
Kyle Evans
7aaa50c6b5 split: add word order fix
This was meant to note that both pattern and line matching were
previously restricted, but words are difficult.  +line and rearrange.

Sponsored by:	Klara, Inc.
2022-10-25 16:52:14 -05:00
Kyle Evans
75c3ca1ebf split: add some tests
This should cover all of the basic functionality, as well as the recent
enhancement to use a dynamic buffer size rather than limiting patterns
and lines to MAXBSIZE.

Reviewed by:	bapt
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D36324
2022-10-25 10:05:24 -05:00
Kyle Evans
5c053aa3c5 split: switch to getline() for line/pattern matching
Get rid of split's home-grown logic for growing the buffer; arbitrarily
breaking at LONG_MAX bytes instead of 65536 bytes gives us much more
wiggle room.  Additionally, we'll actually fail out entirely if we can't
fit a line, which makes noticing this class of problem much easier.

Reviewed by:	bapt, emaste, pauamma
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D36323
2022-10-25 10:05:23 -05:00
Fernando Apesteguía
e48cafb55d split(1): Add EXAMPLES section
Add EXAMPLES covering -d, -n and -p
Include small explanation about the size of the chunks for the -n option

Approved by:	0mp
Differential Revision:	https://reviews.freebsd.org/D25198
2020-06-18 15:14:10 +00:00
Alexander Kabaev
bcd34af473 Revert r352953: Convert pnmatch to single element array in regexec calls
Requested by: cem
2019-10-02 16:08:01 +00:00
Alexander Kabaev
c5672dd7b9 Convert pnmatch to single element array in regexec calls
The regexec function is declared as taking an array of regmatch_t
elements, and passing in the pointer to singleton element, while
correct, triggers a Coverity warning. Convert the singleton into
an array of one to silence the warning.

Reported by:	Coverity
Coverity CID:	1009732, 1009733
MFC after:	2 weeks
2019-10-02 06:15:30 +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
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
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
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Baptiste Daroussin
3e11bd9e2a Convert to usr.bin/ to LIBADD
Reduce overlinking
2014-11-25 14:29:10 +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
b736a4db5b New/updated dependencies 2014-05-05 18:31:00 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Eitan Adler
b1b2a0ed64 Add missed DPADD
Reported by:	swildner@DragonflyBSD.org
2013-11-09 09:05:50 +00:00
Eitan Adler
3ebd4af7e8 Change manual string conversion to expand_number
Reviewed by:	adrian
2013-11-09 08:57:21 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Eitan Adler
89c5c3aab8 Avoid signed overflow in error handling code.
Reviewed by:	cperciva, bjk
2013-05-21 19:56:03 +00:00
Eitan Adler
a93b9b7d11 Bump .Dd for recent content change.
Reported by:	delphij
2013-05-10 12:49:16 +00:00
Eitan Adler
7f418e3407 Implement 'split -d' which allows a numeric suffix instead of an
alphabetic one.

PR:		bin/116209
Submitted by:	Marcin Gryszkalis <mg@fork.pl> (adapted from)
Reviewed by:	will
MFC after:	1 week
2013-05-10 04:23:03 +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
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
Eitan Adler
af9eff1f20 Fix warning when compiling with gcc46:
error: variable 'defname' set but not use

Approved by:	dim
MFC after:	3 day
2012-01-10 02:55:43 +00:00
Ed Schouten
973aa6bc58 Add missing static keywords to split(1) 2011-11-06 08:17:11 +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
Gavin Atkinson
f806ea8af1 Correct spelling mistake, int -> into
MFC after:	3 days
2010-09-02 21:29:50 +00:00
Tom Rhodes
cff548f0dd When "-b" is specified, one could easily create "smaller" files
that are much larger than expected (given the default size).
Change "smaller files" to "split files" which is more in line
with what "-b" actually does.

PR:		119329
Submitted by:	Julian Stacey <jhs@berklix.org>
2009-01-24 05:32:11 +00:00
David Schultz
0e286f086c Add a -n option to split(1) to split files into N chunks rather than
having to specify the right number of bytes.

Obtained from:	NetBSD
Submitted by:	Jan Schaumann <jschauma@netmeister.org>
PR:		113175
2008-03-16 15:15:32 +00:00
Ruslan Ermilov
cb29445a92 Markup fixes. 2006-09-29 15:20:48 +00:00
Giorgos Keramidas
a6dd1c93f4 Add support for splitting at gigabyte boundaries. [1]
Also make both lowercase and uppercase suffix letters work
as byte-count suffixes, i.e. the following two commands are
equivalent now:

    % split -b 4m foo
    % split -b 4M foo

Submitted by:		Roman Divacky [1]
Lots of help by:	cperciva
Reviewed by:		cperciva
MFC after:		1 week
2006-08-10 10:41:47 +00:00
Giorgos Keramidas
49198c4297 Update usage & SYNOPSIS and clarify that input files are not removed.
Sort getopt option handling of -p too, while here.

The changes are adapted from a patch by Ruslan Ermilov, posted as
followup to docs/33852.

PR:             docs/33852
Submitted by:   Gary W. Swearingen <swear@blarg.net>
MFC after:      1 week
2006-08-08 21:25:22 +00:00
Ruslan Ermilov
4e9e907d63 -mdoc sweep. 2005-11-18 10:36:29 +00:00
Tim J. Robbins
33eafb83b7 Include option-argument names in the list in the DESCRIPTION section.
Remove a non-bug from the BUGS section.
2005-08-30 12:48:28 +00:00
Tim J. Robbins
bb78dba49b Remove undocumented historic support for treating "-" as an option
instead of a file operand; this is not compatible with POSIX.
2005-08-30 12:32:18 +00:00
Tim J. Robbins
e93586df9d Remove the hack that varied the first character of the output file name
if none was specified on the command line. This is not permitted by
POSIX, and no longer needed now that we have the -a option.

PR:		85099
Submitted by:	Toby Peterson (Apple Computer)
2005-08-21 06:35:02 +00:00
Ruslan Ermilov
a866e17077 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
Tim J. Robbins
cd2890d712 Fix document year.
Noticed by:	simon
2004-07-11 15:04:16 +00:00
Tim J. Robbins
5c9fc89962 Add fairly standard ENVIRONMENT and DIAGNOSTICS sections. 2004-07-11 14:47:32 +00:00
Tim J. Robbins
0742d4ed1a Respect locale settings from the environment. 2004-07-11 14:44:23 +00:00
Tim J. Robbins
c81180b861 Support larger files (at least 64-bit offsets) by using off_t instead of
int to store offsets.
2002-07-15 05:31:55 +00:00
Juli Mallett
2c69ee9b45 Remove <sys/types> where we use <sys/param> already.
protoize.
2002-06-15 11:03:28 +00:00
Tim J. Robbins
242093bb8c Sort sections. 2002-06-03 14:42:28 +00:00
Tim J. Robbins
03c249af41 Correct HISTORY section - split(1) appeared at least as early as V3. 2002-06-03 14:41:32 +00:00
Ruslan Ermilov
f9988a58ec mdoc(7) police: use .Fl to denote stdin. 2002-05-30 06:07:29 +00:00
Tim J. Robbins
3662a24058 Claim conformance to IEEE Std 1003.1-2001.
See also csplit(1).
2002-05-27 06:08:14 +00:00