unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* stime.c forcing errno
@ 2004-02-14  0:09 Kevin Ryde
  2004-02-14  3:52 ` Paul Jarc
  2004-02-23 19:32 ` Marius Vollmer
  0 siblings, 2 replies; 5+ messages in thread
From: Kevin Ryde @ 2004-02-14  0:09 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 717 bytes --]

        * 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.


[-- Attachment #2: stime.c.errno.diff --]
[-- Type: text/plain, Size: 1357 bytes --]

--- 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 (&lt);
   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;
 

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-02-23 19:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-14  0:09 stime.c forcing errno Kevin Ryde
2004-02-14  3:52 ` Paul Jarc
2004-02-14  3:58   ` Paul Jarc
2004-02-14 22:54   ` Kevin Ryde
2004-02-23 19:32 ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).