mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Solve the 'Turkish problem' with undesirable locale behavior for case
conversion of basic ASCII letters. Remove all uses of strcasecmp and strncasecmp in favor of new functions pg_strcasecmp and pg_strncasecmp; remove most but not all direct uses of toupper and tolower in favor of pg_toupper and pg_tolower. These functions use the same notions of case folding already developed for identifier case conversion. I left the straight locale-based folding in place for situations where we are just manipulating user data and not trying to match it to built-in strings --- for example, the SQL upper() function is still locale dependent. Perhaps this will prove not to be what's wanted, but at the moment we can initdb and pass regression tests in Turkish locale.
This commit is contained in:
@ -62,7 +62,7 @@ spell_init(PG_FUNCTION_ARGS)
|
||||
pcfg = cfg;
|
||||
while (pcfg->key)
|
||||
{
|
||||
if (strcasecmp("DictFile", pcfg->key) == 0)
|
||||
if (pg_strcasecmp("DictFile", pcfg->key) == 0)
|
||||
{
|
||||
if (dictloaded)
|
||||
{
|
||||
@ -81,7 +81,7 @@ spell_init(PG_FUNCTION_ARGS)
|
||||
}
|
||||
dictloaded = true;
|
||||
}
|
||||
else if (strcasecmp("AffFile", pcfg->key) == 0)
|
||||
else if (pg_strcasecmp("AffFile", pcfg->key) == 0)
|
||||
{
|
||||
if (affloaded)
|
||||
{
|
||||
@ -100,7 +100,7 @@ spell_init(PG_FUNCTION_ARGS)
|
||||
}
|
||||
affloaded = true;
|
||||
}
|
||||
else if (strcasecmp("StopFile", pcfg->key) == 0)
|
||||
else if (pg_strcasecmp("StopFile", pcfg->key) == 0)
|
||||
{
|
||||
text *tmp = char2text(pcfg->value);
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define MAX_NORM 1024
|
||||
#define MAXNORMLEN 256
|
||||
|
||||
#define STRNCASECMP(x,y) (strncasecmp(x,y,strlen(y)))
|
||||
#define STRNCASECMP(x,y) pg_strncasecmp(x, y, strlen(y))
|
||||
#define GETWCHAR(W,L,N,T) ( ((uint8*)(W))[ ((T)=='p') ? (N) : ( (L) - 1 - (N) ) ] )
|
||||
#define GETCHAR(A,N,T) GETWCHAR( (A)->repl, (A)->replen, N, T )
|
||||
|
||||
@ -304,19 +304,19 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!STRNCASECMP(str, "suffixes"))
|
||||
if (STRNCASECMP(str, "suffixes")==0)
|
||||
{
|
||||
suffixes = 1;
|
||||
prefixes = 0;
|
||||
continue;
|
||||
}
|
||||
if (!STRNCASECMP(str, "prefixes"))
|
||||
if (STRNCASECMP(str, "prefixes")==0)
|
||||
{
|
||||
suffixes = 0;
|
||||
prefixes = 1;
|
||||
continue;
|
||||
}
|
||||
if (!STRNCASECMP(str, "flag "))
|
||||
if (STRNCASECMP(str, "flag ")==0)
|
||||
{
|
||||
s = str + 5;
|
||||
flagflags=0;
|
||||
|
@ -210,15 +210,15 @@ prsd_headline(PG_FUNCTION_ARGS)
|
||||
|
||||
while (mptr && mptr->key)
|
||||
{
|
||||
if (strcasecmp(mptr->key, "MaxWords") == 0)
|
||||
if (pg_strcasecmp(mptr->key, "MaxWords") == 0)
|
||||
max_words = pg_atoi(mptr->value, 4, 1);
|
||||
else if (strcasecmp(mptr->key, "MinWords") == 0)
|
||||
else if (pg_strcasecmp(mptr->key, "MinWords") == 0)
|
||||
min_words = pg_atoi(mptr->value, 4, 1);
|
||||
else if (strcasecmp(mptr->key, "ShortWord") == 0)
|
||||
else if (pg_strcasecmp(mptr->key, "ShortWord") == 0)
|
||||
shortword = pg_atoi(mptr->value, 4, 1);
|
||||
else if (strcasecmp(mptr->key, "StartSel") == 0)
|
||||
else if (pg_strcasecmp(mptr->key, "StartSel") == 0)
|
||||
prs->startsel = pstrdup(mptr->value);
|
||||
else if (strcasecmp(mptr->key, "StopSel") == 0)
|
||||
else if (pg_strcasecmp(mptr->key, "StopSel") == 0)
|
||||
prs->stopsel = pstrdup(mptr->value);
|
||||
|
||||
pfree(mptr->key);
|
||||
|
Reference in New Issue
Block a user