Commit 909daf9543a6e364a50568485278fdfd6c6abb7d

Authored by Jay Berkenbilt
1 parent 24f28f07

Move page spec processing earlier

ChangeLog
  1 +2017-08-05 Jay Berkenbilt <ejb@ql.org>
  2 +
  3 + * Process --pages options earlier so that certain inspection
  4 + options, like --show-pages, can show the state after the merging
  5 + operations.
  6 +
1 2017-08-02 Jay Berkenbilt <ejb@ql.org> 7 2017-08-02 Jay Berkenbilt <ejb@ql.org>
2 8
3 * Fix off-by-one error in parsing pages options. Fixes #129. 9 * Fix off-by-one error in parsing pages options. Fixes #129.
qpdf/qpdf.cc
@@ -1874,12 +1874,6 @@ static void set_encryption_options(QPDF&amp; pdf, Options&amp; o, QPDFWriter&amp; w) @@ -1874,12 +1874,6 @@ static void set_encryption_options(QPDF&amp; pdf, Options&amp; o, QPDFWriter&amp; w)
1874 static void write_outfile(QPDF& pdf, Options& o) 1874 static void write_outfile(QPDF& pdf, Options& o)
1875 { 1875 {
1876 QPDF encryption_pdf; 1876 QPDF encryption_pdf;
1877 - std::vector<PointerHolder<QPDF> > page_heap;  
1878 - if (! o.page_specs.empty())  
1879 - {  
1880 - handle_page_specs(pdf, o, page_heap);  
1881 - }  
1882 -  
1883 if (strcmp(o.outfilename, "-") == 0) 1877 if (strcmp(o.outfilename, "-") == 0)
1884 { 1878 {
1885 o.outfilename = 0; 1879 o.outfilename = 0;
@@ -2020,6 +2014,12 @@ int main(int argc, char* argv[]) @@ -2020,6 +2014,12 @@ int main(int argc, char* argv[])
2020 pdf.processFile(o.infilename, o.password); 2014 pdf.processFile(o.infilename, o.password);
2021 } 2015 }
2022 2016
  2017 + std::vector<PointerHolder<QPDF> > page_heap;
  2018 + if (! o.page_specs.empty())
  2019 + {
  2020 + handle_page_specs(pdf, o, page_heap);
  2021 + }
  2022 +
2023 if (o.outfilename == 0) 2023 if (o.outfilename == 0)
2024 { 2024 {
2025 do_inspection(pdf, o); 2025 do_inspection(pdf, o);
qpdf/qtest/qpdf.test
@@ -206,7 +206,7 @@ $td-&gt;runtest(&quot;remove page we don&#39;t have&quot;, @@ -206,7 +206,7 @@ $td-&gt;runtest(&quot;remove page we don&#39;t have&quot;,
206 show_ntests(); 206 show_ntests();
207 # ---------- 207 # ----------
208 $td->notify("--- Miscellaneous Tests ---"); 208 $td->notify("--- Miscellaneous Tests ---");
209 -$n_tests += 94; 209 +$n_tests += 95;
210 210
211 $td->runtest("qpdf version", 211 $td->runtest("qpdf version",
212 {$td->COMMAND => "qpdf --version"}, 212 {$td->COMMAND => "qpdf --version"},
@@ -652,6 +652,13 @@ $td-&gt;runtest(&quot;don&#39;t overwrite self&quot;, @@ -652,6 +652,13 @@ $td-&gt;runtest(&quot;don&#39;t overwrite self&quot;,
652 {$td->REGEXP => "input file and output file are the same.*", 652 {$td->REGEXP => "input file and output file are the same.*",
653 $td->EXIT_STATUS => 2}); 653 $td->EXIT_STATUS => 2});
654 654
  655 +$td->runtest("combine show and --pages",
  656 + {$td->COMMAND =>
  657 + "qpdf --empty --pages minimal.pdf -- --show-pages"},
  658 + {$td->FILE => "show-pages-pages.out",
  659 + $td->EXIT_STATUS => 0},
  660 + $td->NORMALIZE_NEWLINES);
  661 +
655 show_ntests(); 662 show_ntests();
656 # ---------- 663 # ----------
657 $td->notify("--- Numeric range parsing tests ---"); 664 $td->notify("--- Numeric range parsing tests ---");
qpdf/qtest/qpdf/show-pages-pages.out 0 → 100644
  1 +page 1: 3 0 R
  2 + content:
  3 + 4 0 R