Re: [BUGS] Turkish locale bug

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [BUGS] Turkish locale bug
Дата
Msg-id 12661.982684809@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [BUGS] Turkish locale bug  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Sezai YILMAZ <sezaiy@ata.cs.hun.edu.tr> 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: enable-debug considered pointless
Следующее
От: Tom Lane
Дата:
Сообщение: Re: beta5 ...