On Thu, Jan 5, 2017 at 2:37 AM, Paul Eggert <eggert@cs.ucla.edu> wrote:
Bradley White wrote:

One solution would be to trim trailing, no-op transitions from the end of
the zic transitions before adding the rule-generated ones.  The reference
implementation doesn't need them.

Thanks for catching that bug. The attached patch takes your suggestion for localtime.c. It also attempts to fix zic.c to not generate the incorrect transition in Pacific/Tongatapu in January 2038. Either part of the patch should suffice to fix the bug.

Thanks.  I can verify that:

(1) the zic.c change only affects Pacific/Tongatapu and Pacific/Fiji, and

(2) the zic.c and/or the localtime.c changes fix the problem.

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--;