mirror of
https://github.com/postgres/postgres.git
synced 2025-12-01 12:18:01 +03:00
pgindent run for 8.3.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* Copyright (c) 2007, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jis_2004_and_shift_jis_2004/euc_jis_2004_and_shift_jis_2004.c,v 1.1 2007/03/25 11:56:02 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jis_2004_and_shift_jis_2004/euc_jis_2004_and_shift_jis_2004.c,v 1.2 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ euc_jis_20042shift_jis_2004(const unsigned char *euc, unsigned char *p, int len)
|
||||
{
|
||||
int c1,
|
||||
ku,
|
||||
ten;
|
||||
ten;
|
||||
int l;
|
||||
|
||||
while (len > 0)
|
||||
@@ -104,7 +104,7 @@ euc_jis_20042shift_jis_2004(const unsigned char *euc, unsigned char *p, int len)
|
||||
{
|
||||
*p++ = euc[1];
|
||||
}
|
||||
else if (c1 == SS3 && l == 3) /* JIS X 0213 plane 2? */
|
||||
else if (c1 == SS3 && l == 3) /* JIS X 0213 plane 2? */
|
||||
{
|
||||
ku = euc[1] - 0xa0;
|
||||
ten = euc[2] - 0xa0;
|
||||
@@ -146,7 +146,7 @@ euc_jis_20042shift_jis_2004(const unsigned char *euc, unsigned char *p, int len)
|
||||
*p++ = ten + 0x9e;
|
||||
}
|
||||
|
||||
else if (l == 2) /* JIS X 0213 plane 1? */
|
||||
else if (l == 2) /* JIS X 0213 plane 1? */
|
||||
{
|
||||
ku = c1 - 0xa0;
|
||||
ten = euc[1] - 0xa0;
|
||||
@@ -187,26 +187,29 @@ euc_jis_20042shift_jis_2004(const unsigned char *euc, unsigned char *p, int len)
|
||||
* *ku = 0: "ku" = even
|
||||
* *ku = 1: "ku" = odd
|
||||
*/
|
||||
static int get_ten(int b, int *ku)
|
||||
static int
|
||||
get_ten(int b, int *ku)
|
||||
{
|
||||
int ten;
|
||||
int ten;
|
||||
|
||||
if (b >= 0x40 && b <= 0x7e)
|
||||
{
|
||||
ten = b - 0x3f;
|
||||
*ku = 1;
|
||||
} else if (b >= 0x80 && b <= 0x9e)
|
||||
}
|
||||
else if (b >= 0x80 && b <= 0x9e)
|
||||
{
|
||||
ten = b - 0x40;
|
||||
*ku = 1;
|
||||
} else if (b >= 0x9f && b <= 0xfc)
|
||||
}
|
||||
else if (b >= 0x9f && b <= 0xfc)
|
||||
{
|
||||
ten = b - 0x9e;
|
||||
*ku = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ten = -1; /* error */
|
||||
ten = -1; /* error */
|
||||
}
|
||||
return ten;
|
||||
}
|
||||
@@ -219,8 +222,10 @@ static void
|
||||
shift_jis_20042euc_jis_2004(const unsigned char *sjis, unsigned char *p, int len)
|
||||
{
|
||||
int c1,
|
||||
c2;
|
||||
int ku, ten, kubun;
|
||||
c2;
|
||||
int ku,
|
||||
ten,
|
||||
kubun;
|
||||
int plane;
|
||||
int l;
|
||||
|
||||
@@ -281,7 +286,8 @@ shift_jis_20042euc_jis_2004(const unsigned char *sjis, unsigned char *p, int len
|
||||
(const char *) sjis, len);
|
||||
ku -= kubun;
|
||||
}
|
||||
else if (c1 >= 0xf0 && c1 <= 0xf3) /* plane 2 1,3,4,5,8,12,13,14,15 ku */
|
||||
else if (c1 >= 0xf0 && c1 <= 0xf3) /* plane 2
|
||||
* 1,3,4,5,8,12,13,14,15 ku */
|
||||
{
|
||||
plane = 2;
|
||||
ten = get_ten(c2, &kubun);
|
||||
@@ -291,16 +297,16 @@ shift_jis_20042euc_jis_2004(const unsigned char *sjis, unsigned char *p, int len
|
||||
switch (c1)
|
||||
{
|
||||
case 0xf0:
|
||||
ku = kubun == 0? 8: 1;
|
||||
ku = kubun == 0 ? 8 : 1;
|
||||
break;
|
||||
case 0xf1:
|
||||
ku = kubun == 0? 4: 3;
|
||||
ku = kubun == 0 ? 4 : 3;
|
||||
break;
|
||||
case 0xf2:
|
||||
ku = kubun == 0? 12: 5;
|
||||
ku = kubun == 0 ? 12 : 5;
|
||||
break;
|
||||
default:
|
||||
ku = kubun == 0? 14: 13;
|
||||
ku = kubun == 0 ? 14 : 13;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.16 2007/03/25 11:56:02 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.17 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -46,7 +46,7 @@ big5_to_utf8(PG_FUNCTION_ARGS)
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len >= 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapBIG5, NULL,
|
||||
LocalToUtf(src, dest, LUmapBIG5, NULL,
|
||||
sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), 0, PG_BIG5, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@@ -63,7 +63,7 @@ utf8_to_big5(PG_FUNCTION_ARGS)
|
||||
Assert(PG_GETARG_INT32(1) == PG_BIG5);
|
||||
Assert(len >= 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapBIG5, NULL,
|
||||
UtfToLocal(src, dest, ULmapBIG5, NULL,
|
||||
sizeof(ULmapBIG5) / sizeof(pg_utf_to_local), 0, PG_BIG5, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.19 2007/03/25 11:56:02 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.20 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,8 +47,8 @@ utf8_to_koi8r(PG_FUNCTION_ARGS)
|
||||
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
|
||||
Assert(len >= 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapKOI8R, NULL,
|
||||
sizeof(ULmapKOI8R) / sizeof(pg_utf_to_local), 0, PG_KOI8R, len);
|
||||
UtfToLocal(src, dest, ULmapKOI8R, NULL,
|
||||
sizeof(ULmapKOI8R) / sizeof(pg_utf_to_local), 0, PG_KOI8R, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -65,7 +65,7 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapKOI8R, NULL,
|
||||
sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), 0, PG_KOI8R, len);
|
||||
sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), 0, PG_KOI8R, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.17 2007/03/25 11:56:02 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.18 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_CN, NULL,
|
||||
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), 0, PG_EUC_CN, len);
|
||||
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), 0, PG_EUC_CN, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ utf8_to_euc_cn(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapEUC_CN, NULL,
|
||||
sizeof(ULmapEUC_CN) / sizeof(pg_utf_to_local), 0, PG_EUC_CN, len);
|
||||
sizeof(ULmapEUC_CN) / sizeof(pg_utf_to_local), 0, PG_EUC_CN, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jis_2004/utf8_and_euc_jis_2004.c,v 1.1 2007/03/25 11:56:03 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jis_2004/utf8_and_euc_jis_2004.c,v 1.2 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ euc_jis_2004_to_utf8(PG_FUNCTION_ARGS)
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_JIS_2004, LUmapEUC_JIS_2004_combined,
|
||||
sizeof(LUmapEUC_JIS_2004) / sizeof(pg_local_to_utf),
|
||||
sizeof(LUmapEUC_JIS_2004_combined) / sizeof(pg_local_to_utf_combined),
|
||||
sizeof(LUmapEUC_JIS_2004_combined) / sizeof(pg_local_to_utf_combined),
|
||||
PG_EUC_JIS_2004, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@@ -69,7 +69,7 @@ utf8_to_euc_jis_2004(PG_FUNCTION_ARGS)
|
||||
|
||||
UtfToLocal(src, dest, ULmapEUC_JIS_2004, ULmapEUC_JIS_2004_combined,
|
||||
sizeof(ULmapEUC_JIS_2004) / sizeof(pg_utf_to_local),
|
||||
sizeof(ULmapEUC_JIS_2004_combined) / sizeof(pg_utf_to_local_combined),
|
||||
sizeof(ULmapEUC_JIS_2004_combined) / sizeof(pg_utf_to_local_combined),
|
||||
PG_EUC_JIS_2004, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.17 2007/03/25 11:56:03 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.18 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_JP, NULL,
|
||||
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), 0, PG_EUC_JP, len);
|
||||
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), 0, PG_EUC_JP, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ utf8_to_euc_jp(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapEUC_JP, NULL,
|
||||
sizeof(ULmapEUC_JP) / sizeof(pg_utf_to_local), 0, PG_EUC_JP, len);
|
||||
sizeof(ULmapEUC_JP) / sizeof(pg_utf_to_local), 0, PG_EUC_JP, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.17 2007/03/25 11:56:03 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.18 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_KR, NULL,
|
||||
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), 0, PG_EUC_KR, len);
|
||||
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), 0, PG_EUC_KR, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ utf8_to_euc_kr(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapEUC_KR, NULL,
|
||||
sizeof(ULmapEUC_KR) / sizeof(pg_utf_to_local), 0, PG_EUC_KR, len);
|
||||
sizeof(ULmapEUC_KR) / sizeof(pg_utf_to_local), 0, PG_EUC_KR, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.17 2007/03/25 11:56:03 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.18 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_TW, NULL,
|
||||
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), 0, PG_EUC_TW, len);
|
||||
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), 0, PG_EUC_TW, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ utf8_to_euc_tw(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapEUC_TW, NULL,
|
||||
sizeof(ULmapEUC_TW) / sizeof(pg_utf_to_local), 0, PG_EUC_TW, len);
|
||||
sizeof(ULmapEUC_TW) / sizeof(pg_utf_to_local), 0, PG_EUC_TW, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.18 2007/03/25 11:56:03 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.19 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ gb18030_to_utf8(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapGB18030, NULL,
|
||||
sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), 0, PG_GB18030, len);
|
||||
sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), 0, PG_GB18030, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ utf8_to_gb18030(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapGB18030, NULL,
|
||||
sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), 0, PG_GB18030, len);
|
||||
sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), 0, PG_GB18030, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.26 2007/03/25 11:56:03 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.27 2007/11/15 21:14:41 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -134,7 +134,7 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INTERNAL_ERROR),
|
||||
errmsg("unexpected encoding ID %d for ISO 8859 character sets", encoding)));
|
||||
errmsg("unexpected encoding ID %d for ISO 8859 character sets", encoding)));
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -162,7 +162,7 @@ utf8_to_iso8859(PG_FUNCTION_ARGS)
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INTERNAL_ERROR),
|
||||
errmsg("unexpected encoding ID %d for ISO 8859 character sets", encoding)));
|
||||
errmsg("unexpected encoding ID %d for ISO 8859 character sets", encoding)));
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.17 2007/03/25 11:56:03 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.18 2007/11/15 21:14:41 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,7 +47,7 @@ johab_to_utf8(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapJOHAB, NULL,
|
||||
sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), 0, PG_JOHAB, len);
|
||||
sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), 0, PG_JOHAB, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ utf8_to_johab(PG_FUNCTION_ARGS)
|
||||
Assert(len >= 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapJOHAB, NULL,
|
||||
sizeof(ULmapJOHAB) / sizeof(pg_utf_to_local), 0, PG_JOHAB, len);
|
||||
sizeof(ULmapJOHAB) / sizeof(pg_utf_to_local), 0, PG_JOHAB, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_shift_jis_2004/utf8_and_shift_jis_2004.c,v 1.1 2007/03/25 11:56:03 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_shift_jis_2004/utf8_and_shift_jis_2004.c,v 1.2 2007/11/15 21:14:41 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ shift_jis_2004_to_utf8(PG_FUNCTION_ARGS)
|
||||
|
||||
LocalToUtf(src, dest, LUmapSHIFT_JIS_2004, LUmapSHIFT_JIS_2004_combined,
|
||||
sizeof(LUmapSHIFT_JIS_2004) / sizeof(pg_local_to_utf),
|
||||
sizeof(LUmapSHIFT_JIS_2004_combined) / sizeof(pg_local_to_utf_combined),
|
||||
sizeof(LUmapSHIFT_JIS_2004_combined) / sizeof(pg_local_to_utf_combined),
|
||||
PG_SHIFT_JIS_2004, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@@ -69,7 +69,7 @@ utf8_to_shift_jis_2004(PG_FUNCTION_ARGS)
|
||||
|
||||
UtfToLocal(src, dest, ULmapSHIFT_JIS_2004, ULmapSHIFT_JIS_2004_combined,
|
||||
sizeof(ULmapSHIFT_JIS_2004) / sizeof(pg_utf_to_local),
|
||||
sizeof(ULmapSHIFT_JIS_2004_combined) / sizeof(pg_utf_to_local_combined),
|
||||
sizeof(ULmapSHIFT_JIS_2004_combined) / sizeof(pg_utf_to_local_combined),
|
||||
PG_SHIFT_JIS_2004, len);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c,v 1.10 2007/03/25 11:56:04 ishii Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c,v 1.11 2007/11/15 21:14:41 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -124,7 +124,7 @@ win_to_utf8(PG_FUNCTION_ARGS)
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INTERNAL_ERROR),
|
||||
errmsg("unexpected encoding ID %d for WIN character sets", encoding)));
|
||||
errmsg("unexpected encoding ID %d for WIN character sets", encoding)));
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -152,7 +152,7 @@ utf8_to_win(PG_FUNCTION_ARGS)
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INTERNAL_ERROR),
|
||||
errmsg("unexpected encoding ID %d for WIN character sets", encoding)));
|
||||
errmsg("unexpected encoding ID %d for WIN character sets", encoding)));
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Encoding names and routines for work with it. All
|
||||
* in this file is shared bedween FE and BE.
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.36 2007/10/15 22:46:27 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.37 2007/11/15 21:14:40 momjian Exp $
|
||||
*/
|
||||
#ifdef FRONTEND
|
||||
#include "postgres_fe.h"
|
||||
@@ -47,8 +47,8 @@ pg_encname pg_encname_tbl[] =
|
||||
* Chinese */
|
||||
{
|
||||
"eucjis2004", PG_EUC_JIS_2004
|
||||
}, /* EUC-JIS-2004; Extended UNIX Code fixed Width for
|
||||
* Japanese, standard JIS X 0213 */
|
||||
}, /* EUC-JIS-2004; Extended UNIX Code fixed
|
||||
* Width for Japanese, standard JIS X 0213 */
|
||||
{
|
||||
"eucjp", PG_EUC_JP
|
||||
}, /* EUC-JP; Extended UNIX Code fixed Width for
|
||||
@@ -164,8 +164,8 @@ pg_encname pg_encname_tbl[] =
|
||||
|
||||
{
|
||||
"shiftjis2004", PG_SHIFT_JIS_2004
|
||||
}, /* SHIFT-JIS-2004; Shift JIS for
|
||||
* Japanese, standard JIS X 0213 */
|
||||
}, /* SHIFT-JIS-2004; Shift JIS for Japanese,
|
||||
* standard JIS X 0213 */
|
||||
{
|
||||
"sjis", PG_SJIS
|
||||
}, /* alias for Shift_JIS */
|
||||
@@ -470,7 +470,7 @@ static char *
|
||||
clean_encoding_name(const char *key, char *newkey)
|
||||
{
|
||||
const char *p;
|
||||
char *np;
|
||||
char *np;
|
||||
|
||||
for (p = key, np = newkey; *p != '\0'; p++)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* (currently mule internal code (mic) is used)
|
||||
* Tatsuo Ishii
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.67 2007/10/13 20:18:41 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.68 2007/11/15 21:14:40 momjian Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
@@ -277,8 +277,8 @@ pg_do_encoding_conversion(unsigned char *src, int len,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("out of memory"),
|
||||
errdetail("String of %d bytes is too long for encoding conversion.",
|
||||
len)));
|
||||
errdetail("String of %d bytes is too long for encoding conversion.",
|
||||
len)));
|
||||
|
||||
result = palloc(len * MAX_CONVERSION_GROWTH + 1);
|
||||
|
||||
@@ -305,12 +305,13 @@ pg_convert_to(PG_FUNCTION_ARGS)
|
||||
namein, CStringGetDatum(DatabaseEncoding->name));
|
||||
Datum result;
|
||||
|
||||
/* pg_convert expects a bytea as its first argument. We're passing it
|
||||
* a text argument here, relying on the fact that they are both in fact
|
||||
/*
|
||||
* pg_convert expects a bytea as its first argument. We're passing it a
|
||||
* text argument here, relying on the fact that they are both in fact
|
||||
* varlena types, and thus structurally identical.
|
||||
*/
|
||||
result = DirectFunctionCall3(
|
||||
pg_convert, string, src_encoding_name, dest_encoding_name);
|
||||
pg_convert, string, src_encoding_name, dest_encoding_name);
|
||||
|
||||
/* free memory allocated by namein */
|
||||
pfree((void *) src_encoding_name);
|
||||
@@ -333,13 +334,14 @@ pg_convert_from(PG_FUNCTION_ARGS)
|
||||
Datum result;
|
||||
|
||||
result = DirectFunctionCall3(
|
||||
pg_convert, string, src_encoding_name, dest_encoding_name);
|
||||
pg_convert, string, src_encoding_name, dest_encoding_name);
|
||||
|
||||
/* free memory allocated by namein */
|
||||
pfree((void *) src_encoding_name);
|
||||
|
||||
/* pg_convert returns a bytea, which we in turn return as text, relying
|
||||
* on the fact that they are both in fact varlena types, and thus
|
||||
/*
|
||||
* pg_convert returns a bytea, which we in turn return as text, relying on
|
||||
* the fact that they are both in fact varlena types, and thus
|
||||
* structurally identical. Although not all bytea values are valid text,
|
||||
* in this case it will be because we've told pg_convert to return one
|
||||
* that is valid as text in the current database encoding.
|
||||
@@ -378,7 +380,7 @@ pg_convert(PG_FUNCTION_ARGS)
|
||||
|
||||
/* make sure that source string is valid and null terminated */
|
||||
len = VARSIZE(string) - VARHDRSZ;
|
||||
pg_verify_mbstr(src_encoding,VARDATA(string),len,false);
|
||||
pg_verify_mbstr(src_encoding, VARDATA(string), len, false);
|
||||
str = palloc(len + 1);
|
||||
memcpy(str, VARDATA(string), len);
|
||||
*(str + len) = '\0';
|
||||
@@ -415,11 +417,11 @@ pg_convert(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
length_in_encoding(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bytea *string = PG_GETARG_BYTEA_P(0);
|
||||
bytea *string = PG_GETARG_BYTEA_P(0);
|
||||
char *src_encoding_name = NameStr(*PG_GETARG_NAME(1));
|
||||
int src_encoding = pg_char_to_encoding(src_encoding_name);
|
||||
int len = VARSIZE(string) - VARHDRSZ;
|
||||
int retval;
|
||||
int len = VARSIZE(string) - VARHDRSZ;
|
||||
int retval;
|
||||
|
||||
if (src_encoding < 0)
|
||||
ereport(ERROR,
|
||||
@@ -429,7 +431,7 @@ length_in_encoding(PG_FUNCTION_ARGS)
|
||||
|
||||
retval = pg_verify_mbstr_len(src_encoding, VARDATA(string), len, false);
|
||||
PG_RETURN_INT32(retval);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -545,8 +547,8 @@ perform_default_encoding_conversion(const char *src, int len, bool is_client_to_
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("out of memory"),
|
||||
errdetail("String of %d bytes is too long for encoding conversion.",
|
||||
len)));
|
||||
errdetail("String of %d bytes is too long for encoding conversion.",
|
||||
len)));
|
||||
|
||||
result = palloc(len * MAX_CONVERSION_GROWTH + 1);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* conversion functions between pg_wchar and multibyte streams.
|
||||
* Tatsuo Ishii
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.65 2007/10/15 22:46:27 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.66 2007/11/15 21:14:40 momjian Exp $
|
||||
*
|
||||
*/
|
||||
/* can be used in either frontend or backend */
|
||||
@@ -1310,7 +1310,7 @@ pg_wchar_tbl pg_wchar_table[] = {
|
||||
{pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, pg_euckr_verifier, 3}, /* 3; PG_EUC_KR */
|
||||
{pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, pg_euctw_verifier, 4}, /* 4; PG_EUC_TW */
|
||||
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3}, /* 5; PG_EUC_JIS_2004 */
|
||||
{pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, pg_utf8_verifier, 4}, /* 6; PG_UTF8 */
|
||||
{pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, pg_utf8_verifier, 4}, /* 6; PG_UTF8 */
|
||||
{pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* 7; PG_MULE_INTERNAL */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 8; PG_LATIN1 */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* 9; PG_LATIN2 */
|
||||
@@ -1343,7 +1343,7 @@ pg_wchar_tbl pg_wchar_table[] = {
|
||||
{0, pg_gbk_mblen, pg_gbk_dsplen, pg_gbk_verifier, 2}, /* 36; PG_GBK */
|
||||
{0, pg_uhc_mblen, pg_uhc_dsplen, pg_uhc_verifier, 2}, /* 37; PG_UHC */
|
||||
{0, pg_gb18030_mblen, pg_gb18030_dsplen, pg_gb18030_verifier, 4}, /* 38; PG_GB18030 */
|
||||
{0, pg_johab_mblen, pg_johab_dsplen, pg_johab_verifier, 3}, /* 39; PG_JOHAB */
|
||||
{0, pg_johab_mblen, pg_johab_dsplen, pg_johab_verifier, 3}, /* 39; PG_JOHAB */
|
||||
{0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2} /* 40; PG_SHIFT_JIS_2004 */
|
||||
};
|
||||
|
||||
@@ -1427,7 +1427,7 @@ pg_database_encoding_max_length(void)
|
||||
bool
|
||||
pg_verifymbstr(const char *mbstr, int len, bool noError)
|
||||
{
|
||||
return
|
||||
return
|
||||
pg_verify_mbstr_len(GetDatabaseEncoding(), mbstr, len, noError) >= 0;
|
||||
}
|
||||
|
||||
@@ -1441,22 +1441,22 @@ pg_verify_mbstr(int encoding, const char *mbstr, int len, bool noError)
|
||||
return pg_verify_mbstr_len(encoding, mbstr, len, noError) >= 0;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Verify mbstr to make sure that it is validly encoded in the specified
|
||||
* encoding.
|
||||
*
|
||||
* mbstr is not necessarily zero terminated; length of mbstr is
|
||||
* specified by len.
|
||||
*
|
||||
* If OK, return length of string in the encoding.
|
||||
* If OK, return length of string in the encoding.
|
||||
* If a problem is found, return -1 when noError is
|
||||
* true; when noError is false, ereport() a descriptive message.
|
||||
*/
|
||||
*/
|
||||
int
|
||||
pg_verify_mbstr_len(int encoding, const char *mbstr, int len, bool noError)
|
||||
{
|
||||
mbverifier mbverify;
|
||||
int mb_len;
|
||||
int mb_len;
|
||||
|
||||
Assert(PG_VALID_ENCODING(encoding));
|
||||
|
||||
@@ -1476,7 +1476,7 @@ pg_verify_mbstr_len(int encoding, const char *mbstr, int len, bool noError)
|
||||
|
||||
/* fetch function pointer just once */
|
||||
mbverify = pg_wchar_table[encoding].mbverify;
|
||||
|
||||
|
||||
mb_len = 0;
|
||||
|
||||
while (len > 0)
|
||||
|
||||
Reference in New Issue
Block a user