From 12d9c4ea9d89c95a2cd33e7928ba5e877674b0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Sun, 29 May 2016 17:57:41 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20assert=20on=20weird=20custom=20?= =?UTF-8?q?number=20formatting=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 5d2b2b3d7a11c5b2dac03e5043dcf76095e5c3b5) --- src/common/numformatter.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/common/numformatter.cpp b/src/common/numformatter.cpp index 2428ef34b5..369ec15b5c 100644 --- a/src/common/numformatter.cpp +++ b/src/common/numformatter.cpp @@ -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