Sezai YILMAZ <[EMAIL PROTECTED]> writes:
> You are right. What about this one?

>                   setlocale(LC_ALL, "C");  

>                     for(i = 0; yytext[i]; i++)
>                           if (isascii((unsigned char)yytext[i]) &&
>                                 isupper(yytext[i]))
>                                 yytext[i] = tolower(yytext[i]);

>                     /* This sets locale to default locale which 
>                        user prefer to use */

>                   setlocale(LC_ALL, "");  

This isn't really better than "if (isupper(ch)) ch = ch + ('a' - 'A')".
It still breaks the existing locale-aware handling of identifier case,
which I believe is considered a good thing in all locales except C
and Turkish.  Another small problem is that setlocale() is moderately
expensive in most implementations, and we don't want to call it twice
for every identifier scanned.

I am starting to think that the only real solution is a special case
for Turkish users.  Perhaps use tolower() normally but have a compile-
time option to use a non-locale-aware method:

#ifdef LOCALE_AWARE_IDENTIFIER_FOLDING
                  if (isupper(yytext[i]))
                     yytext[i] = tolower(yytext[i]);
#else
                  /* this assumes ASCII encoding... */
                  if (yytext[i] >= 'A' && yytext[i] <= 'Z')
                     yytext[i] += 'a' - 'A';
#endif

and then document that you have to disable
LOCALE_AWARE_IDENTIFIER_FOLDING to use Turkish locale.

                        regards, tom lane

Reply via email to