minor corrections to TranslateFromUnicodeFormat()

- Don't try to dereference end() iteratorm this will fail (unlike comparing
  pointer with NUL)
- Use prefix rather than postfix increment for iterator
- Use wxUniChar::GetValue() rather than cast to char for consistency with
  other switch statements in the same file


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-03-26 23:07:07 +00:00
parent 07c4e84f7b
commit 55fffc3418

View File

@@ -1071,22 +1071,24 @@ static wxString GetLocaleDateFormat()
// so we need a translation function, bluntly copied from the windows
// version above and enhanced with the additional elements needed
static wxString TranslateFromUnicodeFormat( const wxString& fmt)
static wxString TranslateFromUnicodeFormat(const wxString& fmt)
{
wxString fmtWX;
wxChar chLast = _T('\0');
size_t lastCount = 0;
for ( wxString::const_iterator p = fmt.begin(); /* NUL handled inside */; p++ )
for ( wxString::const_iterator p = fmt.begin(); /* end handled inside */; ++p )
{
if ( *p == chLast )
if ( p == fmt.end() || *p == chLast )
{
lastCount++;
if ( p == fmt.end() )
break;
continue;
}
switch ( (char) *p )
switch ( (*p).GetValue() )
{
// these characters come in groups, start counting them
case _T('d'):
@@ -1239,20 +1241,14 @@ static wxString TranslateFromUnicodeFormat( const wxString& fmt)
// not a special character so must be just a separator,
// treat as is
if ( *p != _T('\0') )
if ( *p == _T('%') )
{
if ( *p == _T('%') )
{
// this one needs to be escaped
fmtWX += _T('%');
}
fmtWX += *p;
// this one needs to be escaped
fmtWX += _T('%');
}
}
if ( *p == _T('\0') )
break;
fmtWX += *p;
}
}
return fmtWX;