3471 Commits

Author SHA1 Message Date
Eduardo Gómez
b7fb3c686e
Merge 8793ca53e5dbcade50fbf281fe5ad99833cbaa95 into 17500e457b198c37c4374d142fa7a1d36e4651fe 2026-07-29 10:29:23 -07:00
Victor Zverovich
26c01df3bd Handle const-qualified named arguments
A named argument that arrives const-qualified was not recognized by
is_named_arg, silently dropping its name. This happens both when a
named argument is passed through an intermediate function returning
const T& (https://github.com/fmtlib/fmt/issues/4866) and in fmt's own
compiled format path, which passes arguments as const T&.

Make is_named_arg and is_static_named_arg see through top-level const so
the name is preserved instead of dropped.
2026-07-29 09:20:23 -07:00
Eduardo Gomez Saldias
8793ca53e5 Move wide_cp_range struct into display_width_of() 2026-07-28 13:32:28 +02:00
Eduardo Gomez Saldias
4a2a6e448d Make wide_cp_ranges C++11-compatible; apply clang-format 2026-07-28 13:10:27 +02:00
Victor Zverovich
2a2d9edb25 Remove extra newline 2026-07-25 07:52:08 -07:00
Eduardo Gomez Saldias
84343f152b Widen display_width_of() to cover Emoji_Presentation code points
fmt::detail::display_width_of() only treated East Asian Wide/Fullwidth
code points and two hand-picked emoji ranges as two columns wide, so
emoji outside those ranges (e.g. the Dingbats block: cross mark U+274C,
white heavy check mark U+2705) were measured as one column even though
most terminals render them double-width. This produced visibly
inconsistent padding under {:^N} compared to CJK text (fixes #4851).

Replaced the ad hoc boolean expression with a sorted table of ranges
(East Asian Wide/Fullwidth plus the full Emoji_Presentation set from
Unicode's emoji-data.txt) looked up via binary search, and added
regression tests covering the original report plus edge cases:
multiple emoji, mixed emoji/CJK/ASCII content, precision truncation,
alignment/fill variants, newly covered emoji ranges, and regional
indicator (flag) pairs.
2026-07-24 00:10:08 +02:00
Avi Kivity
6439aa09b1
Export ostream formatters and streamed() from the module (#4861)
Make basic_ostream_formatter, ostream_formatter and streamed() accessible
to module users via FMT_BEGIN_EXPORT/FMT_BEGIN_EXPORT. Drop now unneeded
FMT_EXPORT for print() and println().
2026-07-23 08:14:21 -07:00
Victor Zverovich
7b4ef1c814 Optimize 128-bit integer formatting
count_digits and do_format_decimal divided the full 128-bit value by a
constant in a loop. Compilers do not strength-reduce 128-bit division, so
each iteration became a slow __udivti3 library call (~27 per number).

Reduce the value to 64-bit chunks by dividing by 10^19 (at most twice) and
reuse the fast 64-bit paths, giving a ~5x speedup on full-range values.
2026-07-19 17:05:39 -07:00
Victor Zverovich
b5d1e5404b Annotate FMT_USE_RTTI #endif directives
Add trailing "// FMT_USE_RTTI" comments to the matching #endif lines to make
the conditional-compilation blocks easier to follow.
2026-07-17 12:12:25 -07:00
Victor Zverovich
7852fc384c Fix out-of-range integers with the 'c' presentation type (#4839)
Formatting an integer with ':c' used the magnitude (abs_value) and never
range-checked, so negatives were mangled and out-of-range values silently
truncated. Copy the value as a character and report an error when it is out
of range, treating all character types as unsigned for portability.
2026-07-17 11:36:52 -07:00
Victor Zverovich
d45179c1e7 Merge the two integer write overloads into one
The appender and generic-iterator overloads only differed in whether the
integer formatting code was inlined. Merge them into a single overload and
select write_int_noinline vs inline write_int via if constexpr, keeping the
same codegen (out of line for appenders, inlined for compiled formatting)
with no size regression.
2026-07-17 11:16:40 -07:00
AMAN UPADHYAY
af2d9f2b78
Fix FMT_COMPILE failure with format_as mapped types (Issue #4794) (#4836) 2026-07-12 09:21:55 -07:00
Avi Kivity
1a99c2630c
Format nested exceptions in std::exception formatter (#4844)
Detect when a std::exception also derives from std::nested_exception
(e.g. via std::throw_with_nested) and unwind the whole chain, joining
each level with ": ". The type-name flag ({:t}) is honored at every
level, and the std::exception_ptr formatter inherits this behavior.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 08:50:10 -07:00
Victor Zverovich
7077b016cc Guard fast decimal path on bit width instead of byte size
Use num_bits<UInt>() == 32 instead of sizeof(UInt) == 4 in
do_format_decimal. The magic-number two-digit algorithm requires
exactly 32 value bits, so this is more precise on platforms where
CHAR_BIT != 8 and is consistent with existing num_bits<T>() usage.
2026-07-11 09:18:24 -07:00
Victor Zverovich
9d13c41ce6 Format null std::exception_ptr as "none"
Change the null exception_ptr representation from "nullptr" to "none" to
convey the "no exception" state more clearly, and update the test.
2026-07-11 08:21:32 -07:00
Jan
6dac6cad05
feat: add formatter for std::exception_ptr (#4808) (#4819) 2026-07-05 09:22:18 -07:00
Victor Zverovich
cd67635a19 Suppress MSVC C4702 header-wide instead of restructuring code
Revert the explicit-else workaround from #4822 and instead disable the
"unreachable code" warning for all of base.h. Add an FMT_PRAGMA_MSVC
helper (mirroring FMT_PRAGMA_GCC/CLANG) and wrap the header in a single
warning(push)/disable:4702/pop pair, keeping the original control flow.
2026-07-04 10:01:11 -07:00
torsten48
b54093c658
avoid MSC warning C4702: unreachable code (#4822)
if FMT_CONSTEXPR is resolved to constexpr MSC warns about dead code
after 'return' instruction. Explicitly using 'else' in these cases
avoids the warning.
2026-07-03 10:39:09 -07:00
Victor Zverovich
d24fef27d1 Minor cleanup 2026-06-26 15:57:41 -07:00
Jan Engelhardt
719823cc64
Turn libfmt-c into a shared library (#4812)
Linux distros don't like having static archives. Set fmt-c to shared
just like the main fmt library.
2026-06-26 06:55:44 -07:00
Yat Ho
0e601c34de
fix: explicitly check operator[] in is_contiguous (#4825)
Prevent false positives when the container itself does not have `operator[](size_t)`, but the target type of one of the non-explicit user-defined conversion functions does.
2026-06-25 12:21:59 -07:00
Vinay Kumar
588b3a0f8f
Fix fallback uint128 bitwise not (#4813) 2026-06-17 23:52:12 -07:00
Victor Zverovich
979c94dff8 Fix hang/assertion when printing to a pipe with closed read end (#4797) 2026-06-18 08:08:44 +02:00
aizu-m
de4c6c502e
fix out-of-range float to int conversion in to_nonnegative_int (#4802) 2026-06-16 23:14:58 -07:00
aizu-m
128ba144ab
fix out-of-bounds read in basic_format_args::get (#4800) 2026-06-09 22:18:35 -07:00
Ferdinand Bachmann
ffd8397db1
Add fmt_print to C API (#4789)
* Add FMT_FORMAT_ARGS(fmt, ...) macro to C API to simplify user-defined format wrappers

* Add fmt_print to C API
2026-06-05 06:40:30 -07:00
Victor Zverovich
70f794e395 Bump version 2026-06-02 15:16:15 -07:00
Jiami Lin
a90ad5d6fd
Fix formatting std::tm with null tm_zone (#4790) 2026-06-01 18:16:49 -07:00
Victor Zverovich
46cf422f54 Unify copyright notices 2026-05-31 08:54:06 -07:00
Victor Zverovich
a823ba0699 Deconstexprify exception formatter 2026-05-31 08:24:38 -07:00
j4niwzis
029d543768
Fix compile time format for ranges, style, and std (#4759) 2026-05-31 08:21:35 -07:00
ahoarau
0acf106c52
Add println functions for formatted output with color support (#4782) 2026-05-25 08:30:36 -07:00
Victor Zverovich
93e26fa578 Cleanup is_contiguous 2026-05-22 08:04:50 -07:00
Vladislav Shchapov
a30cf7d1ad
Provide reasonable default definition for is_contiguous (#4770)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2026-05-21 07:19:19 -07:00
theflashwin
2f18a88e68 fix GCC PCH Breakage Triggered by fmt Scoped #pragma GCC optimize(0g) 2026-05-11 07:20:40 -07:00
Vladislav Shchapov
9cb8c0f92b
Fix ambiguous formatter<std::optional<T>> between fmt/std.h and fmt/ranges.h on C++26 (P3168R2) (#4761)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2026-05-03 07:37:46 -07:00
Victor Zverovich
5a9a184448 Apply clang-format 2026-05-03 07:33:53 -07:00
Kağan Can Şit
d0e3d20af8
chore(IWYU):Remove redundant includes (#4758) 2026-04-29 20:50:56 -07:00
Victor Zverovich
432fda7bfa Fix false positive in tsan (fixes #4755) 2026-04-29 17:16:36 -07:00
user202729
eeff8680ed
Avoid dropping null byte in format string (#4732)
* Avoid dropping null byte in format string

* Add a test for null byte in format string
2026-04-23 09:34:27 -07:00
Victor Zverovich
27d0c03c4d Minor cleanup 2026-04-12 09:50:12 -07:00
Cazadorro
03cfb8645e
Workaround a CUDA issue in handing UTF-32 literals (#4719) 2026-04-10 16:28:52 -07:00
Raúl Marín
4ccf1d4faf
Fix out-of-bounds read in vprintf with trailing '%' (#4742) 2026-04-10 12:23:57 -07:00
Mike Vastola
be98ea8add
Fix bug re: return type of f(un)lockfile wrappers for Windows (#4739)
Just a tiny bugfix I spotted: The `f(un)lockfile` wrappers in
`format-inl.h` that wrap Windows's `_(un)lock_file` methods are
defined with a trailing return type derived by using decltype on a
hypothetical call to the underlying functions.

The wrappers don't contain a `return` in their bodies, however, so if
the return type of the underlying functions were to ever change from
`void`, there would be a compile error. This just adds `return` to each.
2026-04-10 08:01:13 -07:00
Victor Zverovich
d2a159fbe7 Apply clang-format 2026-04-03 17:35:28 -07:00
Victor Zverovich
602df7dab8 Simplify copy 2026-03-28 09:33:45 -07:00
user202729
7b2c4d064b
Speed up iterator_buffer (#4679) 2026-03-25 07:38:47 -07:00
Victor Zverovich
dc05bee307 Don't assume nul termination in printf
Thanks ZUENS2020 for reporting.
2026-03-23 13:28:26 -07:00
sunmy2019
ea85b81ccd
Support fmt::runtime with wchar_t in fmt::format_to_n (#4715) 2026-03-21 17:10:17 -07:00
Victor Chernyakin
ae6fd83e2e
Make fmt/fmt-c.h compile with Clang on Windows (#4712) 2026-03-13 17:51:48 -07:00