Commit 60e9c224 authored by Tom Lane's avatar Tom Lane

Fix ASCII case in pg_wchar2mule_with_len.

Also some cosmetic improvements for wchar-to-mblen patch.
parent 379607c9
......@@ -99,8 +99,7 @@ pg_euc2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
*to |= *from++;
len -= 2;
}
else
/* must be ASCII */
else /* must be ASCII */
{
*to = *from++;
len--;
......@@ -354,7 +353,7 @@ pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
{
unsigned char c;
if ((c = *from >> 24))
if ((c = (*from >> 24)))
{
*to++ = c;
*to++ = (*from >> 16) & 0xff;
......@@ -362,14 +361,14 @@ pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
*to++ = *from & 0xff;
cnt += 4;
}
else if ((c = *from >> 16))
else if ((c = (*from >> 16)))
{
*to++ = c;
*to++ = (*from >> 8) & 0xff;
*to++ = *from & 0xff;
cnt += 3;
}
else if ((c = *from >> 8))
else if ((c = (*from >> 8)))
{
*to++ = c;
*to++ = *from & 0xff;
......@@ -803,10 +802,11 @@ static int
pg_wchar2mule_with_len(const pg_wchar *from, unsigned char *to, int len)
{
int cnt = 0;
unsigned char lb;
while (len > 0 && *from)
{
unsigned char lb;
lb = (*from >> 16) & 0xff;
if (IS_LC1(lb))
{
......@@ -853,7 +853,7 @@ pg_wchar2mule_with_len(const pg_wchar *from, unsigned char *to, int len)
}
else
{
*to++ = lb;
*to++ = *from & 0xff;
cnt += 1;
}
from++;
......
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