>From b6320135511f8aa720f6532d515fcdcaab335b29 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 8 Jan 2017 10:40:32 -0800
Subject: [PROPOSED] Improve trailing-transition test

* NEWS: Add thanks.
* localtime.c (tzloadbody): Ignore trailing no-op transitions,
instead of transitions at 0x7fffffff.  Patch from Bradley White.
---
 NEWS        |  3 ++-
 localtime.c | 12 ++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index ec1437a..6ad908f 100644
--- a/NEWS
+++ b/NEWS
@@ -68,7 +68,8 @@ Unreleased, experimental changes
     attempts to work around Qt bug 53071.  This fixes a bug affecting
     Pacific/Tongatapu that was introduced in zic 2016e.  localtime.c
     now contains a workaround, useful when loading a file generated by
-    a buggy zic.  (Problem reported by Bradley White.)
+    a buggy zic.  (Problem and localtime.c fix reported by Bradley
+    White.)
 
     zdump -i now outputs non-hour numeric time zone abbreviations
     without a colon, e.g., "+0530" rather than "+05:30".  This agrees
diff --git a/localtime.c b/localtime.c
index 1568aac..b653e5c 100644
--- a/localtime.c
+++ b/localtime.c
@@ -598,12 +598,12 @@ tzloadbody(char const *name, struct state *sp, bool doextend,
 			  if (gotabbr == 2) {
 			    sp->charcnt = charcnt;
 
-			    /* Ignore any transition that was almost surely
-			       generated because of WORK_AROUND_QTBUG_53071 in
-			       zic.c, as it doesn't help here and can run
-			       afoul of bugs in zic 2016j or earlier.  */
-			    if (1 < sp->timecnt
-				&& sp->ats[sp->timecnt - 1] == 0x7fffffff)
+			    /* 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--;
 
 			    for (i = 0; i < ts->timecnt; i++)
-- 
2.7.4

