747 Commits

Author SHA1 Message Date
Satyakam Mishra
b4b1657c2a
Fix debug format width calculation (#4902) 2026-09-04 09:17:58 -07:00
Victor Zverovich
bc82c408a6 Test dynamic width in nested_formatter 2026-09-02 10:53:56 -07:00
Victor Zverovich
cbb264122a Simplify nested_formatter context handling
Format nested values directly through the stored formatter so dynamic
specifications resolve against the enclosing operation.
2026-09-02 10:14:09 -07:00
Eduardo Gómez
d0cec7ae2e
Fix inconsistent display width for emoji outside East Asian Wide ranges (#4896)
* 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.

* Make wide_cp_ranges C++11-compatible; apply clang-format

* Move wide_cp_range struct into display_width_of()

* Derive wide_cp_ranges from East_Asian_Width data, restore constexpr

* Move wide_cp_ranges to display_width_of function body

* Update format.h

* Update wide_cp_ranges array to include comments

* Add inline to display_width_of and add 1F300-1F5FF and 1F900-1F9FF ranges to match [format.string.std]

* Update display_width_of lo hi varible declaration

---------

Co-authored-by: Eduardo Gomez Saldias <50159560+edugomez102@users.noreply.github.com>
2026-08-30 08:05:50 -07:00
TheNonConformist
8a84280f26
Suppress GCC 16 incomplete type warning (#4893) 2026-08-29 15:09:36 -07:00
Advit Arora
e76a9520a3
Right-align inf and nan with a bare width (#4895)
fmt::format("{:6}", nan) gave "nan   " where std::format and printf("%6f")
give "   nan". write_nonfinite was the only numeric write path taking
write_padded's align::left default, so a width with no explicit align
left-aligned inf and nan while every finite value right-aligned. That
default only reaches align::none, leaving explicit <, > and ^ and the 0
flag unchanged.
2026-08-27 08:54:40 -07:00
hexonal
6c285ba88a
Format zero as 0x0p+0 in hexfloat (#4878)
fmt::format("{:a}", 0.0) produced 0x0p-1022 where printf's %a gives
0x0p+0, and likewise for -0.0, {:A}, {:#a} and any explicit precision.

basic_fp::assign maps a zero biased exponent to 1 ("subnormals use
biased exponent 1"), which is right for subnormals but not for zero, so
format_hexfloat inherited the minimum subnormal exponent for a value
whose significand carries no information. Reset the exponent there
rather than in assign, which the decimal path shares.

A zero significand can only come from +-0: normals get the implicit bit
added, and a subnormal has a nonzero significand by definition. So the
guard cannot affect anything else, and denorm_min keeps its existing
denormalized form (0x0.0000000000001p-1022, asserted in format_double).

The five new expectations were taken from printf rather than derived,
and all fail without this change.
2026-08-10 09:52:03 -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
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
Victor Zverovich
46cf422f54 Unify copyright notices 2026-05-31 08:54:06 -07:00
Kağan Can Şit
9396f77fe4
Remove unused header includes in test files (#4729) 2026-04-05 18:40:48 -07:00
Victor Zverovich
dc05bee307 Don't assume nul termination in printf
Thanks ZUENS2020 for reporting.
2026-03-23 13:28:26 -07:00
Victor Zverovich
eb99f6eba6 Move std::byte formatter to std.h 2026-02-03 10:16:20 -08:00
Victor Zverovich
b98926b73b uint128_fallback -> uint128 2026-02-02 19:13:14 -08:00
Victor Zverovich
3f98b54bd7 Move _BitInt next to bitref formatter 2026-02-02 17:08:10 -08:00
Victor Zverovich
45ed657df3 Cleanup locking 2026-02-01 11:09:19 -08:00
Victor Zverovich
26c6b1c23d Move copy to format.h 2026-01-29 21:30:20 -08:00
Victor Zverovich
45f230b9b2 Remove const_check 2026-01-29 20:18:18 -08:00
Victor Zverovich
3391f9e992 Cleanup test 2025-11-22 19:14:32 -08:00
Victor Zverovich
a6fb4d3b06 Remove invalid tests 2025-11-22 07:00:06 -08:00
Victor Zverovich
f91dc80f4c Minor cleanup 2025-08-16 14:49:26 -07:00
Victor Zverovich
4120581167 Minor cleanup 2025-08-16 14:20:06 -07:00
Victor Zverovich
7ffc3ca15b Minor cleanup 2025-08-16 12:20:02 -07:00
Murat Toprak
0d145936ec
Handle allocator propagation in basic_memory_buffer::move, Fix #4487 (#4490)
* Handle allocator propagation in basic_memory_buffer::move

Update `basic_memory_buffer::move` to respect `propagate_on_container_move_assignment`allocator trait.
If the allocator should not propagate and differs from the target's allocator,
fallback to copying the buffer instead of transferring ownership.

This avoids potential allocator mismatch issues and ensures exception safety.

* Add test cases for the updated move ctor

- Added two test cases `move_ctor_inline_buffer_non_propagating` and `move_ctor_dynamic_buffer_non_propagating`
- Added `PropageteOnMove` template parameter to `allocator_ref` class to be compatible with the old test cases
- `allocator_ref` now implements `!=` and `==` operators
2025-08-09 08:14:15 -07:00
Victor Zverovich
300ce75ca6 Handle invalid glibc FILE buffer 2025-07-06 11:17:16 -07:00
Victor Zverovich
6a3b40524c Use actual example code and move safe_fopen to os-test 2025-07-04 09:50:55 -07:00
Victor Chernyakin
2fa3e1a1bb
Fix interaction between debug presentation, precision, and width for strings (#4478) 2025-07-04 07:33:47 -07:00
Victor Zverovich
fc0c76a075 Handle large precision 2025-06-01 08:49:41 -07:00
Victor Zverovich
befbc5fdb8 Fix ADL lookup for memory_buffer 2025-05-26 09:44:35 -07:00
Victor Zverovich
8aa1d6a9fb Minor cleanup 2025-05-25 10:14:24 -07:00
Nikhil
6d79757a38
Interpret precision as display width (#4443) 2025-05-25 08:42:47 -07:00
Victor Chernyakin
b5266fd3b9
Remove some redundant consts (#4445)
`constexpr` variables are implicitly `const`.
2025-05-12 10:41:58 -07:00
Victor Zverovich
448929d491 Update and apply clang-format 2025-05-03 07:29:31 -07:00
Victor Zverovich
c81cbed2b7 Simplify test 2025-04-23 12:32:26 -07:00
LocalSpook
c709138359 Add support for incomplete types 2025-04-20 10:16:11 -07:00
Victor Zverovich
2f58430573 Move buffering tests to os-test 2025-03-30 09:38:40 -07:00
Dean Glazeski
37e6474718
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
2025-03-15 09:34:11 -07:00
Victor Zverovich
9212ff6ca1 Apply coding conventions and use constexpr 2025-03-02 09:03:06 -08:00
Dean Glazeski
864bdf9638
Report error on duplicate named arg names (#4367) 2025-03-02 07:47:03 -08:00
Victor Zverovich
52eeeb52a6 Make exponent threshold depend on representation (#3649) 2025-01-26 12:10:48 -08:00
Vladislav Shchapov
898d438571
Fix formatting into std::ostreambuf_iterator using a compiled format (#4312)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2025-01-18 07:16:06 -08:00
Victor Zverovich
a35389b3c2 Corrently handle buffer flush 2024-11-09 10:56:31 -08:00
Victor Zverovich
a197a994c5 Add member format_as for std 2024-09-20 08:49:49 -07:00
Victor Zverovich
1782a6eac0 Rename pragma macros 2024-09-12 19:20:32 -07:00
Victor Zverovich
689ec7a087 Cleanup 2024-09-11 16:05:34 -07:00
Victor Zverovich
1bde49e545 Remove FMT_USE_USER_LITERALS 2024-09-11 11:27:27 -07:00
Victor Zverovich
f5a16a484b Cleanup 2024-09-06 12:41:53 -07:00
Victor Zverovich
894b71da85 Fix handling of _BitInt 2024-09-03 11:32:31 -07:00
Victor Zverovich
60740b7c24 Cleanup base API 2024-09-01 19:35:00 -07:00