Date: Sun, 7 Apr 2013 22:31:51 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: Cedric Blancher <cedric.blancher@googlemail.com> Cc: freebsd-hackers@freebsd.org, freebsd-standards@freebsd.org Subject: Re: Fwd: Where does FreeBSD tr -C differ from tr -c? Message-ID: <20130407203151.GA47134@stack.nl> In-Reply-To: <CALXu0UcmPAKCphiS-5LXv8y6G4JpAsi%2BekadoMUMrq-rXu44GQ@mail.gmail.com> References: <CALXu0Ue5uX05md777qJP8rHKZR1f1L-%2B0CR3Osjo1rRET8shrg@mail.gmail.com> <CALXu0UcmPAKCphiS-5LXv8y6G4JpAsi%2BekadoMUMrq-rXu44GQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Apr 07, 2013 at 09:12:57PM +0200, Cedric Blancher wrote: > Forwarding to freebsd-hackers@/freebsd-standards@freebsd.org > The question remain open and I need help. tr -C is implemented by > FreeBSD tr -C but I can't find examples (or a testcase) where tr -c > and tr -C differ. Reading the rationale of POSIX, here is an example of a difference: % printf 'a\200'|LC_ALL=en_US.US-ASCII tr -cd '\000-\177'|hd 00000000 61 |a| 00000001 % printf 'a\200'|LC_ALL=en_US.US-ASCII tr -Cd '\000-\177'|hd 00000000 61 80 |a.| 00000002 Because the bytes 128..255 are not characters in us-ascii, they cannot be removed with -Cd, only with -cd. Here is another difference (using LC_CTYPE=en_US.UTF-8, rest C): % echo $'\U0001a000'|tr -cd '\U0001a000'|hd % echo $'\U0001a000'|tr -Cd '\U0001a000'|hd 00000000 f0 9a 80 80 |....| 00000004 The cause is that iswrune(3) returns false for the unassigned code point U+0001A000. This may well contain bugs because Unicode adds new characters from time to time and our tables seem to be updated very rarely. POSIX also says things about collation order. You may not have detected this because FreeBSD does not implement LC_COLLATE for multibyte locales yet. > PS: Who wrote tr -C and how can I contact the author? You can read the Subversion logs but people may no longer be around. -- Jilles Tjoelker
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130407203151.GA47134>