minor cleanup of Unix GetInfo(): assert if invalid parameters are passed; don't use explict wxString ctors

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59912 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-03-29 15:13:40 +00:00
parent 04a7eed137
commit f33427816c

View File

@@ -2689,36 +2689,42 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
/* static */ /* static */
wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
{ {
struct lconv *locale_info = localeconv(); lconv * const lc = localeconv();
switch (cat) if ( !lc )
return wxString();
switch ( cat )
{ {
case wxLOCALE_CAT_NUMBER: case wxLOCALE_CAT_NUMBER:
switch (index) switch ( index )
{ {
case wxLOCALE_THOUSANDS_SEP: case wxLOCALE_THOUSANDS_SEP:
return wxString(locale_info->thousands_sep, return lc->thousands_sep;
*wxConvCurrent);
case wxLOCALE_DECIMAL_POINT: case wxLOCALE_DECIMAL_POINT:
return wxString(locale_info->decimal_point, return lc->decimal_point;
*wxConvCurrent);
default:
return wxEmptyString;
} }
break;
case wxLOCALE_CAT_MONEY: case wxLOCALE_CAT_MONEY:
switch (index) switch ( index )
{ {
case wxLOCALE_THOUSANDS_SEP: case wxLOCALE_THOUSANDS_SEP:
return wxString(locale_info->mon_thousands_sep, return lc->mon_thousands_sep;
*wxConvCurrent);
case wxLOCALE_DECIMAL_POINT: case wxLOCALE_DECIMAL_POINT:
return wxString(locale_info->mon_decimal_point, return lc->mon_decimal_point;
*wxConvCurrent);
default:
return wxEmptyString;
} }
break;
default: default:
return wxEmptyString; wxFAIL_MSG( "unknown wxLocaleCategory" );
return wxString(); // skip second assert below
} }
wxFAIL_MSG( "unknown wxLocaleInfo value for this category" );
return wxString();
} }
#endif // platform #endif // platform