diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2015-07-19 10:12:39 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2015-07-19 10:12:39 (GMT) |
commit | b31266c1076c6284116f17241d9e8aa048f88e60 (patch) | |
tree | 3504af4c401a616449931bdbd820a7ab5eb98931 /src/util.cpp | |
parent | 4116648d3c62aee54c385644a4fe754ee7a4261d (diff) | |
download | Doxygen-b31266c1076c6284116f17241d9e8aa048f88e60.zip Doxygen-b31266c1076c6284116f17241d9e8aa048f88e60.tar.gz Doxygen-b31266c1076c6284116f17241d9e8aa048f88e60.tar.bz2 |
Bug 751984 - PATCH: Honour SOURCE_DATE_EPOCH environment variable for reproducible output
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index d367c40..db6a19c 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -18,6 +18,7 @@ #include <ctype.h> #include <errno.h> #include <math.h> +#include <limits.h> #include "md5.h" @@ -2472,6 +2473,35 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode) QCString dateToString(bool includeTime) { QDateTime current = QDateTime::currentDateTime(); + QCString sourceDateEpoch = portable_getenv("SOURCE_DATE_EPOCH"); + if (!sourceDateEpoch.isEmpty()) + { + bool ok; + uint64 epoch = sourceDateEpoch.toUInt64(&ok); + if (!ok) + { + static bool warnedOnce=FALSE; + if (!warnedOnce) + { + warn_uncond("Environment variable SOURCE_DATE_EPOCH does not contain a valid number; value is '%s'\n", + sourceDateEpoch.data()); + warnedOnce=TRUE; + } + } + else if (epoch>UINT_MAX) + { + static bool warnedOnce=FALSE; + if (!warnedOnce) + { + warn_uncond("Environment variable SOURCE_DATA_EPOCH must have a value smaller than or equal to %llu; actual value %llu\n",UINT_MAX,epoch); + warnedOnce=TRUE; + } + } + else // all ok, replace current time with epoch value + { + current.setTime_t((ulong)epoch); // TODO: add support for 64bit epoch value + } + } return theTranslator->trDateTime(current.date().year(), current.date().month(), current.date().day(), |