From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: stime.c forcing errno Date: Sat, 14 Feb 2004 10:09:59 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87fzdeplm0.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1076717568 13537 80.91.224.253 (14 Feb 2004 00:12:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 14 Feb 2004 00:12:48 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Feb 14 01:12:43 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ArnQJ-0004TI-00 for ; Sat, 14 Feb 2004 01:12:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ArnOl-00049g-HU for guile-devel@m.gmane.org; Fri, 13 Feb 2004 19:11:07 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1ArnOS-00046v-0f for guile-devel@gnu.org; Fri, 13 Feb 2004 19:10:48 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1ArnNv-0003yR-G8 for guile-devel@gnu.org; Fri, 13 Feb 2004 19:10:46 -0500 Original-Received: from [61.8.0.85] (helo=mailout2.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ArnNu-0003xn-6i for guile-devel@gnu.org; Fri, 13 Feb 2004 19:10:14 -0500 Original-Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86]) by mailout2.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id i1E0AA5O007067 for ; Sat, 14 Feb 2004 11:10:10 +1100 Original-Received: from localhost (ppp182.dyn249.pacific.net.au [203.143.249.182]) by mailproxy1.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id i1E0A80H016954 for ; Sat, 14 Feb 2004 11:10:09 +1100 Original-Received: from gg by localhost with local (Exim 3.36 #1 (Debian)) id 1ArnNf-0000NV-00; Sat, 14 Feb 2004 10:09:59 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:3371 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3371 --=-=-= * stime.c (scm_localtime, scm_gmtime, scm_mktime, scm_strptime): Set errno = EINVAL ahead of time calls, for the benefit of SCM_SYSERROR if those calls don't set errno themselves. For glibc 2.3.2 mktime with a year out of range returns -1 and doesn't set errno. This is something I'd mentioned a while ago. For instance a bogus errno can be seen from (mktime #(0 0 0 1 0 9999 4 0 0 0 "GMT")) This would be for the 1.6 branch too I think. I'm not sure what the standards say about these time functions setting errno. Perhaps being libc functions rather than system calls they don't ever set it, or only set it incidentally if some timezone data file is not found or something. --=-=-= Content-Disposition: inline; filename=stime.c.errno.diff --- stime.c.~1.82.~ 2004-01-04 08:25:02.000000000 +1000 +++ stime.c 2004-02-13 11:22:51.000000000 +1000 @@ -327,6 +327,7 @@ #ifdef LOCALTIME_CACHE tzset (); #endif + errno = EINVAL; /* in case localtime doesn't set this */ ltptr = localtime (&itime); err = errno; if (ltptr) @@ -347,6 +348,7 @@ /* the struct is copied in case localtime and gmtime share a buffer. */ if (ltptr) lt = *ltptr; + errno = EINVAL; /* in case gmtime doesn't set errno */ utc = gmtime (&itime); if (utc == NULL) err = errno; @@ -389,6 +391,7 @@ itime = SCM_NUM2LONG (1, time); SCM_DEFER_INTS; + errno = EINVAL; /* in case gmtime doesn't set errno */ bd_time = gmtime (&itime); if (bd_time == NULL) SCM_SYSERROR; @@ -460,6 +463,7 @@ #ifdef LOCALTIME_CACHE tzset (); #endif + errno = EINVAL; /* in case mktime doesn't set this */ itime = mktime (<); err = errno; @@ -480,6 +484,7 @@ } /* get timezone offset in seconds west of UTC. */ + errno = EINVAL; /* in case gmtime doesn't set errno */ utc = gmtime (&itime); if (utc == NULL) err = errno; @@ -659,6 +664,7 @@ fields, hence the use of SCM_DEFER_INTS. */ t.tm_isdst = -1; SCM_DEFER_INTS; + errno = EINVAL; /* in case strptime doesn't set errno */ if ((rest = strptime (str, fmt, &t)) == NULL) SCM_SYSERROR; --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--