Skip to content

Commit 5afaa2e

Browse files
committed
Rationalize code placement between wchar.c, encnames.c, and mbutils.c.
Move all the backend-only code that'd crept into wchar.c and encnames.c into mbutils.c. To remove the last few #ifdef dependencies from wchar.c and encnames.c, also make the following changes: * Adjust get_encoding_name_for_icu to return NULL, not throw an error, for unsupported encodings. Its sole caller can perfectly well throw an error instead. (While at it, I also made this function and its sibling is_encoding_supported_by_icu proof against out-of-range encoding IDs.) * Remove the overlength-name error condition from pg_char_to_encoding. It's completely silly not to treat that just like any other the-name-is-not-in-the-table case. Also, get rid of pg_mic_mblen --- there's no obvious reason why conv.c shouldn't call pg_mule_mblen instead. Other than that, this is just code movement and comment-polishing with no functional changes. Notably, I reordered declarations in pg_wchar.h to show which functions are frontend-accessible and which are not. Discussion: https://postgr.es/m/CA+TgmoYO8oq-iy8E02rD8eX25T-9SmyxKWqqks5OMHxKvGXpXQ@mail.gmail.com
1 parent 3d4cb5d commit 5afaa2e

File tree

6 files changed

+505
-536
lines changed

6 files changed

+505
-536
lines changed

src/backend/utils/adt/pg_locale.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,9 +1555,14 @@ init_icu_converter(void)
15551555
UConverter *conv;
15561556

15571557
if (icu_converter)
1558-
return;
1558+
return; /* already done */
15591559

15601560
icu_encoding_name = get_encoding_name_for_icu(GetDatabaseEncoding());
1561+
if (!icu_encoding_name)
1562+
ereport(ERROR,
1563+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1564+
errmsg("encoding \"%s\" not supported by ICU",
1565+
pg_encoding_to_char(GetDatabaseEncoding()))));
15611566

15621567
status = U_ZERO_ERROR;
15631568
conv = ucnv_open(icu_encoding_name, &status);

src/backend/utils/mb/conv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ mic2latin(const unsigned char *mic, unsigned char *p, int len,
115115
}
116116
else
117117
{
118-
int l = pg_mic_mblen(mic);
118+
int l = pg_mule_mblen(mic);
119119

120120
if (len < l)
121121
report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic,
@@ -217,7 +217,7 @@ mic2latin_with_table(const unsigned char *mic,
217217
}
218218
else
219219
{
220-
int l = pg_mic_mblen(mic);
220+
int l = pg_mule_mblen(mic);
221221

222222
if (len < l)
223223
report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy