diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-02-24 12:35:01 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-02-24 12:35:01 +0000 |
commit | 6b03fdfcfaa7cd5a48c2e4a0b00d0497ac91b52f (patch) | |
tree | 52bba93b152de8dda6e82066260b58747f4f6b40 /Build/source/texk/dvipdfm-x/pdffont.c | |
parent | 5a5800df04f8ac0c19b3c2f4c96eb9e46d6f992e (diff) |
texk/dvipdfm-x: Support to output a unique pdf from a unique xdv/dvi file.
git-svn-id: svn://tug.org/texlive/trunk@39846 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm-x/pdffont.c')
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdffont.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Build/source/texk/dvipdfm-x/pdffont.c b/Build/source/texk/dvipdfm-x/pdffont.c index 66e290dfe19..66578da8915 100644 --- a/Build/source/texk/dvipdfm-x/pdffont.c +++ b/Build/source/texk/dvipdfm-x/pdffont.c @@ -83,6 +83,34 @@ pdf_font_set_dpi (int font_dpi) PKFont_set_dpi(font_dpi); } + +#if defined(_MSC_VER) +#define strtoll _strtoi64 +#endif + +/* If an environment variable SOURCE_DATE_EPOCH is correctly defined like + * SOURCE_DATE_EPOCH=1456304492, then returns this value, to be used as the + * 'current time', otherwise returns 0. + */ + +time_t +get_unique_time_if_given(void) +{ + const char *source_date_epoch; + int64_t epoch; + char *endptr; + time_t ret = 0; + + 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; +} + void pdf_font_make_uniqueTag (char *tag) { @@ -91,7 +119,11 @@ pdf_font_make_uniqueTag (char *tag) static char first = 1; if (first) { - srand(time(NULL)); + time_t current_time; + current_time = get_unique_time_if_given(); + if (current_time == 0) + current_time = time(NULL); + srand(current_time); first = 0; } |