Skip to content

Commit

Permalink
Merge branch 'upstream' of github.com:kassane/fmt into zig-pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Jan 2, 2024
2 parents 3577865 + 6c3b2d4 commit 9634a92
Show file tree
Hide file tree
Showing 35 changed files with 1,140 additions and 878 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CIFuzz
on: [pull_request]

permissions:
contents: read

jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@061583ebb5a96653e42feb3a97ee513eedc18078 # master
with:
oss-fuzz-project-name: 'fmt'
dry-run: false
language: c++
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@061583ebb5a96653e42feb3a97ee513eedc18078 # master
with:
oss-fuzz-project-name: 'fmt'
fuzz-seconds: 300
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: SARIF file
path: results.sarif
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ option(FMT_INSTALL "Generate the install target." ON)
option(FMT_TEST "Generate the test target." ${FMT_MASTER_PROJECT})
option(FMT_FUZZ "Generate the fuzz target." OFF)
option(FMT_CUDA_TEST "Generate the cuda-test target." OFF)
option(FMT_OS "Include core requiring OS (Windows/Posix) " ON)
option(FMT_OS "Include OS-specific APIs." ON)
option(FMT_MODULE "Build a module instead of a traditional library." OFF)
option(FMT_SYSTEM_HEADERS "Expose headers with marking them as system." OFF)

Expand Down Expand Up @@ -278,9 +278,6 @@ add_headers(FMT_HEADERS args.h chrono.h color.h compile.h core.h format.h
format-inl.h os.h ostream.h printf.h ranges.h std.h
xchar.h)
set(FMT_SOURCES src/format.cc)
if (FMT_OS)
set(FMT_SOURCES ${FMT_SOURCES} src/os.cc)
endif ()

