Replace catalog object only if root object does not exist.
Signed-off-by: yzrh <yzrh@noema.org>
This commit is contained in:
parent
56ffe14d5a
commit
a7ecc15614
2 changed files with 14 additions and 8 deletions
|
@ -375,9 +375,11 @@ cnki_pdf(cnki_t **param)
|
||||||
printf("Root object is %d.\n", root);
|
printf("Root object is %d.\n", root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int root_gen;
|
||||||
|
|
||||||
pdf_object_t *tmp;
|
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)
|
if ((*param)->stat > 0)
|
||||||
printf("Root object is missing\n");
|
printf("Root object is missing\n");
|
||||||
|
|
||||||
|
@ -442,13 +444,15 @@ cnki_pdf(cnki_t **param)
|
||||||
if ((*param)->stat > 0)
|
if ((*param)->stat > 0)
|
||||||
printf("Catalog object is %d.\n", catalog);
|
printf("Catalog object is %d.\n", catalog);
|
||||||
|
|
||||||
if ((*param)->stat > 1)
|
if (root_gen != 0) {
|
||||||
printf("Replacing catalog object\n");
|
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)
|
if ((*param)->stat > 0)
|
||||||
printf("Replaced catalog object\n");
|
printf("Replaced catalog object\n");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((*param)->stat > 0)
|
if ((*param)->stat > 0)
|
||||||
printf("Catalog object is missing\n");
|
printf("Catalog object is missing\n");
|
||||||
|
|
|
@ -232,7 +232,8 @@ pdf_load(pdf_object_t **pdf, FILE **fp, int size_buf)
|
||||||
* A dictionary object may have nested dictionary,
|
* A dictionary object may have nested dictionary,
|
||||||
* but it should not be in a stream
|
* but it should not be in a stream
|
||||||
*/
|
*/
|
||||||
while ((tmp = _memmem_whitespace(tail + 3,
|
while (ptr->size - (tail - buf) > 3 &&
|
||||||
|
(tmp = _memmem_whitespace(tail + 3,
|
||||||
ptr->size - (tail - buf) - 3,
|
ptr->size - (tail - buf) - 3,
|
||||||
">>", 2)) != NULL &&
|
">>", 2)) != NULL &&
|
||||||
memmem(tail + 3,
|
memmem(tail + 3,
|
||||||
|
@ -241,7 +242,8 @@ pdf_load(pdf_object_t **pdf, FILE **fp, int size_buf)
|
||||||
tail = tmp;
|
tail = tmp;
|
||||||
|
|
||||||
/* Hack needed for invalid object */
|
/* Hack needed for invalid object */
|
||||||
while ((tmp = memmem(tail + 2,
|
while (ptr->size - (tail - buf) > 2 &&
|
||||||
|
(tmp = memmem(tail + 2,
|
||||||
ptr->size - (tail - buf) - 2,
|
ptr->size - (tail - buf) - 2,
|
||||||
">>", 2)) != NULL &&
|
">>", 2)) != NULL &&
|
||||||
memmem(tail + 2,
|
memmem(tail + 2,
|
||||||
|
|
Loading…
Reference in a new issue