diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2022-02-28 15:14:45 +0000 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2022-05-05 14:48:01 +0100 |
commit | 37bfab6a555c0de04d72d7b2ceefc3018c40fb55 (patch) | |
tree | 827dd57ab8ecbe48b84e94ed7bed08d231e5792a /pdf/pdf_repair.c | |
parent | c20f3914daf63feee4cc1df9bf766b8045095f22 (diff) | |
download | ghostpdl-37bfab6a555c0de04d72d7b2ceefc3018c40fb55.tar.gz |
Add pdfi_read_bare_keyword function.
Performs exactly the same as reading a token, but doesn't actually
allocate a pdf_obj for it, just returns an enum value. Saves on
allocating/deallocating keywords.
There are still places in the code that read keywords as objects,
hence pdf_keyword still exists. These will be dealt with in future
commits.
Diffstat (limited to 'pdf/pdf_repair.c')
-rw-r--r-- | pdf/pdf_repair.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index 7e02dcb9a..cc44e13d7 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -245,27 +245,16 @@ int pdfi_repair_file(pdf_context *ctx) index = 0; } while (index < 9); do { - code = pdfi_read_token(ctx, ctx->main_stream, 0, 0); - if (code < 0) { - if (code != gs_error_VMerror && code != gs_error_ioerror) - continue; + code = pdfi_read_bare_keyword(ctx, ctx->main_stream); + if (code == gs_error_VMerror || code == gs_error_ioerror) goto exit; + if (code == TOKEN_ENDOBJ) { + code = pdfi_repair_add_object(ctx, object_num, generation_num, offset); + if (code == gs_error_VMerror || code == gs_error_ioerror) + goto exit; + break; } - if (code > 0) { - if (ctx->stack_top[-1]->type == PDF_KEYWORD){ - pdf_keyword *k = (pdf_keyword *)ctx->stack_top[-1]; - if (k->key == TOKEN_ENDOBJ) { - code = pdfi_repair_add_object(ctx, object_num, generation_num, offset); - if (code < 0) { - if (code != gs_error_VMerror && code != gs_error_ioerror) - break; - goto exit; - } - break; - } - } - } - }while(ctx->main_stream->eof == false); + } while(ctx->main_stream->eof == false); pdfi_clearstack(ctx); break; |