From 4edc089ccb6d06d6ba47e37a18b80fe95afede13 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Mon, 5 May 1997 21:01:57 +0000 Subject: [PATCH] * filesys.c (scm_input_waiting_p): add missing third argument to scm_misc_error. * stime.c (scm_localtime): copy the result of localtime before calling gmtime in case they share a buffer. (scm_localtime, scm_mktime): throw an error if neither HAVE_TM_ZONE nor HAVE_TZNAME. --- libguile/ChangeLog | 12 +++++++++++- libguile/filesys.c | 3 ++- libguile/ioext.c | 3 ++- libguile/stime.c | 39 ++++++++++++++++++++++++--------------- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index c210417cd..c2a09b124 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,7 +1,17 @@ +Mon May 5 20:35:08 1997 Gary Houston + + * filesys.c (scm_input_waiting_p): add missing third argument to + scm_misc_error. + + * stime.c (scm_localtime): copy the result of localtime before + calling gmtime in case they share a buffer. + (scm_localtime, scm_mktime): throw an error if neither HAVE_TM_ZONE + nor HAVE_TZNAME. + Fri May 2 19:07:11 1997 Gary Houston * eq.c (scm_equal_p): use SCM_TYP7SD (y) not SCM_TYP7SD (x). - + Thu May 1 17:01:45 1997 Jim Blandy * Makefile.am (check-local): New target, which causes 'make check' diff --git a/libguile/filesys.c b/libguile/filesys.c index 723632072..58011f609 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -921,7 +921,8 @@ scm_input_waiting_p (f, caller) return remir; } # else - scm_misc_error ("char-ready?", "Not fully implemented"); + scm_misc_error ("char-ready?", "Not fully implemented on this platform", + SCM_EOL); # endif # endif } diff --git a/libguile/ioext.c b/libguile/ioext.c index c7cfaa033..255393a7d 100644 --- a/libguile/ioext.c +++ b/libguile/ioext.c @@ -413,7 +413,8 @@ scm_setfileno (fs, fd) #ifdef SET_FILE_FD_FIELD SET_FILE_FD_FIELD(fs, fd); #else - scm_misc_error ("scm_setfileno", "Not fully implemented", SCM_EOL); + scm_misc_error ("scm_setfileno", "Not fully implemented on this platform", + SCM_EOL); #endif } diff --git a/libguile/stime.c b/libguile/stime.c index 3781dd9ed..47e8cae03 100644 --- a/libguile/stime.c +++ b/libguile/stime.c @@ -283,7 +283,7 @@ SCM scm_localtime (SCM time, SCM zone) { timet itime; - struct tm *lt, *utc; + struct tm *ltptr, lt, *utc; SCM result; int zoff; char *zname = 0; @@ -293,44 +293,50 @@ scm_localtime (SCM time, SCM zone) itime = scm_num2long (time, (char *) SCM_ARG1, s_localtime); SCM_DEFER_INTS; oldtz = setzone (zone, SCM_ARG2, s_localtime); - lt = localtime (&itime); + ltptr = localtime (&itime); err = errno; + /* copied in case localtime and gmtime share a buffer. */ + if (ltptr) + lt = *ltptr; utc = gmtime (&itime); if (utc == NULL) err = errno; - if (lt) + if (ltptr) { #ifdef HAVE_TM_ZONE - zname = lt->tm_zone; + zname = lt.tm_zone; #else # ifdef HAVE_TZNAME /* must be copied before calling tzset again. */ - char *ptr = tzname[ (lt->tm_isdst == 1) ? 1 : 0 ]; + char *ptr = tzname[ (lt.tm_isdst == 1) ? 1 : 0 ]; zname = scm_must_malloc (strlen (ptr) + 1, s_localtime); strcpy (zname, ptr); -#endif +# else + scm_misc_error (s_localtime, "Not fully implemented on this platform", + SCM_EOF); +# endif #endif } restorezone (zone, oldtz); /* delayed until zone has been restored. */ errno = err; - if (utc == NULL || lt == NULL) + if (utc == NULL || ltptr == NULL) scm_syserror (s_localtime); /* calculate timezone offset in seconds west of UTC. */ - zoff = (utc->tm_hour - lt->tm_hour) * 3600 + (utc->tm_min - lt->tm_min) * 60 - + utc->tm_sec - lt->tm_sec; - if (utc->tm_year < lt->tm_year) + zoff = (utc->tm_hour - lt.tm_hour) * 3600 + (utc->tm_min - lt.tm_min) * 60 + + utc->tm_sec - lt.tm_sec; + if (utc->tm_year < lt.tm_year) zoff -= 24 * 60 * 60; - else if (utc->tm_year > lt->tm_year) + else if (utc->tm_year > lt.tm_year) zoff += 24 * 60 * 60; - else if (utc->tm_yday < lt->tm_yday) + else if (utc->tm_yday < lt.tm_yday) zoff -= 24 * 60 * 60; - else if (utc->tm_yday > lt->tm_yday) + else if (utc->tm_yday > lt.tm_yday) zoff += 24 * 60 * 60; - result = filltime (lt, zoff, zname); + result = filltime (<, zoff, zname); SCM_ALLOW_INTS; return result; } @@ -417,7 +423,10 @@ scm_mktime (SCM sbd_time, SCM zone) zname = scm_must_malloc (strlen (ptr) + 1, s_mktime); strcpy (zname, ptr); -#endif +# else + scm_misc_error (s_localtime, "Not fully implemented on this platform", + SCM_EOF); +# endif #endif } restorezone (zone, oldtz);