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.
This commit is contained in:
parent
60ae112694
commit
5d2b2b3d7a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user