From 6d079554a634d6d9a80ad83624a8487a2b4202dd Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 6 Dec 2016 13:37:54 +1100 Subject: [PATCH] format: fix escaped percent before value specifier --- format.ipp | 6 +++++- test/format.cpp | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/format.ipp b/format.ipp index e1a69d3f..92721b40 100644 --- a/format.ipp +++ b/format.ipp @@ -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...); } diff --git a/test/format.cpp b/test/format.cpp index 2d8fe76d..ca4efa5a 100644 --- a/test/format.cpp +++ b/test/format.cpp @@ -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);