to int so that they return the number of whcars.
# Makefile for utils/mb
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.8 2000/05/29 05:45:34 tgl Exp $
+# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.9 2000/08/27 10:40:48 ishii Exp $
#
#-------------------------------------------------------------------------
SUBSYS.o: $(OBJS)
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
-sjistest: $(OBJS)
- $(CC) -c $(CFLAGS) -DDEBUGMAIN conv.c
- $(CC) -o sjistest conv.o \
+palloc.o: palloc.c
+ $(CC) -c $(CFLAGS) palloc.c
+
+sjistest.o: sjistest.c
+ $(CC) -c $(CFLAGS) sjistest.c
+
+liketest.o: liketest.c
+ $(CC) -c $(CFLAGS) liketest.c
+
+sjistest: $(OBJS) sjistest.o palloc.o
+ $(CC) -o sjistest sjistest.o palloc.o \
+ common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o \
+ big5.o $(LDFLAGS)
+
+liketest: $(OBJS) liketest.o palloc.o
+ $(CC) -o liketest liketest.o palloc.o conv.o \
common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o \
big5.o $(LDFLAGS)
* WIN1250 client encoding support contributed by Pavel Behal
* SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya
*
- * $Id: conv.c,v 1.16 2000/06/28 03:32:45 tgl Exp $
+ * $Id: conv.c,v 1.17 2000/08/27 10:40:48 ishii Exp $
*
*
*/
{WIN1250, "WIN1250", 1, win12502mic, mic2win1250}, /* WIN 1250 */
{-1, "", 0, 0, 0} /* end mark */
};
-
-#ifdef DEBUGMAIN
-#include "postgres.h"
-#include "utils/memutils.h"
-/*
- * testing for sjis2mic() and mic2sjis()
- */
-
-int
-main()
-{
- unsigned char eucbuf[1024];
- unsigned char sjisbuf[1024];
- unsigned char sjis[] = {0x81, 0x40, 0xa1, 0xf0, 0x40, 0xf0, 0x9e, 0xf5, 0x40, 0xfa, 0x40, 0xfa, 0x54, 0xfa, 0x7b, 0x00};
-
- int i;
-
- sjis2mic(sjis, eucbuf, 1024);
- for (i = 0; i < 1024; i++)
- {
- if (eucbuf[i])
- printf("%02x ", eucbuf[i]);
- else
- {
- printf("\n");
- break;
- }
- }
-
- mic2sjis(eucbuf, sjisbuf, 1024);
- for (i = 0; i < 1024; i++)
- {
- if (sjisbuf[i])
- printf("%02x ", sjisbuf[i]);
- else
- {
- printf("\n");
- break;
- }
- }
-
- return (0);
-}
-
-void
-elog(int lev, const char *fmt,...)
-{
-}
-
-MemoryContext CurrentMemoryContext;
-
-void *
-MemoryContextAlloc(MemoryContext context, Size size)
-{
-}
-
-void
-pfree(void *pointer)
-{
-}
-
-void *
-repalloc(void *pointer, Size size)
-{
-}
-
-#endif
* client encoding and server internal encoding.
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
- * $Id: mbutils.c,v 1.10 2000/06/13 07:35:12 tgl Exp $ */
+ * $Id: mbutils.c,v 1.11 2000/08/27 10:40:48 ishii Exp $ */
#include "postgres.h"
}
/* convert a multi-byte string to a wchar */
-void
+int
pg_mb2wchar(const unsigned char *from, pg_wchar * to)
{
- (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, strlen(from));
+ return (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, strlen(from));
}
/* convert a multi-byte string to a wchar with a limited length */
-void
+int
pg_mb2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
{
- (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, len);
+ return (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, len);
}
/* returns the byte length of a multi-byte word */
/*
* conversion functions between pg_wchar and multi-byte streams.
* Tatsuo Ishii
- * $Id: wchar.c,v 1.11 2000/04/12 17:16:06 momjian Exp $
+ * $Id: wchar.c,v 1.12 2000/08/27 10:40:48 ishii Exp $
*
* WIN1250 client encoding updated by Pavel Behal
*
/*
* SQL/ASCII
*/
-static void pg_ascii2wchar_with_len
+static int pg_ascii2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
{
+ int cnt = 0;
+
while (*from && len > 0)
{
*to++ = *from++;
len--;
+ cnt++;
}
*to = 0;
+ return(cnt);
}
static int
* EUC
*/
-static void pg_euc2wchar_with_len
+static int pg_euc2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
{
+ int cnt = 0;
+
while (*from && len > 0)
{
if (*from == SS2)
len--;
}
to++;
+ cnt++;
}
*to = 0;
+ return(cnt);
}
static int
/*
* EUC_JP
*/
-static void pg_eucjp2wchar_with_len
+static int pg_eucjp2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
{
- pg_euc2wchar_with_len(from, to, len);
+ return(pg_euc2wchar_with_len(from, to, len));
}
static int
/*
* EUC_KR
*/
-static void pg_euckr2wchar_with_len
+static int pg_euckr2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
{
- pg_euc2wchar_with_len(from, to, len);
+ return(pg_euc2wchar_with_len(from, to, len));
}
static int
/*
* EUC_CN
*/
-static void pg_euccn2wchar_with_len
+static int pg_euccn2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
{
+ int cnt = 0;
+
while (*from && len > 0)
{
if (*from == SS2)
len--;
}
to++;
+ cnt++;
}
*to = 0;
+ return(cnt);
}
static int
/*
* EUC_TW
*/
-static void pg_euctw2wchar_with_len
+static int pg_euctw2wchar_with_len
(const unsigned char *from, pg_wchar * to, int len)
{
+ int cnt = 0;
+
while (*from && len > 0)
{
if (*from == SS2)
len--;
}
to++;
+ cnt++;
}
*to = 0;
+ return(cnt);
}
static int
* len: length of from.
* "from" not necessarily null terminated.
*/
-static void
+static int
pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
{
unsigned char c1,
c2,
c3;
+ int cnt = 0;
while (*from && len > 0)
{
len--;
}
to++;
+ cnt++;
}
*to = 0;
+ return(cnt);
}
static int
* len: length of from.
* "from" not necessarily null terminated.
*/
-static void
+static int
pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
{
+ int cnt = 0;
+
while (*from && len > 0)
{
if (IS_LC1(*from))
len--;
}
to++;
+ cnt++;
}
*to = 0;
+ return(cnt);
}
int
/*
* ISO8859-1
*/
-static void
+static int
pg_latin12wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
{
+ int cnt = 0;
+
while (*from && len-- > 0)
+ {
*to++ = *from++;
+ cnt++;
+ }
*to = 0;
+ return(cnt);
}
static int