summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-02-24 12:35:01 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-02-24 12:35:01 +0000
commit6b03fdfcfaa7cd5a48c2e4a0b00d0497ac91b52f (patch)
tree52bba93b152de8dda6e82066260b58747f4f6b40 /Build
parent5a5800df04f8ac0c19b3c2f4c96eb9e46d6f992e (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')
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog9
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdoc.c9
-rw-r--r--Build/source/texk/dvipdfm-x/pdfencrypt.c10
-rw-r--r--Build/source/texk/dvipdfm-x/pdffont.c34
-rw-r--r--Build/source/texk/dvipdfm-x/pdfobj.h5
-rw-r--r--Build/source/texk/dvipdfm-x/xbb.c6
6 files changed, 62 insertions, 11 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index c6dcfecc7a2..ba4742f1ee5 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,12 @@
+2016-02-24 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * pdfdoc.c, pdfencrypt.c, pdffont.c, pdfobj.h, xbb.c: Support to output
+ a unique pdf file from a unique xdv/dvi file. If an environment
+ variable SOURCE_DATE_EPOCH is defined correctly like
+ SOURCE_DATE_EPOCH=1456304783, the value is used as the current time,
+ and if the name of the output pdf file is the same, its contents is
+ exactly unique.
+
2016-02-23 Masamichi HOSODA <trueroad@trueroad.jp>
* pdfdoc.c: Support UTF-16 with null bytes as labels.
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.c b/Build/source/texk/dvipdfm-x/pdfdoc.c
index dd4cdf81a57..b724789aa9b 100644
--- a/Build/source/texk/dvipdfm-x/pdfdoc.c
+++ b/Build/source/texk/dvipdfm-x/pdfdoc.c
@@ -437,11 +437,14 @@ pdf_doc_set_eop_content (const char *content, unsigned length)
static int32_t
compute_timezone_offset()
{
- const time_t now = time(NULL);
+ time_t now;
struct tm tm;
struct tm local;
time_t gmtoff;
+ now = get_unique_time_if_given();
+ if (now == 0)
+ now = time(NULL);
localtime_r(&now, &local);
gmtime_r(&now, &tm);
return (mktime(&local) - mktime(&tm));
@@ -460,7 +463,9 @@ asn_date (char *date_string)
time_t current_time;
struct tm *bd_time;
- time(&current_time);
+ current_time = get_unique_time_if_given();
+ if (current_time == 0)
+ time(&current_time);
bd_time = localtime(&current_time);
#ifdef HAVE_TM_GMTOFF
diff --git a/Build/source/texk/dvipdfm-x/pdfencrypt.c b/Build/source/texk/dvipdfm-x/pdfencrypt.c
index 309cc7e2664..b039be1f50c 100644
--- a/Build/source/texk/dvipdfm-x/pdfencrypt.c
+++ b/Build/source/texk/dvipdfm-x/pdfencrypt.c
@@ -97,9 +97,13 @@ void pdf_enc_set_verbose (void)
static void
pdf_enc_init (int use_aes, int encrypt_metadata)
{
+ time_t current_time;
struct pdf_sec *p = &sec_data;
- srand((unsigned) time(NULL)); /* For AES IV */
+ current_time = get_unique_time_if_given();
+ if (current_time == 0)
+ current_time = time(NULL);
+ srand(current_time); /* For AES IV */
p->setting.use_aes = use_aes;
p->setting.encrypt_metadata = encrypt_metadata;
}
@@ -122,7 +126,9 @@ pdf_enc_compute_id_string (char *dviname, char *pdfname)
MD5_init(&md5);
date_string = NEW(15, char);
- time(&current_time);
+ current_time = get_unique_time_if_given();
+ if (current_time == 0)
+ time(&current_time);
bd_time = localtime(&current_time);
sprintf(date_string, "%04d%02d%02d%02d%02d%02d",
bd_time->tm_year + 1900, bd_time->tm_mon + 1, bd_time->tm_mday,
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;
}
diff --git a/Build/source/texk/dvipdfm-x/pdfobj.h b/Build/source/texk/dvipdfm-x/pdfobj.h
index 342ad438a98..98347a8f77a 100644
--- a/Build/source/texk/dvipdfm-x/pdfobj.h
+++ b/Build/source/texk/dvipdfm-x/pdfobj.h
@@ -198,9 +198,6 @@ extern int pdfobj_escape_str (char *buffer, int size, const unsigned char *
extern pdf_obj *pdf_new_indirect (pdf_file *pf, unsigned label, unsigned short generation);
-#define MAX_IMAGES 5000 /* This may be enough */
-extern int PageBox;
-extern uint8_t PageBox_of_id[];
-extern int ImageSpecial;
+extern time_t get_unique_time_if_given(void);
#endif /* _PDFOBJ_H_ */
diff --git a/Build/source/texk/dvipdfm-x/xbb.c b/Build/source/texk/dvipdfm-x/xbb.c
index f86605cb170..96cee108fd4 100644
--- a/Build/source/texk/dvipdfm-x/xbb.c
+++ b/Build/source/texk/dvipdfm-x/xbb.c
@@ -41,7 +41,7 @@
#include "dvipdfmx.h"
#include "pdflimits.h"
-int PageBox = 0;
+static int PageBox = 0;
/*
PageBox=0 :default
PageBox=1 :cropbox
@@ -94,7 +94,9 @@ static void do_time(FILE *file)
time_t current_time;
struct tm *bd_time;
- time(&current_time);
+ current_time = get_unique_time_if_given();
+ if (current_time == 0)
+ time(&current_time);
bd_time = localtime(&current_time);
fprintf(file, "%%%%CreationDate: %s\n", asctime(bd_time));
}