From b37be85bf1e142079fdeb4a96639b32f78770914 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 8 Sep 2024 16:10:01 -0700 Subject: [PATCH] Optionally disable named arguments --- include/fmt/base.h | 8 ++++++-- include/fmt/format.h | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 8f4c9899..a040f2f9 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -298,6 +298,10 @@ # define FMT_API #endif +#ifndef FMT_OPTIMIZE_SIZE +# define FMT_OPTIMIZE_SIZE 0 +#endif + // Specifies whether to handle built-in and string types specially. // FMT_BUILTIN_TYPE=0 may result in smaller library size at the cost of higher // per-call binary size. @@ -1416,7 +1420,7 @@ FMT_CONSTEXPR auto parse_arg_id(const Char* begin, const Char* end, handler.on_index(index); return begin; } - if (!is_name_start(c)) { + if (FMT_OPTIMIZE_SIZE > 1 || !is_name_start(c)) { report_error("invalid format string"); return begin; } @@ -2365,7 +2369,7 @@ struct is_output_iterator< #ifdef FMT_USE_LOCALE // Use the provided definition. -#elif defined(FMT_STATIC_THOUSANDS_SEPARATOR) +#elif defined(FMT_STATIC_THOUSANDS_SEPARATOR) || FMT_OPTIMIZE_SIZE > 1 # define FMT_USE_LOCALE 0 #else # define FMT_USE_LOCALE 1 diff --git a/include/fmt/format.h b/include/fmt/format.h index 9533c97c..54e20de7 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -151,10 +151,6 @@ FMT_END_NAMESPACE # endif #endif -#ifndef FMT_OPTIMIZE_SIZE -# define FMT_OPTIMIZE_SIZE 0 -#endif - // Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of // integer formatter template instantiations to just one by only using the // largest integer type. This results in a reduction in binary size but will