> > Are there any present-day systems with unsigned 64-bit time_t's?<br><div class="gmail_quote"><div> </div>> Nothing major that I know of. <br>> However, NewOS
does it that way and might be considered to be present-day.<br><br>That being true, I've attached a change that caters to 64-bit unsigned systems (with the usual mangled copy below);<br>these changes are relative to the current ftpable version of localtime.c<br>
<br> --ado<br><br>8.17<br>2110 lines<br>8.19<br>2126 lines<br>*** /tmp/,alocaltime.c 2012-07-11 15:55:34.439147200 -0400<br>--- /tmp/,blocaltime.c 2012-07-11 15:55:34.641947500 -0400<br>***************<br>*** 5,11 ****<br>
<br> #ifndef lint<br> #ifndef NOID<br>! static char elsieid[] = "@(#)localtime.c 8.17";<br> #endif /* !defined NOID */<br> #endif /* !defined lint */<br> <br>--- 5,11 ----<br> <br> #ifndef lint<br>
#ifndef NOID<br>! static char elsieid[] = "@(#)localtime.c 8.19";<br> #endif /* !defined NOID */<br> #endif /* !defined lint */<br> <br>***************<br>*** 277,282 ****<br>--- 277,287 ----<br> /*<br>
** And to get the latest zone names into tzname. . .<br> */<br>+ for (i = 0; i < sp->typecnt; ++i) {<br>+ register const struct ttinfo * const ttisp = &sp->ttis[i];<br>+ <br>+ tzname[ttisp->tt_isdst] = &sp->chars[ttisp->tt_abbrind];<br>
+ } <br> for (i = 0; i < sp->timecnt; ++i) {<br> register const struct ttinfo * const ttisp =<br> &sp->ttis[<br>***************<br>*** 489,508 ****<br> ** signed time_t system but using a data file with<br>
** unsigned values (or vice versa).<br> */<br>! for (i = 0; i < sp->timecnt - 2; ++i)<br>! if (sp->ats[i] > sp->ats[i + 1]) {<br>! ++i;<br> if (TYPE_SIGNED(time_t)) {<br>
/*<br> ** Ignore the end (easy).<br> */<br>! sp->timecnt = i;<br> } else {<br> /*<br> ** Ignore the beginning (harder).<br>
*/<br> register int j;<br> <br> for (j = 0; j + i < sp->timecnt; ++j) {<br> sp->ats[j] = sp->ats[j + i];<br> sp->types[j] = sp->types[j + i];<br>
--- 494,524 ----<br> ** signed time_t system but using a data file with<br> ** unsigned values (or vice versa).<br> */<br>! for (i = 0; i < sp->timecnt; ++i)<br>! if ((i < sp->timecnt - 1 &&<br>
! sp->ats[i] > sp->ats[i + 1]) ||<br>! (i == sp->timecnt - 1 && !TYPE_SIGNED(time_t) &&<br>! sp->ats[i] ><br>! ((stored == 4) ? INT32_MAX : INT64_MAX))) {<br>
if (TYPE_SIGNED(time_t)) {<br> /*<br> ** Ignore the end (easy).<br> */<br>! sp->timecnt = i + 1;<br> } else {<br>
/*<br> ** Ignore the beginning (harder).<br> */<br> register int j;<br> <br>+ /*<br>+ ** Keep the record right before the<br>
+ ** epoch boundary,<br>+ ** but tweak it so that it starts<br>+ ** right with the epoch<br>+ ** (thanks to Doug Bailey).<br>+ */<br>
+ sp->ats[i] = 0;<br> for (j = 0; j + i < sp->timecnt; ++j) {<br> sp->ats[j] = sp->ats[j + i];<br> sp->types[j] = sp->types[j + i];<br>
<br></div>