Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbeb4480

Browse files
committed
Refactor get_collation_current_version().
The code paths for three different OSes finished up with three differentways of excluding C[.xxx] and POSIX from consideration. Merge them.Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/20210117215940.GE8560%40telsasoft.com
1 parent9cf184c commitbeb4480

File tree

1 file changed

+4
-30
lines changed

1 file changed

+4
-30
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,37 +1636,17 @@ get_collation_current_version(char collprovider, const char *collcollate)
16361636
}
16371637
else
16381638
#endif
1639-
if (collprovider==COLLPROVIDER_LIBC)
1639+
if (collprovider==COLLPROVIDER_LIBC&&
1640+
pg_strcasecmp("C",collcollate)!=0&&
1641+
pg_strncasecmp("C.",collcollate,2)!=0&&
1642+
pg_strcasecmp("POSIX",collcollate)!=0)
16401643
{
16411644
#if defined(__GLIBC__)
1642-
char*copy=pstrdup(collcollate);
1643-
char*copy_suffix=strstr(copy,".");
1644-
boolneed_version= true;
1645-
1646-
/*
1647-
* Check for names like C.UTF-8 by chopping off the encoding suffix on
1648-
* our temporary copy, so we can skip the version.
1649-
*/
1650-
if (copy_suffix)
1651-
*copy_suffix='\0';
1652-
if (pg_strcasecmp("c",copy)==0||
1653-
pg_strcasecmp("posix",copy)==0)
1654-
need_version= false;
1655-
pfree(copy);
1656-
if (!need_version)
1657-
returnNULL;
1658-
16591645
/* Use the glibc version because we don't have anything better. */
16601646
collversion=pstrdup(gnu_get_libc_version());
16611647
#elif defined(LC_VERSION_MASK)
16621648
locale_tloc;
16631649

1664-
/* C[.encoding] and POSIX never change. */
1665-
if (strcmp("C",collcollate)==0||
1666-
strncmp("C.",collcollate,2)==0||
1667-
strcmp("POSIX",collcollate)==0)
1668-
returnNULL;
1669-
16701650
/* Look up FreeBSD collation version. */
16711651
loc=newlocale(LC_COLLATE,collcollate,NULL);
16721652
if (loc)
@@ -1687,12 +1667,6 @@ get_collation_current_version(char collprovider, const char *collcollate)
16871667
NLSVERSIONINFOEXversion= {sizeof(NLSVERSIONINFOEX)};
16881668
WCHARwide_collcollate[LOCALE_NAME_MAX_LENGTH];
16891669

1690-
/* These would be invalid arguments, but have no version. */
1691-
if (pg_strcasecmp("c",collcollate)==0||
1692-
pg_strcasecmp("posix",collcollate)==0)
1693-
returnNULL;
1694-
1695-
/* For all other names, ask the OS. */
16961670
MultiByteToWideChar(CP_ACP,0,collcollate,-1,wide_collcollate,
16971671
LOCALE_NAME_MAX_LENGTH);
16981672
if (!GetNLSVersionEx(COMPARE_STRING,wide_collcollate,&version))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp