Don’t assert on weird custom number formatting settings

On OS X at least, the user is free to customize numbers formatting rules
and use more than one character for separators. Don’t assert in such
cases (the rules are untrusted input), but instead fall back to
something reasonable, as is already done if we can’t retrieve the rules.

(cherry picked from commit 5d2b2b3d7a)
This commit is contained in:
Václav Slavík
2016-05-29 17:57:41 +02:00
parent 3de9fd84fe
commit 12d9c4ea9d

View File

@@ -122,20 +122,16 @@ wxChar wxNumberFormatter::GetDecimalSeparator()
{
const wxString
s = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER);
if ( s.empty() )
if ( s.length() == 1 )
{
s_decimalSeparator = s[0];
}
else
{
// We really must have something for decimal separator, so fall
// back to the C locale default.
s_decimalSeparator = '.';
}
else
{
// To the best of my knowledge there are no locales like this.
wxASSERT_MSG( s.length() == 1,
"Multi-character decimal separator?" );
s_decimalSeparator = s[0];
}
}
return s_decimalSeparator;
@@ -154,11 +150,8 @@ bool wxNumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep)
{
const wxString
s = wxLocale::GetInfo(wxLOCALE_THOUSANDS_SEP, wxLOCALE_CAT_NUMBER);
if ( !s.empty() )
if ( s.length() == 1 )
{
wxASSERT_MSG( s.length() == 1,
"Multi-character thousands separator?" );
s_thousandsSeparator = s[0];
}
//else: Unlike above it's perfectly fine for the thousands separator to