7934 Commits

Author SHA1 Message Date
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
Victor Zverovich
caf5e48b1c Update changelog 2026-07-26 13:12:27 -07:00
Victor Zverovich
2a2d9edb25 Remove extra newline 2026-07-25 07:52:08 -07:00
Victor Zverovich
90567e92d4 Exercise compiled field path in FMT_COMPILE format_as test
The FMT_COMPILE("{}") format string takes a to_string fast path that
never runs the compiled field code the format_as fix (#4836) touched.
Use "[{}]" so the test actually goes through detail::field::format.
2026-07-23 13:35:44 -07:00
Victor Zverovich
c851fbe658 Apply clang-format 2026-07-23 13:10:37 -07: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
4e5ff510f8 Simplify build-tree export and rename INSTALL_TARGETS
Rename INSTALL_TARGETS to FMT_TARGETS since the list is now used for both
installation and the build-tree export, and move INSTALL_FILE_SET into the
FMT_INSTALL block as only install(TARGETS) uses it.

Replace the export-test static library and export-lib.cc with an INTERFACE
library, which reproduces the same CMake export dependency check (#4806).
2026-07-22 11:24:25 -07:00
Yoshi
bcaa44d055
Document that hexfloat 'a'/'A' always emits the 0x prefix (#4862) 2026-07-20 16:24:55 -07:00
hexonal
a749e9d880
Generate CMake export set regardless of FMT_INSTALL (#4850)
export() was scoped inside if (FMT_INSTALL), so projects that pull in
fmt via add_subdirectory()/FetchContent without installing it had no
way to get the exported fmt::* targets. If such a project tries to
export its own targets that depend on fmt, CMake fails with "target
... requires target fmt that is not in any export set".

Hoist the target list/export name and the export() call itself out of
the FMT_INSTALL guard so the build-tree export file is always
generated; the install()-only pieces (config/version files, pkgconfig,
install(EXPORT ...)) stay behind the guard and installed behavior is
unchanged.

Fixes #4806

Co-authored-by: flink <w741069229@gmail.com>
2026-07-20 15:09:34 -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
Victor Zverovich
a79df4504c
Fix links in README.md 2026-07-12 09:37:53 -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
dependabot[bot]
77b6ff700b
Bump actions/checkout from 6.0.0 to 7.0.0 (#4835)
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1af3b93b68...9c091bb21b)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-07-01 09:07:12 -07:00
Soumik15630m
81516a20d9
Skip VERSION/SOVERSION/DEBUG_POSTFIX on the header-only INTERFACE target (#4830)
* Skip VERSION/SOVERSION/DEBUG_POSTFIX on the header-only INTERFACE target

* Lint check fixed
2026-06-28 08:38:06 -07:00
Victor Zverovich
d24fef27d1 Minor cleanup 2026-06-26 15:57:41 -07:00
Victor Zverovich
a2206152d5 Simplify test 2026-06-26 12:29:26 -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
Brooklyn widz
62abc0f30a
fix extra closing paragraph tag in doc/index.md (#4826) 2026-06-25 16:09:46 -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
Victor Zverovich
1be298e1bd Update version 12.2.0 2026-06-16 07:05:35 +02:00
Victor Zverovich
5ea06b13fe Exclude the build tree from the source package
The .gitignore-derived `build/` pattern does not actually prune the build
directory or its contents from the CPack source package, so an empty build/
(and, once docs were built in CI, build/doc-html) leaked into the zip. Ignore
the whole build tree in CPACK_SOURCE_IGNORE_FILES.
2026-06-16 07:04:03 +02:00
Victor Zverovich
11ddbcb789 Build docs in the release workflow so the source zip includes doc-html
The source-zip build moved to CI, which configured out-of-source and never
ran the doc target, so the pre-rendered HTML docs (doc-html/) silently
dropped out of the package. Install the doc toolchain, build the docs, and
stage them into the source tree before package_source so CPack picks them up.
2026-06-12 17:01:05 +02:00
Victor Zverovich
e8deaf2ec3 Update changelog 2026-06-10 11:30:17 +02:00
aizu-m
128ba144ab
fix out-of-bounds read in basic_format_args::get (#4800) 2026-06-09 22:18:35 -07:00
Victor Zverovich
e60274b29c Run lint workflow on all PRs to fix stuck required checks
The lint workflow was path-filtered to source files, so PRs that didn't
touch them never ran clang-format/cmake-format. Since those checks are
required, such PRs were blocked forever waiting for a status that never
came. Drop the paths filter so the workflow always reports a status.
2026-06-09 15:56:50 +02:00
Victor Zverovich
87bb05d3b2 Fix release workflow startup failure from insufficient permissions
The provenance job called the SLSA generator with contents: read, but the
generator's upload-assets job declares contents: write. A reusable
workflow's job permissions may not exceed the caller's, so GitHub failed
the run at startup. Grant contents: write; the upload-assets job is still
skipped at runtime since upload-assets is false.
2026-06-09 15:48:28 +02:00
Pedro Montes Alcalde
2de684d52d
Add .gradle directory to .gitignore (#4799) 2026-06-09 06:03:37 -07:00
Victor Zverovich
1ccba0cf80 Attach SLSA provenance to the draft instead of a new release
With upload-assets the SLSA generator created and published its own
release (and tag) to host the attestation, duplicating the draft. Disable
upload-assets and add a job that downloads the provenance artifact and
attaches it to the draft alongside the source zip.
2026-06-09 06:23:34 +02:00
Victor Zverovich
c1c7296bfa Add a test for fmt_print 2026-06-08 08:18:43 +02:00
Victor Zverovich
841040e781 Attach release artifacts to draft via workflow_dispatch
Draft releases do not fire the `release: created` event, so the release
workflow never ran and the source zip and SLSA provenance were not
attached to the draft. Trigger the workflow explicitly from release.py
via workflow_dispatch, passing the tag to attach to and the ref to build
from, and resolve the tag/ref in the workflow for both event types.
2026-06-08 07:48:52 +02:00
Victor Zverovich
1819f7fa43 Update changelog 2026-06-08 07:35:25 +02:00
Victor Zverovich
e6a8751df7 Restore api.html redirect to fix broken deep links
Re-enable generation of the api.html redirect page during docs deploy so
legacy links such as api.html#udt forward to the new MkDocs api/ page with
their URL hash preserved.
2026-06-05 08:06:58 -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
9afcd929ba Fix release script 2026-06-02 17:32:47 -07:00
Victor Zverovich
9764b90ddb Drop redundant section 2026-06-02 17:17:04 -07:00
Victor Zverovich
ae2121216c Update changelog 2026-06-02 17:07:17 -07:00
Victor Zverovich
f2995637c2 Fix release script 2026-06-02 16:21:20 -07:00
Victor Zverovich
9cd653cac1 Use venv in the release script 2026-06-02 15:32:58 -07:00