<br><br><div class="gmail_quote">On Sat, Feb 6, 2010 at 11:49 AM, Arthur David Olson <span dir="ltr"><<a href="mailto:olsona@elsie.nci.nih.gov">olsona@elsie.nci.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Here are the proposed changes, revised to incorporate KRE's suggestion<br>
on how to handle NULLs passed to asctime_r.<br>
<br>
                                --ado<br>
<br>
------- asctime.c -------<br>
*** /tmp/geta27327      Sat Feb  6 14:46:35 2010<br>
--- /tmp/getb27327      Sat Feb  6 14:46:35 2010<br>
[...]<br>
<br>
***************<br>
*** 91,96 ****<br>
--- 91,101 ----<br>
        char                    year[INT_STRLEN_MAXIMUM(int) + 2];<br>
        char                    result[MAX_ASCTIME_BUF_SIZE];<br>
<br>
+       if (timeptr == NULL) {<br>
+               errno = EINVAL;<br>
+               (void) strcpy(buf, "??? ??? ?? ??:??:?? ????\n");<br>
+               return buf;<br>
+       }<br>
        if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)<br>
                wn = "???";<br>
        else    wn = wday_name[timeptr->tm_wday];<br></blockquote><div><br><br>You could avoid the cast by using:<br><br>    return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");<br><br>This is one of the few occasions when the return value from strcpy() actually is useful.  (So often, it would be more useful if it returned a pointer to the NUL '\0' at the end of the string.)<br>

<br></div></div><br><br clear="all"><br>-- <br>Jonathan Leffler <<a href="mailto:jonathan.leffler@gmail.com">jonathan.leffler@gmail.com</a>>  #include <disclaimer.h><br>Guardian of DBD::Informix - v2008.0513 - <a href="http://dbi.perl.org">http://dbi.perl.org</a><br>

"Blessed are we who can laugh at ourselves, for we shall never cease to be amused."<br>