Add support for SOURCE_DATE_EPOCH environment variable (Issue #193)

This commit is contained in:
Michael Sweet 2017-04-23 12:49:40 -04:00
parent 3700ebd2c3
commit b79d3e0f07
3 changed files with 11 additions and 2 deletions

View File

@ -6,6 +6,8 @@
(Issue #184)
- The configure script now properly supports cross-compilation (Issue #188)
- The mxmldoc utility now supports generation of EPUB files (Issue #189)
- The mxmldoc utility now supports the `SOURCE_DATE_EPOCH` environment
variable for reproducible builds (Issue #193)
- The mxmldoc utility now supports Markdown (Issue #194)

View File

@ -1,4 +1,4 @@
.TH mxml 3 "Mini-XML API" "04/21/17" "Mini-XML API"
.TH mxml 3 "Mini-XML API" "04/23/17" "Mini-XML API"
.SH NAME
mxml \- Mini-XML API
.SH INCLUDE FILE

View File

@ -5604,6 +5604,7 @@ write_man(const char *man_name, /* I - Name of manpage */
*parent; /* Parent class */
int inscope; /* Variable/method scope */
char prefix; /* Prefix character */
const char *source_date_epoch; /* SOURCE_DATE_EPOCH environment variable */
time_t curtime; /* Current time */
struct tm *curdate; /* Current date */
char buffer[1024]; /* String buffer */
@ -5617,9 +5618,15 @@ write_man(const char *man_name, /* I - Name of manpage */
/*
* Standard man page...
*
* Get the current date, using the SOURCE_DATE_EPOCH environment variable, if
* present, for the number of seconds since the epoch - this enables
* reproducible builds (Issue #193).
*/
curtime = time(NULL);
if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL || (curtime = (time_t)strtol(source_date_epoch, NULL, 10)) <= 0)
curtime = time(NULL);
curdate = localtime(&curtime);
strftime(buffer, sizeof(buffer), "%x", curdate);