Hmmm...if a binary file has 32-bit values that are in sort and that all have their<br>high-order bits set, it might be because it contains signed values that are all<br>pre-epoch. It might also be because it contains unsigned values that are all<br>
post-2038--that's unlikely now, but likelier as time goes by.<br><br>If we're lucky, 32-bit systems will be a thing of the past by the time it's likely.<br>That being so, I've attached a slightly-revised version of Doug Bailey's fixes<br>
(they also appear below, with tabs mangled by Firefox/Gmail).<br><br>Are there any present-day systems with unsigned 64-bit time_t's?<br><br> --ado<br><br>8.17<br>2110 lines<br>8.18<br>2127 lines<br>*** /tmp/,alocaltime.c 2012-07-10 15:14:38.372363200 -0400<br>
--- /tmp/,blocaltime.c 2012-07-10 15:14:38.509371000 -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.18";<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,525 ----<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 &&<br>! !TYPE_SIGNED(time_t) &&<br>! stored == 4 &&<br>! sp->ats[i] > INT32_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>