Up to [local] / src / usr.bin / uniq
Request diff between arbitrary revisions
Default branch: MAIN
Revision 1.33 / (download) - annotate - [select for diffs], Sat Jan 1 18:20:52 2022 UTC (2 years, 5 months ago) by cheloha
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE,
OPENBSD_7_5,
OPENBSD_7_4_BASE,
OPENBSD_7_4,
OPENBSD_7_3_BASE,
OPENBSD_7_3,
OPENBSD_7_2_BASE,
OPENBSD_7_2,
OPENBSD_7_1_BASE,
OPENBSD_7_1,
HEAD
Changes since 1.32: +9 -16 lines
Diff to previous 1.32 (colored) to selected 1.25 (colored)
uniq(1): miscellaneous style(9)-ish stuff - Include what you use: + Add <strings.h> for strcasecmp(3). + Drop <errno.h>, unused. - Pull the "errstr" declaration out of the getopt(3) loop up to the top of main(). - Align the strtonum(3) error messages with the argument names in the uniq.1 manpage and the usage string. They are referred to as "chars" and "fields". - Trim some whitespace. - Return from main() instead of exit(3). - De-(void) fprintf(3). - Prefer getprogname(3) to __progname.
Revision 1.32 / (download) - annotate - [select for diffs], Sat Jan 1 17:44:18 2022 UTC (2 years, 5 months ago) by cheloha
Branch: MAIN
Changes since 1.31: +7 -8 lines
Diff to previous 1.31 (colored) to selected 1.25 (colored)
uniq(1): bump numchars, numfields from int to long long Also bump repeats from int to unsigned long long. While here, don't cast the result of strtonum() and unwrap some lines.
Revision 1.31 / (download) - annotate - [select for diffs], Sat Jan 1 02:20:38 2022 UTC (2 years, 5 months ago) by cheloha
Branch: MAIN
Changes since 1.30: +19 -39 lines
Diff to previous 1.30 (colored) to selected 1.25 (colored)
uniq(1): freopen(3) stdin, stdout uniq(1) defaults to stdin and stdout, has exactly one input and one output, and permits the user to replace the default input and/or the default output with a given file. freopen(3) is the right idiom in this context. Get rid of file() and the extra FILE pointers. Switch from fprintf(3) to printf(3). While here, const the "str" argument to show(). Thread: https://marc.info/?l=openbsd-tech&m=164078603312936&w=2 ok millert@
Revision 1.30 / (download) - annotate - [select for diffs], Fri Dec 24 17:59:28 2021 UTC (2 years, 5 months ago) by cheloha
Branch: MAIN
Changes since 1.29: +16 -12 lines
Diff to previous 1.29 (colored) to selected 1.25 (colored)
uniq(1): skip() each input line only once In uniq(1), skip() is very expensive. We should only do it once per input line. Doing it more than once is redundant, anyway. Thread: https://marc.info/?l=openbsd-tech&m=163950278018535&w=2 ok millert@
Revision 1.29 / (download) - annotate - [select for diffs], Wed Nov 17 23:09:38 2021 UTC (2 years, 6 months ago) by cheloha
Branch: MAIN
Changes since 1.28: +11 -5 lines
Diff to previous 1.28 (colored) to selected 1.25 (colored)
uniq(1): ignore trailing newlines when comparing lines POSIX.1-2008 tweaked the uniq definition in light of AGI 1003.1-2001 #133. uniq must now *ignore* the trailing newline when comparing lines from the input. In practice this means that if the last line in the input is missing a trailing newline it isn't necessarily different from the line preceding it. So, uniq(1) now stubs the trailing newline before doing any line comparisons. For sake of simplicity, this patch introduces a second change: if the last line in the input is missing a trailing newline and we choose to print the line, a newline is appended when we print it. Adopting the newline change aligns our implementation with with POSIX.1-2008 (which we already claim in the manpage). Adopting both changes aligns our behavior with that of FreeBSD and GNU uniq. For better or worse, OpenBSD's uniq no longer behaves like NetBSD's uniq in this corner case. References: POSIX.1-2001 uniq: https://pubs.opengroup.org/onlinepubs/009695399/utilities/uniq.html Austin Group Interpretation 1003.1-2001 #133: https://collaboration.opengroup.org/austin/interps/documents/14355/AI-133.txt POSIX.1-2008 uniq: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/uniq.html -- Discussed with millert@. With input from schwarze@. Positive feedback from bcallah@. Thread: https://marc.info/?l=openbsd-tech&m=163581613829524&w=2 ok millert@
Revision 1.28 / (download) - annotate - [select for diffs], Mon Nov 1 23:20:35 2021 UTC (2 years, 7 months ago) by cheloha
Branch: MAIN
Changes since 1.27: +23 -13 lines
Diff to previous 1.27 (colored) to selected 1.25 (colored)
uniq(1): support arbitrarily long input lines Switch from fgets(3) to getline(3) to support input lines of any length. Tested by sthen@, who uncovered a dumb bug that cut throughput in half. getline(3) is indeed slower than fgets(3), but not *twice* as slow. millert@ suggests that preallocating both line buffers might be worthwhile. I will need to do some additional testing to figure out whether 8KB buffers (like we had for fgets(3)) are appropriate starting lengths. For now I am not preallocating either buffer. ok millert@ sthen@
Revision 1.27 / (download) - annotate - [select for diffs], Tue Jul 31 02:55:57 2018 UTC (5 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE,
OPENBSD_7_0,
OPENBSD_6_9_BASE,
OPENBSD_6_9,
OPENBSD_6_8_BASE,
OPENBSD_6_8,
OPENBSD_6_7_BASE,
OPENBSD_6_7,
OPENBSD_6_6_BASE,
OPENBSD_6_6,
OPENBSD_6_5_BASE,
OPENBSD_6_5,
OPENBSD_6_4_BASE,
OPENBSD_6_4
Changes since 1.26: +2 -2 lines
Diff to previous 1.26 (colored) to selected 1.25 (colored)
KNF
Revision 1.26 / (download) - annotate - [select for diffs], Sun Dec 24 00:11:43 2017 UTC (6 years, 5 months ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE,
OPENBSD_6_3
Changes since 1.25: +2 -2 lines
Diff to previous 1.25 (colored)
Avoid comparing equal lines twice when running without -i. From kshe, ok jca
Revision 1.25 / (download) - annotate - [selected], Thu Dec 21 10:05:59 2017 UTC (6 years, 5 months ago) by tb
Branch: MAIN
Changes since 1.24: +8 -5 lines
Diff to previous 1.24 (colored)
Add an -i option for case insensitive comparison of lines. From Claus Assmann with minor tweaks by me. ok millert
Revision 1.24 / (download) - annotate - [select for diffs], Sat Dec 19 10:21:01 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE,
OPENBSD_6_2,
OPENBSD_6_1_BASE,
OPENBSD_6_1,
OPENBSD_6_0_BASE,
OPENBSD_6_0,
OPENBSD_5_9_BASE,
OPENBSD_5_9
Changes since 1.23: +28 -7 lines
Diff to previous 1.23 (colored) to selected 1.25 (colored)
UTF-8 support: Let -f recognize non-ASCII blank characters and let -s count characters rather than bytes. OK zhuk@ bentley@
Revision 1.23 / (download) - annotate - [select for diffs], Mon Nov 2 20:25:42 2015 UTC (8 years, 7 months ago) by mmcc
Branch: MAIN
Changes since 1.22: +2 -2 lines
Diff to previous 1.22 (colored) to selected 1.25 (colored)
Cast isdigit()'s argument to an unsigned char. ok millert@, jca@
Revision 1.22 / (download) - annotate - [select for diffs], Fri Oct 9 01:37:09 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.21: +5 -5 lines
Diff to previous 1.21 (colored) to selected 1.25 (colored)
Change all tame callers to namechange to pledge(2).
Revision 1.21 / (download) - annotate - [select for diffs], Sun Oct 4 04:56:50 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.20: +2 -2 lines
Diff to previous 1.20 (colored) to selected 1.25 (colored)
Repair tame() error check to be == -1
Revision 1.20 / (download) - annotate - [select for diffs], Sat Oct 3 02:18:20 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.19: +7 -1 lines
Diff to previous 1.19 (colored) to selected 1.25 (colored)
uniq has a complicated initialization around getopt. beforehands, we can tame "stdio rpath wpath cpath"; all three paths abilities are needed for it to setup the right files (worst case spotted by sthen). later once the files are opened, the program is only looking at strings and outputing via stdio functions, so we can tame "stdio".
Revision 1.19 / (download) - annotate - [select for diffs], Tue Nov 26 19:25:39 2013 UTC (10 years, 6 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE,
OPENBSD_5_8,
OPENBSD_5_7_BASE,
OPENBSD_5_7,
OPENBSD_5_6_BASE,
OPENBSD_5_6,
OPENBSD_5_5_BASE,
OPENBSD_5_5
Changes since 1.18: +3 -3 lines
Diff to previous 1.18 (colored) to selected 1.25 (colored)
unsigned char casts for ctype ok okan
Revision 1.18 / (download) - annotate - [select for diffs], Tue Oct 27 23:59:46 2009 UTC (14 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE,
OPENBSD_5_4,
OPENBSD_5_3_BASE,
OPENBSD_5_3,
OPENBSD_5_2_BASE,
OPENBSD_5_2,
OPENBSD_5_1_BASE,
OPENBSD_5_1,
OPENBSD_5_0_BASE,
OPENBSD_5_0,
OPENBSD_4_9_BASE,
OPENBSD_4_9,
OPENBSD_4_8_BASE,
OPENBSD_4_8,
OPENBSD_4_7_BASE,
OPENBSD_4_7
Changes since 1.17: +1 -14 lines
Diff to previous 1.17 (colored) to selected 1.25 (colored)
rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
Revision 1.17 / (download) - annotate - [select for diffs], Sun Nov 11 17:50:29 2007 UTC (16 years, 7 months ago) by kili
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE,
OPENBSD_4_6,
OPENBSD_4_5_BASE,
OPENBSD_4_5,
OPENBSD_4_4_BASE,
OPENBSD_4_4,
OPENBSD_4_3_BASE,
OPENBSD_4_3
Changes since 1.16: +3 -3 lines
Diff to previous 1.16 (colored) to selected 1.25 (colored)
Mention that -cd and -cu are possible, and that it's an extension to POSIX. discussed with jmc and otto ok jmc
Revision 1.16 / (download) - annotate - [select for diffs], Fri Nov 9 20:04:03 2007 UTC (16 years, 7 months ago) by kili
Branch: MAIN
Changes since 1.15: +19 -23 lines
Diff to previous 1.15 (colored) to selected 1.25 (colored)
Allow -c in conjunction with -d (and -u). If field skipping is active, don't skip beyond the last non-blank of a field, and use isblank() instead of isspace() -- POSIX states that the longest string matching [[:blank:]]*[^[:blank:]]* makes up a field. Don't skip over trailing newlines. Help, testing and ok millert@
Revision 1.15 / (download) - annotate - [select for diffs], Fri Apr 7 05:10:02 2006 UTC (18 years, 2 months ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE,
OPENBSD_4_2,
OPENBSD_4_1_BASE,
OPENBSD_4_1,
OPENBSD_4_0_BASE,
OPENBSD_4_0
Changes since 1.14: +34 -22 lines
Diff to previous 1.14 (colored) to selected 1.25 (colored)
Stylistic changes initially from Thordur I. Bjornsson, more cleanup and delinting from me. OK otto@ and jaredy@
Revision 1.14 / (download) - annotate - [select for diffs], Tue Jun 3 02:56:21 2003 UTC (21 years ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE,
OPENBSD_3_9,
OPENBSD_3_8_BASE,
OPENBSD_3_8,
OPENBSD_3_7_BASE,
OPENBSD_3_7,
OPENBSD_3_6_BASE,
OPENBSD_3_6,
OPENBSD_3_5_BASE,
OPENBSD_3_5,
OPENBSD_3_4_BASE,
OPENBSD_3_4
Changes since 1.13: +3 -7 lines
Diff to previous 1.13 (colored) to selected 1.25 (colored)
Remove the advertising clause in the UCB license which Berkeley rescinded 22 July 1999. Proofed by myself and Theo.
Revision 1.13 / (download) - annotate - [select for diffs], Sat Apr 5 16:17:26 2003 UTC (21 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.12: +5 -5 lines
Diff to previous 1.12 (colored) to selected 1.25 (colored)
strlcpy whack; miod ok
Revision 1.12 / (download) - annotate - [select for diffs], Sun Dec 8 22:43:54 2002 UTC (21 years, 6 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE,
OPENBSD_3_3
Changes since 1.11: +4 -2 lines
Diff to previous 1.11 (colored) to selected 1.25 (colored)
Treat a file name of "-" as either stdin or stdout, depending on position.
Revision 1.11 / (download) - annotate - [select for diffs], Sun Dec 8 06:40:44 2002 UTC (21 years, 6 months ago) by millert
Branch: MAIN
Changes since 1.10: +4 -7 lines
Diff to previous 1.10 (colored) to selected 1.25 (colored)
No need to try and catch "--" by hand, getopt() does it for us.
Revision 1.10 / (download) - annotate - [select for diffs], Sat Jul 13 06:04:24 2002 UTC (21 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_2_BASE,
OPENBSD_3_2
Changes since 1.9: +9 -16 lines
Diff to previous 1.9 (colored) to selected 1.25 (colored)
ansi
Revision 1.9 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:56 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE,
OPENBSD_3_1
Changes since 1.8: +7 -7 lines
Diff to previous 1.8 (colored) to selected 1.25 (colored)
Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.
Revision 1.8 / (download) - annotate - [select for diffs], Mon Nov 19 19:02:17 2001 UTC (22 years, 6 months ago) by mpech
Branch: MAIN
Changes since 1.7: +5 -5 lines
Diff to previous 1.7 (colored) to selected 1.25 (colored)
kill more registers millert@ ok
Revision 1.7 / (download) - annotate - [select for diffs], Thu Jul 12 05:17:28 2001 UTC (22 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE,
OPENBSD_3_0
Changes since 1.6: +3 -3 lines
Diff to previous 1.6 (colored) to selected 1.25 (colored)
first pass at a -Wall cleanup
Revision 1.5.12.1 / (download) - annotate - [select for diffs], Fri Oct 6 21:16:17 2000 UTC (23 years, 8 months ago) by jason
Branch: OPENBSD_2_7
Changes since 1.5: +3 -3 lines
Diff to previous 1.5 (colored) next main 1.6 (colored) to selected 1.25 (colored)
Pull in patch from current (even more to come): Fix (millert): warnx?/errx? paranoia (use "%s" not a bare string unless it is a constant). These are not security holes but it is worth fixing them anyway both for robustness and so folks looking for examples in the tree are not misled into doing something potentially dangerous. Furthermore, it is a bad idea to assume that pathnames will not include '%' in them and that error routines don't return strings with '%' in them (especially in light of the possibility of locales).
Revision 1.6 / (download) - annotate - [select for diffs], Fri Jun 30 16:00:22 2000 UTC (23 years, 11 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE,
OPENBSD_2_9,
OPENBSD_2_8_BASE,
OPENBSD_2_8
Changes since 1.5: +3 -3 lines
Diff to previous 1.5 (colored) to selected 1.25 (colored)
warnx?/errx? paranoia (use "%s" not a bare string unless it is a constant). These are not security holes but it is worth fixing them anyway both for robustness and so folks looking for examples in the tree are not misled into doing something potentially dangerous. Furthermore, it is a bad idea to assume that pathnames will not include '%' in them and that error routines don't return strings with '%' in them (especially in light of the possibility of locales).
Revision 1.5 / (download) - annotate - [select for diffs], Fri Jul 25 22:21:40 1997 UTC (26 years, 10 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_2_7_BASE,
OPENBSD_2_6_BASE,
OPENBSD_2_6,
OPENBSD_2_5_BASE,
OPENBSD_2_5,
OPENBSD_2_4_BASE,
OPENBSD_2_4,
OPENBSD_2_3_BASE,
OPENBSD_2_3,
OPENBSD_2_2_BASE,
OPENBSD_2_2
Branch point for: OPENBSD_2_7
Changes since 1.4: +8 -37 lines
Diff to previous 1.4 (colored) to selected 1.25 (colored)
use err(3)
Revision 1.4 / (download) - annotate - [select for diffs], Fri Jul 25 21:05:46 1997 UTC (26 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.3: +5 -5 lines
Diff to previous 1.3 (colored) to selected 1.25 (colored)
#if __STDC__ --> #ifdef __STDC__
Revision 1.3 / (download) - annotate - [select for diffs], Wed Jan 15 23:43:28 1997 UTC (27 years, 5 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_1_BASE,
OPENBSD_2_1
Changes since 1.2: +3 -3 lines
Diff to previous 1.2 (colored) to selected 1.25 (colored)
getopt(3) returns -1 when out of args, not EOF, whee!
Revision 1.2 / (download) - annotate - [select for diffs], Wed Jun 26 05:42:13 1996 UTC (27 years, 11 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_0_BASE,
OPENBSD_2_0
Changes since 1.1: +2 -1 lines
Diff to previous 1.1 (colored) to selected 1.25 (colored)
rcsid
Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Wed Oct 18 08:46:29 1995 UTC (28 years, 7 months ago) by deraadt
CVS Tags: netbsd_1_1
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored) to selected 1.25 (colored)
initial import of NetBSD tree
Revision 1.1 / (download) - annotate - [select for diffs], Wed Oct 18 08:46:29 1995 UTC (28 years, 7 months ago) by deraadt
Branch: MAIN
Diff to selected 1.25 (colored)
Initial revision