https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116657

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:ab884fffe3fc82a710bea66ad651720d71c938b8

commit r14-10660-gab884fffe3fc82a710bea66ad651720d71c938b8
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Apr 30 09:52:13 2024 +0100

    libstdc++: Fix std::chrono::tzdb to work with vanguard format

    I found some issues in the std::chrono::tzdb parser by testing the
    tzdata "vanguard" format, which uses new features that aren't enabled in
    the "main" and "rearguard" data formats.

    Since 2024a the keyword "minimum" is no longer valid for the FROM and TO
    fields in a Rule line, which means that "m" is now a valid abbreviation
    for "maximum". Previously we expected either "mi" or "ma". For backwards
    compatibility, a FROM field beginning with "mi" is still supported and
    is treated as 1900. The "maximum" keyword is only allowed in TO now,
    because it makes no sense in FROM. To support these changes the
    minmax_year and minmax_year2 classes for parsing FROM and TO are
    replaced with a single years_from_to class that reads both fields.

    The vanguard format makes use of %z in Zone FORMAT fields, which caused
    an exception to be thrown from ZoneInfo::set_abbrev because no % or /
    characters were expected when a Zone doesn't use a named Rule. The
    ZoneInfo::to(sys_info&) function now uses format_abbrev_str to replace
    any %z with the current offset. Although format_abbrev_str also checks
    for %s and STD/DST formats, those only make sense when a named Rule is
    in effect, so won't occur when ZoneInfo::to(sys_info&) is used.

    Since making this change on trunk, the tzdata-2024b release started
    using %z in the main format, not just vanguard. This makes a backport to
    release branches necessary (see PR 116657).

    This change also implements a feature that has always been missing from
    time_zone::_M_get_sys_info: finding the Rule that is active before the
    specified time point, so that we can correctly handle %s in the FORMAT
    for the first new sys_info that gets created. This requires implementing
    a poorly documented feature of zic, to get the LETTERS field from a
    later transition, as described at
    https://mm.icann.org/pipermail/tz/2024-April/058891.html
    In order for this to work we need to be able to distinguish an empty
    letters field (as used by CE%sT where the variable part is either empty
    or "S") from "the letters field is not known for this transition". The
    tzdata file uses "-" for an empty letters field, which libstdc++ was
    previously replacing with "" when the Rule was parsed. Instead, we now
    preserve the "-" in the Rule object, so that "" can be used for the case
    where we don't know the letters (and so need to decide it).

    libstdc++-v3/ChangeLog:

            * src/c++20/tzdb.cc (minmax_year, minmax_year2): Remove.
            (years_from_to): New class replacing minmax_year and
            minmax_year2.
            (format_abbrev_str, select_std_or_dst_abbrev): Move earlier in
            the file. Handle "-" for letters.
            (ZoneInfo::to): Use format_abbrev_str to expand %z.
            (ZoneInfo::set_abbrev): Remove exception. Change parameter from
            reference to value.
            (operator>>(istream&, Rule&)): Do not clear letters when it
            contains "-".
            (time_zone::_M_get_sys_info): Add missing logic to find the Rule
            in effect before the time point.
            * testsuite/std/time/tzdb/1.cc: Adjust for vanguard format using
            "GMT" as the Zone name, not as a Link to "Etc/GMT".
            * testsuite/std/time/time_zone/sys_info_abbrev.cc: New test.

    (cherry picked from commit 0ca8d56f2085715f27ee536c6c344bc47af49cdd)

Reply via email to