Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbfdd6a7

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 parent86ff9d2 commitbfdd6a7

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-
#ifdefDEBUGMAIN
1524-
#include"postgres.h"
1525-
#include"utils/memutils.h"
1526-
/*
1527-
*testing for sjis2mic() and mic2sjis()
1528-
*/
1529-
1530-
int
1531-
main()
1532-
{
1533-
unsignedchareucbuf[1024];
1534-
unsignedcharsjisbuf[1024];
1535-
unsignedcharsjis[]= {0x81,0x40,0xa1,0xf0,0x40,0xf0,0x9e,0xf5,0x40,0xfa,0x40,0xfa,0x54,0xfa,0x7b,0x00};
1536-
1537-
inti;
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(intlev,constchar*fmt,...)
1568-
{
1569-
}
1570-
1571-
MemoryContextCurrentMemoryContext;
1572-
1573-
void*
1574-
MemoryContextAlloc(MemoryContextcontext,Sizesize)
1575-
{
1576-
}
1577-
1578-
void
1579-
pfree(void*pointer)
1580-
{
1581-
}
1582-
1583-
void*
1584-
repalloc(void*pointer,Sizesize)
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(constunsignedchar*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(constunsignedchar*from,pg_wchar*to,intlen)
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-
staticvoidpg_ascii2wchar_with_len
23+
staticintpg_ascii2wchar_with_len
2424
(constunsignedchar*from,pg_wchar*to,intlen)
2525
{
26+
intcnt=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
staticint
@@ -41,9 +45,11 @@ pg_ascii_mblen(const unsigned char *s)
4145
* EUC
4246
*/
4347

44-
staticvoidpg_euc2wchar_with_len
48+
staticintpg_euc2wchar_with_len
4549
(constunsignedchar*from,pg_wchar*to,intlen)
4650
{
51+
intcnt=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
staticint
@@ -95,10 +103,10 @@ pg_euc_mblen(const unsigned char *s)
95103
/*
96104
* EUC_JP
97105
*/
98-
staticvoidpg_eucjp2wchar_with_len
106+
staticintpg_eucjp2wchar_with_len
99107
(constunsignedchar*from,pg_wchar*to,intlen)
100108
{
101-
pg_euc2wchar_with_len(from,to,len);
109+
return(pg_euc2wchar_with_len(from,to,len));
102110
}
103111

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

119127
staticint
@@ -125,9 +133,11 @@ pg_euckr_mblen(const unsigned char *s)
125133
/*
126134
* EUC_CN
127135
*/
128-
staticvoidpg_euccn2wchar_with_len
136+
staticintpg_euccn2wchar_with_len
129137
(constunsignedchar*from,pg_wchar*to,intlen)
130138
{
139+
intcnt=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
staticint
@@ -176,9 +188,11 @@ pg_euccn_mblen(const unsigned char *s)
176188
/*
177189
* EUC_TW
178190
*/
179-
staticvoidpg_euctw2wchar_with_len
191+
staticintpg_euctw2wchar_with_len
180192
(constunsignedchar*from,pg_wchar*to,intlen)
181193
{
194+
intcnt=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
staticint
@@ -235,12 +251,13 @@ pg_euctw_mblen(const unsigned char *s)
235251
* len: length of from.
236252
* "from" not necessarily null terminated.
237253
*/
238-
staticvoid
254+
staticint
239255
pg_utf2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
240256
{
241257
unsignedcharc1,
242258
c2,
243259
c3;
260+
intcnt=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
staticint
@@ -297,9 +316,11 @@ pg_utf_mblen(const unsigned char *s)
297316
* len: length of from.
298317
* "from" not necessarily null terminated.
299318
*/
300-
staticvoid
319+
staticint
301320
pg_mule2wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
302321
{
322+
intcnt=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-
staticvoid
389+
staticint
367390
pg_latin12wchar_with_len(constunsignedchar*from,pg_wchar*to,intlen)
368391
{
392+
intcnt=0;
393+
369394
while (*from&&len-->0)
395+
{
370396
*to++=*from++;
397+
cnt++;
398+
}
371399
*to=0;
400+
return(cnt);
372401
}
373402

374403
staticint

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp