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

Commitfebd60b

Browse files
committed
Fix pg_wchar_table[] to match revised ordering of the encoding ID enum.
Add some comments so hopefully the next poor sod doesn't fall into thesame trap. (Wrong comments are worse than none at all...)
1 parent4b21d1f commitfebd60b

File tree

3 files changed

+49
-55
lines changed

3 files changed

+49
-55
lines changed

‎src/backend/utils/mb/encnames.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Encoding names and routines for work with it. All
33
* in this file is shared bedween FE and BE.
44
*
5-
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.35 2007/10/13 20:18:41 tgl Exp $
5+
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.36 2007/10/15 22:46:27 tgl Exp $
66
*/
77
#ifdefFRONTEND
88
#include"postgres_fe.h"
@@ -294,7 +294,7 @@ sizeof(pg_encname_tbl) / sizeof(pg_encname_tbl[0]) - 1;
294294

295295
/* ----------
296296
* These are "official" encoding names.
297-
* XXX must be sorted by the same order as pg_enctype (see mb/pg_wchar.h)
297+
* XXX must be sorted by the same order asenumpg_enc(in mb/pg_wchar.h)
298298
* ----------
299299
*/
300300
pg_enc2namepg_enc2name_tbl[]=

‎src/backend/utils/mb/wchar.c

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* conversion functions between pg_wchar and multibyte streams.
33
* Tatsuo Ishii
4-
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.64 2007/09/18 17:41:17 adunstan Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.65 2007/10/15 22:46:27 tgl Exp $
55
*
66
*/
77
/* can be used in either frontend or backend */
@@ -38,8 +38,7 @@
3838
* SQL/ASCII
3939
*/
4040
staticint
41-
pg_ascii2wchar_with_len
42-
(constunsignedchar*from,pg_wchar*to,intlen)
41+
pg_ascii2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
4342
{
4443
intcnt=0;
4544

@@ -73,8 +72,8 @@ pg_ascii_dsplen(const unsigned char *s)
7372
/*
7473
* EUC
7574
*/
76-
staticintpg_euc2wchar_with_len
77-
(constunsignedchar*from,pg_wchar*to,intlen)
75+
staticint
76+
pg_euc2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
7877
{
7978
intcnt=0;
8079

@@ -148,8 +147,8 @@ pg_euc_dsplen(const unsigned char *s)
148147
/*
149148
* EUC_JP
150149
*/
151-
staticintpg_eucjp2wchar_with_len
152-
(constunsignedchar*from,pg_wchar*to,intlen)
150+
staticint
151+
pg_eucjp2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
153152
{
154153
returnpg_euc2wchar_with_len(from,to,len);
155154
}
@@ -179,8 +178,8 @@ pg_eucjp_dsplen(const unsigned char *s)
179178
/*
180179
* EUC_KR
181180
*/
182-
staticintpg_euckr2wchar_with_len
183-
(constunsignedchar*from,pg_wchar*to,intlen)
181+
staticint
182+
pg_euckr2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
184183
{
185184
returnpg_euc2wchar_with_len(from,to,len);
186185
}
@@ -201,8 +200,8 @@ pg_euckr_dsplen(const unsigned char *s)
201200
* EUC_CN
202201
*
203202
*/
204-
staticintpg_euccn2wchar_with_len
205-
(constunsignedchar*from,pg_wchar*to,intlen)
203+
staticint
204+
pg_euccn2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
206205
{
207206
intcnt=0;
208207

@@ -268,8 +267,8 @@ pg_euccn_dsplen(const unsigned char *s)
268267
* EUC_TW
269268
*
270269
*/
271-
staticintpg_euctw2wchar_with_len
272-
(constunsignedchar*from,pg_wchar*to,intlen)
270+
staticint
271+
pg_euctw2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
273272
{
274273
intcnt=0;
275274

@@ -343,12 +342,6 @@ pg_euctw_dsplen(const unsigned char *s)
343342
/*
344343
* JOHAB
345344
*/
346-
staticint
347-
pg_johab2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
348-
{
349-
returnpg_euc2wchar_with_len(from,to,len);
350-
}
351-
352345
staticint
353346
pg_johab_mblen(constunsignedchar*s)
354347
{
@@ -1307,6 +1300,7 @@ pg_utf8_islegal(const unsigned char *source, int length)
13071300
/*
13081301
*-------------------------------------------------------------------
13091302
* encoding info table
1303+
* XXX must be sorted by the same order as enum pg_enc (in mb/pg_wchar.h)
13101304
*-------------------------------------------------------------------
13111305
*/
13121306
pg_wchar_tblpg_wchar_table[]= {
@@ -1315,41 +1309,41 @@ pg_wchar_tbl pg_wchar_table[] = {
13151309
{pg_euccn2wchar_with_len,pg_euccn_mblen,pg_euccn_dsplen,pg_euccn_verifier,2},/* 2; PG_EUC_CN */
13161310
{pg_euckr2wchar_with_len,pg_euckr_mblen,pg_euckr_dsplen,pg_euckr_verifier,3},/* 3; PG_EUC_KR */
13171311
{pg_euctw2wchar_with_len,pg_euctw_mblen,pg_euctw_dsplen,pg_euctw_verifier,4},/* 4; PG_EUC_TW */
1318-
{pg_utf2wchar_with_len,pg_utf_mblen,pg_utf_dsplen,pg_utf8_verifier,4},/* 5; PG_UTF8 */
1319-
{pg_mule2wchar_with_len,pg_mule_mblen,pg_mule_dsplen,pg_mule_verifier,4},/* 6; PG_MULE_INTERNAL */
1320-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 7; PG_LATIN1 */
1321-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 8; PG_LATIN2 */
1322-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 9; PG_LATIN3 */
1323-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 10; PG_LATIN4 */
1324-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 11; PG_LATIN5 */
1325-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 12; PG_LATIN6 */
1326-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 13; PG_LATIN7 */
1327-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 14; PG_LATIN8 */
1328-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 15; PG_LATIN9 */
1329-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 16; PG_LATIN10 */
1330-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 17; PG_WIN1256 */
1331-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 18; PG_WIN1258 */
1332-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 19; PG_WIN874 */
1333-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 21; PG_KOI8 */
1334-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 22; PG_WIN1251 */
1335-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 23; PG_WIN1252 */
1336-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 24; PG_WIN866 */
1312+
{pg_eucjp2wchar_with_len,pg_eucjp_mblen,pg_eucjp_dsplen,pg_eucjp_verifier,3},/* 5; PG_EUC_JIS_2004 */
1313+
{pg_utf2wchar_with_len,pg_utf_mblen,pg_utf_dsplen,pg_utf8_verifier,4},/* 6; PG_UTF8 */
1314+
{pg_mule2wchar_with_len,pg_mule_mblen,pg_mule_dsplen,pg_mule_verifier,4},/* 7; PG_MULE_INTERNAL */
1315+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 8; PG_LATIN1 */
1316+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 9; PG_LATIN2 */
1317+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 10; PG_LATIN3 */
1318+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 11; PG_LATIN4 */
1319+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 12; PG_LATIN5 */
1320+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 13; PG_LATIN6 */
1321+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 14; PG_LATIN7 */
1322+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 15; PG_LATIN8 */
1323+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 16; PG_LATIN9 */
1324+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 17; PG_LATIN10 */
1325+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 18; PG_WIN1256 */
1326+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 19; PG_WIN1258 */
1327+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 20; PG_WIN866 */
1328+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 21; PG_WIN874 */
1329+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 22; PG_KOI8R */
1330+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 23; PG_WIN1251 */
1331+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 24; PG_WIN1252 */
13371332
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 25; ISO-8859-5 */
1338-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 25; ISO-8859-6 */
1339-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 26; ISO-8859-7 */
1340-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 27; ISO-8859-8 */
1341-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 28; PG_WIN1250 */
1342-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 29; PG_WIN1253 */
1343-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 30; PG_WIN1254 */
1344-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 31; PG_WIN1255 */
1345-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 32; PG_WIN1257 */
1346-
{pg_eucjp2wchar_with_len,pg_eucjp_mblen,pg_eucjp_dsplen,pg_eucjp_verifier,3},/* 33; PG_EUC_JIS_2004 */
1333+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 26; ISO-8859-6 */
1334+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 27; ISO-8859-7 */
1335+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 28; ISO-8859-8 */
1336+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 29; PG_WIN1250 */
1337+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 30; PG_WIN1253 */
1338+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 31; PG_WIN1254 */
1339+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 32; PG_WIN1255 */
1340+
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* 33; PG_WIN1257 */
13471341
{0,pg_sjis_mblen,pg_sjis_dsplen,pg_sjis_verifier,2},/* 34; PG_SJIS */
13481342
{0,pg_big5_mblen,pg_big5_dsplen,pg_big5_verifier,2},/* 35; PG_BIG5 */
13491343
{0,pg_gbk_mblen,pg_gbk_dsplen,pg_gbk_verifier,2},/* 36; PG_GBK */
13501344
{0,pg_uhc_mblen,pg_uhc_dsplen,pg_uhc_verifier,2},/* 37; PG_UHC */
1351-
{pg_johab2wchar_with_len,pg_johab_mblen,pg_johab_dsplen,pg_johab_verifier,3},/* 38;PG_JOHAB */
1352-
{0,pg_gb18030_mblen,pg_gb18030_dsplen,pg_gb18030_verifier,4},/* 39;PG_GB18030 */
1345+
{0,pg_gb18030_mblen,pg_gb18030_dsplen,pg_gb18030_verifier,4},/* 38;PG_GB18030 */
1346+
{0,pg_johab_mblen,pg_johab_dsplen,pg_johab_verifier,3},/* 39;PG_JOHAB */
13531347
{0,pg_sjis_mblen,pg_sjis_dsplen,pg_sjis_verifier,2}/* 40; PG_SHIFT_JIS_2004 */
13541348
};
13551349

@@ -1440,7 +1434,6 @@ pg_verifymbstr(const char *mbstr, int len, bool noError)
14401434
/*
14411435
* Verify mbstr to make sure that it is validly encoded in the specified
14421436
* encoding.
1443-
*
14441437
*/
14451438
bool
14461439
pg_verify_mbstr(intencoding,constchar*mbstr,intlen,boolnoError)

‎src/include/mb/pg_wchar.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.74 2007/10/13 20:18:41 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.75 2007/10/15 22:46:27 tgl Exp $
1010
*
1111
*NOTES
1212
*This is used both by the backend and by libpq, but should not be
@@ -152,8 +152,9 @@ typedef unsigned int pg_wchar;
152152
/*
153153
* PostgreSQL encoding identifiers
154154
*
155-
* WARNING: the order of this table must be same as order
156-
*in the pg_enc2name[] (mb/encnames.c) array!
155+
* WARNING: the order of this enum must be same as order of entries
156+
*in the pg_enc2name_tbl[] array (in mb/encnames.c), and
157+
*in the pg_wchar_table[] array (in mb/wchar.c)!
157158
*
158159
*If you add some encoding don't forget to check
159160
*PG_ENCODING_BE_LAST macro.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp