Added workarounds for missing reentrant versions of wide char
to/from multi-byte conversion functions.
This commit is contained in:
parent
0ce15c1a9b
commit
8dbc9d62bc
|
@ -52,6 +52,7 @@ AC_TYPE_SIZE_T
|
|||
|
||||
dnl checks for structures
|
||||
AC_STRUCT_TM
|
||||
AC_CHECK_TYPES(mbstate_t,,,[#include <wchar.h>])
|
||||
|
||||
dnl checks for compiler characteristics
|
||||
AC_CHECK_SIZEOF(char, 1)
|
||||
|
@ -72,6 +73,7 @@ AC_FUNC_STRFTIME
|
|||
AC_CHECK_FUNCS(gmtime_r)
|
||||
AC_CHECK_FUNCS(getpwuid_r)
|
||||
AC_CHECK_FUNCS(vsnprintf)
|
||||
AC_CHECK_FUNCS(wcrtomb mbrtowc mbsinit)
|
||||
AC_FUNC_SELECT_ARGTYPES
|
||||
ACX_CHECK_POLL
|
||||
dnl use AC_REPLACE_FUNCS() for stuff in string.h
|
||||
|
|
|
@ -70,6 +70,61 @@ setError(bool* errors)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// multibyte conversion stuff when reentrant versions not available
|
||||
//
|
||||
|
||||
#if !HAVE_MBSTATE_T
|
||||
struct mbstate_t { int m_dummy; };
|
||||
#undef HAVE_MBSINIT
|
||||
#undef HAVE_MBRTOWC
|
||||
#undef HAVE_WCRTOMB
|
||||
#endif
|
||||
|
||||
#if !HAVE_MBSINIT
|
||||
static
|
||||
int
|
||||
mbsinit(const mbstate_t*)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !HAVE_MBRTOWC
|
||||
#include "CLock.h"
|
||||
#include "CMutex.h"
|
||||
|
||||
static CMutex s_mbrtowcMutex;
|
||||
|
||||
static
|
||||
size_t
|
||||
mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t*)
|
||||
{
|
||||
CLock lock(&s_mbrtowcMutex);
|
||||
int result = mbtowc(pwc, s, n);
|
||||
if (result < 0)
|
||||
return (size_t)-1;
|
||||
else
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !HAVE_WCRTOMB
|
||||
#include "CLock.h"
|
||||
#include "CMutex.h"
|
||||
|
||||
static CMutex s_wcrtombMutex;
|
||||
|
||||
static
|
||||
size_t
|
||||
wcrtomb(char* s, wchar_t wc, mbstate_t*)
|
||||
{
|
||||
CLock lock(&s_wcrtombMutex);
|
||||
return (size_t)wctomb(s, wc);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// CUnicode
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue