This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fold builtin_tolower, builtin_toupper
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>, <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 30 Jul 2015 15:09:26 +0000
- Subject: Re: [PATCH] fold builtin_tolower, builtin_toupper
- Authentication-results: sourceware.org; auth=none
- References: <1436446689-12180-1-git-send-email-rep dot dot dot nop at gmail dot com> <alpine dot LSU dot 2 dot 11 dot 1507091543110 dot 9923 at zhemvz dot fhfr dot qr>
On Thu, 9 Jul 2015, Richard Biener wrote:
> On Thu, 9 Jul 2015, Bernhard Reutner-Fischer wrote:
>
> > gcc/ChangeLog
> >
> > 2015-07-09 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
> >
> > * builtins.c (fold_builtin_tolower, fold_builtin_toupper): New
> > static functions.
> > (fold_builtin_1): Handle BUILT_IN_TOLOWER, BUILT_IN_TOUPPER.
>
> As I read it you fold tolower (X) to (X) >= target_char_set ('A')
> && (X) <= target_char_set ('Z') ? (X) - target_char_set ('A') +
> target_char_set ('a');
>
> I don't think this can be correct for all locales which need not
> have a lower-case character for all upper-case ones nor do
> all letters having one need to be in the range of 'A' to 'Z'.
And even if the locale contains the ASCII letters, the tolower / toupper
mapping for them may not be the ASCII one (consider tolower ('I') and
toupper ('i') in a Turkish locale tr_TR.ISO-8859-9 - the results are 'Ä'
and 'Ä' which are single-byte characters in that locale).
--
Joseph S. Myers
joseph@codesourcery.com