diff --git a/Foundation/src/Format.cpp b/Foundation/src/Format.cpp index 9a934a8bc..c5697cddd 100644 --- a/Foundation/src/Format.cpp +++ b/Foundation/src/Format.cpp @@ -350,7 +350,7 @@ void format(std::string& result, const std::string& fmt, const std::vector& { case '%': ++itFmt; - if (itFmt != endFmt && itVal != endVal) + if (itFmt != endFmt && (itVal != endVal || *itFmt == '[')) { if (*itFmt == '[') { diff --git a/Foundation/testsuite/src/FormatTest.cpp b/Foundation/testsuite/src/FormatTest.cpp index e922c724e..1ace4f9b5 100644 --- a/Foundation/testsuite/src/FormatTest.cpp +++ b/Foundation/testsuite/src/FormatTest.cpp @@ -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"); }