Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171768582
D10694.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D10694.id.diff
View Options
Index: head/usr.bin/uniq/uniq.1
===================================================================
--- head/usr.bin/uniq/uniq.1
+++ head/usr.bin/uniq/uniq.1
@@ -31,7 +31,7 @@
.\" From: @(#)uniq.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd December 17, 2009
+.Dd May 15, 2017
.Dt UNIQ 1
.Os
.Sh NAME
@@ -39,7 +39,8 @@
.Nd report or filter out repeated lines in a file
.Sh SYNOPSIS
.Nm
-.Op Fl c | Fl d | Fl u
+.Op Fl c
+.Op Fl d | Fl u
.Op Fl i
.Op Fl f Ar num
.Op Fl s Ar chars
Index: head/usr.bin/uniq/uniq.c
===================================================================
--- head/usr.bin/uniq/uniq.c
+++ head/usr.bin/uniq/uniq.c
@@ -129,13 +129,6 @@
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;
-
if (argc > 2)
usage();
@@ -182,9 +175,6 @@
}
tprev = convert(prevline);
- if (!cflag && uflag && dflag)
- show(ofp, prevline);
-
tthis = NULL;
while (getline(&thisline, &thisbuflen, ifp) >= 0) {
if (tthis != NULL)
@@ -200,8 +190,7 @@
if (comp) {
/* If different, print; set previous to new value. */
- if (cflag || !dflag || !uflag)
- show(ofp, prevline);
+ show(ofp, prevline);
p = prevline;
b1 = prevbuflen;
prevline = thisline;
@@ -209,8 +198,6 @@
if (tprev != NULL)
free(tprev);
tprev = tthis;
- if (!cflag && uflag && dflag)
- show(ofp, prevline);
thisline = p;
thisbuflen = b1;
tthis = NULL;
@@ -220,8 +207,7 @@
}
if (ferror(ifp))
err(1, "%s", ifn);
- if (cflag || !dflag || !uflag)
- show(ofp, prevline);
+ show(ofp, prevline);
exit(0);
}
@@ -286,9 +272,11 @@
show(FILE *ofp, const char *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);
}
@@ -351,6 +339,6 @@
usage(void)
{
(void)fprintf(stderr,
-"usage: uniq [-c | -d | -u] [-i] [-f fields] [-s chars] [input [output]]\n");
+"usage: uniq [-c] [-d | -u] [-i] [-f fields] [-s chars] [input [output]]\n");
exit(1);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Sep 14, 9:38 AM (13 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38900290
Default Alt Text
D10694.id.diff (2 KB)
Attached To
Mode
D10694: uniq(1): Allow -c to be used alongside -d or -u
Attached
Detach File
Event Timeline
Log In to Comment