From 404a880bd4af706056cab9d019ac061fd556a94c Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 20 Nov 2019 08:12:23 -0800 Subject: [PATCH] Make parse_arg_id more readable --- include/fmt/format.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index f101c913..e4f7633d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2328,16 +2328,22 @@ FMT_CONSTEXPR const Char* parse_arg_id(const Char* begin, const Char* end, IDHandler&& handler) { FMT_ASSERT(begin != end, ""); Char c = *begin; - if (c == '}' || c == ':') return handler(), begin; + if (c == '}' || c == ':') { + handler(); + return begin; + } if (c >= '0' && c <= '9') { int index = parse_nonnegative_int(begin, end, handler); if (begin == end || (*begin != '}' && *begin != ':')) - return handler.on_error("invalid format string"), begin; - handler(index); + handler.on_error("invalid format string"); + else + handler(index); + return begin; + } + if (!is_name_start(c)) { + handler.on_error("invalid format string"); return begin; } - if (!is_name_start(c)) - return handler.on_error("invalid format string"), begin; auto it = begin; do { ++it;