format: fix escaped percent before value specifier

This commit is contained in:
Danny Robson 2016-12-06 13:37:54 +11:00
parent 0756f3f4cf
commit 6d079554a6
2 changed files with 7 additions and 1 deletions

View File

@ -897,7 +897,11 @@ namespace util { namespace format { namespace detail {
specifier spec;
auto cursor = parse (start, last, spec);
return _render (write (os, spec, val), cursor, last, args...);
if (spec.k == specifier::kind::ESCAPE)
return _render (write (os, spec ), cursor, last, val, args...);
else
return _render (write (os, spec, val), cursor, last, args...);
}

View File

@ -162,6 +162,8 @@ main (void)
CHECK_RENDER ("%% %%", "% %");
CHECK_RENDER (" %% %% ", " % % ");
CHECK_RENDER ("%%%d%%", "%0%", 0);
CHECK_RENDER ("%u %u", "1 2", 1u, 2u);
CHECK_RENDER ("%#o %o", "010 10", 8u, 8u);