workaround for common programming error involving ctime and localtime
The following patch lets the tz package work around a common programming error when using ctime and localtime. =================================================================== RCS file: RCS/localtime.c,v retrieving revision 1994.6.1.1 retrieving revision 1994.6.1.2 diff -c -r1994.6.1.1 -r1994.6.1.2 *** localtime.c 1994/05/05 16:24:49 1994.6.1.1 --- localtime.c 1994/05/09 10:16:11 1994.6.1.2 *************** *** 1136,1142 **** ctime(timep) const time_t * const timep; { ! return asctime(localtime(timep)); } /* --- 1136,1151 ---- ctime(timep) const time_t * const timep; { ! struct tm tm; ! ! /* ! ** The following is equivalent to `return asctime(localtime(timep));', ! ** except it does not modify localtime's static storage, ! ** and thus it works around all-too-common bugs like ! ** `struct tm *p = localtime(&t1); puts(ctime(&t2)); return p->tm_year'. ! */ ! localsub(timep, 0L, &tm); ! return asctime(&tm); } /*
participants (1)
-
yata!eggert@twinsun.com