Applied patch [ 853850 ] Fixes for wxFormatConverter

(M.J.Wetherell)
Added wxConvertFormat function in debug mode to allow for
unit testing
Added tests/formatconverter


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2004-01-11 14:16:32 +00:00
parent 5a410e4453
commit cfee166d4e
5 changed files with 156 additions and 14 deletions

View File

@@ -752,7 +752,11 @@ wxFormatConverter::wxFormatConverter(const wxChar *format)
// precision?
if ( *format == _T('.') )
{
SkipDigits(&format);
CopyFmtChar(*format++);
if ( *format == _T('*') )
CopyFmtChar(*format++);
else
SkipDigits(&format);
}
// next we can have a size modifier
@@ -799,23 +803,14 @@ wxFormatConverter::wxFormatConverter(const wxChar *format)
case _T('c'):
case _T('s'):
// %c -> %lc but %hc stays %hc and %lc is still %lc
switch ( size )
{
case Default:
InsertFmtChar(_T('l'));
break;
case Short:
CopyFmtChar(_T('h'));
break;
case Long:
;
}
if ( size == Default)
InsertFmtChar(_T('l'));
// fall through
default:
// nothing special to do
if ( size != Default )
CopyFmtChar(*(format - 1));
CopyFmtChar(*format++);
}
}
@@ -827,6 +822,14 @@ wxFormatConverter::wxFormatConverter(const wxChar *format)
#define wxFormatConverter(x) (x)
#endif // wxNEED_PRINTF_CONVERSION/!wxNEED_PRINTF_CONVERSION
#ifdef __WXDEBUG__
// For testing the format converter
wxString wxConvertFormat(const wxChar *format)
{
return wxString(wxFormatConverter(format));
}
#endif
// ----------------------------------------------------------------------------
// wxPrintf(), wxScanf() and relatives
// ----------------------------------------------------------------------------