mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Fix arg parsing check with --collate
The check for the number of items was in the wrong place.
This commit is contained in:
parent
8b0ae8bb99
commit
20a134826c
@ -2446,6 +2446,10 @@ QPDFJob::handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_hea
|
||||
|
||||
auto n_collate = m->collate.size();
|
||||
auto n_specs = parsed_specs.size();
|
||||
if (!(n_collate == 0 || n_collate == 1 || n_collate == n_specs)) {
|
||||
usage("--pages: if --collate has more than one value, it must have one value per page "
|
||||
"specification");
|
||||
}
|
||||
if (n_collate > 0 && n_specs > 1) {
|
||||
// Collate the pages by selecting one page from each spec in order. When a spec runs out of
|
||||
// pages, stop selecting from it.
|
||||
|
@ -957,11 +957,6 @@ QPDFJob::PagesConfig::endPages()
|
||||
if (n_specs == 0) {
|
||||
usage("--pages: no page specifications given");
|
||||
}
|
||||
auto n_collate = config->o.m->collate.size();
|
||||
if (!(n_collate == 0 || n_collate == 1 || n_collate == n_specs)) {
|
||||
usage("--pages: if --collate has more than one value, it must have one value per page "
|
||||
"specification");
|
||||
}
|
||||
return this->config;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ cleanup();
|
||||
|
||||
my $td = new TestDriver('arg-parsing');
|
||||
|
||||
my $n_tests = 23;
|
||||
my $n_tests = 24;
|
||||
|
||||
$td->runtest("required argument",
|
||||
{$td->COMMAND => "qpdf --password minimal.pdf"},
|
||||
@ -101,6 +101,13 @@ $td->runtest("wrong number of collate args",
|
||||
{$td->REGEXP => ".*--collate has more than one value.*",
|
||||
$td->EXIT_STATUS => 2},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("wrong number of collate args",
|
||||
{$td->COMMAND =>
|
||||
"qpdf collate-odd.pdf --pages . minimal.pdf collate-even.pdf --" .
|
||||
" --collate=2,3 a.pdf"},
|
||||
{$td->REGEXP => ".*--collate has more than one value.*",
|
||||
$td->EXIT_STATUS => 2},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
|
||||
# Ignoring -- at the top level was never intended but turned out to
|
||||
# have been there for a long time so that people relied on it. It is
|
||||
|
Loading…
Reference in New Issue
Block a user