Commit 0b2288c19d514e18449feb8f43fc1350a10241a1
1 parent
4499e04b
special exit status in --check mode with warnings and no errors
git-svn-id: svn+q:///qpdf/trunk@650 71b93d88-0707-0410-a8cf-f5a4172ac649
Showing
6 changed files
with
31 additions
and
6 deletions
ChangeLog
| 1 | 2009-02-20 Jay Berkenbilt <ejb@ql.org> | 1 | 2009-02-20 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | ||
| 3 | + * qpdf/qpdf.cc: in --check mode, if there are warnings but no | ||
| 4 | + errors, exit with a status of 3. | ||
| 5 | + | ||
| 3 | * libqpdf/QPDF.cc (QPDF::insertXrefEntry): when recovering the | 6 | * libqpdf/QPDF.cc (QPDF::insertXrefEntry): when recovering the |
| 4 | cross-reference table, have objects we encounter later in the file | 7 | cross-reference table, have objects we encounter later in the file |
| 5 | supersede those we found earlier. This improves the chances of | 8 | supersede those we found earlier. This improves the chances of |
TODO
| @@ -4,9 +4,6 @@ | @@ -4,9 +4,6 @@ | ||
| 4 | * Spell check to fix types in messages and comments. Known type in | 4 | * Spell check to fix types in messages and comments. Known type in |
| 5 | "damanged". | 5 | "damanged". |
| 6 | 6 | ||
| 7 | - * Exit with a different exit code if warning are found during check | ||
| 8 | - mode. | ||
| 9 | - | ||
| 10 | 7 | ||
| 11 | General | 8 | General |
| 12 | ======= | 9 | ======= |
manual/qpdf-manual.xml
| @@ -741,7 +741,13 @@ make | @@ -741,7 +741,13 @@ make | ||
| 741 | Checks file structure and well as encryption and | 741 | Checks file structure and well as encryption and |
| 742 | linearization. A file for which <option>--check</option> | 742 | linearization. A file for which <option>--check</option> |
| 743 | reports no errors may still have errors in stream data but | 743 | reports no errors may still have errors in stream data but |
| 744 | - should otherwise be otherwise structurally sound. | 744 | + should otherwise be otherwise structurally sound. If |
| 745 | + <option>--check</option> any errors, qpdf will exit with a | ||
| 746 | + status of 2. There are some recoverable conditions that | ||
| 747 | + <option>--check</option> detects. These are issued as | ||
| 748 | + warnings instead of errors. If qpdf finds no errors but finds | ||
| 749 | + warnings, it will exit with a status of 3 (as of | ||
| 750 | + version 2.0.4). | ||
| 745 | </para> | 751 | </para> |
| 746 | </listitem> | 752 | </listitem> |
| 747 | </varlistentry> | 753 | </varlistentry> |
qpdf/qpdf.cc
| @@ -875,7 +875,15 @@ int main(int argc, char* argv[]) | @@ -875,7 +875,15 @@ int main(int argc, char* argv[]) | ||
| 875 | } | 875 | } |
| 876 | if (okay) | 876 | if (okay) |
| 877 | { | 877 | { |
| 878 | - std::cout << "No errors found" << std::endl; | 878 | + if (! pdf.getWarnings().empty()) |
| 879 | + { | ||
| 880 | + // special exit status for warnings without errors | ||
| 881 | + exit(3); | ||
| 882 | + } | ||
| 883 | + else | ||
| 884 | + { | ||
| 885 | + std::cout << "No errors found" << std::endl; | ||
| 886 | + } | ||
| 879 | } | 887 | } |
| 880 | } | 888 | } |
| 881 | } | 889 | } |
qpdf/qtest/qpdf.test
| @@ -152,7 +152,7 @@ for (my $i = 1; $i <= scalar(@badfiles); ++$i) | @@ -152,7 +152,7 @@ for (my $i = 1; $i <= scalar(@badfiles); ++$i) | ||
| 152 | show_ntests(); | 152 | show_ntests(); |
| 153 | # ---------- | 153 | # ---------- |
| 154 | $td->notify("--- Recovery Tests ---"); | 154 | $td->notify("--- Recovery Tests ---"); |
| 155 | -$n_tests += @badfiles + 6; | 155 | +$n_tests += @badfiles + 7; |
| 156 | 156 | ||
| 157 | # Recovery tests. These are mostly after-the-fact -- when recovery | 157 | # Recovery tests. These are mostly after-the-fact -- when recovery |
| 158 | # was implemented, some degree of recovery was possible on many of the | 158 | # was implemented, some degree of recovery was possible on many of the |
| @@ -211,6 +211,11 @@ $td->runtest("damaged replaced page contents", | @@ -211,6 +211,11 @@ $td->runtest("damaged replaced page contents", | ||
| 211 | $td->runtest("check output", | 211 | $td->runtest("check output", |
| 212 | {$td->FILE => "a.pdf"}, | 212 | {$td->FILE => "a.pdf"}, |
| 213 | {$td->FILE => "append-page-content-damaged.qdf"}); | 213 | {$td->FILE => "append-page-content-damaged.qdf"}); |
| 214 | +$td->runtest("run check on damaged file", | ||
| 215 | + {$td->COMMAND => "qpdf --check append-page-content-damaged.pdf"}, | ||
| 216 | + {$td->FILE => "append-page-content-damaged-check.out", | ||
| 217 | + $td->EXIT_STATUS => 3}, | ||
| 218 | + $td->NORMALIZE_NEWLINES); | ||
| 214 | 219 | ||
| 215 | show_ntests(); | 220 | show_ntests(); |
| 216 | # ---------- | 221 | # ---------- |
qpdf/qtest/qpdf/append-page-content-damaged-check.out
0 → 100644