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

Commit4d1dd8d

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 parent019e2f4 commit4d1dd8d

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-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.16 2005/01/01 05:43:08 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.16.4.1 2010/08/16 00:06:54 tgl Exp $
77
*/
88

99
#include"postgres_fe.h"
@@ -168,28 +168,20 @@ utf2ucs(const unsigned char *c)
168168
if ((*c&0x80)==0)
169169
return (pg_wchar)c[0];
170170
elseif ((*c&0xe0)==0xc0)
171-
{
172171
return (pg_wchar) (((c[0]&0x1f) <<6) |
173172
(c[1]&0x3f));
174-
}
175173
elseif ((*c&0xf0)==0xe0)
176-
{
177174
return (pg_wchar) (((c[0]&0x0f) <<12) |
178175
((c[1]&0x3f) <<6) |
179176
(c[2]&0x3f));
180-
}
181-
elseif ((*c&0xf0)==0xf0)
182-
{
177+
elseif ((*c&0xf8)==0xf0)
183178
return (pg_wchar) (((c[0]&0x07) <<18) |
184179
((c[1]&0x3f) <<12) |
185180
((c[2]&0x3f) <<6) |
186181
(c[3]&0x3f));
187-
}
188182
else
189-
{
190183
/* that is an invalid code on purpose */
191184
return0xffffffff;
192-
}
193185
}
194186

195187
/* mb_utf_wcwidth : calculate column length for the utf8 string pwcs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp