Commit graph

36 commits

Author SHA1 Message Date
Cosimo Cecchi 7dd39ef4e0 comm: close a race condition when comm is fed from stdin
If one of the files has ended, we won't show the column, but we still
need to drain the file pointer to avoid potentially hitting a pipe
failure.

This commit moves the NULL offset checks inside show() so that getline()
and ferror() are still called on fp.

Reviewed by:	allanjude
Sponsored by:	Apple Inc.
Differential Revision:	https://reviews.freebsd.org/D45440
2024-06-06 17:04:38 +00:00
Cosimo Cecchi 63f5c101a1 comm: flush stdout for error checking prior to exiting
UNIX conformance wants utilities to catch any errors when doing I/O, as
opposed to relying on the implicit flush upon exit.
comm currently does not do that.
This commit adds handling of I/O errors on stdout prior to exit.

Reviewed by:	imp, allanjude
Sponsored by:	Apple Inc.
Differential Revision:	https://reviews.freebsd.org/D45439
2024-06-06 17:04:37 +00:00
Warner Losh 0b8224d1cc 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
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 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06: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
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
Baptiste Daroussin a43d43d574 Remove usage of _WITH_GETLINE from usr.bin 2016-07-30 01:07:47 +00:00
Ed Schouten 8d34a0b7bc Mark global functions and/or variables in comm(1) static where possible.
This allows compilers and static analyzers to more thorough analysis.
2011-11-06 18:49:10 +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
Andrey A. Chernov 0100f0ddf7 Add SIZE_MAX overflow check 2010-03-09 21:06:17 +00:00
Andrey A. Chernov 8f82dfe5d1 Rewrite input processing to not exit with error on the first EILSEQ found
in the input data but fallback to "binary comparison" instead.

POSIX says: "The input files shall be text files", nothing more,
so the text file with illegal sequence is valid input.
BTW, GNU sort does not fails on EILSEQ too.
2010-03-08 22:27:46 +00:00
Jaakko Heinonen e8861840c8 - Prevent overflowing of the buffer length variable in getline() by
limiting its maximum value.
- Exit if reallocf(3) fails in getline(). Failure was silently
  considered as end-of-file.

Reviewed by:	ghelmer
Approved by:	trasz (mentor)
2009-12-16 14:34:48 +00:00
Jaakko Heinonen d8eba599f5 Don't read the newline character to line buffer because lines are passed
to wcscoll(3). Newline characters could cause incorrect results when
comparing lines.

Also, if an input line didn't contain a newline character, it was
omitted from the output. According to my interpretation, SUSv3 requires
that the newline is always printed.

Add regression tests for the cases. [1]

PR:		bin/140976
Submitted by:	D'Arcy Cain (original version) [1]
Approved by:	trasz (mentor)
2009-12-12 18:18:46 +00:00
Guy Helmer 16f53ec4b7 Similar to changes previously made to src/usr.bin/uniq/uniq.c,
fix truncation of lines at LINE_MAX characters by dynamically
extending line buffers.
2008-05-28 14:13:35 +00:00
Tim J. Robbins e9fbd31a8c Add support for multibyte characters. 2004-07-02 22:48:29 +00:00
David Malone 19817b8518 ANSIify function definitions to avoid a warning.
Minor constness changes.
2002-07-28 15:28:38 +00:00
Tim J. Robbins fc7f17b1fe No need to handle '-' explicitly in getopt() loop.
Obtained from:	NetBSD
2002-05-28 09:26:08 +00:00
Warner Losh f1bb2cd2aa remove __P 2002-03-22 01:22:50 +00:00
Andrey A. Chernov 6d994e13c8 Use LC_ALL to pick LC_COLLATE too (for strcoll()) 2001-12-30 19:30:10 +00:00
David Malone 9f5b04e925 Style improvements recommended by Bruce as a follow up to some
of the recent WARNS commits. The idea is:

1) FreeBSD id tags should follow vendor tags.
2) Vendor tags should not be compiled (though copyrights probably should).
3) There should be no blank line between including cdefs and __FBSDIF.
2001-12-10 21:13:08 +00:00
Mark Murray 9240706953 Use __FBSDID(). 2001-12-02 23:52:47 +00:00
Mark Murray bcdc82df70 WARNS=2 fixup. 2001-12-02 13:18:59 +00:00
Dima Dorfman 7a19d1bbb9 Include missing header files which define functions for which gcc has
builtins (e.g., exit, strcmp).
2001-06-24 19:50:42 +00:00
Philippe Charnier 3a87eff1cf Rework diagnostics text
Remove unused #include
2001-02-06 20:01:40 +00:00
Andrey A. Chernov 6604897c78 fix the same typo as in uniq 1999-12-10 13:27:02 +00:00
Andrey A. Chernov ff6a49c924 toupper -> tolower to match changed behaviour of new grep case fold 1999-10-29 05:11:06 +00:00
Andrey A. Chernov fe6e52a784 Cosmetique: use standard prototypes scheme
Back out prev change: toupper is more compatible with sort -f
1999-10-24 04:47:57 +00:00
Andrey A. Chernov 4346bfd3f0 toupper->tolower to match what strcasecmp does 1999-10-24 04:21:42 +00:00
Andrey A. Chernov 2c2b14e162 Localize it
PR:		11221
Submitted by:	Grigoriy Strokin <grg@philol.msu.ru>
1999-10-24 03:42:35 +00:00
Peter Wemm c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Archie Cobbs fa146c5335 Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]). 1998-12-06 22:58:23 +00:00
Joerg Wunsch 2ca7dc1598 Teach comm(1) and uniq(1) about an option for case-insensitive work.
PR:		3042
Submitted by:	graphix@iastate.edu (Kent Vander Velden)
1997-09-07 15:09:22 +00:00
Philippe Charnier 0e25805f2f Use err(3). Add DIAGNOSTIC section name in man page. 1997-06-30 06:40:16 +00:00
Warner Losh 1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Peter Wemm 0da30e9aa7 Import some parts of CSRG 4.4BSD-Lite2 usr.bin sources to fix tree build. 1997-03-11 13:08:12 +00:00