aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qpdf.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-12 15:21:52 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-12 15:59:03 +0100
commit53d8e916b75b983c18d4611e91d6e74cb51a49ec (patch)
treea8bc4527d05bae7d232b9e67948db77d49bef9f4 /qpdf/qpdf.cc
parent5f128b9a270347d401b6c1e94b43d418f7cbffef (diff)
downloadqpdf-53d8e916b75b983c18d4611e91d6e74cb51a49ec.tar.zst
Interpret . in --pages as a shortcut for the primary file
Diffstat (limited to 'qpdf/qpdf.cc')
-rw-r--r--qpdf/qpdf.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index e7d9eab7..db3193d5 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -1092,7 +1092,8 @@ ArgParser::argHelp()
<< "password needs to be given only once per file. If any of the input\n"
<< "files are the same as the primary input file or the file used to copy\n"
<< "encryption parameters (if specified), you do not need to repeat the\n"
- << "password here. The same file can be repeated multiple times. All\n"
+ << "password here. The same file can be repeated multiple times. The\n"
+ << "filename \".\" may be used to refer to the current input file. All\n"
<< "non-page data (info, outlines, page numbers, etc. are taken from the\n"
<< "primary input file. To discard this, use --empty as the primary\n"
<< "input.\n"
@@ -3676,6 +3677,17 @@ static void handle_page_specs(QPDF& pdf, Options& o)
// Parse all page specifications and translate them into lists of
// actual pages.
+ // Handle "." as a shortcut for the input file
+ for (std::vector<PageSpec>::iterator iter = o.page_specs.begin();
+ iter != o.page_specs.end(); ++iter)
+ {
+ PageSpec& page_spec = *iter;
+ if (page_spec.filename == ".")
+ {
+ page_spec.filename = o.infilename;
+ }
+ }
+
if (! o.keep_files_open_set)
{
// Count the number of distinct files to determine whether we