On Fri, Jan 6, 2017 at 1:25 PM, Paul Eggert <eggert@cs.ucla.edu> wrote:
On 01/05/2017 10:05 PM, Bradley White wrote:
> Regarding the localtime.c change, perhaps something better than
> ignoring a transition that was "almost surely generated" because
> of WORK_AROUND_QTBUG_53071, is to just ignore any trailing, no-op
> transitions.  That is, ...
>
> +                     /* Ignore any trailing, no-op transitions generated
> +                      * by zic as they don't help here and can run afoul
> +                      * of bugs in zic 2016j or earlier.  */
> +                     while (1 < sp->timecnt &&
> +                            sp->types[sp->timecnt - 1] ==
> +                                sp->types[sp->timecnt - 2])
> +                       sp->timecnt--;
>
I tried something like that but it that worked only on 32-bit clients
because the transitions were still in the 64-bit data and were not at
the end. My memory could be wrong (I didn't save all my work). Plus,
perhaps it could be fixed up somehow. I agree that if someone could get
something like the above to work in both 32- and 64-bit clients, with
both the unfixed and the fixed zic, it'd be a better fix.

Here is what I see for trailing 32-bit and 64-bit data in Pacific/Tongatapu using both the unfixed and fixed zic.

                  32-bit data                                             64-bit data
Unfixed zic:
  2115810000 [type=2] gmtoff=46800 is_dst=F abbr="+13"    2115810000 [type=2] gmtoff=46800 is_dst=F abbr="+13"
  2140606800 [type=5] gmtoff=50400 is_dst=T abbr="+14"    2140606800 [type=5] gmtoff=50400 is_dst=T abbr="+14"
  2147483647 [type=5] gmtoff=50400 is_dst=T abbr="+14"    2147483647 [type=5] gmtoff=50400 is_dst=T abbr="+14"
Fixed zic:
  2115810000 [type=2] gmtoff=46800 is_dst=F abbr="+13"    2115810000 [type=2] gmtoff=46800 is_dst=F abbr="+13"
  2140606800 [type=5] gmtoff=50400 is_dst=T abbr="+14"    2140606800 [type=5] gmtoff=50400 is_dst=T abbr="+14"
  2147259600 [type=2] gmtoff=46800 is_dst=F abbr="+13"    2147259600 [type=2] gmtoff=46800 is_dst=F abbr="+13"
  2147483647 [type=2] gmtoff=46800 is_dst=F abbr="+13"    2147483647 [type=2] gmtoff=46800 is_dst=F abbr="+13"

All of that looks good.  The extra transition is at the end in each case, so the proposed "trim trailing no-op transitions" patch to localtime.c would always do the trick ... correcting the dropped-transition (2147259600) problem for the unfixed zic, and having no effect for the fixed zic.  I'm not sure what issue you may have seen with it.

[One thing I see that has changed in the fixed zic is that the last two "real" transitions are no longer necessarily in the same calendar year.  That's not a problem per se, but my future-extension code assumes it.  :-(  I'll have to fix that.]

Bradley