add_module_library(fmt src/fmt.cc FALLBACK
${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md
Expand All @@ -289,6 +286,10 @@ add_library(fmt::fmt ALIAS fmt)
if (FMT_MODULE)
enable_module(fmt)
endif ()
if (FMT_OS)
target_sources(fmt PRIVATE src/os.cc)
target_compile_definitions(fmt PRIVATE FMT_OS=0)
endif ()

if (FMT_WERROR)
target_compile_options(fmt PRIVATE ${WERROR_FLAG})
Expand Down
152 changes: 131 additions & 21 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# 10.2.0 - TBD
# 10.2.0 - 2024-01-01

- Added support for the `%j` specifier (the number of days) for
`std::chrono::duration` (https://github.com/fmtlib/fmt/issues/3643,
https://github.com/fmtlib/fmt/pull/3732). Thanks @intelfx.

- Added support for the chrono suffix for days and changed
the suffix for minutes from "m" to the correct "min"
(https://github.com/fmtlib/fmt/pull/3664).
(https://github.com/fmtlib/fmt/issues/3662,
https://github.com/fmtlib/fmt/pull/3664).
For example ([godbolt](https://godbolt.org/z/9KhMnq9ba)):

```c++
Expand All @@ -24,11 +25,12 @@
https://github.com/fmtlib/fmt/pull/3727). Thanks @cschreib.

- Added a formatter for `std::source_location`
(https://github.com/fmtlib/fmt/pull/3730). For example
([godbolt](https://godbolt.org/z/YajfKjhhr)):
(https://github.com/fmtlib/fmt/pull/3730).
For example ([godbolt](https://godbolt.org/z/YajfKjhhr)):

```c++
#include <fmt/chrono.h>
#include <source_location>
#include <fmt/std.h>

int main() {
fmt::print("{}\n", std::source_location::current());
Expand Down Expand Up @@ -58,6 +60,37 @@

Thanks @muggenhor.

- Added an experimental `nested_formatter` that provides an easy way of
applying a formatter to one or more subobjects while automatically handling
width, fill and alignment. For example:

```c++
#include <fmt/format.h>

struct point {
double x, y;
};

template <>
struct fmt::formatter<point> : nested_formatter<double> {
auto format(point p, format_context& ctx) const {
return write_padded(ctx, [=](auto out) {
return format_to(out, "({}, {})", nested(p.x), nested(p.y));
});
}
};

int main() {
fmt::print("[{:>20.2f}]", point{1, 2});
}
```

prints

```
[ (1.00, 2.00)]
```

- Added the generic representation (`g`) to `std::filesystem::path`
(https://github.com/fmtlib/fmt/issues/3715,
https://github.com/fmtlib/fmt/pull/3729). For example:
Expand All @@ -75,6 +108,43 @@

Thanks @js324.

- Made `format_as` work with references
(https://github.com/fmtlib/fmt/pull/3739). Thanks @tchaikov.

- Fixed formatting of invalid UTF-8 with precision
(https://github.com/fmtlib/fmt/issues/3284).

- Fixed an inconsistency between `fmt::to_string` and `fmt::format`
(https://github.com/fmtlib/fmt/issues/3684).

- Disallowed unsafe uses of `fmt::styled`
(https://github.com/fmtlib/fmt/issues/3625):

```c++
auto s = fmt::styled(std::string("dangle"), fmt::emphasis::bold);
fmt::print("{}\n", s); // compile error
```

Pass `fmt::styled(...)` as a parameter instead.

- Added a null check when formatting a C string with the `s` specifier
(https://github.com/fmtlib/fmt/issues/3706).

- Disallowed the `c` specifier for `bool`
(https://github.com/fmtlib/fmt/issues/3726,
https://github.com/fmtlib/fmt/pull/3734). Thanks @js324.

- Made the default formatting unlocalized in `fmt::ostream_formatter` for
consistency with the rest of the library
(https://github.com/fmtlib/fmt/issues/3460).

- Fixed localized formatting in bases other than decimal
(https://github.com/fmtlib/fmt/issues/3693,
https://github.com/fmtlib/fmt/pull/3750). Thanks @js324.

- Fixed a performance regression in experimental `fmt::ostream::print`
(https://github.com/fmtlib/fmt/issues/3674).

- Added synchronization with the underlying output stream when writing to
the Windows console
(https://github.com/fmtlib/fmt/pull/3668,
Expand All @@ -89,51 +159,89 @@
- Made `fmt::streamed` `constexpr`.
(https://github.com/fmtlib/fmt/pull/3650). Thanks @muggenhor.

- Added an option to build without `wchar_t` support on Windows
(https://github.com/fmtlib/fmt/pull/3636). Thanks @glebm.
- Enabled `consteval` on older versions of MSVC
(https://github.com/fmtlib/fmt/pull/3757). Thanks @phprus.

- Improved build configuration
(https://github.com/fmtlib/fmt/issues/3701,
https://github.com/fmtlib/fmt/pull/3702). Thanks @pklima.

- Fixed various warnings and compilation issues
(https://github.com/fmtlib/fmt/pull/3610,
- Added an option to build without `wchar_t` support on Windows
(https://github.com/fmtlib/fmt/issues/3631,
https://github.com/fmtlib/fmt/pull/3636). Thanks @glebm.

- Improved build and CI configuration
(https://github.com/fmtlib/fmt/pull/3679,
https://github.com/fmtlib/fmt/issues/3701,
https://github.com/fmtlib/fmt/pull/3702,
https://github.com/fmtlib/fmt/pull/3749).
Thanks @jcar87, @pklima and @tchaikov.

- Fixed various warnings, compilation and test issues
(https://github.com/fmtlib/fmt/issues/3607,
https://github.com/fmtlib/fmt/pull/3610,
https://github.com/fmtlib/fmt/pull/3624,
https://github.com/fmtlib/fmt/pull/3630,
https://github.com/fmtlib/fmt/pull/3634,
https://github.com/fmtlib/fmt/pull/3638,
https://github.com/fmtlib/fmt/issues/3645,
https://github.com/fmtlib/fmt/issues/3646,
https://github.com/fmtlib/fmt/pull/3647,
https://github.com/fmtlib/fmt/pull/3652,
https://github.com/fmtlib/fmt/issues/3654,
https://github.com/fmtlib/fmt/pull/3663,
https://github.com/fmtlib/fmt/issues/3670,
https://github.com/fmtlib/fmt/pull/3680,
https://github.com/fmtlib/fmt/issues/3694,
https://github.com/fmtlib/fmt/pull/3695,
https://github.com/fmtlib/fmt/pull/369,
https://github.com/fmtlib/fmt/pull/3699,
https://github.com/fmtlib/fmt/issues/3705,
https://github.com/fmtlib/fmt/issues/3710,
https://github.com/fmtlib/fmt/issues/3712,
https://github.com/fmtlib/fmt/pull/3713,
https://github.com/fmtlib/fmt/issues/3714,
https://github.com/fmtlib/fmt/pull/3716,
https://github.com/fmtlib/fmt/pull/3723).
https://github.com/fmtlib/fmt/pull/3723,
https://github.com/fmtlib/fmt/issues/3738,
https://github.com/fmtlib/fmt/issues/3740,
https://github.com/fmtlib/fmt/pull/3741,
https://github.com/fmtlib/fmt/pull/3743,
https://github.com/fmtlib/fmt/issues/3745,
https://github.com/fmtlib/fmt/pull/3747,
https://github.com/fmtlib/fmt/pull/3748,
https://github.com/fmtlib/fmt/pull/3751,
https://github.com/fmtlib/fmt/pull/3754,
https://github.com/fmtlib/fmt/pull/3755,
https://github.com/fmtlib/fmt/issues/3760,
https://github.com/fmtlib/fmt/pull/3762,
https://github.com/fmtlib/fmt/issues/3763,
https://github.com/fmtlib/fmt/pull/3764,
https://github.com/fmtlib/fmt/issues/3774,
https://github.com/fmtlib/fmt/pull/3779).
Thanks @danakj, @vinayyadav3016, @cyyever, @phprus, @qimiko, @saschasc,
@gsjaardema, @lazka, @Zhaojun-Liu, @carlsmedstad, @hotwatermorning,
@cptFracassa, @kuguma, @PeterJohnson .
@cptFracassa, @kuguma, @PeterJohnson, @H1X4Dev, @asantoni, @eltociear,
@msimberg, @tchaikov, @waywardmonkeys.

- Improved documentation and README
(https://github.com/fmtlib/fmt/pull/3642,
(https://github.com/fmtlib/fmt/issues/2086,
https://github.com/fmtlib/fmt/issues/3637,
https://github.com/fmtlib/fmt/pull/3642,
https://github.com/fmtlib/fmt/pull/3653,
https://github.com/fmtlib/fmt/pull/3655,
https://github.com/fmtlib/fmt/pull/3661,
https://github.com/fmtlib/fmt/issues/3673,
https://github.com/fmtlib/fmt/pull/3677).
Thanks @idzm, @perlun, @joycebrum, @fennewald.
https://github.com/fmtlib/fmt/pull/3677,
https://github.com/fmtlib/fmt/pull/3737,
https://github.com/fmtlib/fmt/issues/3742,
https://github.com/fmtlib/fmt/pull/3744).
Thanks @idzm, @perlun, @joycebrum, @fennewald, @reinhardt1053, @GeorgeLS.

- Updated CI dependencies
(https://github.com/fmtlib/fmt/pull/3615,
https://github.com/fmtlib/fmt/pull/3622,
https://github.com/fmtlib/fmt/pull/3623,
https://github.com/fmtlib/fmt/pull/3666,
https://github.com/fmtlib/fmt/pull/3696,
https://github.com/fmtlib/fmt/pull/3697).
https://github.com/fmtlib/fmt/pull/3697,
https://github.com/fmtlib/fmt/pull/3759,
https://github.com/fmtlib/fmt/pull/3782).

# 10.1.1 - 2023-08-28

Expand Down Expand Up @@ -524,7 +632,9 @@

Thanks @ShawnZhong.

- Added a formatter for `std::optional` to `fmt/std.h`.
- Added a formatter for `std::optional` to `fmt/std.h`
(https://github.com/fmtlib/fmt/issues/1367,
https://github.com/fmtlib/fmt/pull/3303).
Thanks @tom-huntington.

- Fixed formatting of valueless by exception variants
Expand Down
5 changes: 2 additions & 3 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ for example

will return ``" blue"``.

The experimental ``nested_formatter`` provides an easy way applying a formatter
to one or more subobjects.
The experimental ``nested_formatter`` provides an easy way of applying a
formatter to one or more subobjects.

For example::

Expand Down Expand Up @@ -600,7 +600,6 @@ System APIs
:members:

.. doxygenfunction:: fmt::windows_error
:members:

.. _ostream-api:

Expand Down
11 changes: 8 additions & 3 deletions doc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import errno, os, re, sys
from subprocess import check_call, CalledProcessError, Popen, PIPE, STDOUT

versions = ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0', '4.1.0', '5.0.0', '5.1.0', '5.2.0', '5.2.1', '5.3.0', '6.0.0', '6.1.0', '6.1.1', '6.1.2', '6.2.0', '6.2.1', '7.0.0', '7.0.1', '7.0.2', '7.0.3', '7.1.0', '7.1.1', '7.1.2', '7.1.3', '8.0.0', '8.0.1', '8.1.0', '8.1.1', '9.0.0', '9.1.0', '10.0.0', '10.1.0', '10.1.1', '10.1.1']
versions = [
'1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0', '4.1.0', '5.0.0', '5.1.0',
'5.2.0', '5.2.1', '5.3.0', '6.0.0', '6.1.0', '6.1.1', '6.1.2', '6.2.0',
'6.2.1', '7.0.0', '7.0.1', '7.0.2', '7.0.3', '7.1.0', '7.1.1', '7.1.2',
'7.1.3', '8.0.0', '8.0.1', '8.1.0', '8.1.1', '9.0.0', '9.1.0']
versions += ['10.0.0', '10.1.0', '10.1.1', '10.2.0']

class Pip:
def __init__(self, venv_dir):
Expand All @@ -31,7 +36,7 @@ def create_build_env(venv_dir='virtualenv'):
# Jinja2 >= 3.1 incompatible with sphinx 3.3.0
# See: https://github.com/sphinx-doc/sphinx/issues/10291
pip.install('Jinja2<3.1')
pip.install('sphinx-doc/sphinx', 'v3.3.0')
pip.install('sphinx==3.3.0')
pip.install('michaeljones/breathe', 'v4.25.0')

def build_docs(version='dev', **kwargs):
Expand All @@ -50,7 +55,7 @@ def build_docs(version='dev', **kwargs):
GENERATE_RTF = NO
CASE_SENSE_NAMES = NO
INPUT = {0}/args.h {0}/chrono.h {0}/color.h {0}/core.h \
{0}/compile.h {0}/format.h {0}/os.h {0}/ostream.h \
{0}/compile.h {0}/format.h {0}/os.h {0}/ostream.h \
{0}/printf.h {0}/xchar.h
QUIET = YES
JAVADOC_AUTOBRIEF = YES
Expand Down
7 changes: 4 additions & 3 deletions doc/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,10 @@ The available integer presentation types are:
| none | The same as ``'d'``. |
+---------+----------------------------------------------------------+

Integer presentation types can also be used with character and Boolean values.
Boolean values are formatted using textual representation, either ``true`` or
``false``, if the presentation type is not specified.
Integer presentation types can also be used with character and Boolean values
with the only exception that ``'c'`` cannot be used with `bool`. Boolean values
are formatted using textual representation, either ``true`` or ``false``, if the
presentation type is not specified.

The available presentation types for floating-point values are:

Expand Down
Loading

0 comments on commit 9634a92

Please sign in to comment.