aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-02-21 03:38:33 +0100
committerJay Berkenbilt <ejb@ql.org>2009-02-21 03:38:33 +0100
commit0b2288c19d514e18449feb8f43fc1350a10241a1 (patch)
tree828db178f3c157f292ffa8af2b147a4d038e13dc
parent4499e04b5714747eb954420f8133e650a5137d45 (diff)
downloadqpdf-0b2288c19d514e18449feb8f43fc1350a10241a1.tar.zst
special exit status in --check mode with warnings and no errors
git-svn-id: svn+q:///qpdf/trunk@650 71b93d88-0707-0410-a8cf-f5a4172ac649
-rw-r--r--ChangeLog3
-rw-r--r--TODO3
-rw-r--r--manual/qpdf-manual.xml8
-rw-r--r--qpdf/qpdf.cc10
-rw-r--r--qpdf/qtest/qpdf.test7
-rw-r--r--qpdf/qtest/qpdf/append-page-content-damaged-check.out6
6 files changed, 31 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index da5150df..db68a815 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2009-02-20 Jay Berkenbilt <ejb@ql.org>
+ * qpdf/qpdf.cc: in --check mode, if there are warnings but no
+ errors, exit with a status of 3.
+
* libqpdf/QPDF.cc (QPDF::insertXrefEntry): when recovering the
cross-reference table, have objects we encounter later in the file
supersede those we found earlier. This improves the chances of
diff --git a/TODO b/TODO
index e5097fb7..9f0c9ea5 100644
--- a/TODO
+++ b/TODO
@@ -4,9 +4,6 @@
* Spell check to fix types in messages and comments. Known type in
"damanged".
- * Exit with a different exit code if warning are found during check
- mode.
-
General
=======
diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml
index 442285df..35e6aa81 100644
--- a/manual/qpdf-manual.xml
+++ b/manual/qpdf-manual.xml
@@ -741,7 +741,13 @@ make
Checks file structure and well as encryption and
linearization. A file for which <option>--check</option>
reports no errors may still have errors in stream data but
- should otherwise be otherwise structurally sound.
+ should otherwise be otherwise structurally sound. If
+ <option>--check</option> any errors, qpdf will exit with a
+ status of 2. There are some recoverable conditions that
+ <option>--check</option> detects. These are issued as
+ warnings instead of errors. If qpdf finds no errors but finds
+ warnings, it will exit with a status of 3 (as of
+ version&nbsp;2.0.4).
</para>
</listitem>
</varlistentry>
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index d05f51ec..c7f3cbe0 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -875,7 +875,15 @@ int main(int argc, char* argv[])
}
if (okay)
{
- std::cout << "No errors found" << std::endl;
+ if (! pdf.getWarnings().empty())
+ {
+ // special exit status for warnings without errors
+ exit(3);
+ }
+ else
+ {
+ std::cout << "No errors found" << std::endl;
+ }
}
}
}
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 0fec2af5..7432edbd 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -152,7 +152,7 @@ for (my $i = 1; $i <= scalar(@badfiles); ++$i)
show_ntests();
# ----------
$td->notify("--- Recovery Tests ---");
-$n_tests += @badfiles + 6;
+$n_tests += @badfiles + 7;
# Recovery tests. These are mostly after-the-fact -- when recovery
# was implemented, some degree of recovery was possible on many of the
@@ -211,6 +211,11 @@ $td->runtest("damaged replaced page contents",
$td->runtest("check output",
{$td->FILE => "a.pdf"},
{$td->FILE => "append-page-content-damaged.qdf"});
+$td->runtest("run check on damaged file",
+ {$td->COMMAND => "qpdf --check append-page-content-damaged.pdf"},
+ {$td->FILE => "append-page-content-damaged-check.out",
+ $td->EXIT_STATUS => 3},
+ $td->NORMALIZE_NEWLINES);
show_ntests();
# ----------
diff --git a/qpdf/qtest/qpdf/append-page-content-damaged-check.out b/qpdf/qtest/qpdf/append-page-content-damaged-check.out
new file mode 100644
index 00000000..884de3a5
--- /dev/null
+++ b/qpdf/qtest/qpdf/append-page-content-damaged-check.out
@@ -0,0 +1,6 @@
+WARNING: append-page-content-damaged.pdf: offset 0: file is damaged
+WARNING: append-page-content-damaged.pdf: can't find startxref
+WARNING: Attempting to reconstruct cross-reference table
+checking append-page-content-damaged.pdf
+File is not encrypted
+File is not linearized