From 1293cd8b6ab48ff2df4949f261b89c92158af9db Mon Sep 17 00:00:00 2001 From: David Adam Date: Tue, 15 Nov 2016 12:12:23 +0800 Subject: [PATCH] Check for functions in std namespace On Solaris, some standard wide character functions are only contained in the std:: namespace. The configure script now checks for these, enabling the appropriate `uses` statements in src/common.h. The checks are handwritten, because Autoconf's AC_CHECK_FUNC macro always uses C linkage, but the problem only appears under C++ linkage. Work on #3340. --- configure.ac | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/common.h | 12 +++++++++++ 2 files changed, 68 insertions(+) diff --git a/configure.ac b/configure.ac index 6f58a0756..c35d67709 100644 --- a/configure.ac +++ b/configure.ac @@ -314,6 +314,62 @@ AC_CHECK_FUNCS( getpwent ) AC_CHECK_DECL( [mkostemp], [ AC_CHECK_FUNCS([mkostemp]) ] ) +dnl AC_CHECK_FUNCS uses C linkage, but sometimes (Solaris!) the behaviour is +dnl different with C++. +AC_MSG_CHECKING([for wcsdup]) +AC_TRY_LINK( [ #include ], + [ wchar_t* foo = wcsdup(L""); ], + [ AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_WCSDUP, 1, Define to 1 if you have the `wcsdup' function.) + ], + [AC_MSG_RESULT(no)], + ) + +AC_MSG_CHECKING([for std::wcsdup]) +AC_TRY_LINK( [ #include ], + [ wchar_t* foo = std::wcsdup(L""); ], + [ AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_STD__WCSDUP, 1, Define to 1 if you have the `std::wcsdup' function.) + ], + [AC_MSG_RESULT(no)], + ) + +AC_MSG_CHECKING([for wcscasecmp]) +AC_TRY_LINK( [ #include ], + [ int foo = wcscasecmp(L"", L""); ], + [ AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_WCSCASECMP, 1, Define to 1 if you have the `wcscasecmp' function.) + ], + [AC_MSG_RESULT(no)], + ) + +AC_MSG_CHECKING([for std::wcscasecmp]) +AC_TRY_LINK( [ #include ], + [ int foo = std::wcscasecmp(L"", L""); ], + [ AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_STD__WCSCASECMP, 1, Define to 1 if you have the `std::wcscasecmp' function.) + ], + [AC_MSG_RESULT(no)], + ) + +AC_MSG_CHECKING([for wcsncasecmp]) +AC_TRY_LINK( [ #include ], + [ int foo = wcsncasecmp(L"", L"", 0); ], + [ AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_WCSNCASECMP, 1, Define to 1 if you have the `wcsncasecmp' function.) + ], + [AC_MSG_RESULT(no)], + ) + +AC_MSG_CHECKING([for std::wcsncasecmp]) +AC_TRY_LINK( [ #include ], + [ int foo = std::wcsncasecmp(L"", L"", 0); ], + [ AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_STD__WCSNCASECMP, 1, Define to 1 if you have the `std::wcsncasecmp' function.) + ], + [AC_MSG_RESULT(no)], + ) + if test x$local_gettext != xno; then AC_CHECK_FUNCS( gettext ) diff --git a/src/common.h b/src/common.h index dcf43ac65..61af1e9cc 100644 --- a/src/common.h +++ b/src/common.h @@ -825,4 +825,16 @@ static const wchar_t *enum_to_str(T enum_val, const enum_map map[]) { return NULL; }; +#if !defined(HAVE_WCSDUP) && defined(HAVE_STD__WCSDUP) +using std::wcsdup; +#endif + +#if !defined(HAVE_WCSCASECMP) && defined(HAVE_STD__WCSCASECMP) +using std::wcscasecmp; +#endif + +#if !defined(HAVE_WCSNCASECMP) && defined(HAVE_STD__WCSNCASECMP) +using std::wcsncasecmp; +#endif + #endif