Commit 5db55c6b authored by Bruce Momjian's avatar Bruce Momjian

Remove wchar.c Asserts that were stricter than the main code

Assert errors were thrown for functions being passed invalid encodings,
while the main code handled it just fine.

Also document that libpq's PQclientEncoding() returns -1 for an encoding
lookup failure.

Per report from Peter Geoghegan
parent 0b5c0f3b
......@@ -5377,7 +5377,8 @@ int PQclientEncoding(const PGconn *<replaceable>conn</replaceable>);
</synopsis>
Note that it returns the encoding ID, not a symbolic string
such as <literal>EUC_JP</literal>. To convert an encoding ID to an encoding name, you
such as <literal>EUC_JP</literal>. If unsuccessful, it returns -1.
To convert an encoding ID to an encoding name, you
can use:
<synopsis>
......
......@@ -1778,10 +1778,7 @@ pg_mic_mblen(const unsigned char *mbstr)
int
pg_encoding_mblen(int encoding, const char *mbstr)
{
Assert(PG_VALID_ENCODING(encoding));
return ((encoding >= 0 &&
encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
return (PG_VALID_ENCODING(encoding) ?
((*pg_wchar_table[encoding].mblen) ((const unsigned char *) mbstr)) :
((*pg_wchar_table[PG_SQL_ASCII].mblen) ((const unsigned char *) mbstr)));
}
......@@ -1792,10 +1789,7 @@ pg_encoding_mblen(int encoding, const char *mbstr)
int
pg_encoding_dsplen(int encoding, const char *mbstr)
{
Assert(PG_VALID_ENCODING(encoding));
return ((encoding >= 0 &&
encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
return (PG_VALID_ENCODING(encoding) ?
((*pg_wchar_table[encoding].dsplen) ((const unsigned char *) mbstr)) :
((*pg_wchar_table[PG_SQL_ASCII].dsplen) ((const unsigned char *) mbstr)));
}
......@@ -1808,10 +1802,7 @@ pg_encoding_dsplen(int encoding, const char *mbstr)
int
pg_encoding_verifymb(int encoding, const char *mbstr, int len)
{
Assert(PG_VALID_ENCODING(encoding));
return ((encoding >= 0 &&
encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
return (PG_VALID_ENCODING(encoding) ?
((*pg_wchar_table[encoding].mbverify) ((const unsigned char *) mbstr, len)) :
((*pg_wchar_table[PG_SQL_ASCII].mbverify) ((const unsigned char *) mbstr, len)));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment