Commit 1925ffd4674a3b3b72ad436a79184c358507fb57

Authored by m-holger
Committed by Jay Berkenbilt
1 parent 4d507251

Fix --check-linearization of non-linearized files (fixes #615)

libqpdf/QPDFJob.cc
@@ -1979,7 +1979,12 @@ QPDFJob::doInspection(QPDF& pdf) @@ -1979,7 +1979,12 @@ QPDFJob::doInspection(QPDF& pdf)
1979 } 1979 }
1980 if (m->check_linearization) 1980 if (m->check_linearization)
1981 { 1981 {
1982 - if (pdf.checkLinearization()) 1982 + if (! pdf.isLinearized())
  1983 + {
  1984 + *(this->m->cout)
  1985 + << m->infilename << " is not linearized" << std::endl;
  1986 + }
  1987 + else if (pdf.checkLinearization())
1983 { 1988 {
1984 *(this->m->cout) 1989 *(this->m->cout)
1985 << m->infilename << ": no linearization errors" << std::endl; 1990 << m->infilename << ": no linearization errors" << std::endl;
qpdf/qtest/qpdf.test
@@ -4486,6 +4486,15 @@ $td-&gt;runtest(&quot;check linearization&quot;, @@ -4486,6 +4486,15 @@ $td-&gt;runtest(&quot;check linearization&quot;,
4486 $td->EXIT_STATUS => 0}, 4486 $td->EXIT_STATUS => 0},
4487 $td->NORMALIZE_NEWLINES); 4487 $td->NORMALIZE_NEWLINES);
4488 4488
  4489 +# Test --check-linearization of non-linearized file
  4490 +$n_tests += 1;
  4491 +$td->runtest("check linearization of non-linearized file",
  4492 + {$td->COMMAND => "qpdf --check-linearization minimal.pdf"},
  4493 + {$td->STRING => "minimal.pdf is not linearized\n",
  4494 + $td->EXIT_STATUS => 0},
  4495 + $td->NORMALIZE_NEWLINES);
  4496 +
  4497 +
4489 # Test AES encryption in various ways. 4498 # Test AES encryption in various ways.
4490 $n_tests += 18; 4499 $n_tests += 18;
4491 $td->runtest("encrypt with AES", 4500 $td->runtest("encrypt with AES",