diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2022-11-30 16:17:26 +0000 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2022-11-30 16:24:00 +0000 |
commit | 3ca751ff86ea7d56f0cddd728be49a790a927cdc (patch) | |
tree | 1f742bd496ee27437fb0812f69c602d2f0430547 /pdf/ghostpdf.h | |
parent | 449e0a0d2cec6a032baa8dce5edb12d4dd27c15b (diff) | |
download | ghostpdl-3ca751ff86ea7d56f0cddd728be49a790a927cdc.tar.gz |
GhostPDF - don't record errors/warnings while repairing a PDF
Its quite possible for us to get garbage while repairing a PDF file
without that indicating an actual (additional) problem in the PDF file.
So don't record any warnings or errors encountered while we are
repairing a PDF file, if any of them are real they will be reported as
we process the file.
Diffstat (limited to 'pdf/ghostpdf.h')
-rw-r--r-- | pdf/ghostpdf.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/pdf/ghostpdf.h b/pdf/ghostpdf.h index fe2a0c88a..c2207872e 100644 --- a/pdf/ghostpdf.h +++ b/pdf/ghostpdf.h @@ -407,6 +407,8 @@ typedef struct pdf_context_s bool is_hybrid; /* If we've already repaired the file once, and it still fails, don't try to repair it again */ bool repaired; + /* Repairing is true while the repair code is running, during this we ignore errors and warnings */ + bool repairing; /* The HeaderVersion is the declared version from the PDF header, but this * can be overridden by later trailer dictionaries, so the FinalVersion is @@ -525,17 +527,23 @@ void pdfi_log_info(pdf_context *ctx, const char *pdfi_function, const char *info static inline void pdfi_set_error(pdf_context *ctx, int gs_error, const char *gs_lib_function, pdf_error pdfi_error, const char *pdfi_function_name, const char *extra_info) { - if (pdfi_error != 0) - ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); - if (ctx->args.verbose_errors) - pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); + /* ignore problems while repairing a file */ + if (!ctx->repairing) { + if (pdfi_error != 0) + ctx->pdf_errors[pdfi_error / (sizeof(char) * 8)] |= 1 << pdfi_error % (sizeof(char) * 8); + if (ctx->args.verbose_errors) + pdfi_verbose_error(ctx, gs_error, gs_lib_function, pdfi_error, pdfi_function_name, extra_info); + } } static inline void pdfi_set_warning(pdf_context *ctx, int gs_error, const char *gs_lib_function, pdf_warning pdfi_warning, const char *pdfi_function_name, const char *extra_info) { - ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); - if (ctx->args.verbose_warnings) - pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); + /* ignore problems while repairing a file */ + if (!ctx->repairing) { + ctx->pdf_warnings[pdfi_warning / (sizeof(char) * 8)] |= 1 << pdfi_warning % (sizeof(char) * 8); + if (ctx->args.verbose_warnings) + pdfi_verbose_warning(ctx, gs_error, gs_lib_function, pdfi_warning, pdfi_function_name, extra_info); + } } /* Variants of the above that work in a printf style. */ |