]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix width computation for the chrono formatting [PR120114]
authorTomasz Kamiński <tkaminsk@redhat.com>
Mon, 5 May 2025 14:32:58 +0000 (16:32 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Wed, 7 May 2025 10:14:51 +0000 (12:14 +0200)
commit52f6ab55051ff43fd1b40ff06d9501043f8ba844
treed5147bb12ef66988acd498c7f048d7727f58c4f7
parent83ef989ee189902ca1d434feb0f3dd50519e92cb
libstdc++: Fix width computation for the chrono formatting [PR120114]

Use `__unicode::_field_width` to compute the field width of the output when writting
the formatted output for std::chrono::types. This applies both to characters copied
from format string, and one produced by localized formatting.

We also use _Str_sink::view() instead of get(), which avoids copying the content of
the buffer to std::string in case of small output.

PR libstdc++/120114

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_format): Use __field_width.
* testsuite/std/time/format/pr120114.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/include/bits/chrono_io.h
libstdc++-v3/testsuite/std/time/format/pr120114.cc [new file with mode: 0644]