Fwd: zdump loop problem

Jonathan Leffler jonathan.leffler at gmail.com
Thu Dec 11 00:53:14 UTC 2008

```Originally sent to the wrong email address - sorry.

---------- Forwarded message ----------
From: Jonathan Leffler <jonathan.leffler at gmail.com>
Date: Mon, Dec 8, 2008 at 12:14 PM
Subject: Re: zdump loop problem
To: Robbin Kawabata <Robbin.Kawabata at sun.com>
Cc: tz at lecserver.nci.nih.gov, a.radke at arcor.de

On Mon, Dec 8, 2008 at 11:50 AM, Robbin Kawabata <Robbin.Kawabata at sun.com>wrote:

> I ran ado's fix against all the timezones, and got good results.
>
> This is the diff:
>
> *** zdump_loop.c    Tue Dec  2 11:17:01 2008
> --- zdump_fix_ado.c     Tue Dec  2 12:49:05 2008
> ***************
> *** 312,322 ****
>                         (void) strncpy(buf, abbr(&tm), sizeof (buf) - 1);
>                }
>                for (;;) {
> !                       if (t >= cuthitime)
>                                break;
>                        newt = t + SECSPERHOUR * 12;
> -                       if (newt >= cuthitime)
> -                               break;
>                         if (newt <= t)
>                                break;
>                        newtmp = localtime(&newt);
> --- 312,320 ----
>                         (void) strncpy(buf, abbr(&tm), sizeof (buf) - 1);
>                }
>                for (;;) {
> !                       if (t >= cuthitime || t >= cuthitime - SECSPERHOUR
> * 12)
>                                 break;
>

Isn't that code equivalent to just:

if (t >= cuthitime - SECSPERHOUR * 12)

I've not followed all the details of the thread, but AFAIUI, this code is
protecting against overflow on positive quantities (rather than underflow on
negative ones), and the double test is redundant unless cuthitime is within
12 * SECPERHOUR of the smallest (most negative) integer.

>                        newt = t + SECSPERHOUR * 12;
>                        if (newt <= t)
>                                break;
>                        newtmp = localtime(&newt);
>
>
> However, isn't the check for "if (newt <= t) break" no longer needed?
>

Probably...

> ----- Begin Forwarded Message -----
>
> Date: Mon, 01 Dec 2008 16:21:00 -0500
> From: "Olson, Arthur David (NIH/NCI) [E]" <olsona at dc37a.nci.nih.gov>
> Subject: Re: zdump loop problem
> To: tz at lecserver.nci.nih.gov
> Cc: Andreas Radke <a.radke at arcor.de>
>
> So...in the real world, does changing the zic.c lines reading...
>                         if (t >= cuthitime)
>                                break;
>                        newt = t + SECSPERHOUR * 12;
>                        if (newt >= cuthitime)
>                                break;
> ...to read...
>                         if (t >= cuthitime || t >= cuthitime -
> SECSPERHOUR * 12)
>                                break;
>                        newt = t + SECSPERHOUR * 12;
> ...result in working code? I'd particularly appreciate feedback from
> Andreas Radke or other ArchLinux users.
>
> ----- End Forwarded Message -----
>

--
Jonathan Leffler <jonathan.leffler at gmail.com>  #include <disclaimer.h>
Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm.icann.org/pipermail/tz/attachments/20081210/0a3ad3f4/attachment-0001.html
```

More information about the tz mailing list