Merge branch 'xlocale-fixes'
Fix completely broken wxXLocale and wxLocale unit tests.
This commit is contained in:
5
configure
vendored
5
configure
vendored
@@ -32627,6 +32627,9 @@ $as_echo "$as_me: WARNING: I18n code requires wxFile... disabled" >&2;}
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$wxUSE_XLOCALE" = "yes" ; then
|
if test "$wxUSE_XLOCALE" = "yes" ; then
|
||||||
|
$as_echo "#define wxUSE_XLOCALE 1" >>confdefs.h
|
||||||
|
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for complete xlocale" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for complete xlocale" >&5
|
||||||
$as_echo_n "checking for complete xlocale... " >&6; }
|
$as_echo_n "checking for complete xlocale... " >&6; }
|
||||||
if ${wx_cv_func_strtod_l+:} false; then :
|
if ${wx_cv_func_strtod_l+:} false; then :
|
||||||
@@ -32676,7 +32679,7 @@ fi
|
|||||||
$as_echo "$wx_cv_func_strtod_l" >&6; }
|
$as_echo "$wx_cv_func_strtod_l" >&6; }
|
||||||
|
|
||||||
if test "$wx_cv_func_strtod_l" = "yes" ; then
|
if test "$wx_cv_func_strtod_l" = "yes" ; then
|
||||||
$as_echo "#define wxUSE_XLOCALE 1" >>confdefs.h
|
$as_echo "#define HAVE_LOCALE_T 1" >>confdefs.h
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@@ -5747,6 +5747,8 @@ if test "$wxUSE_INTL" = "yes" ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$wxUSE_XLOCALE" = "yes" ; then
|
if test "$wxUSE_XLOCALE" = "yes" ; then
|
||||||
|
AC_DEFINE(wxUSE_XLOCALE)
|
||||||
|
|
||||||
dnl even if xlocale.h exists, it may not contain all that
|
dnl even if xlocale.h exists, it may not contain all that
|
||||||
dnl wx needs. check if strtod_l() really is available.
|
dnl wx needs. check if strtod_l() really is available.
|
||||||
AC_CACHE_CHECK([for complete xlocale],
|
AC_CACHE_CHECK([for complete xlocale],
|
||||||
@@ -5770,7 +5772,9 @@ if test "$wxUSE_XLOCALE" = "yes" ; then
|
|||||||
])
|
])
|
||||||
|
|
||||||
if test "$wx_cv_func_strtod_l" = "yes" ; then
|
if test "$wx_cv_func_strtod_l" = "yes" ; then
|
||||||
AC_DEFINE(wxUSE_XLOCALE)
|
dnl We don't test (just) for locale_t existence, but we still define
|
||||||
|
dnl this symbol to avoid changing the existing code using it.
|
||||||
|
AC_DEFINE(HAVE_LOCALE_T)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -208,12 +208,17 @@ wxString wxLanguageInfo::GetLocaleName() const
|
|||||||
const char* const orig = wxSetlocale(LC_ALL, NULL);
|
const char* const orig = wxSetlocale(LC_ALL, NULL);
|
||||||
|
|
||||||
const char* const ret = TrySetLocale();
|
const char* const ret = TrySetLocale();
|
||||||
if ( !ret )
|
wxString retval;
|
||||||
return wxString();
|
if ( ret )
|
||||||
|
{
|
||||||
|
// Note that we must copy the returned value before calling setlocale()
|
||||||
|
// again as the string "ret" points to can (and, at least under Linux
|
||||||
|
// with glibc, actually always will) be changed by this call.
|
||||||
|
retval = ret;
|
||||||
wxSetlocale(LC_ALL, orig);
|
wxSetlocale(LC_ALL, orig);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -89,13 +89,11 @@ wxXLocale& wxXLocale::GetCLocale()
|
|||||||
|
|
||||||
#if wxUSE_INTL
|
#if wxUSE_INTL
|
||||||
wxXLocale::wxXLocale(wxLanguage lang)
|
wxXLocale::wxXLocale(wxLanguage lang)
|
||||||
{
|
|
||||||
const wxLanguageInfo * const info = wxLocale::GetLanguageInfo(lang);
|
|
||||||
if ( !info )
|
|
||||||
{
|
{
|
||||||
m_locale = NULL;
|
m_locale = NULL;
|
||||||
}
|
|
||||||
else
|
const wxLanguageInfo * const info = wxLocale::GetLanguageInfo(lang);
|
||||||
|
if ( info )
|
||||||
{
|
{
|
||||||
Init(info->GetLocaleName().c_str());
|
Init(info->GetLocaleName().c_str());
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,6 @@ private:
|
|||||||
CPPUNIT_TEST( Domain );
|
CPPUNIT_TEST( Domain );
|
||||||
CPPUNIT_TEST( Headers );
|
CPPUNIT_TEST( Headers );
|
||||||
CPPUNIT_TEST( DateTimeFmtFrench );
|
CPPUNIT_TEST( DateTimeFmtFrench );
|
||||||
CPPUNIT_TEST( DateTimeFmtC );
|
|
||||||
CPPUNIT_TEST( IsAvailable );
|
CPPUNIT_TEST( IsAvailable );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
@@ -50,7 +49,6 @@ private:
|
|||||||
void Domain();
|
void Domain();
|
||||||
void Headers();
|
void Headers();
|
||||||
void DateTimeFmtFrench();
|
void DateTimeFmtFrench();
|
||||||
void DateTimeFmtC();
|
|
||||||
void IsAvailable();
|
void IsAvailable();
|
||||||
|
|
||||||
static wxString GetDecimalPoint()
|
static wxString GetDecimalPoint()
|
||||||
@@ -189,50 +187,27 @@ void IntlTestCase::DateTimeFmtFrench()
|
|||||||
#else
|
#else
|
||||||
static const char *FRENCH_DATE_FMT = "%d/%m/%Y";
|
static const char *FRENCH_DATE_FMT = "%d/%m/%Y";
|
||||||
static const char *FRENCH_LONG_DATE_FMT = "%A %d %B %Y";
|
static const char *FRENCH_LONG_DATE_FMT = "%A %d %B %Y";
|
||||||
#ifdef __WXOSX__
|
|
||||||
static const char *FRENCH_DATE_TIME_FMT = "%A %d %B %Y %H:%M:%S";
|
|
||||||
#else
|
|
||||||
static const char *FRENCH_DATE_TIME_FMT = "%d/%m/%Y %H:%M:%S";
|
static const char *FRENCH_DATE_TIME_FMT = "%d/%m/%Y %H:%M:%S";
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WX_ASSERT_EQUAL_FORMAT( "French short date", FRENCH_DATE_FMT,
|
WX_ASSERT_EQUAL_FORMAT( "French short date", FRENCH_DATE_FMT,
|
||||||
m_locale->GetInfo(wxLOCALE_SHORT_DATE_FMT) );
|
wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT) );
|
||||||
WX_ASSERT_EQUAL_FORMAT( "French long date", FRENCH_LONG_DATE_FMT,
|
WX_ASSERT_EQUAL_FORMAT( "French long date", FRENCH_LONG_DATE_FMT,
|
||||||
m_locale->GetInfo(wxLOCALE_LONG_DATE_FMT) );
|
wxLocale::GetInfo(wxLOCALE_LONG_DATE_FMT) );
|
||||||
WX_ASSERT_EQUAL_FORMAT( "French date and time", FRENCH_DATE_TIME_FMT,
|
|
||||||
m_locale->GetInfo(wxLOCALE_DATE_TIME_FMT) );
|
|
||||||
WX_ASSERT_EQUAL_FORMAT( "French time", "%H:%M:%S",
|
|
||||||
m_locale->GetInfo(wxLOCALE_TIME_FMT) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntlTestCase::DateTimeFmtC()
|
const wxString fmtDT = wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT);
|
||||||
{
|
|
||||||
// again, glibc uses different defaults
|
|
||||||
#ifdef __GLIBC__
|
|
||||||
static const char *C_DATE_FMT = "%m/%d/%y";
|
|
||||||
static const char *C_LONG_DATE_FMT = "%a %b %d %Y";
|
|
||||||
static const char *C_DATE_TIME_FMT = "%a %b %d %H:%M:%S %Y";
|
|
||||||
#else
|
|
||||||
static const char *C_DATE_FMT = "%d/%m/%Y";
|
|
||||||
static const char *C_LONG_DATE_FMT = "%A %d %B %Y";
|
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
static const char *C_DATE_TIME_FMT = "%A %d %B %Y %H:%M:%S";
|
// Things are difficult to test under macOS as the format keeps changing,
|
||||||
|
// e.g. at some time between 10.10 and 10.12 a new " <20> " string appeared in
|
||||||
|
// its middle, so test it piece-wise and hope it doesn't change too much.
|
||||||
|
INFO("French date and time format is \"" << fmtDT << "\"");
|
||||||
|
CHECK( fmtDT.StartsWith("%A %d %B %Y") );
|
||||||
|
CHECK( fmtDT.EndsWith("%H:%M:%S") );
|
||||||
#else
|
#else
|
||||||
static const char *C_DATE_TIME_FMT = "%d/%m/%Y %H:%M:%S";
|
WX_ASSERT_EQUAL_FORMAT( "French date and time", FRENCH_DATE_TIME_FMT, fmtDT );
|
||||||
#endif
|
#endif
|
||||||
#endif
|
WX_ASSERT_EQUAL_FORMAT( "French time", "%H:%M:%S",
|
||||||
|
wxLocale::GetInfo(wxLOCALE_TIME_FMT) );
|
||||||
setlocale(LC_ALL, "C");
|
|
||||||
|
|
||||||
WX_ASSERT_EQUAL_FORMAT( "C short date", C_DATE_FMT,
|
|
||||||
m_locale->GetInfo(wxLOCALE_SHORT_DATE_FMT) );
|
|
||||||
WX_ASSERT_EQUAL_FORMAT( "C long date", C_LONG_DATE_FMT,
|
|
||||||
m_locale->GetInfo(wxLOCALE_LONG_DATE_FMT) );
|
|
||||||
WX_ASSERT_EQUAL_FORMAT( "C date and time", C_DATE_TIME_FMT,
|
|
||||||
m_locale->GetInfo(wxLOCALE_DATE_TIME_FMT) );
|
|
||||||
WX_ASSERT_EQUAL_FORMAT( "C time", "%H:%M:%S",
|
|
||||||
m_locale->GetInfo(wxLOCALE_TIME_FMT) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntlTestCase::IsAvailable()
|
void IntlTestCase::IsAvailable()
|
||||||
|
Reference in New Issue
Block a user