Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Unified Diff: third_party/libxslt/libexslt/date.c

Issue 2411263002: Roll libxslt to 8345634c5482ca04293ae1862d52fa9dd764aeca (Closed)
Patch Set: config.log Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libxslt/libexslt/common.c ('k') | third_party/libxslt/libexslt/dynamic.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libxslt/libexslt/date.c
diff --git a/third_party/libxslt/libexslt/date.c b/third_party/libxslt/libexslt/date.c
index 87c484875dba61652ff7bcca1f7e0563f622ae92..3af6f7fda2b9f35720202e51a1a7dbb972dbcfb5 100644
--- a/third_party/libxslt/libexslt/date.c
+++ b/third_party/libxslt/libexslt/date.c
@@ -47,6 +47,9 @@
#include <string.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
#ifdef HAVE_MATH_H
#include <math.h>
#endif
@@ -752,21 +755,55 @@ static exsltDateValPtr
exsltDateCurrent (void)
{
struct tm localTm, gmTm;
+#ifndef HAVE_GMTIME_R
+ struct tm *tb = NULL;
+#endif
time_t secs;
int local_s, gm_s;
exsltDateValPtr ret;
+#ifdef HAVE_ERRNO_H
+ char *source_date_epoch;
+#endif /* HAVE_ERRNO_H */
+ int override = 0;
ret = exsltDateCreateDate(XS_DATETIME);
if (ret == NULL)
return NULL;
+#ifdef HAVE_ERRNO_H
+ /*
+ * Allow the date and time to be set externally by an exported
+ * environment variable to enable reproducible builds.
+ */
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch) {
+ errno = 0;
+ secs = (time_t) strtol (source_date_epoch, NULL, 10);
+ if (errno == 0) {
+#if HAVE_GMTIME_R
+ if (gmtime_r(&secs, &localTm) != NULL)
+ override = 1;
+#else
+ tb = gmtime(&secs);
+ if (tb != NULL) {
+ localTm = *tb;
+ override = 1;
+ }
+#endif
+ }
+ }
+#endif /* HAVE_ERRNO_H */
+
+ if (override == 0) {
/* get current time */
- secs = time(NULL);
+ secs = time(NULL);
+
#if HAVE_LOCALTIME_R
- localtime_r(&secs, &localTm);
+ localtime_r(&secs, &localTm);
#else
- localTm = *localtime(&secs);
+ localTm = *localtime(&secs);
#endif
+ }
/* get real year, not years since 1900 */
ret->value.date.year = localTm.tm_year + 1900;
@@ -783,7 +820,9 @@ exsltDateCurrent (void)
#if HAVE_GMTIME_R
gmtime_r(&secs, &gmTm);
#else
- gmTm = *gmtime(&secs);
+ tb = gmtime(&secs);
+ if (tb != NULL)
+ gmTm = *tb;
#endif
ret->value.date.tz_flag = 0;
#if 0
« no previous file with comments | « third_party/libxslt/libexslt/common.c ('k') | third_party/libxslt/libexslt/dynamic.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698