Fix handling of asterisks in wxPrintf() implementation.

Count the number of asterisks before modifying the string we use to do this,
otherwise we were off by one for the format specifications containing two of
them.

This really fixes the handling of asterisks (used for width/precision) in
wxPrintf() format string, it wasn't done correctly by r60120 but now
VsnprintfTestCase::Asterisk() test does pass.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65689 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-09-30 14:30:28 +00:00
parent cdd233ef81
commit e2dd624761

View File

@@ -831,9 +831,13 @@ struct wxPrintfConvSpecParser
// special handling for specifications including asterisks: we need // special handling for specifications including asterisks: we need
// to reserve an extra slot (or two if asterisks were used for both // to reserve an extra slot (or two if asterisks were used for both
// width and precision) in specs array in this case // width and precision) in specs array in this case
for ( const char *f = strchr(spec->m_szFlags, '*'); if ( const char *f = strchr(spec->m_szFlags, '*') )
f; {
f = strchr(f + 1, '*') ) unsigned numAsterisks = 1;
if ( strchr(++f, '*') )
numAsterisks++;
for ( unsigned n = 0; n < numAsterisks; n++ )
{ {
if ( nargs++ == wxMAX_SVNPRINTF_ARGUMENTS ) if ( nargs++ == wxMAX_SVNPRINTF_ARGUMENTS )
break; break;
@@ -867,6 +871,8 @@ struct wxPrintfConvSpecParser
spec = &specs[nargs]; spec = &specs[nargs];
} }
}
// check if this is a positional or normal argument // check if this is a positional or normal argument
if ( spec->m_pos > 0 ) if ( spec->m_pos > 0 )