Skip to content

Commit e467944

Browse files
committed
Make configure probe for mbstowcs_l as well as wcstombs_l.
We previously supposed that any given platform would supply both or neither of these functions, so that one configure test would be sufficient. It now appears that at least on AIX this is not the case ... which is likely an AIX bug, but nonetheless we need to cope with it. So use separate tests. Per bug #6758; thanks to Andrew Hastie for doing the followup testing needed to confirm what was happening. Backpatch to 9.1, where we began using these functions.
1 parent d2528e5 commit e467944

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19149,7 +19149,8 @@ fi
1914919149

1915019150

1915119151

19152-
for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes waitpid wcstombs wcstombs_l
19152+
19153+
for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes waitpid wcstombs wcstombs_l
1915319154
do
1915419155
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1915519156
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ PGAC_VAR_INT_TIMEZONE
11971197
AC_FUNC_ACCEPT_ARGTYPES
11981198
PGAC_FUNC_GETTIMEOFDAY_1ARG
11991199

1200-
AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes waitpid wcstombs wcstombs_l])
1200+
AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid sigprocmask symlink towlower utime utimes waitpid wcstombs wcstombs_l])
12011201

12021202
AC_REPLACE_FUNCS(fseeko)
12031203
case $host_os in

src/backend/utils/adt/pg_locale.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,17 +1205,17 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen,
12051205
else
12061206
{
12071207
#ifdef HAVE_LOCALE_T
1208-
#ifdef HAVE_WCSTOMBS_L
1208+
#ifdef HAVE_MBSTOWCS_L
12091209
/* Use mbstowcs_l for nondefault locales */
12101210
result = mbstowcs_l(to, str, tolen, locale);
1211-
#else /* !HAVE_WCSTOMBS_L */
1211+
#else /* !HAVE_MBSTOWCS_L */
12121212
/* We have to temporarily set the locale as current ... ugh */
12131213
locale_t save_locale = uselocale(locale);
12141214

12151215
result = mbstowcs(to, str, tolen);
12161216

12171217
uselocale(save_locale);
1218-
#endif /* HAVE_WCSTOMBS_L */
1218+
#endif /* HAVE_MBSTOWCS_L */
12191219
#else /* !HAVE_LOCALE_T */
12201220
/* Can't have locale != 0 without HAVE_LOCALE_T */
12211221
elog(ERROR, "mbstowcs_l is not available");

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@
333333
/* Define to 1 if `long long int' works and is 64 bits. */
334334
#undef HAVE_LONG_LONG_INT_64
335335

336+
/* Define to 1 if you have the `mbstowcs_l' function. */
337+
#undef HAVE_MBSTOWCS_L
338+
336339
/* Define to 1 if you have the `memmove' function. */
337340
#undef HAVE_MEMMOVE
338341

src/include/pg_config.h.win32

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@
249249
#define HAVE_LONG_LONG_INT_64
250250
#endif
251251

252+
/* Define to 1 if you have the `mbstowcs_l' function. */
253+
#define HAVE_MBSTOWCS_L 1
254+
252255
/* Define to 1 if you have the `memmove' function. */
253256
#define HAVE_MEMMOVE 1
254257

0 commit comments

Comments
 (0)