summaryrefslogtreecommitdiffstats
path: root/usr.bin/uniq/uniq.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1997-09-07 15:09:22 +0000
committerjoerg <joerg@FreeBSD.org>1997-09-07 15:09:22 +0000
commitcaa2e7e2da294fd9afa91fec5201e2e7cd44ba9b (patch)
tree17ccdf70a6799a645b2de5790c7b81f4fe69b15a /usr.bin/uniq/uniq.c
parentfc4aea9e02bf57962e9fbec614769f5f64003e3d (diff)
downloadFreeBSD-src-caa2e7e2da294fd9afa91fec5201e2e7cd44ba9b.zip
FreeBSD-src-caa2e7e2da294fd9afa91fec5201e2e7cd44ba9b.tar.gz
Teach comm(1) and uniq(1) about an option for case-insensitive work.
PR: 3042 Submitted by: graphix@iastate.edu (Kent Vander Velden)
Diffstat (limited to 'usr.bin/uniq/uniq.c')
-rw-r--r--usr.bin/uniq/uniq.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index 972581f..8f302ca 100644
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)uniq.c 8.3 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: uniq.c,v 1.3 1997/08/21 06:51:10 charnier Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -75,9 +75,10 @@ main (argc, argv)
FILE *ifp, *ofp;
int ch;
char *prevline, *thisline, *p;
+ int iflag = 0, comp;
obsolete(argv);
- while ((ch = getopt(argc, argv, "-cdf:s:u")) != -1)
+ while ((ch = getopt(argc, argv, "-cdif:s:u")) != -1)
switch (ch) {
case '-':
--optind;
@@ -88,6 +89,9 @@ main (argc, argv)
case 'd':
dflag = 1;
break;
+ case 'i':
+ iflag = 1;
+ break;
case 'f':
numfields = strtol(optarg, &p, 10);
if (numfields < 0 || *p)
@@ -152,7 +156,12 @@ done: argc -= optind;
}
/* If different, print; set previous to new value. */
- if (strcmp(t1, t2)) {
+ if (iflag)
+ comp = strcasecmp(t1, t2);
+ else
+ comp = strcmp(t1, t2);
+
+ if (comp) {
show(ofp, prevline);
t1 = prevline;
prevline = thisline;
@@ -245,6 +254,6 @@ static void
usage()
{
(void)fprintf(stderr,
- "usage: uniq [-c | -du] [-f fields] [-s chars] [input [output]]\n");
+ "usage: uniq [-c | -du | -i] [-f fields] [-s chars] [input [output]]\n");
exit(1);
}
OpenPOWER on IntegriCloud