Skip to content

Commit b8266e3

Browse files
committed
Reduce maximum number of format string replacement fields
1 parent 44499c1 commit b8266e3

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

fly/types/string/detail/string_formatter_types.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ class BasicFormatString
499499

500500
lexer m_lexer;
501501

502-
std::array<FormatSpecifier, 256> m_specifiers;
502+
std::array<FormatSpecifier, 64> m_specifiers;
503503
std::size_t m_specifier_count {0};
504504
std::size_t m_specifier_index {0};
505505

test/types/string_formatter_types.cpp

+4-18
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,10 @@ CATCH_TEMPLATE_TEST_CASE(
202202

203203
CATCH_SECTION("Able to parse the maxiumum allowed number of replacement fields")
204204
{
205-
auto format = make_format( // There are 256 format replacement fields here.
205+
auto format = make_format( // There are 64 format replacement fields here.
206206
FMT("{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
207207
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
208-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
209-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
210-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
211-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
212-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
213-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
214-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
215-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"),
208+
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"),
216209
1);
217210
CATCH_CHECK_FALSE(format.has_error());
218211

@@ -699,17 +692,10 @@ CATCH_TEMPLATE_TEST_CASE(
699692
CATCH_SECTION("Cannot exceed maximum number of replacement fields")
700693
{
701694
test_error(
702-
make_format( // There are 257 format replacement fields here.
695+
make_format( // There are 65 format replacement fields here.
703696
FMT("{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
704697
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
705-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
706-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
707-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
708-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
709-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
710-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
711-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"
712-
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"),
698+
"{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}{0}"),
713699
1),
714700
s_too_many_specifiers);
715701
}

0 commit comments

Comments
 (0)