Make parse_arg_id more readable

This commit is contained in:
Victor Zverovich 2019-11-20 08:12:23 -08:00
parent 092d2dc7b2
commit 404a880bd4

View File

@ -2328,16 +2328,22 @@ FMT_CONSTEXPR const Char* parse_arg_id(const Char* begin, const Char* end,
IDHandler&& handler) { IDHandler&& handler) {
FMT_ASSERT(begin != end, ""); FMT_ASSERT(begin != end, "");
Char c = *begin; Char c = *begin;
if (c == '}' || c == ':') return handler(), begin; if (c == '}' || c == ':') {
handler();
return begin;
}
if (c >= '0' && c <= '9') { if (c >= '0' && c <= '9') {
int index = parse_nonnegative_int(begin, end, handler); int index = parse_nonnegative_int(begin, end, handler);
if (begin == end || (*begin != '}' && *begin != ':')) if (begin == end || (*begin != '}' && *begin != ':'))
return handler.on_error("invalid format string"), begin; handler.on_error("invalid format string");
handler(index); else
handler(index);
return begin;
}
if (!is_name_start(c)) {
handler.on_error("invalid format string");
return begin; return begin;
} }
if (!is_name_start(c))
return handler.on_error("invalid format string"), begin;
auto it = begin; auto it = begin;
do { do {
++it; ++it;