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

Commitb4ce97a

Browse files
committed
Cope if platform declares mbstowcs_l(), but not locale_t, in <xlocale.h>.
Previously, we included <xlocale.h> only if necessary to get the definitionof type locale_t. According to notes in PGAC_TYPE_LOCALE_T, this isimportant because on some versions of glibc that file supplies anincompatible declaration of locale_t. (This info may be obsolete, becauseon my RHEL6 box that seems to be the *only* definition of locale_t; butthere may still be glibc's in the wild for which it's a live concern.)It turns out though that on FreeBSD and maybe other BSDen, you can getlocale_t from stdlib.h or locale.h but mbstowcs_l() and friends only from<xlocale.h>. This was leaving us compiling calls to mbstowcs_l() andfriends with no visible prototype, which causes a warning and couldpossibly cause actual trouble, since it's not declared to return int.Hence, adjust the configure checks so that we'll include <xlocale.h>either if it's necessary to get type locale_t or if it's necessary toget a declaration of mbstowcs_l().Report and patch by Aleksander Alekseev, somewhat whacked around by me.Back-patch to all supported branches, since we have been usingmbstowcs_l() since 9.1.
1 parent1bee54e commitb4ce97a

File tree

6 files changed

+92
-2
lines changed

6 files changed

+92
-2
lines changed

‎config/c-library.m4

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,34 @@ fi
343343
if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
344344
AC_DEFINE(LOCALE_T_IN_XLOCALE,1,
345345
[Define to 1 if `locale_t' requires <xlocale.h>.])
346-
fi])])# PGAC_HEADER_XLOCALE
346+
fi])# PGAC_TYPE_LOCALE_T
347+
348+
349+
# PGAC_FUNC_WCSTOMBS_L
350+
# --------------------
351+
# Try to find a declaration for wcstombs_l(). It might be in stdlib.h
352+
# (following the POSIX requirement for wcstombs()), or in locale.h, or in
353+
# xlocale.h. If it's in the latter, define WCSTOMBS_L_IN_XLOCALE.
354+
#
355+
AC_DEFUN([PGAC_FUNC_WCSTOMBS_L],
356+
[AC_CACHE_CHECK([for wcstombs_l declaration],pgac_cv_func_wcstombs_l,
357+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
358+
[#include <stdlib.h>
359+
#include <locale.h>],
360+
[#ifndef wcstombs_l
361+
(void) wcstombs_l;
362+
#endif])],
363+
[pgac_cv_func_wcstombs_l='yes'],
364+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
365+
[#include <stdlib.h>
366+
#include <locale.h>
367+
#include <xlocale.h>],
368+
[#ifndef wcstombs_l
369+
(void) wcstombs_l;
370+
#endif])],
371+
[pgac_cv_func_wcstombs_l='yes (in xlocale.h)'],
372+
[pgac_cv_func_wcstombs_l='no'])])])
373+
if test "$pgac_cv_func_wcstombs_l" = 'yes (in xlocale.h)'; then
374+
AC_DEFINE(WCSTOMBS_L_IN_XLOCALE,1,
375+
[Define to 1 if `wcstombs_l' requires <xlocale.h>.])
376+
fi])# PGAC_FUNC_WCSTOMBS_L

‎configure

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11557,6 +11557,59 @@ $as_echo "#define GETTIMEOFDAY_1ARG 1" >>confdefs.h
1155711557

1155811558
fi
1155911559

11560+
{$as_echo"$as_me:${as_lineno-$LINENO}: checking for wcstombs_l declaration">&5
11561+
$as_echo_n"checking for wcstombs_l declaration...">&6; }
11562+
if${pgac_cv_func_wcstombs_l+:}false;then:
11563+
$as_echo_n"(cached)">&6
11564+
else
11565+
cat confdefs.h -<<_ACEOF >conftest.$ac_ext
11566+
/* end confdefs.h. */
11567+
#include <stdlib.h>
11568+
#include <locale.h>
11569+
int
11570+
main ()
11571+
{
11572+
#ifndef wcstombs_l
11573+
(void) wcstombs_l;
11574+
#endif
11575+
;
11576+
return 0;
11577+
}
11578+
_ACEOF
11579+
if ac_fn_c_try_compile"$LINENO";then:
11580+
pgac_cv_func_wcstombs_l='yes'
11581+
else
11582+
cat confdefs.h -<<_ACEOF >conftest.$ac_ext
11583+
/* end confdefs.h. */
11584+
#include <stdlib.h>
11585+
#include <locale.h>
11586+
#include <xlocale.h>
11587+
int
11588+
main ()
11589+
{
11590+
#ifndef wcstombs_l
11591+
(void) wcstombs_l;
11592+
#endif
11593+
;
11594+
return 0;
11595+
}
11596+
_ACEOF
11597+
if ac_fn_c_try_compile"$LINENO";then:
11598+
pgac_cv_func_wcstombs_l='yes (in xlocale.h)'
11599+
else
11600+
pgac_cv_func_wcstombs_l='no'
11601+
fi
11602+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11603+
fi
11604+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11605+
fi
11606+
{$as_echo"$as_me:${as_lineno-$LINENO}: result:$pgac_cv_func_wcstombs_l">&5
11607+
$as_echo"$pgac_cv_func_wcstombs_l">&6; }
11608+
iftest"$pgac_cv_func_wcstombs_l" ='yes (in xlocale.h)';then
11609+
11610+
$as_echo"#define WCSTOMBS_L_IN_XLOCALE 1">>confdefs.h
11611+
11612+
fi
1156011613

1156111614
# Some versions of libedit contain strlcpy(), setproctitle(), and other
1156211615
# symbols that that library has no business exposing to the world. Pending

‎configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,7 @@ fi
13171317
PGAC_VAR_INT_TIMEZONE
13181318
AC_FUNC_ACCEPT_ARGTYPES
13191319
PGAC_FUNC_GETTIMEOFDAY_1ARG
1320+
PGAC_FUNC_WCSTOMBS_L
13201321

13211322
# Some versions of libedit contain strlcpy(), setproctitle(), and other
13221323
# symbols that that library has no business exposing to the world. Pending

‎src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,9 @@
851851
/* Define to select Win32-style shared memory. */
852852
#undef USE_WIN32_SHARED_MEMORY
853853

854+
/* Define to 1 if `wcstombs_l' requires <xlocale.h>. */
855+
#undef WCSTOMBS_L_IN_XLOCALE
856+
854857
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
855858
significant byte first (like Motorola and SPARC, unlike Intel). */
856859
#if definedAC_APPLE_UNIVERSAL_BUILD

‎src/include/pg_config.h.win32

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,9 @@
670670
/* Define to select Win32-style semaphores. */
671671
#define USE_WIN32_SEMAPHORES 1
672672

673+
/* Define to 1 if `wcstombs_l' requires <xlocale.h>. */
674+
/* #undef WCSTOMBS_L_IN_XLOCALE */
675+
673676
/* Number of bits in a file offset, on hosts where this is settable. */
674677
/* #undef _FILE_OFFSET_BITS */
675678

‎src/include/utils/pg_locale.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define_PG_LOCALE_
1414

1515
#include<locale.h>
16-
#ifdefLOCALE_T_IN_XLOCALE
16+
#if defined(LOCALE_T_IN_XLOCALE)|| defined(WCSTOMBS_L_IN_XLOCALE)
1717
#include<xlocale.h>
1818
#endif
1919

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp