libstdc++: Populate std::time_get::get's %c format for C locale
commitc534e37faccf481afa9bc28f0605ca0ec3846c89
authorJonathan Wakely <jwakely@redhat.com>
Tue, 24 Sep 2024 22:20:56 +0000 (24 23:20 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 2 Oct 2024 10:36:17 +0000 (2 11:36 +0100)
treee5153070a03c390f8eef2764e21d9b107fd644d9
parent5cf26f2569bf007a2c9c058e43ddfe9a5f67da42
libstdc++: Populate std::time_get::get's %c format for C locale

We were using the empty string "" for D_T_FMT and ERA_D_T_FMT in the C
locale, instead of "%a %b %e %T %Y" as the C standard requires. Set it
correctly for each locale implementation that defines time_members.cc.

We can also explicitly set the _M_era_xxx pointers to the same values as
the corresponding _M_xxx ones, rather than setting them to point to
identical string literals. This doesn't rely on the compiler merging
string literals, and makes it more explicit that they're the same in the
C locale.

libstdc++-v3/ChangeLog:

* config/locale/dragonfly/time_members.cc
(__timepunct<char>::_M_initialize_timepunc)
(__timepunct<wchar_t>::_M_initialize_timepunc): Set
_M_date_time_format for C locale. Set %Ex formats to the same
values as the %x formats.
* config/locale/generic/time_members.cc: Likewise.
* config/locale/gnu/time_members.cc: Likewise.
* testsuite/22_locale/time_get/get/char/5.cc: New test.
* testsuite/22_locale/time_get/get/wchar_t/5.cc: New test.
libstdc++-v3/config/locale/dragonfly/time_members.cc
libstdc++-v3/config/locale/generic/time_members.cc
libstdc++-v3/config/locale/gnu/time_members.cc
libstdc++-v3/testsuite/22_locale/time_get/get/char/5.cc [new file with mode: 0644]
libstdc++-v3/testsuite/22_locale/time_get/get/wchar_t/5.cc [new file with mode: 0644]