NetBSD Problem Report #6982
Received: (qmail 13153 invoked from network); 11 Feb 1999 00:02:00 -0000
Message-Id: <199902110001.TAA23692@noc.untraceable.net>
Date: Wed, 10 Feb 1999 19:01:53 -0500 (EST)
From: twofsonet@graffiti.com (Andrew Brown)
Reply-To: twofsonet@graffiti.com (Andrew Brown)
To: gnats-bugs@gnats.netbsd.org
Subject: comm(1) should be able to fold case (ala sort)
X-Send-Pr-Version: 3.95
>Number: 6982
>Category: bin
>Synopsis: comm(1) should be able to fold case (ala sort)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Feb 10 16:05:00 +0000 1999
>Closed-Date: Thu Feb 11 00:45:04 +0000 1999
>Last-Modified: Thu Feb 11 00:55:33 +0000 1999
>Originator: Andrew Brown
>Release: -current
>Organization:
none
>Environment:
System: NetBSD noc 1.2 NetBSD 1.2 (null) #4: Fri Oct 24 01:27:28 EDT 1997 root@noc:/usr/src/sys/arch/i386/compile/null i386 :)
>Description:
try to join a few sort -f'ed files using comm and throw up hands in
frustration at the stupidity of the output.
>How-To-Repeat:
% cat list
five
four
one
six
three
two
% cat remove
four
one
seven
six
TWO
% comm list remove
five
four
one
seven
six
TWO
three
two
# (aargh!)
>Fix:
here's a patch to add -f functionality. notice that comm tris to use
strcoll(3), but that just calls strcmp (for now) so this patch'll need
a little work when locales are implemented properly.
diff -cr comm.orig/comm.c comm/comm.c
*** comm.orig/comm.c Sat Oct 18 16:29:31 1997
--- comm/comm.c Wed Feb 10 18:49:37 1999
***************
*** 76,87 ****
FILE *fp1, *fp2;
char *col1, *col2, *col3;
char **p, line1[MAXLINELEN], line2[MAXLINELEN];
setlocale(LC_ALL, "");
file1done = file2done = 0;
flag1 = flag2 = flag3 = 1;
! while ((ch = getopt(argc, argv, "123")) != -1)
switch(ch) {
case '1':
flag1 = 0;
--- 76,89 ----
FILE *fp1, *fp2;
char *col1, *col2, *col3;
char **p, line1[MAXLINELEN], line2[MAXLINELEN];
+ int (*compare)(const char*,const char*);
setlocale(LC_ALL, "");
file1done = file2done = 0;
flag1 = flag2 = flag3 = 1;
! compare = strcoll;
! while ((ch = getopt(argc, argv, "123f")) != -1)
switch(ch) {
case '1':
flag1 = 0;
***************
*** 92,97 ****
--- 94,102 ----
case '3':
flag3 = 0;
break;
+ case 'f':
+ compare = strcasecmp;
+ break;
case '?':
default:
usage();
***************
*** 135,141 ****
}
/* lines are the same */
! if (!(comp = strcoll(line1, line2))) {
read1 = read2 = 1;
if (col3)
if (printf("%s%s", col3, line1) < 0)
--- 140,146 ----
}
/* lines are the same */
! if (!(comp = compare(line1, line2))) {
read1 = read2 = 1;
if (col3)
if (printf("%s%s", col3, line1) < 0)
diff -cr comm.orig/comm.1 comm/comm.1
*** comm.orig/comm.1 Sat Oct 18 16:29:30 1997
--- comm/comm.1 Wed Feb 10 18:49:22 1999
***************
*** 44,50 ****
.Nd select or reject lines common to two files
.Sh SYNOPSIS
.Nm
! .Op Fl 123
.Ar file1 file2
.Sh DESCRIPTION
The
--- 44,50 ----
.Nd select or reject lines common to two files
.Sh SYNOPSIS
.Nm
! .Op Fl 123f
.Ar file1 file2
.Sh DESCRIPTION
The
***************
*** 71,76 ****
--- 71,78 ----
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
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: hubertf
State-Changed-When: Wed Feb 10 16:45:04 PST 1999
State-Changed-Why:
Hi,
I've applied your patch, thanks a lot for submitting!
I've only casted the setlocale() to (void) to shut up
lint.
- Hubert
.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.