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

Commit4e9fa6d

Browse files
committed
Don't expose Windows' mbstowcs_l() and wcstombs_l().
Windows has similar functions with leading underscores. Previously, weprovided the rename via a macro in win32_port.h. In fact its functionsare not always good replacements for the Unix functions, since theycan't deal with UTF-8. They are only currently used by pg_locale.c,which is careful to redirect to other Windows routines for UTF-8. Giventhat portability hazard, it seem unlikely to be a good idea to encourageany other code to think of these functions as being available outsidepg_locale.c. Any code that thinks it wants these functions probablywants our wchar2char() or char2wchar() routines instead, or it won'tactually work on Windows in UTF-8 databases.Furthermore, some major libc implementations including glibc don't havethem (they only have the standard variants without _l), so external codeis very unlikely to require them to exist.Reviewed-by: Peter Eisentraut <peter@eisentraut.org>Discussion:https://postgr.es/m/CA%2BhUKG%2Bt_CHPzEoPnKyARJBJgE9-GxNajJo6ZuSfRK_KWFO%2B6w%40mail.gmail.com
1 parenta8b7424 commit4e9fa6d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,36 +154,41 @@ static void icu_set_collation_attributes(UCollator *collator, const char *loc,
154154
UErrorCode*status);
155155
#endif
156156

157-
#ifndefWIN32
158157
/*
159158
* POSIX doesn't define _l-variants of these functions, but several systems
160-
* have them. We provide our own replacements here. For Windows, we have
161-
* macros in win32_port.h.
159+
* have them. We provide our own replacements here.
162160
*/
163161
#ifndefHAVE_MBSTOWCS_L
164162
staticsize_t
165163
mbstowcs_l(wchar_t*dest,constchar*src,size_tn,locale_tloc)
166164
{
165+
#ifdefWIN32
166+
return_mbstowcs_l(dest,src,n,loc);
167+
#else
167168
size_tresult;
168169
locale_tsave_locale=uselocale(loc);
169170

170171
result=mbstowcs(dest,src,n);
171172
uselocale(save_locale);
172173
returnresult;
174+
#endif
173175
}
174176
#endif
175177
#ifndefHAVE_WCSTOMBS_L
176178
staticsize_t
177179
wcstombs_l(char*dest,constwchar_t*src,size_tn,locale_tloc)
178180
{
181+
#ifdefWIN32
182+
return_wcstombs_l(dest,src,n,loc);
183+
#else
179184
size_tresult;
180185
locale_tsave_locale=uselocale(loc);
181186

182187
result=wcstombs(dest,src,n);
183188
uselocale(save_locale);
184189
returnresult;
185-
}
186190
#endif
191+
}
187192
#endif
188193

189194
/*

‎src/include/port/win32_port.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,6 @@ extern int_pglstat64(const char *name, struct stat *buf);
455455
#definestrcoll_l _strcoll_l
456456
#definestrxfrm_l _strxfrm_l
457457
#definewcscoll_l _wcscoll_l
458-
#definewcstombs_l _wcstombs_l
459-
#definembstowcs_l _mbstowcs_l
460458

461459
/*
462460
* Versions of libintl >= 0.18? try to replace setlocale() with a macro

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp