Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb49c879

Browse files
committed
Fix psql's copy of utf2ucs() to match the backend's copy exactly;
in particular, propagate a fix in the test to see whether a UTF8 character haslength 4 bytes. This is likely of little real-world consequence because5-or-more-byte UTF8 sequences are not supported by Postgres nor seen anywherein the wild, but still we may as well get it right. Problem found by JosephAdams.Bug is aboriginal, so back-patch all the way.
1 parentf0f46ed commitb49c879

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

‎src/bin/psql/mbprint.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.38 2010/01/02 16:57:59 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.39 2010/08/16 00:06:18 tgl Exp $
77
*
88
* XXX this file does not really belong in psql/. Perhaps move to libpq?
99
* It also seems that the mbvalidate function is redundant with existing
@@ -53,28 +53,20 @@ utf2ucs(const unsigned char *c)
5353
if ((*c&0x80)==0)
5454
return (pg_wchar)c[0];
5555
elseif ((*c&0xe0)==0xc0)
56-
{
5756
return (pg_wchar) (((c[0]&0x1f) <<6) |
5857
(c[1]&0x3f));
59-
}
6058
elseif ((*c&0xf0)==0xe0)
61-
{
6259
return (pg_wchar) (((c[0]&0x0f) <<12) |
6360
((c[1]&0x3f) <<6) |
6461
(c[2]&0x3f));
65-
}
66-
elseif ((*c&0xf0)==0xf0)
67-
{
62+
elseif ((*c&0xf8)==0xf0)
6863
return (pg_wchar) (((c[0]&0x07) <<18) |
6964
((c[1]&0x3f) <<12) |
7065
((c[2]&0x3f) <<6) |
7166
(c[3]&0x3f));
72-
}
7367
else
74-
{
7568
/* that is an invalid code on purpose */
7669
return0xffffffff;
77-
}
7870
}
7971

8072

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp