aboutsummaryrefslogtreecommitdiffstats
path: root/src/cnki_pdf.c
diff options
context:
space:
mode:
authoryzrh <yzrh@noema.org>2023-01-04 17:50:25 +0000
committeryzrh <yzrh@noema.org>2023-01-04 17:50:25 +0000
commita7ecc156141b15cfae8b309697e12deae2740841 (patch)
treec3cc224a165f61f831174c0dda2b389de85dc0b9 /src/cnki_pdf.c
parent56ffe14d5a8c10163850d3e682c67a282d9b8abc (diff)
downloadmelon-a7ecc156141b15cfae8b309697e12deae2740841.tar.gz
melon-a7ecc156141b15cfae8b309697e12deae2740841.tar.zst
Replace catalog object only if root object does not exist.
Signed-off-by: yzrh <yzrh@noema.org>
Diffstat (limited to 'src/cnki_pdf.c')
-rw-r--r--src/cnki_pdf.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/cnki_pdf.c b/src/cnki_pdf.c
index 87fe3f6..0c1ebb0 100644
--- a/src/cnki_pdf.c
+++ b/src/cnki_pdf.c
@@ -375,9 +375,11 @@ cnki_pdf(cnki_t **param)
printf("Root object is %d.\n", root);
}
+ int root_gen;
+
pdf_object_t *tmp;
- if (pdf_get_obj(&pdf, root, &tmp) != 0) {
+ if ((root_gen = pdf_get_obj(&pdf, root, &tmp)) != 0) {
if ((*param)->stat > 0)
printf("Root object is missing\n");
@@ -442,13 +444,15 @@ cnki_pdf(cnki_t **param)
if ((*param)->stat > 0)
printf("Catalog object is %d.\n", catalog);
- if ((*param)->stat > 1)
- printf("Replacing catalog object\n");
+ if (root_gen != 0) {
+ if ((*param)->stat > 1)
+ printf("Replacing catalog object\n");
- pdf_obj_replace(&pdf, catalog, NULL, dictionary, NULL, 0);
+ pdf_obj_replace(&pdf, catalog, NULL, dictionary, NULL, 0);
- if ((*param)->stat > 0)
- printf("Replaced catalog object\n");
+ if ((*param)->stat > 0)
+ printf("Replaced catalog object\n");
+ }
} else {
if ((*param)->stat > 0)
printf("Catalog object is missing\n");