diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2014-06-03 20:57:24 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2014-06-03 20:57:24 +0000 |
commit | 48dd0a487dbb88a2072da8eb393321a20e6ef9be (patch) | |
tree | 91c53a7150eb9e2de18aafe04b236d8910853d34 /usr.bin | |
parent | 5ae27e92c3345d7687edc15055840b271300120e (diff) |
Accept -C as an alias for -c. The -C option should be locale-aware,
but we don't have collation support yet. Man bits OK jmc@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tr/tr.1 | 28 | ||||
-rw-r--r-- | usr.bin/tr/tr.c | 21 |
2 files changed, 30 insertions, 19 deletions
diff --git a/usr.bin/tr/tr.1 b/usr.bin/tr/tr.1 index 1496937cc18..6dabc5ff95d 100644 --- a/usr.bin/tr/tr.1 +++ b/usr.bin/tr/tr.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tr.1,v 1.20 2013/08/14 08:39:27 jmc Exp $ +.\" $OpenBSD: tr.1,v 1.21 2014/06/03 20:57:23 millert Exp $ .\" $NetBSD: tr.1,v 1.5 1994/12/07 08:35:13 jtc Exp $ .\" .\" Copyright (c) 1991, 1993 @@ -33,7 +33,7 @@ .\" .\" @(#)tr.1 8.1 (Berkeley) 6/6/93 .\" -.Dd $Mdocdate: August 14 2013 $ +.Dd $Mdocdate: June 3 2014 $ .Dt TR 1 .Os .Sh NAME @@ -41,18 +41,18 @@ .Nd translate characters .Sh SYNOPSIS .Nm tr -.Op Fl cs +.Op Fl Ccs .Ar string1 string2 .Nm tr -.Op Fl c +.Op Fl Cc .Fl d .Ar string1 .Nm tr -.Op Fl c +.Op Fl Cc .Fl s .Ar string1 .Nm tr -.Op Fl c +.Op Fl Cc .Fl ds .Ar string1 string2 .Sh DESCRIPTION @@ -63,15 +63,18 @@ or deletion of selected characters. .Pp The options are as follows: .Bl -tag -width Ds -.It Fl c +.It Fl C Complements the set of characters in .Ar string1 ; for instance, -.Dq -c\ ab +.Dq -C\ ab includes every character except for .Dq a and .Dq b . +.It Fl c +The same as +.Fl C . .It Fl d The .Fl d @@ -283,7 +286,14 @@ The .Nm utility is compliant with the .St -p1003.1-2008 -specification. +specification, +except that the +.Fl C +option behaves the same as the +.Fl c +option since +.Nm +is not locale-aware. .Pp System V has historically implemented character ranges using the syntax .Dq [c-c] diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c index bd618a94d12..c74fb1c4801 100644 --- a/usr.bin/tr/tr.c +++ b/usr.bin/tr/tr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tr.c,v 1.16 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: tr.c,v 1.17 2014/06/03 20:57:23 millert Exp $ */ /* $NetBSD: tr.c,v 1.5 1995/08/31 22:13:48 jtc Exp $ */ /* @@ -88,8 +88,9 @@ main(int argc, char *argv[]) int cflag, dflag, sflag, isstring2; cflag = dflag = sflag = 0; - while ((ch = getopt(argc, argv, "cds")) != -1) + while ((ch = getopt(argc, argv, "Ccds")) != -1) switch(ch) { + case 'C': case 'c': cflag = 1; break; @@ -120,7 +121,7 @@ main(int argc, char *argv[]) } /* - * tr -ds [-c] string1 string2 + * tr -ds [-Cc] string1 string2 * Delete all characters (or complemented characters) in string1. * Squeeze all characters in string2. */ @@ -140,7 +141,7 @@ main(int argc, char *argv[]) } /* - * tr -d [-c] string1 + * tr -d [-Cc] string1 * Delete all characters (or complemented characters) in string1. */ if (dflag) { @@ -156,7 +157,7 @@ main(int argc, char *argv[]) } /* - * tr -s [-c] string1 + * tr -s [-Cc] string1 * Squeeze all characters (or complemented characters) in string1. */ if (sflag && !isstring2) { @@ -171,7 +172,7 @@ main(int argc, char *argv[]) } /* - * tr [-cs] string1 string2 + * tr [-Ccs] string1 string2 * Replace all characters (or complemented characters) in string1 with * the character in the same position in string2. If the -s option is * specified, squeeze all the characters in string2. @@ -239,9 +240,9 @@ static void usage(void) { fprintf(stderr, - "usage: tr [-cs] string1 string2\n" - " tr [-c] -d string1\n" - " tr [-c] -s string1\n" - " tr [-c] -ds string1 string2\n"); + "usage: tr [-Ccs] string1 string2\n" + " tr [-Cc] -d string1\n" + " tr [-Cc] -s string1\n" + " tr [-Cc] -ds string1 string2\n"); exit(1); } |