Fix dynamic named arg format spec handling (#4361)
When dealing with dynamic named format args, need to account for nested named args when skipping the content of the replacement. Fixes #4360
This commit is contained in:
+13
-1
@@ -1718,7 +1718,19 @@ class format_string_checker {
|
||||
-> const Char* {
|
||||
context_.advance_to(begin);
|
||||
if (id >= 0 && id < NUM_ARGS) return parse_funcs_[id](context_);
|
||||
while (begin != end && *begin != '}') ++begin;
|
||||
|
||||
// If id is out of range, it means we do not know the type and cannot parse
|
||||
// the format at compile time. Instead, skip over content until we finish
|
||||
// the format spec, accounting for any nested replacements.
|
||||
auto bracket_count = 0;
|
||||
while (begin != end && (bracket_count > 0 || *begin != '}')) {
|
||||
if (*begin == '{')
|
||||
++bracket_count;
|
||||
else if (*begin == '}')
|
||||
--bracket_count;
|
||||
|
||||
++begin;
|
||||
}
|
||||
return begin;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user