Module Name: src
Committed By: dholland
Date: Wed Oct 6 06:43:26 UTC 2010
Modified Files:
src/usr.bin/uniq: uniq.1 uniq.c
Log Message:
Allow -c with -d/-u. While uniq -cu isn't that useful, uniq -cd often is.
No objection on tech-userlevel, and the arbitrary restriction has been
irritating me for ages.
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/uniq/uniq.1
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/uniq/uniq.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/uniq/uniq.1
diff -u src/usr.bin/uniq/uniq.1:1.11 src/usr.bin/uniq/uniq.1:1.12
--- src/usr.bin/uniq/uniq.1:1.11 Sat Jan 6 02:18:24 2007
+++ src/usr.bin/uniq/uniq.1 Wed Oct 6 06:43:26 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: uniq.1,v 1.11 2007/01/06 02:18:24 christos Exp $
+.\" $NetBSD: uniq.1,v 1.12 2010/10/06 06:43:26 dholland Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,7 +40,7 @@
.Nd report or filter out repeated lines in a file
.Sh SYNOPSIS
.Nm
-.Op Fl c | Fl d | Fl u
+.Op Fl cdu
.Op Fl f Ar fields
.Op Fl s Ar chars
.Oo
Index: src/usr.bin/uniq/uniq.c
diff -u src/usr.bin/uniq/uniq.c:1.15 src/usr.bin/uniq/uniq.c:1.16
--- src/usr.bin/uniq/uniq.c:1.15 Mon Jul 21 14:19:27 2008
+++ src/usr.bin/uniq/uniq.c Wed Oct 6 06:43:26 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: uniq.c,v 1.15 2008/07/21 14:19:27 lukem Exp $ */
+/* $NetBSD: uniq.c,v 1.16 2010/10/06 06:43:26 dholland Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)uniq.c 8.3 (Berkeley) 5/4/95";
#endif
-__RCSID("$NetBSD: uniq.c,v 1.15 2008/07/21 14:19:27 lukem Exp $");
+__RCSID("$NetBSD: uniq.c,v 1.16 2010/10/06 06:43:26 dholland Exp $");
#endif /* not lint */
#include <err.h>
@@ -107,13 +107,6 @@
done: argc -= optind;
argv +=optind;
- /* If no flags are set, default is -d -u. */
- if (cflag) {
- if (dflag || uflag)
- usage();
- } else if (!dflag && !uflag)
- dflag = uflag = 1;
-
switch(argc) {
case 0:
ifp = stdin;
@@ -192,10 +185,13 @@
show(FILE *ofp, const char *str)
{
- if (cflag && *str)
+ if ((dflag && repeats == 0) || (uflag && repeats > 0))
+ return;
+ if (cflag) {
(void)fprintf(ofp, "%4d %s", repeats + 1, str);
- if ((dflag && repeats) || (uflag && !repeats))
+ } else {
(void)fprintf(ofp, "%s", str);
+ }
}
static const char *