summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipdfm-x/pdfobj.c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2018-09-06 00:10:18 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2018-09-06 00:10:18 +0000
commita5f499f4bf951ea37b2db47198fa21c11a5f8645 (patch)
tree3e4b270136fe2b6425d1d971973609fca7d9febf /Build/source/texk/dvipdfm-x/pdfobj.c
parentecd1605a23ef54d2a4a69e1a361172d350e03b3b (diff)
Fix broken ToUnicode CMap support (S. Hirata)
git-svn-id: svn://tug.org/texlive/trunk@48595 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm-x/pdfobj.c')
-rw-r--r--Build/source/texk/dvipdfm-x/pdfobj.c59
1 files changed, 49 insertions, 10 deletions
diff --git a/Build/source/texk/dvipdfm-x/pdfobj.c b/Build/source/texk/dvipdfm-x/pdfobj.c
index f503a38d6b8..1a08f64e578 100644
--- a/Build/source/texk/dvipdfm-x/pdfobj.c
+++ b/Build/source/texk/dvipdfm-x/pdfobj.c
@@ -67,8 +67,17 @@ struct pdf_obj
unsigned refcount; /* Number of links to this object */
int flags;
void *data;
+
+#if defined(PDFOBJ_DEBUG)
+ int obj_id;
+#endif
};
+#if defined(PDFOBJ_DEBUG)
+static pdf_obj *bucket[65535];
+static int cur_obj_id = 0;
+#endif
+
struct pdf_boolean
{
char value;
@@ -540,6 +549,25 @@ pdf_out_flush (void)
MFCLOSE(pdf_output_file);
}
+#if defined(PDFOBJ_DEBUG)
+ {
+ int i;
+ MESG("\ndebug>> %d PDF objects created.", cur_obj_id);
+ for (i = 0; i < cur_obj_id; i++) {
+ pdf_obj *obj = bucket[i];
+ if (obj) {
+ if (obj->label > 0) {
+ WARN("Object obj_id=<%lu, %u> unreleased...", obj->label, obj->generation);
+ WARN("Reference count=%d", obj->refcount);
+ } else {
+ WARN("Unreleased object found: %d", i);
+ pdf_write_obj(obj, stderr);
+ MESG("\n");
+ }
+ }
+ }
+ }
+#endif
}
void
@@ -680,6 +708,12 @@ pdf_new_obj(int type)
result->refcount = 1;
result->flags = 0;
+#if defined(PDFOBJ_DEBUG)
+ result->obj_id = cur_obj_id;
+ bucket[cur_obj_id] = result;
+ cur_obj_id++;
+#endif
+
return result;
}
@@ -2771,6 +2805,9 @@ pdf_release_obj (pdf_obj *object)
}
object->refcount -= 1;
if (object->refcount == 0) {
+#if defined(PDFOBJ_DEBUG)
+ bucket[object->obj_id] = NULL;
+#endif
/*
* Nothing is using this object so it's okay to remove it.
* Nonzero "label" means object needs to be written before it's destroyed.
@@ -3576,19 +3613,17 @@ parse_xref_stream (pdf_file *pf, int xref_pos, pdf_obj **trailer)
if (index_obj) {
unsigned int index_len;
if (!PDF_OBJ_ARRAYTYPE(index_obj) ||
- ((index_len = pdf_array_length(index_obj)) % 2 ))
+ ((index_len = pdf_array_length(index_obj)) % 2 ))
goto error;
i = 0;
while (i < index_len) {
pdf_obj *first = pdf_get_array(index_obj, i++);
size_obj = pdf_get_array(index_obj, i++);
- if (!PDF_OBJ_NUMBERTYPE(first) ||
- !PDF_OBJ_NUMBERTYPE(size_obj) ||
- parse_xrefstm_subsec(pf, &p, &length, W, wsum,
- (int) pdf_number_value(first),
- (int) pdf_number_value(size_obj)))
- goto error;
+ if (!PDF_OBJ_NUMBERTYPE(first) || !PDF_OBJ_NUMBERTYPE(size_obj) ||
+ parse_xrefstm_subsec(pf, &p, &length, W, wsum,
+ (int) pdf_number_value(first), (int) pdf_number_value(size_obj)))
+ goto error;
}
} else if (parse_xrefstm_subsec(pf, &p, &length, W, wsum, 0, size))
goto error;
@@ -3752,6 +3787,10 @@ pdf_file_get_trailer (pdf_file *pf)
return pdf_link_obj(pf->trailer);
}
+/* FIXME:
+ * pdf_file_get_trailer() does pdf_link_obj() but
+ * pdf_file_get_catalog() does not. Why?
+ */
pdf_obj *
pdf_file_get_catalog (pdf_file *pf)
{
@@ -3807,9 +3846,9 @@ pdf_open (const char *ident, FILE *file)
if (!PDF_OBJ_NAMETYPE(new_version) ||
sscanf(pdf_name_value(new_version), "%u.%u", &major, &minor) != 2) {
- pdf_release_obj(new_version);
- WARN("Illegal Version entry in document catalog. Broken PDF file?");
- goto error;
+ pdf_release_obj(new_version);
+ WARN("Illegal Version entry in document catalog. Broken PDF file?");
+ goto error;
}
if (pf->version < major*10+minor)