mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
AK+Everywhere: Fix compiletime format parsing of replacement fields
This commit is contained in:
parent
c0d1a75881
commit
944855ca18
Notes:
sideshowbarker
2024-07-18 17:03:02 +09:00
Author: https://github.com/alimpfard
Commit: 944855ca18
Pull-request: https://github.com/SerenityOS/serenity/pull/7673
Reviewed-by: https://github.com/linusg ✅
3 changed files with 17 additions and 12 deletions
|
@ -79,6 +79,7 @@ consteval auto count_fmt_params(const char (&fmt)[N])
|
|||
|
||||
size_t unclosed_braces { 0 };
|
||||
size_t extra_closed_braces { 0 };
|
||||
size_t nesting_level { 0 };
|
||||
|
||||
Array<size_t, 4> last_format_specifier_start { 0 };
|
||||
size_t total_used_last_format_specifier_start_count { 0 };
|
||||
|
@ -100,13 +101,17 @@ consteval auto count_fmt_params(const char (&fmt)[N])
|
|||
result.last_format_specifier_start[result.total_used_last_format_specifier_start_count++] = i + 1;
|
||||
|
||||
++result.unclosed_braces;
|
||||
++result.nesting_level;
|
||||
break;
|
||||
case '}':
|
||||
if (i + 1 < N && fmt[i + 1] == '}') {
|
||||
++i;
|
||||
continue;
|
||||
if (result.nesting_level == 0) {
|
||||
if (i + 1 < N && fmt[i + 1] == '}') {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (result.unclosed_braces) {
|
||||
--result.nesting_level;
|
||||
--result.unclosed_braces;
|
||||
|
||||
if (result.total_used_last_format_specifier_start_count == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue