This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fold builtin_tolower, builtin_toupper


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]