mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Make some use of anonymous unions [pg_locale_t]
Make some use of anonymous unions, which are allowed as of C11, as examples and encouragement for future code, and to test compilers. This commit changes the pg_locale_t type. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/f00a9968-388e-4f8c-b5ef-5102e962d997%40eisentraut.org
This commit is contained in:
@@ -290,8 +290,8 @@ create_pg_locale_icu(Oid collid, MemoryContext context)
|
||||
collator = make_icu_collator(iculocstr, icurules);
|
||||
|
||||
result = MemoryContextAllocZero(context, sizeof(struct pg_locale_struct));
|
||||
result->info.icu.locale = MemoryContextStrdup(context, iculocstr);
|
||||
result->info.icu.ucol = collator;
|
||||
result->icu.locale = MemoryContextStrdup(context, iculocstr);
|
||||
result->icu.ucol = collator;
|
||||
result->deterministic = deterministic;
|
||||
result->collate_is_c = false;
|
||||
result->ctype_is_c = false;
|
||||
@@ -571,7 +571,7 @@ strncoll_icu_utf8(const char *arg1, ssize_t len1, const char *arg2, ssize_t len2
|
||||
Assert(GetDatabaseEncoding() == PG_UTF8);
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
result = ucol_strcollUTF8(locale->info.icu.ucol,
|
||||
result = ucol_strcollUTF8(locale->icu.ucol,
|
||||
arg1, len1,
|
||||
arg2, len2,
|
||||
&status);
|
||||
@@ -608,7 +608,7 @@ strnxfrm_icu(char *dest, size_t destsize, const char *src, ssize_t srclen,
|
||||
|
||||
ulen = uchar_convert(icu_converter, uchar, ulen + 1, src, srclen);
|
||||
|
||||
result_bsize = ucol_getSortKey(locale->info.icu.ucol,
|
||||
result_bsize = ucol_getSortKey(locale->icu.ucol,
|
||||
uchar, ulen,
|
||||
(uint8_t *) dest, destsize);
|
||||
|
||||
@@ -644,7 +644,7 @@ strnxfrm_prefix_icu_utf8(char *dest, size_t destsize,
|
||||
uiter_setUTF8(&iter, src, srclen);
|
||||
state[0] = state[1] = 0; /* won't need that again */
|
||||
status = U_ZERO_ERROR;
|
||||
result = ucol_nextSortKeyPart(locale->info.icu.ucol,
|
||||
result = ucol_nextSortKeyPart(locale->icu.ucol,
|
||||
&iter,
|
||||
state,
|
||||
(uint8_t *) dest,
|
||||
@@ -755,7 +755,7 @@ icu_convert_case(ICU_Convert_Func func, pg_locale_t mylocale,
|
||||
*buff_dest = palloc(len_dest * sizeof(**buff_dest));
|
||||
status = U_ZERO_ERROR;
|
||||
len_dest = func(*buff_dest, len_dest, buff_source, len_source,
|
||||
mylocale->info.icu.locale, &status);
|
||||
mylocale->icu.locale, &status);
|
||||
if (status == U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
/* try again with adjusted length */
|
||||
@@ -763,7 +763,7 @@ icu_convert_case(ICU_Convert_Func func, pg_locale_t mylocale,
|
||||
*buff_dest = palloc(len_dest * sizeof(**buff_dest));
|
||||
status = U_ZERO_ERROR;
|
||||
len_dest = func(*buff_dest, len_dest, buff_source, len_source,
|
||||
mylocale->info.icu.locale, &status);
|
||||
mylocale->icu.locale, &status);
|
||||
}
|
||||
if (U_FAILURE(status))
|
||||
ereport(ERROR,
|
||||
@@ -859,7 +859,7 @@ strncoll_icu(const char *arg1, ssize_t len1,
|
||||
ulen1 = uchar_convert(icu_converter, uchar1, ulen1 + 1, arg1, len1);
|
||||
ulen2 = uchar_convert(icu_converter, uchar2, ulen2 + 1, arg2, len2);
|
||||
|
||||
result = ucol_strcoll(locale->info.icu.ucol,
|
||||
result = ucol_strcoll(locale->icu.ucol,
|
||||
uchar1, ulen1,
|
||||
uchar2, ulen2);
|
||||
|
||||
@@ -904,7 +904,7 @@ strnxfrm_prefix_icu(char *dest, size_t destsize,
|
||||
uiter_setString(&iter, uchar, ulen);
|
||||
state[0] = state[1] = 0; /* won't need that again */
|
||||
status = U_ZERO_ERROR;
|
||||
result_bsize = ucol_nextSortKeyPart(locale->info.icu.ucol,
|
||||
result_bsize = ucol_nextSortKeyPart(locale->icu.ucol,
|
||||
&iter,
|
||||
state,
|
||||
(uint8_t *) dest,
|
||||
|
||||
Reference in New Issue
Block a user