mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-23 13:00:34 +02:00
(scm_localtime, scm_gmtime, scm_mktime): Provide a default
errno EINVAL in case localtime and gmtime don't set it. (scm_mktime, scm_strptime): Forcibly use errno EINVAL for our SCM_SYSERROR, since mktime and strptime generally don't set errno.
This commit is contained in:
parent
46da76382d
commit
ccad5f61c0
1 changed files with 20 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
|
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2004 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -362,6 +362,9 @@ SCM_DEFINE (scm_localtime, "localtime", 1, 1, 0,
|
||||||
#ifdef LOCALTIME_CACHE
|
#ifdef LOCALTIME_CACHE
|
||||||
tzset ();
|
tzset ();
|
||||||
#endif
|
#endif
|
||||||
|
/* POSIX says localtime sets errno, but C99 doesn't say that.
|
||||||
|
Give a sensible default value in case localtime doesn't set it. */
|
||||||
|
errno = EINVAL;
|
||||||
ltptr = localtime (&itime);
|
ltptr = localtime (&itime);
|
||||||
err = errno;
|
err = errno;
|
||||||
if (ltptr)
|
if (ltptr)
|
||||||
|
@ -382,6 +385,9 @@ SCM_DEFINE (scm_localtime, "localtime", 1, 1, 0,
|
||||||
/* the struct is copied in case localtime and gmtime share a buffer. */
|
/* the struct is copied in case localtime and gmtime share a buffer. */
|
||||||
if (ltptr)
|
if (ltptr)
|
||||||
lt = *ltptr;
|
lt = *ltptr;
|
||||||
|
/* POSIX says gmtime sets errno, but C99 doesn't say that.
|
||||||
|
Give a sensible default value in case gmtime doesn't set it. */
|
||||||
|
errno = EINVAL;
|
||||||
utc = gmtime (&itime);
|
utc = gmtime (&itime);
|
||||||
if (utc == NULL)
|
if (utc == NULL)
|
||||||
err = errno;
|
err = errno;
|
||||||
|
@ -423,6 +429,9 @@ SCM_DEFINE (scm_gmtime, "gmtime", 1, 0, 0,
|
||||||
|
|
||||||
itime = SCM_NUM2LONG (1, time);
|
itime = SCM_NUM2LONG (1, time);
|
||||||
SCM_DEFER_INTS;
|
SCM_DEFER_INTS;
|
||||||
|
/* POSIX says gmtime sets errno, but C99 doesn't say that.
|
||||||
|
Give a sensible default value in case gmtime doesn't set it. */
|
||||||
|
errno = EINVAL;
|
||||||
bd_time = gmtime (&itime);
|
bd_time = gmtime (&itime);
|
||||||
if (bd_time == NULL)
|
if (bd_time == NULL)
|
||||||
SCM_SYSERROR;
|
SCM_SYSERROR;
|
||||||
|
@ -495,7 +504,9 @@ SCM_DEFINE (scm_mktime, "mktime", 1, 1, 0,
|
||||||
tzset ();
|
tzset ();
|
||||||
#endif
|
#endif
|
||||||
itime = mktime (<);
|
itime = mktime (<);
|
||||||
err = errno;
|
/* POSIX doesn't say mktime sets errno, and on glibc 2.3.2 for instance it
|
||||||
|
doesn't. Force a sensible value for our error message. */
|
||||||
|
err = EINVAL;
|
||||||
|
|
||||||
if (itime != -1)
|
if (itime != -1)
|
||||||
{
|
{
|
||||||
|
@ -693,7 +704,13 @@ SCM_DEFINE (scm_strptime, "strptime", 2, 0, 0,
|
||||||
t.tm_isdst = -1;
|
t.tm_isdst = -1;
|
||||||
SCM_DEFER_INTS;
|
SCM_DEFER_INTS;
|
||||||
if ((rest = strptime (str, fmt, &t)) == NULL)
|
if ((rest = strptime (str, fmt, &t)) == NULL)
|
||||||
SCM_SYSERROR;
|
{
|
||||||
|
/* POSIX doesn't say strptime sets errno, and on glibc 2.3.2 for
|
||||||
|
instance it doesn't. Force a sensible value for our error
|
||||||
|
message. */
|
||||||
|
errno = EINVAL;
|
||||||
|
SCM_SYSERROR;
|
||||||
|
}
|
||||||
|
|
||||||
SCM_ALLOW_INTS;
|
SCM_ALLOW_INTS;
|
||||||
return scm_cons (filltime (&t, 0, NULL), SCM_MAKINUM (rest - str));
|
return scm_cons (filltime (&t, 0, NULL), SCM_MAKINUM (rest - str));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue