2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

special exit status in --check mode with warnings and no errors

git-svn-id: svn+q:///qpdf/trunk@650 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
Jay Berkenbilt 2009-02-21 02:38:33 +00:00
parent 4499e04b57
commit 0b2288c19d
6 changed files with 31 additions and 6 deletions

View File

@ -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

3
TODO
View File

@ -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
=======

View File

@ -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>

View File

@ -874,11 +874,19 @@ int main(int argc, char* argv[])
std::cout << e.what() << std::endl;
}
if (okay)
{
if (! pdf.getWarnings().empty())
{
// special exit status for warnings without errors
exit(3);
}
else
{
std::cout << "No errors found" << std::endl;
}
}
}
}
else
{
if (strcmp(outfilename, "-") == 0)

View File

@ -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();
# ----------

View File

@ -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