* time/tzfile.c (__tzfile_compute): Do leap second computations
first, to avoid the need for a goto and a label.
---
time/tzfile.c | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
@@ -581,6 +581,26 @@ __tzfile_compute (__time64_t timer, int use_localtime,
{
tzidx i;
+ /* Find the last leap second correction transition time before TIMER. */
+ int corr = 0;
+ bool hit = false;
+ for (i = leapcnt; 0 < i; )
+ {
+ i--;
+ if (leaps[i].occur <= timer)
+ {
+ /* Apply its correction. */
+ corr = leaps[i].corr;
+
+ /* A hit if exactly at a positive leap second. */
+ hit = (timer == leaps[i].occur
+ && (i == 0 ? 0 : leaps[i - 1].corr) < leaps[i].corr);
+ break;
+ }
+ }
+ *leap_correct = corr;
+ *leap_hit = hit;
+
if (use_localtime)
{
unsigned char ti;
@@ -609,7 +629,7 @@ __tzfile_compute (__time64_t timer, int use_localtime,
/* Use the rules from the TZ string to compute the change. */
__tz_compute (timer, tp);
- goto leap;
+ return;
}
else
{
@@ -679,24 +699,6 @@ __tzfile_compute (__time64_t timer, int use_localtime,
this is closer to what proleptic TZ does. */
__tzname[dst] = tm_zone;
}
-
- leap:
- *leap_correct = 0;
- *leap_hit = false;
-
- /* Find the last leap second correction transition time before TIMER. */
- i = leapcnt;
- do
- if (i-- == 0)
- return;
- while (timer < leaps[i].occur);
-
- /* Apply its correction. */
- *leap_correct = leaps[i].corr;
-
- if (timer == leaps[i].occur /* Exactly at the transition time. */
- && (leaps[i].corr > (i == 0 ? 0 : leaps[i - 1].corr)))
- *leap_hit = true;
}
weak_alias (transitions, __libc_tzfile_freemem_ptr)