提交 33575772 编写于 作者: T Tatsuo Ishii

Change Assert(len > 0) to Assert(len >= 0)

Change PG_RETURN_INT32(0) to PG_RETURN_VOID()
上级 6d77f6e5
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -41,11 +41,11 @@ ascii_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
pg_ascii2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -57,9 +57,9 @@ mic_to_ascii(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII);
Assert(len > 0);
Assert(len >= 0);
pg_mic2ascii(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -88,11 +88,11 @@ koi8r_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
koi8r2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -104,11 +104,11 @@ mic_to_koi8r(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len > 0);
Assert(len >= 0);
mic2koi8r(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -120,11 +120,11 @@ iso_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
iso2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -136,11 +136,11 @@ mic_to_iso(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
Assert(len > 0);
Assert(len >= 0);
mic2iso(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -152,11 +152,11 @@ win1251_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
win12512mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -168,11 +168,11 @@ mic_to_win1251(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len > 0);
Assert(len >= 0);
mic2win1251(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -184,11 +184,11 @@ alt_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ALT);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
alt2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -200,11 +200,11 @@ mic_to_alt(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_ALT);
Assert(len > 0);
Assert(len >= 0);
mic2alt(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -217,14 +217,14 @@ koi8r_to_win1251(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
koi8r2mic(src, buf, len);
mic2win1251(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -237,14 +237,14 @@ win1251_to_koi8r(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
win12512mic(src, buf, len);
mic2koi8r(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -257,14 +257,14 @@ koi8r_to_alt(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_ALT);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
koi8r2mic(src, buf, len);
mic2alt(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -277,14 +277,14 @@ alt_to_koi8r(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ALT);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
alt2mic(src, buf, len);
mic2koi8r(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -297,14 +297,14 @@ alt_to_win1251(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ALT);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
alt2mic(src, buf, len);
mic2win1251(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -317,14 +317,14 @@ win1251_to_alt(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_ALT);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
win12512mic(src, buf, len);
mic2alt(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -337,14 +337,14 @@ iso_to_koi8r(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
iso2mic(src, buf, len);
mic2koi8r(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -357,14 +357,14 @@ koi8r_to_iso(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
koi8r2mic(src, buf, len);
mic2iso(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -377,14 +377,14 @@ iso_to_win1251(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
iso2mic(src, buf, len);
mic2win1251(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -397,14 +397,14 @@ win1251_to_iso(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
win12512mic(src, buf, len);
mic2win1251(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -417,14 +417,14 @@ iso_to_alt(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
Assert(PG_GETARG_INT32(1) == PG_ALT);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
iso2mic(src, buf, len);
mic2alt(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -437,14 +437,14 @@ alt_to_iso(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ALT);
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
alt2mic(src, buf, len);
mic2alt(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
/*
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -44,11 +44,11 @@ euc_cn_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_CN);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
euc_cn2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -60,11 +60,11 @@ mic_to_euc_cn(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_EUC_CN);
Assert(len > 0);
Assert(len >= 0);
mic2euc_cn(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
/*
......@@ -75,7 +75,7 @@ euc_cn2mic(unsigned char *euc, unsigned char *p, int len)
{
int c1;
while (len > 0 && (c1 = *euc++))
while (len >= 0 && (c1 = *euc++))
{
if (c1 & 0x80)
{
......@@ -101,7 +101,7 @@ mic2euc_cn(unsigned char *mic, unsigned char *p, int len)
{
int c1;
while (len > 0 && (c1 = *mic))
while (len >= 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -69,14 +69,14 @@ euc_jp_to_sjis(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
Assert(PG_GETARG_INT32(1) == PG_SJIS);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
euc_jp2mic(src, buf, len);
mic2sjis(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -89,14 +89,14 @@ sjis_to_euc_jp(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_SJIS);
Assert(PG_GETARG_INT32(1) == PG_EUC_JP);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
sjis2mic(src, buf, len);
mic2euc_jp(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -108,11 +108,11 @@ euc_jp_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
euc_jp2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -124,11 +124,11 @@ mic_to_euc_jp(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_EUC_JP);
Assert(len > 0);
Assert(len >= 0);
mic2sjis(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -140,11 +140,11 @@ sjis_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_SJIS);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
sjis2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -156,11 +156,11 @@ mic_to_sjis(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_SJIS);
Assert(len > 0);
Assert(len >= 0);
mic2sjis(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
/*
......@@ -177,7 +177,7 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
k2;
/* Eiji Tokuya patched end */
while (len > 0 && (c1 = *sjis++))
while (len >= 0 && (c1 = *sjis++))
{
if (c1 >= 0xa1 && c1 <= 0xdf)
{
......@@ -303,7 +303,7 @@ mic2sjis(unsigned char *mic, unsigned char *p, int len)
c2,
k;
while (len > 0 && (c1 = *mic))
while (len >= 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
......@@ -383,7 +383,7 @@ euc_jp2mic(unsigned char *euc, unsigned char *p, int len)
{
int c1;
while (len > 0 && (c1 = *euc++))
while (len >= 0 && (c1 = *euc++))
{
if (c1 == SS2)
{ /* 1 byte kana? */
......@@ -422,7 +422,7 @@ mic2euc_jp(unsigned char *mic, unsigned char *p, int len)
{
int c1;
while (len > 0 && (c1 = *mic))
while (len >= 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -44,11 +44,11 @@ euc_kr_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_KR);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
euc_kr2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -60,11 +60,11 @@ mic_to_euc_kr(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_EUC_KR);
Assert(len > 0);
Assert(len >= 0);
mic2euc_kr(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
/*
......@@ -75,7 +75,7 @@ euc_kr2mic(unsigned char *euc, unsigned char *p, int len)
{
int c1;
while (len > 0 && (c1 = *euc++))
while (len >= 0 && (c1 = *euc++))
{
if (c1 & 0x80)
{
......@@ -101,7 +101,7 @@ mic2euc_kr(unsigned char *mic, unsigned char *p, int len)
{
int c1;
while (len > 0 && (c1 = *mic))
while (len >= 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -57,14 +57,14 @@ euc_tw_to_big5(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
Assert(PG_GETARG_INT32(1) == PG_BIG5);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
euc_tw2mic(src, buf, len);
mic2big5(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -77,14 +77,14 @@ big5_to_euc_tw(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_BIG5);
Assert(PG_GETARG_INT32(1) == PG_EUC_TW);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
big52mic(src, buf, len);
mic2euc_tw(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -96,11 +96,11 @@ euc_tw_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
euc_tw2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -112,11 +112,11 @@ mic_to_euc_tw(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_EUC_TW);
Assert(len > 0);
Assert(len >= 0);
mic2big5(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -128,11 +128,11 @@ big5_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_BIG5);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
big52mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -144,11 +144,11 @@ mic_to_big5(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_BIG5);
Assert(len > 0);
Assert(len >= 0);
mic2big5(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
/*
......@@ -159,7 +159,7 @@ euc_tw2mic(unsigned char *euc, unsigned char *p, int len)
{
int c1;
while (len > 0 && (c1 = *euc++))
while (len >= 0 && (c1 = *euc++))
{
if (c1 == SS2)
{
......@@ -201,7 +201,7 @@ mic2euc_tw(unsigned char *mic, unsigned char *p, int len)
{
int c1;
while (len > 0 && (c1 = *mic))
while (len >= 0 && (c1 = *mic))
{
len -= pg_mic_mblen(mic++);
......@@ -250,7 +250,7 @@ big52mic(unsigned char *big5, unsigned char *p, int len)
char bogusBuf[3];
int i;
while (len > 0 && (c1 = *big5++))
while (len >= 0 && (c1 = *big5++))
{
if (c1 <= 0x7fU)
{ /* ASCII */
......@@ -302,7 +302,7 @@ mic2big5(unsigned char *mic, unsigned char *p, int len)
unsigned short big5buf,
cnsBuf;
while (len > 0 && (c1 = *mic))
while (len >= 0 && (c1 = *mic))
{
l = pg_mic_mblen(mic++);
len -= l;
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -56,11 +56,11 @@ latin2_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_LATIN2);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
latin22mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -72,11 +72,11 @@ mic_to_latin2(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_LATIN2);
Assert(len > 0);
Assert(len >= 0);
mic2latin2(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -88,11 +88,11 @@ win1250_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
win12502mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -104,11 +104,11 @@ mic_to_win1250(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_WIN1250);
Assert(len > 0);
Assert(len >= 0);
mic2win1250(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -121,14 +121,14 @@ latin2_to_win1250(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_LATIN2);
Assert(PG_GETARG_INT32(1) == PG_WIN1250);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
latin22mic(src, buf, len);
mic2win1250(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -141,14 +141,14 @@ win1250_to_latin2(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
Assert(PG_GETARG_INT32(1) == PG_LATIN2);
Assert(len > 0);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
win12502mic(src, buf, len);
mic2latin2(buf, dest, strlen(buf));
pfree(buf);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
static void
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -56,11 +56,11 @@ latin1_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_LATIN1);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
latin12mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -72,11 +72,11 @@ mic_to_latin1(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_LATIN1);
Assert(len > 0);
Assert(len >= 0);
mic2latin1(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -88,11 +88,11 @@ latin3_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_LATIN3);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
latin32mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -104,11 +104,11 @@ mic_to_latin3(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_LATIN3);
Assert(len > 0);
Assert(len >= 0);
mic2latin3(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -120,11 +120,11 @@ latin4_to_mic(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_LATIN4);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len > 0);
Assert(len >= 0);
latin42mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -136,11 +136,11 @@ mic_to_latin4(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_LATIN4);
Assert(len > 0);
Assert(len >= 0);
mic2latin4(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
static void
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -41,11 +41,11 @@ ascii_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
pg_ascii2mic(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -57,9 +57,9 @@ utf8_to_ascii(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII);
Assert(len > 0);
Assert(len >= 0);
pg_mic2ascii(src, dest, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ big5_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_BIG5);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapBIG5,
sizeof(LUmapBIG5) / sizeof(pg_local_to_utf), PG_BIG5, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_big5(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_BIG5);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapBIG5,
sizeof(ULmapBIG5) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -55,12 +55,12 @@ utf8_to_koi8r(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmap_KOI8R,
sizeof(ULmap_KOI8R) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -72,12 +72,12 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapKOI8R,
sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -89,12 +89,12 @@ utf8_to_win1251(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmap_WIN1251,
sizeof(ULmap_WIN1251) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -106,12 +106,12 @@ win1251_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN1251,
sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -123,12 +123,12 @@ utf8_to_alt(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_ALT);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmap_ALT,
sizeof(ULmap_ALT) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -140,10 +140,10 @@ alt_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_ALT);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapALT,
sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_CN);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapEUC_CN,
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_euc_cn(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_EUC_CN);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapEUC_CN,
sizeof(ULmapEUC_CN) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapEUC_JP,
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_euc_jp(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_EUC_JP);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapEUC_JP,
sizeof(ULmapEUC_JP) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_KR);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapEUC_KR,
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_euc_kr(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_EUC_KR);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapEUC_KR,
sizeof(ULmapEUC_KR) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapEUC_TW,
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_euc_tw(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_EUC_TW);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapEUC_TW,
sizeof(ULmapEUC_TW) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ gb18030_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_GB18030);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapGB18030,
sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_gb18030(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_GB18030);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapGB18030,
sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ gbk_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_GBK);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapGBK,
sizeof(LUmapGBK) / sizeof(pg_local_to_utf), PG_GBK, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_gbk(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_GBK);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapGBK,
sizeof(ULmapGBK) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -133,11 +133,11 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, maps[encoding].map1, maps[encoding].size1, encoding, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -149,9 +149,9 @@ utf8_to_iso8859(PG_FUNCTION_ARGS)
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, maps[encoding].map2, maps[encoding].size2, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,7 +42,7 @@ iso8859_1_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_LATIN1);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
while (len-- > 0 && (c = *src++))
{
......@@ -56,7 +56,7 @@ iso8859_1_to_utf8(PG_FUNCTION_ARGS)
}
*dest = '\0';
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -71,9 +71,9 @@ utf8_to_iso8859_1(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_LATIN1);
Assert(len > 0);
Assert(len >= 0);
while (len > 0 && (c = *src++))
while (len >= 0 && (c = *src++))
{
if ((c & 0xe0) == 0xc0)
{
......@@ -93,5 +93,5 @@ utf8_to_iso8859_1(PG_FUNCTION_ARGS)
}
*dest = '\0';
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ johab_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_JOHAB);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapJOHAB,
sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_johab(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_JOHAB);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapJOHAB,
sizeof(ULmapJOHAB) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ sjis_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_SJIS);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapSJIS,
sizeof(LUmapSJIS) / sizeof(pg_local_to_utf), PG_SJIS, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_sjis(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_SJIS);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapSJIS,
sizeof(ULmapSJIS) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ tcvn_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_TCVN);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapTCVN,
sizeof(LUmapTCVN) / sizeof(pg_local_to_utf), PG_TCVN, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_tcvn(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_TCVN);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapTCVN,
sizeof(ULmapTCVN) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.4 2002/09/13 06:41:17 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -42,12 +42,12 @@ uhc_to_utf8(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UHC);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapUHC,
sizeof(LUmapUHC) / sizeof(pg_local_to_utf), PG_UHC, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -59,10 +59,10 @@ utf8_to_uhc(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_UHC);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapUHC,
sizeof(ULmapUHC) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.4 2002/09/13 06:41:18 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -43,12 +43,12 @@ utf_to_win1250(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_WIN1250);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapWIN1250,
sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -60,10 +60,10 @@ win1250_to_utf(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN1250,
sizeof(LUmapWIN1250) / sizeof(pg_local_to_utf), PG_WIN1250, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.4 2002/09/13 06:41:18 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -43,12 +43,12 @@ utf_to_win1256(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_WIN1256);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapWIN1256,
sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -60,10 +60,10 @@ win1256_to_utf(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN1256);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN1256,
sizeof(LUmapWIN1256) / sizeof(pg_local_to_utf), PG_WIN1256, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.4 2002/09/13 06:41:18 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -43,12 +43,12 @@ utf_to_win874(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_UTF8);
Assert(PG_GETARG_INT32(1) == PG_WIN874);
Assert(len > 0);
Assert(len >= 0);
UtfToLocal(src, dest, ULmapWIN874,
sizeof(ULmapWIN874) / sizeof(pg_utf_to_local), len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Datum
......@@ -60,10 +60,10 @@ win874_to_utf(PG_FUNCTION_ARGS)
Assert(PG_GETARG_INT32(0) == PG_WIN874);
Assert(PG_GETARG_INT32(1) == PG_UTF8);
Assert(len > 0);
Assert(len >= 0);
LocalToUtf(src, dest, LUmapWIN874,
sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len);
PG_RETURN_INT32(0);
PG_RETURN_VOID();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册