Commit b18820d72afdb03efe288992fa32161c4501b396

Authored by m-holger
Committed by GitHub
2 parents 3fbae967 039abac4

Merge pull request #1516 from m-holger/warn_lin

Refactor linearization checks: change `checkLinearizationInternal` to…
include/qpdf/QPDF.hh
... ... @@ -1001,7 +1001,7 @@ class QPDF
1001 1001  
1002 1002 // methods to support linearization checking -- implemented in QPDF_linearization.cc
1003 1003 void readLinearizationData();
1004   - bool checkLinearizationInternal();
  1004 + void checkLinearizationInternal();
1005 1005 void dumpLinearizationDataInternal();
1006 1006 void linearizationWarning(std::string_view);
1007 1007 QPDFObjectHandle readHintStream(Pipeline&, qpdf_offset_t offset, size_t length);
... ...
libqpdf/QPDF_linearization.cc
... ... @@ -77,15 +77,15 @@ QPDF::linearizationWarning(std::string_view msg)
77 77 bool
78 78 QPDF::checkLinearization()
79 79 {
80   - bool result = false;
81 80 try {
82 81 readLinearizationData();
83   - result = checkLinearizationInternal();
  82 + checkLinearizationInternal();
  83 + return !m->linearization_warnings;
84 84 } catch (std::runtime_error& e) {
85 85 linearizationWarning(
86 86 "error encountered while checking linearization data: " + std::string(e.what()));
  87 + return false;
87 88 }
88   - return result;
89 89 }
90 90  
91 91 bool
... ... @@ -404,7 +404,7 @@ QPDF::readHGeneric(BitStream h, HGeneric& t)
404 404 t.group_length = h.getBitsInt(32); // 4
405 405 }
406 406  
407   -bool
  407 +void
408 408 QPDF::checkLinearizationInternal()
409 409 {
410 410 // All comments referring to the PDF spec refer to the spec for version 1.4.
... ... @@ -521,8 +521,6 @@ QPDF::checkLinearizationInternal()
521 521 checkHSharedObject(pages, shared_idx_to_obj);
522 522 checkHPageOffset(pages, shared_idx_to_obj);
523 523 checkHOutlines();
524   -
525   - return !m->linearization_warnings;
526 524 }
527 525  
528 526 qpdf_offset_t
... ...
libqpdf/qpdf/QPDF_private.hh
... ... @@ -519,7 +519,7 @@ class QPDF::Members
519 519 // Linearization data
520 520 qpdf_offset_t first_xref_item_offset{0}; // actual value from file
521 521 bool uncompressed_after_compressed{false};
522   - bool linearization_warnings{false};
  522 + bool linearization_warnings{false}; // set by linearizationWarning, used by checkLinearization
523 523  
524 524 // Linearization parameter dictionary and hint table data: may be read from file or computed
525 525 // prior to writing a linearized file
... ...