proposed time zone package changes (revised)
Arthur David Olson
olsona at lecserver.nci.nih.gov
Sat Feb 6 20:11:50 UTC 2010
> You could avoid the casing:
> return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
The cast can also be avoided in another part of the asctime.c code;
the latest is below.
--ado
------- asctime.c -------
*** /tmp/geta27586 Sat Feb 6 15:08:55 2010
--- /tmp/getb27586 Sat Feb 6 15:08:55 2010
***************
*** 11,17 ****
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)asctime.c 8.2";
#endif /* !defined NOID */
#endif /* !defined lint */
--- 11,17 ----
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)asctime.c 8.5";
#endif /* !defined NOID */
#endif /* !defined lint */
***************
*** 91,96 ****
--- 91,100 ----
char year[INT_STRLEN_MAXIMUM(int) + 2];
char result[MAX_ASCTIME_BUF_SIZE];
+ if (timeptr == NULL) {
+ errno = EINVAL;
+ return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
+ }
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
wn = "???";
else wn = wday_name[timeptr->tm_wday];
***************
*** 113,122 ****
timeptr->tm_mday, timeptr->tm_hour,
timeptr->tm_min, timeptr->tm_sec,
year);
! if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) {
! (void) strcpy(buf, result);
! return buf;
! } else {
#ifdef EOVERFLOW
errno = EOVERFLOW;
#else /* !defined EOVERFLOW */
--- 117,125 ----
timeptr->tm_mday, timeptr->tm_hour,
timeptr->tm_min, timeptr->tm_sec,
year);
! if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime)
! return strcpy(buf, result);
! else {
#ifdef EOVERFLOW
errno = EOVERFLOW;
#else /* !defined EOVERFLOW */
More information about the tz
mailing list