Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 60e9c22

Browse files
committed
Fix ASCII case in pg_wchar2mule_with_len.
Also some cosmetic improvements for wchar-to-mblen patch.
1 parent 379607c commit 60e9c22

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/backend/utils/mb/wchar.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ pg_euc2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
9999
*to |= *from++;
100100
len -= 2;
101101
}
102-
else
103-
/* must be ASCII */
102+
else /* must be ASCII */
104103
{
105104
*to = *from++;
106105
len--;
@@ -340,7 +339,7 @@ pg_euctw_dsplen(const unsigned char *s)
340339
}
341340

342341
/*
343-
* Convert pg_wchar to EUC_* encoding.
342+
* Convert pg_wchar to EUC_* encoding.
344343
* caller must allocate enough space for "to", including a trailing zero!
345344
* len: length of from.
346345
* "from" not necessarily null terminated.
@@ -353,23 +352,23 @@ pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
353352
while (len > 0 && *from)
354353
{
355354
unsigned char c;
356-
357-
if ((c = *from >> 24))
355+
356+
if ((c = (*from >> 24)))
358357
{
359358
*to++ = c;
360359
*to++ = (*from >> 16) & 0xff;
361360
*to++ = (*from >> 8) & 0xff;
362361
*to++ = *from & 0xff;
363362
cnt += 4;
364363
}
365-
else if ((c = *from >> 16))
364+
else if ((c = (*from >> 16)))
366365
{
367366
*to++ = c;
368367
*to++ = (*from >> 8) & 0xff;
369368
*to++ = *from & 0xff;
370369
cnt += 3;
371370
}
372-
else if ((c = *from >> 8))
371+
else if ((c = (*from >> 8)))
373372
{
374373
*to++ = c;
375374
*to++ = *from & 0xff;
@@ -379,7 +378,7 @@ pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
379378
{
380379
*to++ = *from;
381380
cnt++;
382-
}
381+
}
383382
from++;
384383
len--;
385384
}
@@ -516,7 +515,7 @@ pg_wchar2utf_with_len(const pg_wchar *from, unsigned char *to, int len)
516515
while (len > 0 && *from)
517516
{
518517
int char_len;
519-
518+
520519
unicode_to_utf8(*from, to);
521520
char_len = pg_utf_mblen(to);
522521
cnt += char_len;
@@ -803,10 +802,11 @@ static int
803802
pg_wchar2mule_with_len(const pg_wchar *from, unsigned char *to, int len)
804803
{
805804
int cnt = 0;
806-
unsigned char lb;
807805

808806
while (len > 0 && *from)
809807
{
808+
unsigned char lb;
809+
810810
lb = (*from >> 16) & 0xff;
811811
if (IS_LC1(lb))
812812
{
@@ -853,7 +853,7 @@ pg_wchar2mule_with_len(const pg_wchar *from, unsigned char *to, int len)
853853
}
854854
else
855855
{
856-
*to++ = lb;
856+
*to++ = *from & 0xff;
857857
cnt += 1;
858858
}
859859
from++;

0 commit comments

Comments
 (0)