diff options
author | Jay Berkenbilt <ejb@ql.org> | 2020-11-09 17:12:34 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2020-11-09 17:12:34 +0100 |
commit | a7ef572c8485636aeb988f9c912979401c1e2164 (patch) | |
tree | f23b926c0c2b9573ba5033cb2575da87ba25a5d4 | |
parent | 47f4ebcdac39256b084cdbb91ff04392fca4bb8d (diff) | |
download | qpdf-a7ef572c8485636aeb988f9c912979401c1e2164.tar.zst |
Small enhancement to --pages argument parsing
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | qpdf/qpdf.cc | 14 | ||||
-rw-r--r-- | qpdf/qpdf.testcov | 1 | ||||
-rw-r--r-- | qpdf/qtest/qpdf.test | 10 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/merge-dot-implicit-ranges.pdf | bin | 0 -> 968 bytes |
5 files changed, 26 insertions, 4 deletions
@@ -1,3 +1,8 @@ +2020-11-09 Jay Berkenbilt <ejb@ql.org> + + * Handle "." appearing in --pages not preceded by a numeric range + as a special case in comand-line parsing code. + 2020-11-04 Jay Berkenbilt <ejb@ql.org> * Ignore the value of the offset/generation field in an xref entry diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index 32a1fc90..a5f18d7e 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -2877,9 +2877,17 @@ ArgParser::parsePagesOptions() // The range is invalid. Let's see if it's a file. try { - fclose(QUtil::safe_fopen(range, "rb")); - // Yup, it's a file. - QTC::TC("qpdf", "qpdf pages range omitted in middle"); + if (strcmp(range, ".") == 0) + { + // "." means the input file. + QTC::TC("qpdf", "qpdf pages range omitted with ."); + } + else + { + fclose(QUtil::safe_fopen(range, "rb")); + QTC::TC("qpdf", "qpdf pages range omitted in middle"); + // Yup, it's a file. + } range_omitted = true; } catch (std::runtime_error&) diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov index ced20279..7a2da359 100644 --- a/qpdf/qpdf.testcov +++ b/qpdf/qpdf.testcov @@ -456,3 +456,4 @@ qpdf found shared xobject in leaf 0 QPDF copy foreign with data 1 QPDF copy foreign with foreign_stream 1 QPDFObjectHandle need_newline 1 +qpdf pages range omitted with . 0 diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index 1c136126..58f646f4 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -2093,7 +2093,7 @@ foreach my $f (qw(page_api_2 direct-pages)) show_ntests(); # ---------- $td->notify("--- Merging and Splitting ---"); -$n_tests += 26; +$n_tests += 28; # Select pages from the same file multiple times including selecting # twice from an encrypted file and specifying the password only the @@ -2149,6 +2149,14 @@ $td->runtest("merge with implicit ranges", $td->runtest("check output", {$td->FILE => "a.pdf"}, {$td->FILE => "merge-implicit-ranges.pdf"}); +$td->runtest("merge with . and implicit ranges", + {$td->COMMAND => + "qpdf minimal.pdf a.pdf --pages minimal.pdf . 1 --" . + " --static-id"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); +$td->runtest("check output", + {$td->FILE => "a.pdf"}, + {$td->FILE => "merge-dot-implicit-ranges.pdf"}); $td->runtest("merge with multiple labels", {$td->COMMAND => "qpdf --empty a.pdf" . diff --git a/qpdf/qtest/qpdf/merge-dot-implicit-ranges.pdf b/qpdf/qtest/qpdf/merge-dot-implicit-ranges.pdf Binary files differnew file mode 100644 index 00000000..494b4c1a --- /dev/null +++ b/qpdf/qtest/qpdf/merge-dot-implicit-ranges.pdf |