diff options
author | William M. Brack <wbrack@src.gnome.org> | 2004-02-26 17:04:11 +0000 |
---|---|---|
committer | William M. Brack <wbrack@src.gnome.org> | 2004-02-26 17:04:11 +0000 |
commit | 85831bf16141a154484c3bd95fdf4bca93340cbb (patch) | |
tree | 5d370da941a5d999e334dca4890a7af63dcd3373 /libexslt | |
parent | 58b080f3fbe363edee4b830a4cc5cc8572f8c888 (diff) | |
download | libxslt-85831bf16141a154484c3bd95fdf4bca93340cbb.tar.gz libxslt-85831bf16141a154484c3bd95fdf4bca93340cbb.tar.bz2 libxslt-85831bf16141a154484c3bd95fdf4bca93340cbb.zip |
added test for localtime_r added usage of localtime_r if present on system
* configure.in, config.h.in: added test for localtime_r
* libexslt/date.c: added usage of localtime_r if present on
system (bug 129983, suggested by Vasily Tchekalkin)
Diffstat (limited to 'libexslt')
-rw-r--r-- | libexslt/date.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/libexslt/date.c b/libexslt/date.c index 9853e0be..a15a61e2 100644 --- a/libexslt/date.c +++ b/libexslt/date.c @@ -28,6 +28,10 @@ #include "config.h" #endif +#if HAVE_LOCALTIME_R /* _POSIX_SOURCE required by gnu libc */ +#define _POSIX_SOURCE +#endif + #include <libxml/tree.h> #include <libxml/xpath.h> #include <libxml/xpathInternals.h> @@ -41,14 +45,14 @@ #include <string.h> -#ifdef HAVE_TIME_H -#include <time.h> -#endif - #ifdef HAVE_MATH_H #include <math.h> #endif +#ifdef HAVE_TIME_H +#include <time.h> +#endif + /* * types of date and/or time (from schema datatypes) * somewhat ordered from least specific to most specific (i.e. @@ -106,7 +110,8 @@ struct _exsltDateVal { * * ****************************************************************/ -#if defined(HAVE_TIME_H) && defined(HAVE_LOCALTIME) \ +#if defined(HAVE_TIME_H) \ + && (defined(HAVE_LOCALTIME) || defined(HAVE_LOCALTIME_R)) \ && defined(HAVE_TIME) && defined(HAVE_GMTIME) #define WITH_TIME #endif @@ -728,6 +733,9 @@ static exsltDateValPtr exsltDateCurrent (void) { struct tm *localTm, *gmTm; time_t secs; +#if HAVE_LOCALTIME_R + struct tm localTmS; +#endif exsltDateValPtr ret; ret = exsltDateCreateDate(XS_DATETIME); @@ -736,7 +744,12 @@ exsltDateCurrent (void) { /* get current time */ secs = time(NULL); +#if HAVE_LOCALTIME_R + localtime_r(&secs, &localTmS); + localTm = &localTmS; +#else localTm = localtime(&secs); +#endif /* get real year, not years since 1900 */ ret->value.date.year = localTm->tm_year + 1900; |