Commit graph

54 commits

Author SHA1 Message Date
Andrey A. Chernov d2796d06d3 Add SIZE_MAX overflow check 2010-03-09 21:06:01 +00:00
Andrey A. Chernov 5eaad26eaf 1) Reimplement (differently) unlimited line length restricted in prev.
commit.

2) Honor missing the very last \n (if absent) on output.
2010-03-08 19:40:22 +00:00
Andrey A. Chernov aa6c3b4c60 Remove vestiges of old %-format which prevents build on amd64 2010-03-06 22:38:38 +00:00
Andrey A. Chernov d4c2dafa6c 1) Rewrite input processing to not exit with error on the first EILSEQ found
in the input data but fallback to "binary equal" check instead.

POSIX says: "The input file shall be a text file", nothing more,
so the text file with illegal sequence is valid input.
BTW, GNU sort does not fails on EILSEQ too.

2) Speedup input processing a bit in complex cases like skipping fields,
chars or ignore case.

3) Enforce the implied LINE_MAX limit (from POSIX definition of "text file"
and POSIX uniq(1) description).
2010-03-06 19:21:57 +00:00
Jaakko Heinonen a8092021a0 Sync getline() with comm(1):
- 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-17 17:03:47 +00:00
Jaakko Heinonen 698f926389 The input line length limit mentioned on the manual page was removed by
r176119.

Approved by:	trasz (mentor)
2009-12-17 16:59:19 +00:00
Guy Helmer 8a4313c59c Fix truncation of lines at LINE_MAX characters by dynamically
extending line buffers.

PR:		bin/76578
2008-02-08 23:04:13 +00:00
Juli Mallett 26cfaf71bb Fix typo. 2007-05-17 00:19:56 +00:00
Juli Mallett 36c5e18daa o) Correct for missing whitespace.
o) We don't need to check if ifp == stdin to give the filename, since we already
   know that ifn will be "stdin" if it is.
2007-05-17 00:18:01 +00:00
Juli Mallett 2fdb65fd82 Fix confusing misindentation of a closing-brace. (It goes with the switch, not
with the while.)
2007-05-17 00:11:58 +00:00
Giorgos Keramidas 1833a7eaee Document that uniq(1) limits input line length to LINE_MAX characters.
PR:		docs/107578
Submitted by:	Jan Schaumann, jschauma.at.netmeister.org
MFC after:	3 days
2007-01-15 23:25:51 +00:00
Ruslan Ermilov a866e17077 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
Tim J. Robbins 0cd82603c0 Remove a bogus check that caused empty lines not to be counted when the
-c option was given.

Noticed by:	sf
2004-09-14 12:01:18 +00:00
Tim J. Robbins 3fead394ea Add support for multibyte characters. 2004-07-02 23:43:05 +00:00
Ruslan Ermilov 6a3e8b0adc Mechanically kill hard sentence breaks. 2004-07-02 22:22:35 +00:00
Tim J. Robbins e90e39d92f Document the fact that uniq(1) does not recognize multibyte characters. 2004-06-24 16:29:28 +00:00
Tim J. Robbins 058d268671 Mention the environment variables that affect the execution of uniq.
Of particular interest is the fact that LC_COLLATE affects how uniq
determines whether lines are equal. This was the subject of a fairly heated
debate a year or so ago, and it turns out that the current behaviour is
correct and that the standard contained an error.

Now that the standard has been corrected by Cor. 1-2002, refer to 1003.1-2001
instead of the 1992 edition in the Standards section.
2003-04-12 04:17:14 +00:00
Ruslan Ermilov 06e482e60a mdoc(7) police: markup polishing.
Approved by:	re
2002-11-26 17:33:37 +00:00
David Malone f4ac32def2 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
2002-09-04 23:29:10 +00:00
Tim J. Robbins fa745288a7 Correct the History section; uniq(1) appeared at least as early as V3.
Move the section to after Standards.
2002-07-05 09:44:47 +00:00
Tim J. Robbins 898e5fd3f3 Remove redundant description of input_file and output_file arguments. 2002-07-05 09:37:34 +00:00
Tim J. Robbins 7dd4ac68f1 Use err instead of errx when malloc fails. "malloc" is not a helpful
error message.
2002-07-05 09:28:13 +00:00
Tim J. Robbins 382ac430cd Skip fields in the manner required by POSIX, and the way V7 did it.
MFC after:	1 week
2002-06-21 07:59:31 +00:00
Tim J. Robbins 4e774f7fbe Newline characters should not participate in line comparisons. Only apparent
when -s is used or the last line of the file is missing a newline.
Noticed by the textutils test suite.

MFC after:	1 week
2002-06-21 07:08:34 +00:00
Juli Mallett 6fc8ba94c6 Note that this appeared at least as early as PWB UNIX.
Use the literal string 'PWB UNIX', as we still have no .At macro for it.
2002-06-10 22:59:59 +00:00
Andrey A. Chernov e12155c834 Back out rev 1.19 because
1) It breaks uniq for real life languages when "substitute" directive used in
the collating table.
2) It breaks uniq usage in tool chain with other localized utilities which
use collate.
3) To follow LC_COLLATE it is directly allowed for uniq
by POSIX P1003.1 Draft7 (7.3.2). It means that rev 1.19 gains no additional
POSIX conformance.
2002-06-06 13:44:14 +00:00
Tim J. Robbins 5935c07540 Compare lines with strcmp(), not strcoll(). We are interested only in
equality, not ordering.
2002-06-06 03:13:08 +00:00
Tim J. Robbins 6a8be5c4f2 Sync usage() with manual page synopsis. 2002-06-06 03:05:30 +00:00
Tim J. Robbins 38b1ff46af Accept an input file name of "-" to mean standard input, as required by
P1003.2.
2002-05-30 00:07:14 +00:00
Tim J. Robbins a9986a105a Fields should be separated by <blank>s, not <space>s according to P1003.2. 2002-05-29 23:55:44 +00:00
Tim J. Robbins fc63032590 Don't bother trying to handle "-" arguments ourselves, getopt(3) already
does this for us.
2002-05-29 23:52:55 +00:00
Tom Rhodes e223a77118 Add the word ``fields'' to the description, and change an instance from
fields to num in the SYNOPSIS

Noticed by:	keramida
2002-05-24 19:12:02 +00:00
Tom Rhodes 69cc776cd6 Reword a small part of the uniq(1) manual page to help reduce word
duplication (ie: fields fields).

PR:		38161
Reviewed by:	keramida
MFC after:	3 days
2002-05-21 16:54:58 +00:00
Andrey A. Chernov b285e2683f Use LC_ALL to pick collate
Noticed by:	tjr
2002-04-19 08:16:01 +00:00
Warner Losh 3f330d7d1a remove __P 2002-03-22 01:42:45 +00:00
Mark Murray 7e52b238c7 WARNS=2 is going to become the default, so remove it from here. 2001-12-11 23:27:23 +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
David Malone c83caf7b8d Warns cleanups. Add FreeBSD ID to Makefile. 2001-12-03 21:37:35 +00:00
Ruslan Ermilov d628d776c4 mdoc(7) police: utilize the new .Ex macro. 2001-08-15 09:09:47 +00:00
Philippe Charnier dbb9d8f826 Add DIAGNOSTICS section name 2000-03-26 15:06:46 +00:00
Andrey A. Chernov 579f26f4a8 fix fatal typo 1999-12-10 13:06:53 +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 e91cb30636 Cosmetique: use standard prototypes scheme
Back out prev. change: toupper is more compatible with sort -f
1999-10-24 04:41:31 +00:00
Andrey A. Chernov 4346bfd3f0 toupper->tolower to match what strcasecmp does 1999-10-24 04:21:42 +00:00
Andrey A. Chernov c02e589456 Use strcoll to provide the same results as sort and comm
Use LINE_MAX for max line size (as comm does)
1999-10-24 04:08:15 +00:00
Peter Wemm c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Bill Fumerola faaf9d7f46 Grammar nits, double negatives
PR:		docs/10491
Submitted By:	Tom Hukins <tom@eborcom.com>
1999-03-15 02:57:29 +00:00
Andrey A. Chernov 0c312497c7 Localize it 1998-03-08 20:56:43 +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 213915d456 Use err(3) instead of local redefinition. 1997-08-21 06:51:10 +00:00