mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Fix ASCII case in pg_wchar2mule_with_len.
Also some cosmetic improvements for wchar-to-mblen patch.
This commit is contained in:
@ -99,8 +99,7 @@ pg_euc2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
|
|||||||
*to |= *from++;
|
*to |= *from++;
|
||||||
len -= 2;
|
len -= 2;
|
||||||
}
|
}
|
||||||
else
|
else /* must be ASCII */
|
||||||
/* must be ASCII */
|
|
||||||
{
|
{
|
||||||
*to = *from++;
|
*to = *from++;
|
||||||
len--;
|
len--;
|
||||||
@ -340,7 +339,7 @@ pg_euctw_dsplen(const unsigned char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert pg_wchar to EUC_* encoding.
|
* Convert pg_wchar to EUC_* encoding.
|
||||||
* caller must allocate enough space for "to", including a trailing zero!
|
* caller must allocate enough space for "to", including a trailing zero!
|
||||||
* len: length of from.
|
* len: length of from.
|
||||||
* "from" not necessarily null terminated.
|
* "from" not necessarily null terminated.
|
||||||
@ -353,8 +352,8 @@ pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
|
|||||||
while (len > 0 && *from)
|
while (len > 0 && *from)
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
||||||
if ((c = *from >> 24))
|
if ((c = (*from >> 24)))
|
||||||
{
|
{
|
||||||
*to++ = c;
|
*to++ = c;
|
||||||
*to++ = (*from >> 16) & 0xff;
|
*to++ = (*from >> 16) & 0xff;
|
||||||
@ -362,14 +361,14 @@ pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
|
|||||||
*to++ = *from & 0xff;
|
*to++ = *from & 0xff;
|
||||||
cnt += 4;
|
cnt += 4;
|
||||||
}
|
}
|
||||||
else if ((c = *from >> 16))
|
else if ((c = (*from >> 16)))
|
||||||
{
|
{
|
||||||
*to++ = c;
|
*to++ = c;
|
||||||
*to++ = (*from >> 8) & 0xff;
|
*to++ = (*from >> 8) & 0xff;
|
||||||
*to++ = *from & 0xff;
|
*to++ = *from & 0xff;
|
||||||
cnt += 3;
|
cnt += 3;
|
||||||
}
|
}
|
||||||
else if ((c = *from >> 8))
|
else if ((c = (*from >> 8)))
|
||||||
{
|
{
|
||||||
*to++ = c;
|
*to++ = c;
|
||||||
*to++ = *from & 0xff;
|
*to++ = *from & 0xff;
|
||||||
@ -379,7 +378,7 @@ pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
|
|||||||
{
|
{
|
||||||
*to++ = *from;
|
*to++ = *from;
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
from++;
|
from++;
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
@ -516,7 +515,7 @@ pg_wchar2utf_with_len(const pg_wchar *from, unsigned char *to, int len)
|
|||||||
while (len > 0 && *from)
|
while (len > 0 && *from)
|
||||||
{
|
{
|
||||||
int char_len;
|
int char_len;
|
||||||
|
|
||||||
unicode_to_utf8(*from, to);
|
unicode_to_utf8(*from, to);
|
||||||
char_len = pg_utf_mblen(to);
|
char_len = pg_utf_mblen(to);
|
||||||
cnt += char_len;
|
cnt += char_len;
|
||||||
@ -803,10 +802,11 @@ static int
|
|||||||
pg_wchar2mule_with_len(const pg_wchar *from, unsigned char *to, int len)
|
pg_wchar2mule_with_len(const pg_wchar *from, unsigned char *to, int len)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
unsigned char lb;
|
|
||||||
|
|
||||||
while (len > 0 && *from)
|
while (len > 0 && *from)
|
||||||
{
|
{
|
||||||
|
unsigned char lb;
|
||||||
|
|
||||||
lb = (*from >> 16) & 0xff;
|
lb = (*from >> 16) & 0xff;
|
||||||
if (IS_LC1(lb))
|
if (IS_LC1(lb))
|
||||||
{
|
{
|
||||||
@ -853,7 +853,7 @@ pg_wchar2mule_with_len(const pg_wchar *from, unsigned char *to, int len)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*to++ = lb;
|
*to++ = *from & 0xff;
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
}
|
}
|
||||||
from++;
|
from++;
|
||||||
|
Reference in New Issue
Block a user