Merge pull request #460 from oldium/develop

Allow absolute index to be used when all values has been used.
This commit is contained in:
Aleksandar Fabijanic 2014-05-29 07:23:54 -05:00
commit ce3ad64e16
2 changed files with 4 additions and 1 deletions

View File

@ -350,7 +350,7 @@ void format(std::string& result, const std::string& fmt, const std::vector<Any>&
{
case '%':
++itFmt;
if (itFmt != endFmt && itVal != endVal)
if (itFmt != endFmt && (itVal != endVal || *itFmt == '['))
{
if (*itFmt == '[')
{

View File

@ -349,6 +349,9 @@ void FormatTest::testIndex()
s = format("%%%[1]d%%%[2]d%%%d", 1, 2, 3);
assert(s == "%2%3%1");
s = format("%%%d%%%d%%%[0]d", 1, 2);
assert(s == "%1%2%1");
}