Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Mar 1997 17:47:53 -0800 (PST)
From:      graphix@iastate.edu
To:        freebsd-gnats-submit@freebsd.org
Subject:   bin/3042: comm and uniq do not have a case insensitive mode
Message-ID:  <199703200147.RAA12139@freefall.freebsd.org>
Resent-Message-ID: <199703200150.RAA12390@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         3042
>Category:       bin
>Synopsis:       comm and uniq do not have a case insensitive mode
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 19 17:50:01 PST 1997
>Last-Modified:
>Originator:     Kent Vander Velden
>Organization:
Iowa State University
>Release:        FreeBSD-"CURRENT"
>Environment:
FreeBSD pseudo.cc.iastate.edu 3.0-CURRENT FreeBSD 3.0-CURRENT #0: Sun Feb  9 02:37:42 CST 1997     kent@pseudo.cc.iastate.edu:/usr/src/sys/compile/PSEUDO  i386

>Description:
comm and uniq do not have a case insensitive mode.  While these commands
generally do not have this mode, it should would be helpful in some
siutations.
>How-To-Repeat:

>Fix:
Index: comm/comm.1
===================================================================
RCS file: /jaz/FreeBSD-CVS/src/usr.bin/comm/comm.1,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 comm.1
*** comm.1      1994/05/27 12:30:58     1.1.1.1
--- comm.1      1997/03/20 00:56:56
***************
*** 42,48 ****
  .Nd select or reject lines common to two files
  .Sh SYNOPSIS
  .Nm comm
! .Op Fl 123
  .Ar file1 file2
  .Sh DESCRIPTION
  The
--- 42,48 ----
  .Nd select or reject lines common to two files
  .Sh SYNOPSIS
  .Nm comm
! .Op Fl 123i
  .Ar file1 file2
  .Sh DESCRIPTION
  The
***************
*** 69,74 ****
--- 69,76 ----
  Suppress printing of column 2.
  .It Fl 3
  Suppress printing of column 3.
+ .It Fl i
+ Case insensitive comparison of lines.
  .El
  .Pp
  Each column will have a number of tab characters prepended to it
Index: comm/comm.c
===================================================================
RCS file: /jaz/FreeBSD-CVS/src/usr.bin/comm/comm.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 comm.c
*** comm.c      1997/03/11 13:04:26     1.1.1.2
--- comm.c      1997/03/20 01:01:39
***************
*** 66,78 ****
        char *argv[];
  {
        int comp, file1done, file2done, read1, read2;
!       int ch, flag1, flag2, flag3;
        FILE *fp1, *fp2;
        char *col1, *col2, *col3;
        char **p, line1[MAXLINELEN], line2[MAXLINELEN];
  
        flag1 = flag2 = flag3 = 1;
!       while ((ch = getopt(argc, argv, "-123")) != EOF)
                switch(ch) {
                case '-':
                        --optind;
--- 66,79 ----
        char *argv[];
  {
        int comp, file1done, file2done, read1, read2;
!       int ch, flag1, flag2, flag3, iflag;
        FILE *fp1, *fp2;
        char *col1, *col2, *col3;
        char **p, line1[MAXLINELEN], line2[MAXLINELEN];
  
        flag1 = flag2 = flag3 = 1;
!       iflag = 0;
!       while ((ch = getopt(argc, argv, "-123i")) != EOF)
                switch(ch) {
                case '-':
                        --optind;
***************
*** 86,91 ****
--- 87,95 ----
                case '3':
                        flag3 = 0;
                        break;
+               case 'i':
+                       iflag = 1;
+                       break;
                case '?':
                default:
                        usage();
***************
*** 128,135 ****
                        break;
                }
  
                /* lines are the same */
!               if (!(comp = strcmp(line1, line2))) {
                        read1 = read2 = 1;
                        if (col3)
                                (void)printf("%s%s", col3, line1);
--- 132,145 ----
                        break;
                }
  
+               if(iflag) {
+                       comp = strcasecmp(line1, line2);
+               } else {
+                       comp = strcmp(line1, line2);
+               }
+ 
                /* lines are the same */
!               if (!comp) {
                        read1 = read2 = 1;
                        if (col3)
                                (void)printf("%s%s", col3, line1);
***************
*** 182,187 ****
  usage()
  {
  
!       (void)fprintf(stderr, "usage: comm [-123] file1 file2\n");
        exit(1);
  }
--- 192,197 ----
  usage()
  {
  
!       (void)fprintf(stderr, "usage: comm [-123i] file1 file2\n");
        exit(1);
  }
Index: uniq/uniq.1
===================================================================
RCS file: /jaz/FreeBSD-CVS/src/usr.bin/uniq/uniq.1,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 uniq.1
*** uniq.1      1994/05/27 12:33:16     1.1.1.1
--- uniq.1      1997/03/20 01:04:07
***************
*** 43,48 ****
--- 43,49 ----
  .Sh SYNOPSIS
  .Nm uniq
  .Op Fl c | Fl d | Fl u
+ .Op Fl i 
  .Op Fl f Ar fields
  .Op Fl s Ar chars
  .Oo
***************
*** 87,92 ****
--- 88,95 ----
  Character numbers are one based, i.e. the first character is character one.
  .It Fl u
  Don't output lines that are repeated in the input.
+ .It Fl i
+ Case insensitive comparison of lines.
  .\".It Fl Ns Ar n
  .\"(Deprecated; replaced by
  .\".Fl f ) .
Index: uniq/uniq.c
===================================================================
RCS file: /jaz/FreeBSD-CVS/src/usr.bin/uniq/uniq.c,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 uniq.c
*** uniq.c      1997/03/11 13:08:01     1.1.1.2
--- uniq.c      1997/03/20 01:02:26
***************
*** 70,80 ****
  {
        register char *t1, *t2;
        FILE *ifp, *ofp;
!       int ch;
        char *prevline, *thisline, *p;
  
        obsolete(argv);
!       while ((ch = getopt(argc, argv, "-cdf:s:u")) != EOF)
                switch (ch) {
                case '-':
                        --optind;
--- 70,82 ----
  {
        register char *t1, *t2;
        FILE *ifp, *ofp;
!       int ch, iflag, comp;
        char *prevline, *thisline, *p;
  
+       iflag=0;
+ 
        obsolete(argv);
!       while ((ch = getopt(argc, argv, "-cdf:s:ui")) != EOF)
                switch (ch) {
                case '-':
                        --optind;
***************
*** 98,103 ****
--- 100,108 ----
                case 'u':
                        uflag = 1;
                        break;
+               case 'i':
+                       iflag = 1;
+                       break;
                case '?':
                default:
                        usage();
***************
*** 148,155 ****
                        t2 = prevline;
                }
  
                /* If different, print; set previous to new value. */
!               if (strcmp(t1, t2)) {
                        show(ofp, prevline);
                        t1 = prevline;
                        prevline = thisline;
--- 153,166 ----
                        t2 = prevline;
                }
  
+               if(iflag) {
+                       comp = strcasecmp(t1, t2);
+               } else {
+                       comp = strcmp(t1, t2);
+               }
+ 
                /* If different, print; set previous to new value. */
!               if (comp) {
                        show(ofp, prevline);
                        t1 = prevline;
                        prevline = thisline;

>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703200147.RAA12139>