Commit f8e4b6161cce4d851222dababb2c8c96e4b1c864

Authored by Jay Berkenbilt
1 parent e3248a8c

With --no-warn, suppress warnings in split-pages

Warnings issued on the output QPDF object were not suppressing
warnings since that option was only set on the input QPDF object.
qpdf/qpdf.cc
@@ -5593,6 +5593,10 @@ static void do_split_pages(QPDF& pdf, Options& o) @@ -5593,6 +5593,10 @@ static void do_split_pages(QPDF& pdf, Options& o)
5593 } 5593 }
5594 QPDF outpdf; 5594 QPDF outpdf;
5595 outpdf.emptyPDF(); 5595 outpdf.emptyPDF();
  5596 + if (o.suppress_warnings)
  5597 + {
  5598 + outpdf.setSuppressWarnings(true);
  5599 + }
5596 for (size_t pageno = first; pageno <= last; ++pageno) 5600 for (size_t pageno = first; pageno <= last; ++pageno)
5597 { 5601 {
5598 QPDFObjectHandle page = pages.at(pageno - 1); 5602 QPDFObjectHandle page = pages.at(pageno - 1);
qpdf/qtest/qpdf.test
@@ -1724,7 +1724,7 @@ my @sp_cases = ( @@ -1724,7 +1724,7 @@ my @sp_cases = (
1724 [1, 'broken data', '--pages broken-lzw.pdf --', 'split-out.pdf', 1724 [1, 'broken data', '--pages broken-lzw.pdf --', 'split-out.pdf',
1725 {$td->FILE => "broken-lzw.out", $td->EXIT_STATUS => 3}], 1725 {$td->FILE => "broken-lzw.out", $td->EXIT_STATUS => 3}],
1726 ); 1726 );
1727 -$n_tests += 35; 1727 +$n_tests += 36;
1728 $n_compare_pdfs += 1; 1728 $n_compare_pdfs += 1;
1729 for (@sp_cases) 1729 for (@sp_cases)
1730 { 1730 {
@@ -1845,6 +1845,13 @@ $td-&gt;runtest(&quot;unreferenced resources with bad token&quot;, @@ -1845,6 +1845,13 @@ $td-&gt;runtest(&quot;unreferenced resources with bad token&quot;,
1845 $td->runtest("check output", 1845 $td->runtest("check output",
1846 {$td->FILE => "split-out-bad-token-1-2.pdf"}, 1846 {$td->FILE => "split-out-bad-token-1-2.pdf"},
1847 {$td->FILE => "split-tokens-split-1-2.pdf"}); 1847 {$td->FILE => "split-tokens-split-1-2.pdf"});
  1848 +$td->runtest("--no-warn with proxied warnings during split",
  1849 + {$td->COMMAND =>
  1850 + "qpdf --qdf --static-id --split-pages=2" .
  1851 + " --no-warn --remove-unreferenced-resources=yes" .
  1852 + " split-tokens.pdf split-out-bad-token.pdf"},
  1853 + {$td->STRING => "", $td->EXIT_STATUS => 3},
  1854 + $td->NORMALIZE_NEWLINES);
1848 1855
1849 $td->runtest("shared images in form xobject", 1856 $td->runtest("shared images in form xobject",
1850 {$td->COMMAND => "qpdf --qdf --static-id --split-pages". 1857 {$td->COMMAND => "qpdf --qdf --static-id --split-pages".