Commit 5fdf37b1bac9cfa1b1f77f47aded7f916fd81fd9
1 parent
2046f653
Handle warnings in --pages from other files
Warnings were not being handled per --no-warn or generating exit code 3.
Showing
1 changed file
with
9 additions
and
5 deletions
qpdf/qpdf.cc
| @@ -5000,7 +5000,7 @@ static bool should_remove_unreferenced_resources(QPDF& pdf, Options& o) | @@ -5000,7 +5000,7 @@ static bool should_remove_unreferenced_resources(QPDF& pdf, Options& o) | ||
| 5000 | return false; | 5000 | return false; |
| 5001 | } | 5001 | } |
| 5002 | 5002 | ||
| 5003 | -static void handle_page_specs(QPDF& pdf, Options& o) | 5003 | +static void handle_page_specs(QPDF& pdf, Options& o, bool& warnings) |
| 5004 | { | 5004 | { |
| 5005 | // Parse all page specifications and translate them into lists of | 5005 | // Parse all page specifications and translate them into lists of |
| 5006 | // actual pages. | 5006 | // actual pages. |
| @@ -5261,6 +5261,10 @@ static void handle_page_specs(QPDF& pdf, Options& o) | @@ -5261,6 +5261,10 @@ static void handle_page_specs(QPDF& pdf, Options& o) | ||
| 5261 | selected_from_orig.insert(pageno); | 5261 | selected_from_orig.insert(pageno); |
| 5262 | } | 5262 | } |
| 5263 | } | 5263 | } |
| 5264 | + if (page_data.qpdf->anyWarnings()) | ||
| 5265 | + { | ||
| 5266 | + warnings = true; | ||
| 5267 | + } | ||
| 5264 | if (cis) | 5268 | if (cis) |
| 5265 | { | 5269 | { |
| 5266 | cis->stayOpen(false); | 5270 | cis->stayOpen(false); |
| @@ -5819,9 +5823,10 @@ int realmain(int argc, char* argv[]) | @@ -5819,9 +5823,10 @@ int realmain(int argc, char* argv[]) | ||
| 5819 | return EXIT_IS_NOT_ENCRYPTED; | 5823 | return EXIT_IS_NOT_ENCRYPTED; |
| 5820 | } | 5824 | } |
| 5821 | } | 5825 | } |
| 5826 | + bool other_warnings = false; | ||
| 5822 | if (! o.page_specs.empty()) | 5827 | if (! o.page_specs.empty()) |
| 5823 | { | 5828 | { |
| 5824 | - handle_page_specs(pdf, o); | 5829 | + handle_page_specs(pdf, o, other_warnings); |
| 5825 | } | 5830 | } |
| 5826 | if (! o.rotations.empty()) | 5831 | if (! o.rotations.empty()) |
| 5827 | { | 5832 | { |
| @@ -5829,7 +5834,6 @@ int realmain(int argc, char* argv[]) | @@ -5829,7 +5834,6 @@ int realmain(int argc, char* argv[]) | ||
| 5829 | } | 5834 | } |
| 5830 | handle_under_overlay(pdf, o); | 5835 | handle_under_overlay(pdf, o); |
| 5831 | handle_transformations(pdf, o); | 5836 | handle_transformations(pdf, o); |
| 5832 | - bool split_warnings = false; | ||
| 5833 | 5837 | ||
| 5834 | if ((o.outfilename == 0) && (! o.replace_input)) | 5838 | if ((o.outfilename == 0) && (! o.replace_input)) |
| 5835 | { | 5839 | { |
| @@ -5837,13 +5841,13 @@ int realmain(int argc, char* argv[]) | @@ -5837,13 +5841,13 @@ int realmain(int argc, char* argv[]) | ||
| 5837 | } | 5841 | } |
| 5838 | else if (o.split_pages) | 5842 | else if (o.split_pages) |
| 5839 | { | 5843 | { |
| 5840 | - do_split_pages(pdf, o, split_warnings); | 5844 | + do_split_pages(pdf, o, other_warnings); |
| 5841 | } | 5845 | } |
| 5842 | else | 5846 | else |
| 5843 | { | 5847 | { |
| 5844 | write_outfile(pdf, o); | 5848 | write_outfile(pdf, o); |
| 5845 | } | 5849 | } |
| 5846 | - if ((! pdf.getWarnings().empty()) || split_warnings) | 5850 | + if ((! pdf.getWarnings().empty()) || other_warnings) |
| 5847 | { | 5851 | { |
| 5848 | if (! o.suppress_warnings) | 5852 | if (! o.suppress_warnings) |
| 5849 | { | 5853 | { |