aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/mb
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/mb')
-rw-r--r--src/backend/utils/mb/conv.c13
-rw-r--r--src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c14
-rw-r--r--src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c35
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c6
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c4
-rw-r--r--src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c4
-rw-r--r--src/backend/utils/mb/encnames.c22
-rw-r--r--src/backend/utils/mb/mbutils.c30
-rw-r--r--src/backend/utils/mb/wchar.c123
19 files changed, 159 insertions, 132 deletions
diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c
index 02082db5ef7..a395384c931 100644
--- a/src/backend/utils/mb/conv.c
+++ b/src/backend/utils/mb/conv.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.54 2005/09/24 17:53:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.55 2005/10/15 02:49:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -223,8 +223,8 @@ pg_mic2ascii(unsigned char *mic, unsigned char *p, int len)
void
latin2mic_with_table(
unsigned char *l, /* local charset string (source) */
- unsigned char *p, /* pointer to store mule internal
- * code (destination) */
+ unsigned char *p, /* pointer to store mule internal code
+ * (destination) */
int len, /* length of l */
int lc, /* leading character of p */
unsigned char *tab /* code conversion table */
@@ -265,8 +265,7 @@ latin2mic_with_table(
*/
void
mic2latin_with_table(
- unsigned char *mic, /* mule internal code
- * (source) */
+ unsigned char *mic, /* mule internal code (source) */
unsigned char *p, /* local code (destination) */
int len, /* length of p */
int lc, /* leading character */
@@ -380,8 +379,8 @@ UtfToLocal(unsigned char *utf, unsigned char *iso,
{
ereport(WARNING,
(errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
- errmsg("ignoring unconvertible UTF8 character 0x%04x",
- iutf)));
+ errmsg("ignoring unconvertible UTF8 character 0x%04x",
+ iutf)));
continue;
}
if (p->code & 0xff000000)
diff --git a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
index 277224103ac..3b215b2c4fb 100644
--- a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
+++ b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.12 2005/09/24 17:53:18 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.13 2005/10/15 02:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -462,7 +462,7 @@ euc_jp2sjis(unsigned char *euc, unsigned char *p, int len)
while (euc_end >= euc && (c1 = *euc++))
{
- if(c1 < 0x80)
+ if (c1 < 0x80)
{
/* should be ASCII */
*p++ = c1;
@@ -487,7 +487,8 @@ euc_jp2sjis(unsigned char *euc, unsigned char *p, int len)
}
else
{
- int i, k2;
+ int i,
+ k2;
/* IBM kanji */
for (i = 0;; i++)
@@ -508,9 +509,9 @@ euc_jp2sjis(unsigned char *euc, unsigned char *p, int len)
}
}
}
- }
+ }
else
- {
+ {
/* JIS X0208 kanji? */
c2 = *euc++;
k = (c1 << 8) | (c2 & 0xff);
@@ -543,7 +544,7 @@ sjis2euc_jp(unsigned char *sjis, unsigned char *p, int len)
while (sjis_end >= sjis && (c1 = *sjis++))
{
- if(c1 < 0x80)
+ if (c1 < 0x80)
{
/* should be ASCII */
*p++ = c1;
@@ -643,4 +644,3 @@ sjis2euc_jp(unsigned char *sjis, unsigned char *p, int len)
}
*p = '\0';
}
-
diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
index 4bdbfe95635..0447c2a9e7d 100644
--- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
+++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c
@@ -7,7 +7,7 @@
*
* 1999/1/15 Tatsuo Ishii
*
- * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c,v 1.5 2004/08/30 02:54:40 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c,v 1.6 2005/10/15 02:49:34 momjian Exp $
*/
/* can be used in either frontend or backend */
@@ -19,7 +19,7 @@ typedef struct
{
unsigned short code,
peer;
-} codes_t;
+} codes_t;
/* map Big5 Level 1 to CNS 11643-1992 Plane 1 */
static codes_t big5Level1ToCnsPlane1[25] = { /* range */
@@ -205,7 +205,7 @@ static unsigned short b2c3[][2] = {
};
static unsigned short BinarySearchRange
- (codes_t *array, int high, unsigned short code)
+ (codes_t * array, int high, unsigned short code)
{
int low,
mid,
@@ -230,24 +230,24 @@ static unsigned short BinarySearchRange
/*
* NOTE: big5 high_byte: 0xa1-0xfe, low_byte: 0x40-0x7e,
- * 0xa1-0xfe (radicals: 0x00-0x3e, 0x3f-0x9c) big5 radix
- * is 0x9d. [region_low, region_high]
- * We should remember big5 has two different regions
- * (above). There is a bias for the distance between these
- * regions. 0xa1 - 0x7e + bias = 1 (Distance between 0xa1
- * and 0x7e is 1.) bias = - 0x22.
+ * 0xa1-0xfe (radicals: 0x00-0x3e, 0x3f-0x9c) big5 radix is
+ * 0x9d. [region_low, region_high] We
+ * should remember big5 has two different regions (above).
+ * There is a bias for the distance between these regions.
+ * 0xa1 - 0x7e + bias = 1 (Distance between 0xa1 and 0x7e is
+ * 1.) bias = - 0x22.
*/
distance = tmp * 0x9d + high - low +
(high >= 0xa1 ? (low >= 0xa1 ? 0 : -0x22)
: (low >= 0xa1 ? +0x22 : 0));
/*
- * NOTE: we have to convert the distance into a code
- * point. The code point's low_byte is 0x21 plus mod_0x5e.
- * In the first, we extract the mod_0x5e of the starting
- * code point, subtracting 0x21, and add distance to it.
- * Then we calculate again mod_0x5e of them, and restore
- * the final codepoint, adding 0x21.
+ * NOTE: we have to convert the distance into a code point.
+ * The code point's low_byte is 0x21 plus mod_0x5e. In the
+ * first, we extract the mod_0x5e of the starting code point,
+ * subtracting 0x21, and add distance to it. Then we calculate
+ * again mod_0x5e of them, and restore the final codepoint,
+ * adding 0x21.
*/
tmp = (array[mid].peer & 0x00ff) + distance - 0x21;
tmp = (array[mid].peer & 0xff00) + ((tmp / 0x5e) << 8)
@@ -260,9 +260,8 @@ static unsigned short BinarySearchRange
tmp = ((code & 0xff00) - (array[mid].code & 0xff00)) >> 8;
/*
- * NOTE: ISO charsets ranges between 0x21-0xfe
- * (94charset). Its radix is 0x5e. But there is no
- * distance bias like big5.
+ * NOTE: ISO charsets ranges between 0x21-0xfe (94charset).
+ * Its radix is 0x5e. But there is no distance bias like big5.
*/
distance = tmp * 0x5e
+ ((int) (code & 0x00ff) - (int) (array[mid].code & 0x00ff));
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c
index 3330f89d5df..efab622c94f 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c
@@ -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.11 2005/09/24 17:53:20 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.12 2005/10/15 02:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -75,7 +75,7 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapKOI8R,
- sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len);
+ sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len);
PG_RETURN_VOID();
}
@@ -109,7 +109,7 @@ win1251_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN1251,
- sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len);
+ sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c
index 29196cb4e8d..9dcd87355a8 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c
@@ -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.11 2005/09/24 17:53:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.12 2005/10/15 02:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapEUC_CN,
- sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
+ sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c
index bbe849de904..4231bc08dff 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c
@@ -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.11 2005/09/24 17:53:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.12 2005/10/15 02:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapEUC_JP,
- sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
+ sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c
index db1505ab626..b197b064eeb 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c
@@ -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.11 2005/09/24 17:53:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.12 2005/10/15 02:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapEUC_KR,
- sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
+ sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c
index cc05c64cc13..b2f7d465a77 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c
@@ -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.11 2005/09/24 17:53:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.12 2005/10/15 02:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapEUC_TW,
- sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
+ sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c
index 37f207ec153..6cc235e7327 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c
@@ -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.11 2005/09/24 17:53:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.12 2005/10/15 02:49:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ gb18030_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapGB18030,
- sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len);
+ sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
index b6c56324ec3..0038db58e62 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
@@ -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.14 2005/09/24 17:53:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.15 2005/10/15 02:49:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -65,7 +65,7 @@ typedef struct
pg_utf_to_local *map2; /* from UTF8 map name */
int size1; /* size of map1 */
int size2; /* size of map2 */
-} pg_conv_map;
+} pg_conv_map;
static pg_conv_map maps[] = {
{PG_SQL_ASCII}, /* SQL/ASCII */
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c
index 9e93be9c496..3de91947af8 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c
@@ -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.11 2005/09/24 17:53:24 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.12 2005/10/15 02:49:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ johab_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapJOHAB,
- sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len);
+ sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c
index cd79893ae8c..6789ca7aaa5 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c
@@ -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_win1250/utf8_and_win1250.c,v 1.12 2005/09/24 17:53:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c,v 1.13 2005/10/15 02:49:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,7 +63,7 @@ win1250_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN1250,
- sizeof(LUmapWIN1250) / sizeof(pg_local_to_utf), PG_WIN1250, len);
+ sizeof(LUmapWIN1250) / sizeof(pg_local_to_utf), PG_WIN1250, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c
index b7592b6c30c..b4d2b2375a9 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c
@@ -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_win1252/utf8_and_win1252.c,v 1.4 2005/09/24 17:53:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c,v 1.5 2005/10/15 02:49:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,7 +63,7 @@ win1252_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN1252,
- sizeof(LUmapWIN1252) / sizeof(pg_local_to_utf), PG_WIN1252, len);
+ sizeof(LUmapWIN1252) / sizeof(pg_local_to_utf), PG_WIN1252, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c
index a0036d80e63..d6b83d8f837 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c
@@ -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_win1256/utf8_and_win1256.c,v 1.12 2005/09/24 17:53:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c,v 1.13 2005/10/15 02:49:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,7 +63,7 @@ win1256_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN1256,
- sizeof(LUmapWIN1256) / sizeof(pg_local_to_utf), PG_WIN1256, len);
+ sizeof(LUmapWIN1256) / sizeof(pg_local_to_utf), PG_WIN1256, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c
index 3b74f81ba9c..7cdcfd3c120 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c
@@ -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_win1258/utf8_and_win1258.c,v 1.2 2005/09/24 17:53:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c,v 1.3 2005/10/15 02:49:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ win1258_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN1258,
- sizeof(LUmapWIN1258) / sizeof(pg_local_to_utf), PG_WIN1258, len);
+ sizeof(LUmapWIN1258) / sizeof(pg_local_to_utf), PG_WIN1258, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c b/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c
index 48f30b2cad9..7eda096a9be 100644
--- a/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c
+++ b/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c
@@ -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_win874/utf8_and_win874.c,v 1.12 2005/09/24 17:53:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c,v 1.13 2005/10/15 02:49:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,7 +63,7 @@ win874_to_utf8(PG_FUNCTION_ARGS)
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN874,
- sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len);
+ sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len);
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c
index 5c0b15fd745..145343a881d 100644
--- a/src/backend/utils/mb/encnames.c
+++ b/src/backend/utils/mb/encnames.c
@@ -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.25 2005/03/14 18:31:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.26 2005/10/15 02:49:33 momjian Exp $
*/
#ifdef FRONTEND
#include "postgres_fe.h"
@@ -45,16 +45,16 @@ pg_encname pg_encname_tbl[] =
}, /* Big5; Chinese for Taiwan multibyte set */
{
"euccn", PG_EUC_CN
- }, /* EUC-CN; Extended Unix Code for
- * simplified Chinese */
+ }, /* EUC-CN; Extended Unix Code for simplified
+ * Chinese */
{
"eucjp", PG_EUC_JP
- }, /* EUC-JP; Extended UNIX Code fixed Width
- * for Japanese, standard OSF */
+ }, /* EUC-JP; Extended UNIX Code fixed Width for
+ * Japanese, standard OSF */
{
"euckr", PG_EUC_KR
- }, /* EUC-KR; Extended Unix Code for Korean ,
- * KS X 1001 standard */
+ }, /* EUC-KR; Extended Unix Code for Korean , KS
+ * X 1001 standard */
{
"euctw", PG_EUC_TW
}, /* EUC-TW; Extended Unix Code for
@@ -111,8 +111,8 @@ pg_encname pg_encname_tbl[] =
}, /* ISO-8859-9; RFC1345,KXS2 */
{
"johab", PG_JOHAB
- }, /* JOHAB; Extended Unix Code for
- * simplified Chinese */
+ }, /* JOHAB; Extended Unix Code for simplified
+ * Chinese */
{
"koi8", PG_KOI8R
}, /* _dirty_ alias for KOI8-R (backward
@@ -185,8 +185,8 @@ pg_encname pg_encname_tbl[] =
}, /* alias for WIN1258 */
{
"win", PG_WIN1251
- }, /* _dirty_ alias for windows-1251
- * (backward compatibility) */
+ }, /* _dirty_ alias for windows-1251 (backward
+ * compatibility) */
{
"win1250", PG_WIN1250
}, /* alias for Windows-1250 */
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c
index 8058fc8d27a..f8dc7a31922 100644
--- a/src/backend/utils/mb/mbutils.c
+++ b/src/backend/utils/mb/mbutils.c
@@ -4,7 +4,7 @@
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
*
- * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.51 2005/09/24 17:53:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.52 2005/10/15 02:49:33 momjian Exp $
*/
#include "postgres.h"
@@ -107,12 +107,11 @@ SetClientEncoding(int encoding, bool doit)
}
/*
- * If we're not inside a transaction then we can't do catalog lookups,
- * so fail. After backend startup, this could only happen if we are
+ * If we're not inside a transaction then we can't do catalog lookups, so
+ * fail. After backend startup, this could only happen if we are
* re-reading postgresql.conf due to SIGHUP --- so basically this just
* constrains the ability to change client_encoding on the fly from
- * postgresql.conf. Which would probably be a stupid thing to do
- * anyway.
+ * postgresql.conf. Which would probably be a stupid thing to do anyway.
*/
if (!IsTransactionState())
return -1;
@@ -136,8 +135,8 @@ SetClientEncoding(int encoding, bool doit)
return 0;
/*
- * load the fmgr info into TopMemoryContext so that it survives
- * outside transaction.
+ * load the fmgr info into TopMemoryContext so that it survives outside
+ * transaction.
*/
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
to_server = palloc(sizeof(FmgrInfo));
@@ -180,8 +179,8 @@ InitializeClientEncoding(void)
if (SetClientEncoding(pending_client_encoding, true) < 0)
{
/*
- * Oops, the requested conversion is not available. We couldn't
- * fail before, but we can now.
+ * Oops, the requested conversion is not available. We couldn't fail
+ * before, but we can now.
*/
ereport(FATAL,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -256,8 +255,8 @@ pg_do_encoding_conversion(unsigned char *src, int len,
}
/*
- * XXX we should avoid throwing errors in OidFunctionCall. Otherwise
- * we are going into infinite loop! So we have to make sure that the
+ * XXX we should avoid throwing errors in OidFunctionCall. Otherwise we
+ * are going into infinite loop! So we have to make sure that the
* function exists before calling OidFunctionCall.
*/
if (!SearchSysCacheExists(PROCOID,
@@ -290,11 +289,11 @@ pg_convert(PG_FUNCTION_ARGS)
Datum string = PG_GETARG_DATUM(0);
Datum dest_encoding_name = PG_GETARG_DATUM(1);
Datum src_encoding_name = DirectFunctionCall1(
- namein, CStringGetDatum(DatabaseEncoding->name));
+ namein, CStringGetDatum(DatabaseEncoding->name));
Datum result;
result = DirectFunctionCall3(
- pg_convert2, string, src_encoding_name, dest_encoding_name);
+ pg_convert2, string, src_encoding_name, dest_encoding_name);
/* free memory allocated by namein */
pfree((void *) src_encoding_name);
@@ -343,8 +342,7 @@ pg_convert2(PG_FUNCTION_ARGS)
/*
* build text data type structure. we cannot use textin() here, since
- * textin assumes that input string encoding is same as database
- * encoding.
+ * textin assumes that input string encoding is same as database encoding.
*/
len = strlen((char *) result) + VARHDRSZ;
retval = palloc(len);
@@ -502,7 +500,7 @@ pg_mbstrlen_with_len(const char *mbstr, int limit)
while (limit > 0 && *mbstr)
{
- int l = pg_mblen(mbstr);
+ int l = pg_mblen(mbstr);
limit -= l;
mbstr += l;
diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c
index 59116e2e818..e8866ba35ca 100644
--- a/src/backend/utils/mb/wchar.c
+++ b/src/backend/utils/mb/wchar.c
@@ -1,7 +1,7 @@
/*
* conversion functions between pg_wchar and multibyte streams.
* Tatsuo Ishii
- * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.45 2005/09/24 17:53:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.46 2005/10/15 02:49:33 momjian Exp $
*
* WIN1250 client encoding updated by Pavel Behal
*
@@ -406,14 +406,14 @@ pg_utf_mblen(const unsigned char *s)
len = 1;
else if ((*s & 0xe0) == 0xc0)
len = 2;
- else if ((*s & 0xf0) == 0xe0)
- len = 3;
- else if ((*s & 0xf8) == 0xf0)
- len = 4;
- else if ((*s & 0xfc) == 0xf8)
- len = 5;
- else if ((*s & 0xfe) == 0xfc)
- len = 6;
+ else if ((*s & 0xf0) == 0xe0)
+ len = 3;
+ else if ((*s & 0xf8) == 0xf0)
+ len = 4;
+ else if ((*s & 0xfc) == 0xf8)
+ len = 5;
+ else if ((*s & 0xfe) == 0xfc)
+ len = 6;
return (len);
}
@@ -727,8 +727,8 @@ pg_wchar_tbl pg_wchar_table[] = {
{pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, 3}, /* 3; PG_EUC_KR */
{pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, 3}, /* 4; PG_EUC_TW */
{pg_johab2wchar_with_len, pg_johab_mblen, pg_johab_dsplen, 3}, /* 5; PG_JOHAB */
- {pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, 4}, /* 6; PG_UTF8 */
- {pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, 3}, /* 7; PG_MULE_INTERNAL */
+ {pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, 4}, /* 6; PG_UTF8 */
+ {pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, 3}, /* 7; PG_MULE_INTERNAL */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 1}, /* 8; PG_LATIN1 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 1}, /* 9; PG_LATIN2 */
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 1}, /* 10; PG_LATIN3 */
@@ -775,8 +775,8 @@ pg_encoding_mblen(int encoding, const char *mbstr)
return ((encoding >= 0 &&
encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
- ((*pg_wchar_table[encoding].mblen) ((const unsigned char *) mbstr)) :
- ((*pg_wchar_table[PG_SQL_ASCII].mblen) ((const unsigned char *) mbstr)));
+ ((*pg_wchar_table[encoding].mblen) ((const unsigned char *) mbstr)) :
+ ((*pg_wchar_table[PG_SQL_ASCII].mblen) ((const unsigned char *) mbstr)));
}
/*
@@ -789,8 +789,8 @@ pg_encoding_dsplen(int encoding, const char *mbstr)
return ((encoding >= 0 &&
encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
- ((*pg_wchar_table[encoding].dsplen) ((const unsigned char *) mbstr)) :
- ((*pg_wchar_table[PG_SQL_ASCII].dsplen) ((const unsigned char *) mbstr)));
+ ((*pg_wchar_table[encoding].dsplen) ((const unsigned char *) mbstr)) :
+ ((*pg_wchar_table[PG_SQL_ASCII].dsplen) ((const unsigned char *) mbstr)));
}
/*
@@ -806,28 +806,57 @@ pg_encoding_max_length(int encoding)
#ifndef FRONTEND
-bool pg_utf8_islegal(const unsigned char *source, int length) {
- unsigned char a;
- const unsigned char *srcptr = source+length;
- switch (length) {
- default: return false;
- /* Everything else falls through when "true"... */
- case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
- case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
- case 2: if ((a = (*--srcptr)) > 0xBF) return false;
- switch (*source) {
- /* no fall-through in this inner switch */
- case 0xE0: if (a < 0xA0) return false; break;
- case 0xED: if (a > 0x9F) return false; break;
- case 0xF0: if (a < 0x90) return false; break;
- case 0xF4: if (a > 0x8F) return false; break;
- default: if (a < 0x80) return false;
- }
-
- case 1: if (*source >= 0x80 && *source < 0xC2) return false;
- }
- if (*source > 0xF4) return false;
- return true;
+bool
+pg_utf8_islegal(const unsigned char *source, int length)
+{
+ unsigned char a;
+ const unsigned char *srcptr = source + length;
+
+ switch (length)
+ {
+ default:
+ return false;
+ /* Everything else falls through when "true"... */
+ case 4:
+ if ((a = (*--srcptr)) < 0x80 || a > 0xBF)
+ return false;
+ case 3:
+ if ((a = (*--srcptr)) < 0x80 || a > 0xBF)
+ return false;
+ case 2:
+ if ((a = (*--srcptr)) > 0xBF)
+ return false;
+ switch (*source)
+ {
+ /* no fall-through in this inner switch */
+ case 0xE0:
+ if (a < 0xA0)
+ return false;
+ break;
+ case 0xED:
+ if (a > 0x9F)
+ return false;
+ break;
+ case 0xF0:
+ if (a < 0x90)
+ return false;
+ break;
+ case 0xF4:
+ if (a > 0x8F)
+ return false;
+ break;
+ default:
+ if (a < 0x80)
+ return false;
+ }
+
+ case 1:
+ if (*source >= 0x80 && *source < 0xC2)
+ return false;
+ }
+ if (*source > 0xF4)
+ return false;
+ return true;
}
@@ -855,11 +884,11 @@ pg_verifymbstr(const char *mbstr, int len, bool noError)
while (len > 0 && *mbstr)
{
l = pg_mblen(mbstr);
-
+
/* special UTF-8 check */
if (encoding == PG_UTF8)
{
- if(!pg_utf8_islegal((const unsigned char *) mbstr, l))
+ if (!pg_utf8_islegal((const unsigned char *) mbstr, l))
{
if (noError)
return false;
@@ -868,7 +897,9 @@ pg_verifymbstr(const char *mbstr, int len, bool noError)
errmsg("invalid UNICODE byte sequence detected near byte 0x%02x",
(unsigned char) *mbstr)));
}
- } else {
+ }
+ else
+ {
for (i = 1; i < l; i++)
{
/*
@@ -878,23 +909,23 @@ pg_verifymbstr(const char *mbstr, int len, bool noError)
if (i >= len || (mbstr[i] & 0x80) == 0)
{
char buf[8 * 2 + 1];
- char *p = buf;
- int j,
- jlimit;
+ char *p = buf;
+ int j,
+ jlimit;
if (noError)
return false;
jlimit = Min(l, len);
- jlimit = Min(jlimit, 8); /* prevent buffer overrun */
+ jlimit = Min(jlimit, 8); /* prevent buffer overrun */
for (j = 0; j < jlimit; j++)
p += sprintf(p, "%02x", (unsigned char) mbstr[j]);
ereport(ERROR,
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
- errmsg("invalid byte sequence for encoding \"%s\": 0x%s",
- GetDatabaseEncodingName(), buf)));
+ errmsg("invalid byte sequence for encoding \"%s\": 0x%s",
+ GetDatabaseEncodingName(), buf)));
}
}
}