diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-02-17 03:35:50 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-02-17 03:35:50 +0000 |
commit | fb5a3fa6a2137d17687fbb8eb8e7abe371925a4b (patch) | |
tree | b25bad43973ccf94b518a8bf627c5179eb86f1f4 | |
parent | 9094e8495bc69620e8a25405a9e2f38d813db1c9 (diff) |
-f option for case folding; twofsonet@graffiti.com
-rw-r--r-- | usr.bin/comm/comm.1 | 6 | ||||
-rw-r--r-- | usr.bin/comm/comm.c | 13 |
2 files changed, 13 insertions, 6 deletions
diff --git a/usr.bin/comm/comm.1 b/usr.bin/comm/comm.1 index 78a461e56b0..93093a1afb3 100644 --- a/usr.bin/comm/comm.1 +++ b/usr.bin/comm/comm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: comm.1,v 1.3 1998/09/23 04:32:38 aaron Exp $ +.\" $OpenBSD: comm.1,v 1.4 1999/02/17 03:35:49 deraadt Exp $ .\" $NetBSD: comm.1,v 1.4 1995/03/26 09:25:50 glass Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 @@ -45,7 +45,7 @@ .Nd select or reject lines common to two files .Sh SYNOPSIS .Nm comm -.Op Fl 123 +.Op Fl 123f .Ar file1 file2 .Sh DESCRIPTION The @@ -72,6 +72,8 @@ Suppress printing of column 1. Suppress printing of column 2. .It Fl 3 Suppress printing of column 3. +.It Fl f +Fold case in line comparisons. .El .Pp Each column will have a number of tab characters prepended to it diff --git a/usr.bin/comm/comm.c b/usr.bin/comm/comm.c index f83ccfaea1b..a0ecbd81d1a 100644 --- a/usr.bin/comm/comm.c +++ b/usr.bin/comm/comm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comm.c,v 1.2 1996/06/26 05:32:18 deraadt Exp $ */ +/* $OpenBSD: comm.c,v 1.3 1999/02/17 03:35:49 deraadt Exp $ */ /* $NetBSD: comm.c,v 1.10 1995/09/05 19:57:43 jtc Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)comm.c 8.4 (Berkeley) 5/4/95"; #endif -static char rcsid[] = "$OpenBSD: comm.c,v 1.2 1996/06/26 05:32:18 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: comm.c,v 1.3 1999/02/17 03:35:49 deraadt Exp $"; #endif /* not lint */ #include <err.h> @@ -76,11 +76,13 @@ main(argc, argv) FILE *fp1, *fp2; char *col1, *col2, *col3; char **p, line1[MAXLINELEN], line2[MAXLINELEN]; + int (*compare) __P((const char * ,const char *)); setlocale(LC_ALL, ""); flag1 = flag2 = flag3 = 1; - while ((ch = getopt(argc, argv, "123")) != -1) + compare = strcoll; + while ((ch = getopt(argc, argv, "123f")) != -1) switch(ch) { case '1': flag1 = 0; @@ -91,6 +93,9 @@ main(argc, argv) case '3': flag3 = 0; break; + case 'f': + compare = strcasecmp; + break; case '?': default: usage(); @@ -134,7 +139,7 @@ main(argc, argv) } /* lines are the same */ - if (!(comp = strcoll(line1, line2))) { + if (!(comp = compare(line1, line2))) { read1 = read2 = 1; if (col3) if (printf("%s%s", col3, line1) < 0) |