<br><br><div class="gmail_quote">On Sat, Feb 6, 2010 at 11:49 AM, Arthur David Olson <span dir="ltr">&lt;<a href="mailto:olsona@elsie.nci.nih.gov">olsona@elsie.nci.nih.gov</a>&gt;</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&#39;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, &quot;??? ??? ?? ??:??:?? ????\n&quot;);<br>
+               return buf;<br>
+       }<br>
        if (timeptr-&gt;tm_wday &lt; 0 || timeptr-&gt;tm_wday &gt;= DAYSPERWEEK)<br>
                wn = &quot;???&quot;;<br>
        else    wn = wday_name[timeptr-&gt;tm_wday];<br></blockquote><div><br><br>You could avoid the cast by using:<br><br>    return strcpy(buf, &quot;??? ??? ?? ??:??:?? ????\n&quot;);<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 &#39;\0&#39; at the end of the string.)<br>

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

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