diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-05-04 12:10:04 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-05-04 12:10:04 +0000 |
commit | f14daac6b6677753c7a1fc54ea2dfff39997e91b (patch) | |
tree | 0cf85e0149d667faf4516fa6bf29ed64b2b3851c | |
parent | 37e784a34b7fa6aa6a0803ad8cbb43a2f9053c09 (diff) |
dvipsk: support SOURCE_DATE_EPOCH for %%CreationDate
git-svn-id: svn://tug.org/texlive/trunk@40885 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/dvipsk/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/output.c | 37 |
2 files changed, 38 insertions, 3 deletions
diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index 3d06bf0435c..356a0010db9 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,7 @@ +2016-05-04 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + + * output.c: Support SOURCE_DATE_EPOCH for %%CreationDate. + 2016-03-24 Akira Kakuto <kakuto@fuk.kindai.ac.jp> * writet1.c: Fix one-byte buffer overflow bug reported by Hanno Boeck: diff --git a/Build/source/texk/dvipsk/output.c b/Build/source/texk/dvipsk/output.c index 0fc3d7ad691..ff5931c3b18 100644 --- a/Build/source/texk/dvipsk/output.c +++ b/Build/source/texk/dvipsk/output.c @@ -85,7 +85,32 @@ static struct papsiz defpapsiz = { #endif #include <time.h> /* asctime() and localtime(), at least on BSD Unix */ static time_t jobtime; + +#if defined(_MSC_VER) +#define strtoll _strtoi64 #endif + +#define INVALID_EPOCH_VALUE 0x7fffffffffffffffULL + +static time_t +get_unique_time_if_given(void) +{ + const char *source_date_epoch; + int64_t epoch; + char *endptr; + time_t ret = INVALID_EPOCH_VALUE; + + source_date_epoch = getenv("SOURCE_DATE_EPOCH"); + if (source_date_epoch) { + errno = 0; + epoch = strtoll(source_date_epoch, &endptr, 10); + if (!(epoch < 0 || *endptr != '\0' || errno != 0)) + ret = (time_t) epoch; + } + return ret; +} +#endif /* CREATIONDATE */ + /* * This routine copies a file down the pipe. Search path uses the * header path. @@ -1388,9 +1413,15 @@ initprinter(sectiontype *sect) if (*iname) fprintf(bitfile, "%%%%Title: %s\n", iname); #ifdef CREATIONDATE - jobtime=time(0); - fprintf(bitfile, "%%%%CreationDate: %s", - asctime(localtime(&jobtime))); + jobtime = get_unique_time_if_given(); + if (jobtime == INVALID_EPOCH_VALUE) { + jobtime = time(0); + fprintf(bitfile, "%%%%CreationDate: %s", + asctime(localtime(&jobtime))); + } else { + fprintf(bitfile, "%%%%CreationDate: %s", + asctime(gmtime(&jobtime))); + } #endif if (! isepsf) { /* |