diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-08-18 22:36:07 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-08-18 22:36:07 +0000 |
commit | 327edc933ae08980d1ddfdf5348f969a8b09d692 (patch) | |
tree | 286d804f52c10bbc0f40596eaccf5c62845c6bbc /Build | |
parent | c40a155d475889151a0880c43f8c491f62da2f0c (diff) |
web2c/lib/texmfmp.c, web2c/pdftexdir/utils.c: sync with the upstream of pdftex
git-svn-id: svn://tug.org/texlive/trunk@38146 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/web2c/lib/texmfmp.c | 39 | ||||
-rw-r--r-- | Build/source/texk/web2c/pdftexdir/utils.c | 8 |
2 files changed, 35 insertions, 12 deletions
diff --git a/Build/source/texk/web2c/lib/texmfmp.c b/Build/source/texk/web2c/lib/texmfmp.c index e3e0aa43dc0..f646d362260 100644 --- a/Build/source/texk/web2c/lib/texmfmp.c +++ b/Build/source/texk/web2c/lib/texmfmp.c @@ -2888,6 +2888,7 @@ void pdftex_fail(const char *fmt, ...) } #endif /* not pdfTeX */ +static boolean start_time_set = false; #if !defined(XeTeX) static time_t start_time = 0; #define TIME_STR_SIZE 30 @@ -2895,7 +2896,7 @@ char start_time_str[TIME_STR_SIZE]; static char time_str[TIME_STR_SIZE]; /* minimum size for time_str is 24: "D:YYYYmmddHHMMSS+HH'MM'" */ -static void makepdftime(time_t t, char *time_str) +static void makepdftime(time_t t, char *time_str, boolean utc) { struct tm lt, gmt; @@ -2903,7 +2904,12 @@ static void makepdftime(time_t t, char *time_str) int i, off, off_hours, off_mins; /* get the time */ - lt = *localtime(&t); + if (utc) { + lt = *gmtime(&t); + } + else { + lt = *localtime(&t); + } size = strftime(time_str, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", <); /* expected format: "YYYYmmddHHMMSS" */ if (size == 0) { @@ -2943,11 +2949,32 @@ static void makepdftime(time_t t, char *time_str) } } +#if defined(_MSC_VER) +#define strtoll _strtoi64 +#endif + void initstarttime(void) { - if (start_time == 0) { - start_time = time((time_t *) NULL); - makepdftime(start_time, start_time_str); + char *source_date_epoch; + int64_t epoch; + char *endptr; + if (!start_time_set) { + start_time_set = true; + 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) { + fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: invalid value: %s\n", source_date_epoch); + uexit(EXIT_FAILURE); + } + start_time = epoch; + makepdftime(start_time, start_time_str, /* utc= */true); + } + else { + start_time = time((time_t *) NULL); + makepdftime(start_time, start_time_str, /* utc= */false); + } } } @@ -3034,7 +3061,7 @@ void getfilemoddate(integer s) if (stat(file_name, &file_data) == 0) { size_t len; - makepdftime(file_data.st_mtime, time_str); + makepdftime(file_data.st_mtime, time_str, /* utc= */false); len = strlen(time_str); if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) { poolptr = poolsize; diff --git a/Build/source/texk/web2c/pdftexdir/utils.c b/Build/source/texk/web2c/pdftexdir/utils.c index 43b9ba4b73f..88b8f09e11c 100644 --- a/Build/source/texk/web2c/pdftexdir/utils.c +++ b/Build/source/texk/web2c/pdftexdir/utils.c @@ -703,9 +703,6 @@ void unescapehex(poolpointer in) */ void printID(strnumber filename) { - time_t t; - size_t size; - char time_str[32]; md5_state_t state; md5_byte_t digest[16]; char id[64]; @@ -714,9 +711,8 @@ void printID(strnumber filename) /* start md5 */ md5_init(&state); /* get the time */ - t = time(NULL); - size = strftime(time_str, sizeof(time_str), "%Y%m%dT%H%M%SZ", gmtime(&t)); - md5_append(&state, (const md5_byte_t *) time_str, size); + initstarttime(); + md5_append(&state, (const md5_byte_t *) start_time_str, strlen(start_time_str)); /* get the file name */ if (getcwd(pwd, sizeof(pwd)) == NULL) pdftex_fail("getcwd() failed (%s), path too long?", strerror(errno)); |