aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2018-04-04 17:07:10 +0200
committerDuncaen <mail@duncano.de>2018-04-04 17:32:10 +0200
commit6c666de971e3db30b5e033bea8c74fa5cf9125c1 (patch)
tree244dd0886812d9d7677275338aac83d067e5a603
parent726cf7147fc852ffe83ccd829e54d59f92d189d1 (diff)
downloadlobase-6c666de971e3db30b5e033bea8c74fa5cf9125c1.tar.gz
usr.bin/uniq: update to OPENBSD_6_3
-rw-r--r--usr.bin/uniq/uniq.118
-rw-r--r--usr.bin/uniq/uniq.c13
2 files changed, 21 insertions, 10 deletions
diff --git a/usr.bin/uniq/uniq.1 b/usr.bin/uniq/uniq.1
index 1c3f10c..affd478 100644
--- a/usr.bin/uniq/uniq.1
+++ b/usr.bin/uniq/uniq.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: uniq.1,v 1.19 2016/10/24 13:46:58 schwarze Exp $
+.\" $OpenBSD: uniq.1,v 1.21 2017/12/23 00:52:33 schwarze Exp $
.\" $NetBSD: uniq.1,v 1.5 1994/12/06 07:51:15 jtc Exp $
.\"
.\" Copyright (c) 1991, 1993
@@ -33,7 +33,7 @@
.\"
.\" @(#)uniq.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: October 24 2016 $
+.Dd $Mdocdate: December 23 2017 $
.Dt UNIQ 1
.Os
.Sh NAME
@@ -41,7 +41,7 @@
.Nd report or filter out repeated lines in a file
.Sh SYNOPSIS
.Nm uniq
-.Op Fl c
+.Op Fl ci
.Op Fl d | u
.Op Fl f Ar fields
.Op Fl s Ar chars
@@ -73,6 +73,8 @@ in each input line when doing comparisons.
A field is a string of non-blank characters separated from adjacent fields
by blanks, with blanks considered part of the following field.
Field numbers are one based, i.e., the first field is field one.
+.It Fl i
+Regard lower and upper case ASCII characters as identical.
.It Fl s Ar chars
Ignore the first
.Ar chars
@@ -126,6 +128,10 @@ If unset or set to
.Qq POSIX ,
or an unsupported value, each byte is treated as a character,
and only space and tab are considered blank.
+.Pp
+This variable is ignored for case comparisons.
+Lower and upper case versions of non-ASCII characters are always
+considered different.
.El
.Sh EXIT STATUS
.Ex -std uniq
@@ -138,13 +144,15 @@ utility is compliant with the
.St -p1003.1-2008
specification.
.Pp
-The use of
+The
+.Fl i
+option and the use of
.Fl c
in conjunction with
.Fl d
or
.Fl u
-is an extension to that specification.
+are extensions to that specification.
.Pp
The historic
.Cm + Ns Ar number
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index 7e4d7b8..ae5d76c 100644
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uniq.c,v 1.24 2015/12/19 10:21:01 schwarze Exp $ */
+/* $OpenBSD: uniq.c,v 1.26 2017/12/24 00:11:43 tb Exp $ */
/* $NetBSD: uniq.c,v 1.7 1995/08/31 22:03:48 jtc Exp $ */
/*
@@ -47,7 +47,7 @@
#define MAXLINELEN (8 * 1024)
-int cflag, dflag, uflag;
+int cflag, dflag, iflag, uflag;
int numchars, numfields, repeats;
FILE *file(char *, char *);
@@ -70,7 +70,7 @@ main(int argc, char *argv[])
err(1, "pledge");
obsolete(argv);
- while ((ch = getopt(argc, argv, "cdf:s:u")) != -1) {
+ while ((ch = getopt(argc, argv, "cdf:is:u")) != -1) {
const char *errstr;
switch (ch) {
@@ -87,6 +87,9 @@ main(int argc, char *argv[])
errx(1, "field skip value is %s: %s",
errstr, optarg);
break;
+ case 'i':
+ iflag = 1;
+ break;
case 's':
numchars = (int)strtonum(optarg, 0, INT_MAX,
&errstr);
@@ -149,7 +152,7 @@ main(int argc, char *argv[])
}
/* If different, print; set previous to new value. */
- if (strcmp(t1, t2)) {
+ if ((iflag ? strcasecmp : strcmp)(t1, t2)) {
show(ofp, prevline);
t1 = prevline;
prevline = thisline;
@@ -257,7 +260,7 @@ usage(void)
extern char *__progname;
(void)fprintf(stderr,
- "usage: %s [-c] [-d | -u] [-f fields] [-s chars] [input_file [output_file]]\n",
+ "usage: %s [-ci] [-d | -u] [-f fields] [-s chars] [input_file [output_file]]\n",
__progname);
exit(1);
}