Skip to content

Commit bfdd6a7

Browse files
committed
Change pg_mblen and pg_encoding_mblen return types from void
to int so that they return the number of whcars.
1 parent 86ff9d2 commit bfdd6a7

File tree

4 files changed

+64
-89
lines changed

4 files changed

+64
-89
lines changed

src/backend/utils/mb/Makefile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for utils/mb
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.8 2000/05/29 05:45:34 tgl Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.9 2000/08/27 10:40:48 ishii Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -19,9 +19,22 @@ all: SUBSYS.o
1919
SUBSYS.o: $(OBJS)
2020
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
2121

22-
sjistest: $(OBJS)
23-
$(CC) -c $(CFLAGS) -DDEBUGMAIN conv.c
24-
$(CC) -o sjistest conv.o \
22+
palloc.o: palloc.c
23+
$(CC) -c $(CFLAGS) palloc.c
24+
25+
sjistest.o: sjistest.c
26+
$(CC) -c $(CFLAGS) sjistest.c
27+
28+
liketest.o: liketest.c
29+
$(CC) -c $(CFLAGS) liketest.c
30+
31+
sjistest: $(OBJS) sjistest.o palloc.o
32+
$(CC) -o sjistest sjistest.o palloc.o \
33+
common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o \
34+
big5.o $(LDFLAGS)
35+
36+
liketest: $(OBJS) liketest.o palloc.o
37+
$(CC) -o liketest liketest.o palloc.o conv.o \
2538
common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o \
2639
big5.o $(LDFLAGS)
2740

src/backend/utils/mb/conv.c

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* WIN1250 client encoding support contributed by Pavel Behal
77
* SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya
88
*
9-
* $Id: conv.c,v 1.16 2000/06/28 03:32:45 tgl Exp $
9+
* $Id: conv.c,v 1.17 2000/08/27 10:40:48 ishii Exp $
1010
*
1111
*
1212
*/
@@ -1519,70 +1519,3 @@ pg_encoding_conv_tbl pg_conv_tbl[] = {
15191519
{WIN1250, "WIN1250", 1, win12502mic, mic2win1250}, /* WIN 1250 */
15201520
{-1, "", 0, 0, 0} /* end mark */
15211521
};
1522-
1523-
#ifdef DEBUGMAIN
1524-
#include "postgres.h"
1525-
#include "utils/memutils.h"
1526-
/*
1527-
* testing for sjis2mic() and mic2sjis()
1528-
*/
1529-
1530-
int
1531-
main()
1532-
{
1533-
unsigned char eucbuf[1024];
1534-
unsigned char sjisbuf[1024];
1535-
unsigned char sjis[] = {0x81, 0x40, 0xa1, 0xf0, 0x40, 0xf0, 0x9e, 0xf5, 0x40, 0xfa, 0x40, 0xfa, 0x54, 0xfa, 0x7b, 0x00};
1536-
1537-
int i;
1538-
1539-
sjis2mic(sjis, eucbuf, 1024);
1540-
for (i = 0; i < 1024; i++)
1541-
{
1542-
if (eucbuf[i])
1543-
printf("%02x ", eucbuf[i]);
1544-
else
1545-
{
1546-
printf("\n");
1547-
break;
1548-
}
1549-
}
1550-
1551-
mic2sjis(eucbuf, sjisbuf, 1024);
1552-
for (i = 0; i < 1024; i++)
1553-
{
1554-
if (sjisbuf[i])
1555-
printf("%02x ", sjisbuf[i]);
1556-
else
1557-
{
1558-
printf("\n");
1559-
break;
1560-
}
1561-
}
1562-
1563-
return (0);
1564-
}
1565-
1566-
void
1567-
elog(int lev, const char *fmt,...)
1568-
{
1569-
}
1570-
1571-
MemoryContext CurrentMemoryContext;
1572-
1573-
void *
1574-
MemoryContextAlloc(MemoryContext context, Size size)
1575-
{
1576-
}
1577-
1578-
void
1579-
pfree(void *pointer)
1580-
{
1581-
}
1582-
1583-
void *
1584-
repalloc(void *pointer, Size size)
1585-
{
1586-
}
1587-
1588-
#endif

src/backend/utils/mb/mbutils.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* client encoding and server internal encoding.
44
* (currently mule internal code (mic) is used)
55
* Tatsuo Ishii
6-
* $Id: mbutils.c,v 1.10 2000/06/13 07:35:12 tgl Exp $ */
6+
* $Id: mbutils.c,v 1.11 2000/08/27 10:40:48 ishii Exp $ */
77

88

99
#include "postgres.h"
@@ -173,17 +173,17 @@ pg_server_to_client(unsigned char *s, int len)
173173
}
174174

175175
/* convert a multi-byte string to a wchar */
176-
void
176+
int
177177
pg_mb2wchar(const unsigned char *from, pg_wchar * to)
178178
{
179-
(*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, strlen(from));
179+
return (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, strlen(from));
180180
}
181181

182182
/* convert a multi-byte string to a wchar with a limited length */
183-
void
183+
int
184184
pg_mb2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
185185
{
186-
(*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, len);
186+
return (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, len);
187187
}
188188

189189
/* returns the byte length of a multi-byte word */

