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

Commit3c6cd8a

Browse files
committed
Fixes motivated by snake and spoonbill pgbuildfarm members
1 parent725ace4 commit3c6cd8a

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

‎contrib/tsearch2/ts_locale.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,44 @@
88
#if defined(TS_USE_WIDE)&& defined(WIN32)
99

1010
size_t
11-
wchar2char(constchar*to,constwchar_t*from,size_tlen ) {
11+
wchar2char(char*to,constwchar_t*from,size_tlen ) {
1212
if (GetDatabaseEncoding()==PG_UTF8) {
13-
intr;
13+
intr,nbytes;
1414

1515
if (len==0)
1616
return0;
1717

18+
/* in any case, *to should be allocated with enough space */
19+
nbytes=WideCharToMultiByte(CP_UTF8,0,from,len,NULL,0,NULL,NULL);
20+
if (nbytes==0 )
21+
ereport(ERROR,
22+
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
23+
errmsg("UTF-16 to UTF-8 translation failed: %lu",
24+
GetLastError())));
25+
1826
r=WideCharToMultiByte(CP_UTF8,0,from,len,to,nbytes,
1927
NULL,NULL);
2028

21-
2229
if (r==0 )
2330
ereport(ERROR,
2431
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
2532
errmsg("UTF-16 to UTF-8 translation failed: %lu",
2633
GetLastError())));
27-
2834
returnr;
2935
}
3036

3137
returnwcstombs(to,from,len);
3238
}
3339

3440
size_t
35-
char2wchar(constwchar_t*to,constchar*from,size_tlen ) {
41+
char2wchar(wchar_t*to,constchar*from,size_tlen ) {
3642
if (GetDatabaseEncoding()==PG_UTF8) {
3743
intr;
3844

3945
if (len==0)
4046
return0;
4147

42-
r=MultiByteToWideChar(CP_UTF8,0,from,len,
43-
to,len);
48+
r=MultiByteToWideChar(CP_UTF8,0,from,len,to,len);
4449

4550
if (!r) {
4651
pg_verifymbstr(from,len, false);
@@ -50,7 +55,7 @@ char2wchar( const wchar_t *to, const char *from, size_t len ) {
5055
errhint("The server's LC_CTYPE locale is probably incompatible with the database encoding.")));
5156
}
5257

53-
Assert(r <=nbytes);
58+
Assert(r <=len);
5459

5560
returnr;
5661
}

‎contrib/tsearch2/ts_locale.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
#ifdefWIN32
2424

25-
size_twchar2char(constchar*to,constwchar_t*from,size_tlen );
26-
size_tchar2wchar(constwchar_t*to,constchar*from,size_tlen );
25+
size_twchar2char(char*to,constwchar_t*from,size_tlen );
26+
size_tchar2wchar(wchar_t*to,constchar*from,size_tlen );
2727

2828
#else/* WIN32 */
2929

‎contrib/tsearch2/wordparser/parser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ TParserClose( TParser* prs ) {
7979
static int\
8080
p_is##type(TParser *prs) {\
8181
Assert( prs->state );\
82-
return ( ( prs->usewide ) ? isw##type( (wint_t)*( prs->wstr + prs->state->poschar ) ) :\
82+
return ( ( prs->usewide ) ? isw##type( (wint_t)*( prs->wstr + prs->state->poschar ) ) :\
8383
is##type( (unsigned char)*( prs->str + prs->state->posbyte ) ) );\
8484
}\
8585
\
@@ -104,7 +104,7 @@ p_iseq(TParser *prs, char c) {
104104
static int\
105105
p_is##type(TParser *prs) {\
106106
Assert( prs->state );\
107-
return is##type( (unsigned char)*( prs->str + prs->state->posbyte ) ) );\
107+
return is##type( (unsigned char)*( prs->str + prs->state->posbyte ) );\
108108
}\
109109
\
110110
static int\
@@ -116,7 +116,7 @@ p_isnot##type(TParser *prs) {\
116116
staticint
117117
p_iseq(TParser*prs,charc) {
118118
Assert(prs->state );
119-
return (*(prs->str+prs->state->posbyte )==c ))?1 :0;
119+
return (*(prs->str+prs->state->posbyte )==c ) ?1 :0;
120120
}
121121

122122
#endif/* TS_USE_WIDE */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp