Commit 12b159118a67abf2c2d47492c6c502f5f5720d7f
1 parent
2b011f9d
Compare versions between CLI and library
Showing
5 changed files
with
44 additions
and
1 deletions
ChangeLog
| 1 | 1 | 2019-04-20 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | |
| 3 | + * When qpdf --version is run, it will detect if the qpdf CLI was | |
| 4 | + built with a different version of qpdf than the library. This | |
| 5 | + usually indicates that multiple versions of qpdf are installed and | |
| 6 | + that the library path is not set up properly. This situation | |
| 7 | + sometimes causes confusing behavior for users who are not actually | |
| 8 | + running the version of qpdf they think they are running. | |
| 9 | + | |
| 3 | 10 | * Add parameter --remove-page-labels to remove page labels from |
| 4 | 11 | output. In qpdf 8.3.0, the behavior changed so that page labels |
| 5 | 12 | were preserved when merging and splitting files. Some users were | ... | ... |
README-maintainer
make_dist
| ... | ... | @@ -63,6 +63,7 @@ cd($tmpdir); |
| 63 | 63 | my $config_version = get_version_from_configure(); |
| 64 | 64 | my $code_version = get_version_from_source(); |
| 65 | 65 | my $doc_version = get_version_from_manual(); |
| 66 | +my $cli_version = get_version_from_cli(); | |
| 66 | 67 | |
| 67 | 68 | my $version_error = 0; |
| 68 | 69 | if ($version ne $config_version) |
| ... | ... | @@ -80,6 +81,11 @@ if ($version ne $doc_version) |
| 80 | 81 | print "$whoami: qpdf-manual.xml version = $doc_version\n"; |
| 81 | 82 | $version_error = 1; |
| 82 | 83 | } |
| 84 | +if ($version ne $cli_version) | |
| 85 | +{ | |
| 86 | + print "$whoami: qpdf.cc version = $cli_version\n"; | |
| 87 | + $version_error = 1; | |
| 88 | +} | |
| 83 | 89 | if ($version_error) |
| 84 | 90 | { |
| 85 | 91 | die "$whoami: version numbers are not consistent\n"; |
| ... | ... | @@ -161,6 +167,22 @@ sub get_version_from_manual |
| 161 | 167 | $doc_version; |
| 162 | 168 | } |
| 163 | 169 | |
| 170 | +sub get_version_from_cli | |
| 171 | +{ | |
| 172 | + my $fh = safe_open("qpdf/qpdf.cc"); | |
| 173 | + my $cli_version = 'unknown'; | |
| 174 | + while (<$fh>) | |
| 175 | + { | |
| 176 | + if (m/expected_version = \"([^\"]+)\"/) | |
| 177 | + { | |
| 178 | + $cli_version = $1; | |
| 179 | + last; | |
| 180 | + } | |
| 181 | + } | |
| 182 | + $fh->close(); | |
| 183 | + $cli_version; | |
| 184 | +} | |
| 185 | + | |
| 164 | 186 | sub safe_open |
| 165 | 187 | { |
| 166 | 188 | my $file = shift; | ... | ... |
qpdf/qpdf.cc
| ... | ... | @@ -30,6 +30,8 @@ static int const EXIT_WARNING = 3; |
| 30 | 30 | |
| 31 | 31 | static char const* whoami = 0; |
| 32 | 32 | |
| 33 | +static std::string expected_version = "8.4.0"; | |
| 34 | + | |
| 33 | 35 | struct PageSpec |
| 34 | 36 | { |
| 35 | 37 | PageSpec(std::string const& filename, |
| ... | ... | @@ -993,6 +995,17 @@ ArgParser::argPositional(char* arg) |
| 993 | 995 | void |
| 994 | 996 | ArgParser::argVersion() |
| 995 | 997 | { |
| 998 | + if (expected_version != QPDF::QPDFVersion()) | |
| 999 | + { | |
| 1000 | + std::cerr << "***\n" | |
| 1001 | + << "WARNING: qpdf CLI from version " << expected_version | |
| 1002 | + << " is using library version " << QPDF::QPDFVersion() | |
| 1003 | + << ".\n" | |
| 1004 | + << "This probably means you have multiple versions of qpdf installed\n" | |
| 1005 | + << "and don't have your library path configured correctly.\n" | |
| 1006 | + << "***" | |
| 1007 | + << std::endl; | |
| 1008 | + } | |
| 996 | 1009 | std::cout |
| 997 | 1010 | << whoami << " version " << QPDF::QPDFVersion() << std::endl |
| 998 | 1011 | << "Run " << whoami << " --copyright to see copyright and license information." | ... | ... |
qpdf/qtest/qpdf.test
| ... | ... | @@ -667,7 +667,7 @@ $n_tests += 3; |
| 667 | 667 | |
| 668 | 668 | $td->runtest("qpdf version", |
| 669 | 669 | {$td->COMMAND => "qpdf --version"}, |
| 670 | - {$td->REGEXP => "qpdf version \S+\n.*", $td->EXIT_STATUS => 0}, | |
| 670 | + {$td->REGEXP => ".*qpdf version \S+\n.*", $td->EXIT_STATUS => 0}, | |
| 671 | 671 | $td->NORMALIZE_NEWLINES); |
| 672 | 672 | $td->runtest("qpdf copyright contains version too", |
| 673 | 673 | {$td->COMMAND => "qpdf --copyright"}, | ... | ... |