src/backend/utils/mb/wchar.c

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* conversion functions between pg_wchar and multi-byte streams.
33
* Tatsuo Ishii
4-
* $Id: wchar.c,v 1.11 2000/04/12 17:16:06 momjian Exp $
4+
* $Id: wchar.c,v 1.12 2000/08/27 10:40:48 ishii Exp $
55
*
66
* WIN1250 client encoding updated by Pavel Behal
77
*
@@ -20,15 +20,19 @@
2020
/*
2121
* SQL/ASCII
2222
*/
23-
static void pg_ascii2wchar_with_len
23+
static int pg_ascii2wchar_with_len
2424
(const unsigned char *from, pg_wchar * to, int len)
2525
{
26+
int cnt = 0;
27+
2628
while (*from && len > 0)
2729
{
2830
*to++ = *from++;
2931
len--;
32+
cnt++;
3033
}
3134
*to = 0;
35+
return(cnt);
3236
}
3337

3438
static int
@@ -41,9 +45,11 @@ pg_ascii_mblen(const unsigned char *s)
4145
* EUC
4246
*/
4347

44-
static void pg_euc2wchar_with_len
48+
static int pg_euc2wchar_with_len
4549
(const unsigned char *from, pg_wchar * to, int len)
4650
{
51+
int cnt = 0;
52+
4753
while (*from && len > 0)
4854
{
4955
if (*from == SS2)
@@ -72,8 +78,10 @@ static void pg_euc2wchar_with_len
7278
len--;
7379
}
7480
to++;
81+
cnt++;
7582
}
7683
*to = 0;
84+
return(cnt);
7785
}
7886

7987
static int
@@ -95,10 +103,10 @@ pg_euc_mblen(const unsigned char *s)
95103
/*
96104
* EUC_JP
97105
*/
98-
static void pg_eucjp2wchar_with_len
106+
static int pg_eucjp2wchar_with_len
99107
(const unsigned char *from, pg_wchar * to, int len)
100108
{
101-
pg_euc2wchar_with_len(from, to, len);
109+
return(pg_euc2wchar_with_len(from, to, len));
102110
}
103111

104112
static int
@@ -110,10 +118,10 @@ pg_eucjp_mblen(const unsigned char *s)
110118
/*
111119
* EUC_KR
112120
*/
113-
static void pg_euckr2wchar_with_len
121+
static int pg_euckr2wchar_with_len
114122
(const unsigned char *from, pg_wchar * to, int len)
115123
{
116-
pg_euc2wchar_with_len(from, to, len);
124+
return(pg_euc2wchar_with_len(from, to, len));
117125
}
118126

119127
static int
@@ -125,9 +133,11 @@ pg_euckr_mblen(const unsigned char *s)
125133
/*
126134
* EUC_CN
127135
*/
128-
static void pg_euccn2wchar_with_len
136+
static int pg_euccn2wchar_with_len
129137
(const unsigned char *from, pg_wchar * to, int len)
130138
{
139+
int cnt = 0;
140+
131141
while (*from && len > 0)
132142
{
133143
if (*from == SS2)
@@ -157,8 +167,10 @@ static void pg_euccn2wchar_with_len
157167
len--;
158168
}
159169
to++;
170+
cnt++;
160171
}
161172
*to = 0;
173+
return(cnt);
162174
}
163175

164176
static int
@@ -176,9 +188,11 @@ pg_euccn_mblen(const unsigned char *s)
176188
/*
177189
* EUC_TW
178190
*/
179-
static void pg_euctw2wchar_with_len
191+
static int pg_euctw2wchar_with_len
180192
(const unsigned char *from, pg_wchar * to, int len)
181193
{
194+
int cnt = 0;
195+
182196
while (*from && len > 0)
183197
{
184198
if (*from == SS2)
@@ -209,8 +223,10 @@ static void pg_euctw2wchar_with_len
209223
len--;
210224
}
211225
to++;
226+
cnt++;
212227
}
213228
*to = 0;
229+
return(cnt);
214230
}
215231

216232
static int
@@ -235,12 +251,13 @@ pg_euctw_mblen(const unsigned char *s)
235251
* len: length of from.
236252
* "from" not necessarily null terminated.
237253
*/
238-
static void
254+
static int
239255
pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
240256
{
241257
unsigned char c1,
242258
c2,
243259
c3;
260+
int cnt = 0;
244261

245262
while (*from && len > 0)
246263
{
@@ -273,8 +290,10 @@ pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
273290
len--;
274291
}
275292
to++;
293+
cnt++;
276294
}
277295
*to = 0;
296+
return(cnt);
278297
}
279298

280299
static int
@@ -297,9 +316,11 @@ pg_utf_mblen(const unsigned char *s)
297316
* len: length of from.
298317
* "from" not necessarily null terminated.
299318
*/
300-
static void
319+
static int
301320
pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
302321
{
322+
int cnt = 0;
323+
303324
while (*from && len > 0)
304325
{
305326
if (IS_LC1(*from))
@@ -336,8 +357,10 @@ pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
336357
len--;
337358
}
338359
to++;
360+
cnt++;
339361
}
340362
*to = 0;
363+
return(cnt);
341364
}
342365

343366
int
@@ -363,12 +386,18 @@ pg_mule_mblen(const unsigned char *s)
363386
/*
364387
* ISO8859-1
365388
*/
366-
static void
389+
static int
367390
pg_latin12wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
368391
{
392+
int cnt = 0;
393+
369394
while (*from && len-- > 0)
395+
{
370396
*to++ = *from++;
397+
cnt++;
398+
}
371399
*to = 0;
400+
return(cnt);
372401
}
373402

374403
static int

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy