aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-30 15:43:07 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-30 19:26:43 +0200
commit7f023701dd843749cf878baabeb3d33917fda62f (patch)
treeb5892c2ed7d7bd5ef296133f02600975f2d58280
parent2878c186bf6828589d220d5b19388934514d08a7 (diff)
downloadqpdf-7f023701dd843749cf878baabeb3d33917fda62f.tar.zst
Formatting: remove space in range-style for loops
Change .clang-format and commit automated changes from a fresh run of format-code
-rw-r--r--.clang-format3
-rw-r--r--examples/pdf-bookmarks.cc6
-rw-r--r--examples/pdf-count-strings.cc2
-rw-r--r--examples/pdf-create.cc6
-rw-r--r--examples/pdf-custom-filter.cc4
-rw-r--r--examples/pdf-double-page-size.cc4
-rw-r--r--examples/pdf-invert-images.cc2
-rw-r--r--examples/pdf-mod-info.cc2
-rw-r--r--examples/pdf-name-number-tree.cc10
-rw-r--r--libqpdf/JSON.cc16
-rw-r--r--libqpdf/NNTree.cc4
-rw-r--r--libqpdf/QPDF.cc4
-rw-r--r--libqpdf/QPDFAcroFormDocumentHelper.cc34
-rw-r--r--libqpdf/QPDFArgParser.cc10
-rw-r--r--libqpdf/QPDFCryptoProvider.cc2
-rw-r--r--libqpdf/QPDFEmbeddedFileDocumentHelper.cc2
-rw-r--r--libqpdf/QPDFFileSpecObjectHelper.cc6
-rw-r--r--libqpdf/QPDFJob.cc44
-rw-r--r--libqpdf/QPDFJob_argv.cc2
-rw-r--r--libqpdf/QPDFJob_json.cc2
-rw-r--r--libqpdf/QPDFObjectHandle.cc20
-rw-r--r--libqpdf/QPDFPageObjectHelper.cc22
-rw-r--r--libqpdf/QPDFWriter.cc6
-rw-r--r--libqpdf/QPDF_Array.cc2
-rw-r--r--libqpdf/QPDF_Dictionary.cc6
-rw-r--r--libqpdf/QPDF_Stream.cc4
-rw-r--r--libqpdf/SF_FlateLzwDecode.cc2
-rw-r--r--libqpdf/SparseOHArray.cc6
-rw-r--r--libtests/cxx11.cc4
-rw-r--r--libtests/nntree.cc4
-rw-r--r--qpdf/fix-qdf.cc14
-rw-r--r--qpdf/test_driver.cc62
32 files changed, 160 insertions, 157 deletions
diff --git a/.clang-format b/.clang-format
index 690d724b..36487f9c 100644
--- a/.clang-format
+++ b/.clang-format
@@ -44,4 +44,7 @@ KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: All
PointerAlignment: Left
PPIndentWidth: 1
+SpaceBeforeCaseColon: false
+SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: false
+SpaceBeforeRangeBasedForLoopColon: false
diff --git a/examples/pdf-bookmarks.cc b/examples/pdf-bookmarks.cc
index de0af8e6..f6c91b21 100644
--- a/examples/pdf-bookmarks.cc
+++ b/examples/pdf-bookmarks.cc
@@ -53,7 +53,7 @@ generate_page_map(QPDF& qpdf)
{
QPDFPageDocumentHelper dh(qpdf);
int n = 0;
- for (auto const& page : dh.getAllPages()) {
+ for (auto const& page: dh.getAllPages()) {
page_map[page.getObjectHandle().getObjGen()] = ++n;
}
}
@@ -69,7 +69,7 @@ show_bookmark_details(QPDFOutlineObjectHelper outline, std::vector<int> numbers)
case st_numbers:
QTC::TC("examples", "pdf-bookmarks numbers");
- for (auto const& number : numbers) {
+ for (auto const& number: numbers) {
std::cout << number << ".";
}
std::cout << " ";
@@ -130,7 +130,7 @@ extract_bookmarks(
// is, so we count up to zero.
numbers.push_back(
(style == st_lines) ? -QIntC::to_int(outlines.size()) : 0);
- for (auto& outline : outlines) {
+ for (auto& outline: outlines) {
++(numbers.back());
show_bookmark_details(outline, numbers);
extract_bookmarks(outline.getKids(), numbers);
diff --git a/examples/pdf-count-strings.cc b/examples/pdf-count-strings.cc
index 23f4b6cb..85e05a5f 100644
--- a/examples/pdf-count-strings.cc
+++ b/examples/pdf-count-strings.cc
@@ -82,7 +82,7 @@ main(int argc, char* argv[])
QPDF pdf;
pdf.processFile(infilename);
int pageno = 0;
- for (auto& page : QPDFPageDocumentHelper(pdf).getAllPages()) {
+ for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) {
++pageno;
// Pass the contents of a page through our string counter.
// If it's an even page, capture the output. This
diff --git a/examples/pdf-create.cc b/examples/pdf-create.cc
index ea315a49..6ba76f63 100644
--- a/examples/pdf-create.cc
+++ b/examples/pdf-create.cc
@@ -253,7 +253,7 @@ check(
}
size_t pageno = 1;
bool errors = false;
- for (auto& page : pages) {
+ for (auto& page: pages) {
auto images = page.getImages();
if (images.size() != 1) {
throw std::logic_error("incorrect number of images on page");
@@ -368,8 +368,8 @@ create_pdf(char const* filename)
filters.push_back("/DCTDecode");
filters.push_back("/RunLengthDecode");
QPDFPageDocumentHelper dh(pdf);
- for (auto const& color_space : color_spaces) {
- for (auto const& filter : filters) {
+ for (auto const& color_space: color_spaces) {
+ for (auto const& filter: filters) {
add_page(dh, font, color_space, filter);
}
}
diff --git a/examples/pdf-custom-filter.cc b/examples/pdf-custom-filter.cc
index 72aa93b5..4514f6df 100644
--- a/examples/pdf-custom-filter.cc
+++ b/examples/pdf-custom-filter.cc
@@ -357,7 +357,7 @@ StreamReplacer::registerStream(
this->copied_streams[og] = stream.copyStream();
// Update the stream dictionary with any changes.
auto dict = stream.getDict();
- for (auto const& k : dict_updates.getKeys()) {
+ for (auto const& k: dict_updates.getKeys()) {
dict.replaceKey(k, dict_updates.getKey(k));
}
// Create the key stream that will be referenced from
@@ -414,7 +414,7 @@ process(
StreamReplacer* replacer = new StreamReplacer(&qpdf);
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> p(replacer);
- for (auto& o : qpdf.getAllObjects()) {
+ for (auto& o: qpdf.getAllObjects()) {
if (o.isStream()) {
// Call registerStream for every stream. Only ones that
// registerStream decides to replace will actually be
diff --git a/examples/pdf-double-page-size.cc b/examples/pdf-double-page-size.cc
index 37e07ff8..f0f86d02 100644
--- a/examples/pdf-double-page-size.cc
+++ b/examples/pdf-double-page-size.cc
@@ -37,7 +37,7 @@ doubleBoxSize(QPDFPageObjectHelper& page, char const* box_name)
" is not an array of four elements");
}
std::vector<QPDFObjectHandle> doubled;
- for (auto& item : box.aitems()) {
+ for (auto& item: box.aitems()) {
doubled.push_back(
QPDFObjectHandle::newReal(item.getNumericValue() * 2.0, 2));
}
@@ -73,7 +73,7 @@ main(int argc, char* argv[])
QPDF qpdf;
qpdf.processFile(infilename, password);
- for (auto& page : QPDFPageDocumentHelper(qpdf).getAllPages()) {
+ for (auto& page: QPDFPageDocumentHelper(qpdf).getAllPages()) {
// Prepend the buffer to the page's contents
page.addPageContents(
QPDFObjectHandle::newStream(&qpdf, content), true);
diff --git a/examples/pdf-invert-images.cc b/examples/pdf-invert-images.cc
index 2ce8f988..bd36f33f 100644
--- a/examples/pdf-invert-images.cc
+++ b/examples/pdf-invert-images.cc
@@ -137,7 +137,7 @@ main(int argc, char* argv[])
QPDFPageObjectHelper& page(*iter);
// Get all images on the page.
std::map<std::string, QPDFObjectHandle> images = page.getImages();
- for (auto& iter2 : images) {
+ for (auto& iter2: images) {
QPDFObjectHandle& image = iter2.second;
QPDFObjectHandle image_dict = image.getDict();
QPDFObjectHandle color_space = image_dict.getKey("/ColorSpace");
diff --git a/examples/pdf-mod-info.cc b/examples/pdf-mod-info.cc
index 8666474f..425a25ba 100644
--- a/examples/pdf-mod-info.cc
+++ b/examples/pdf-mod-info.cc
@@ -31,7 +31,7 @@ dumpInfoDict(
{
QPDFObjectHandle trailer = pdf.getTrailer();
if (trailer.hasKey("/Info")) {
- for (auto& it : trailer.getKey("/Info").ditems()) {
+ for (auto& it: trailer.getKey("/Info").ditems()) {
std::string val;
if (it.second.isString()) {
val = it.second.getStringValue();
diff --git a/examples/pdf-name-number-tree.cc b/examples/pdf-name-number-tree.cc
index 347bfb69..939105e9 100644
--- a/examples/pdf-name-number-tree.cc
+++ b/examples/pdf-name-number-tree.cc
@@ -77,7 +77,7 @@ main(int argc, char* argv[])
// Use range-for iteration
std::cout << "Name tree items:" << std::endl;
- for (auto i : name_tree) {
+ for (auto i: name_tree) {
std::cout << " " << i.first << " -> " << i.second.unparse()
<< std::endl;
}
@@ -86,7 +86,7 @@ main(int argc, char* argv[])
// look at it using dictionary and array iterators.
std::cout << "Keys in name tree object:" << std::endl;
QPDFObjectHandle names;
- for (auto const& i : name_tree_oh.ditems()) {
+ for (auto const& i: name_tree_oh.ditems()) {
std::cout << i.first << std::endl;
if (i.first == "/Names") {
names = i.second;
@@ -94,7 +94,7 @@ main(int argc, char* argv[])
}
// Values in names array:
std::cout << "Values in names:" << std::endl;
- for (auto& i : names.aitems()) {
+ for (auto& i: names.aitems()) {
std::cout << " " << i.unparse() << std::endl;
}
@@ -149,7 +149,7 @@ main(int argc, char* argv[])
}
std::cout << "Numbers:" << std::endl;
int n = 1;
- for (auto& i : number_tree) {
+ for (auto& i: number_tree) {
std::cout << i.first << " -> " << i.second.getUTF8Value();
if (n % 5) {
std::cout << ", ";
@@ -172,7 +172,7 @@ main(int argc, char* argv[])
}
std::cout << "Numbers after filtering:" << std::endl;
n = 1;
- for (auto& i : number_tree) {
+ for (auto& i: number_tree) {
std::cout << i.first << " -> " << i.second.getUTF8Value();
if (n % 5) {
std::cout << ", ";
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index c02e06b8..407e4a64 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -20,7 +20,7 @@ JSON::JSON_dictionary::unparse(size_t depth) const
{
std::string result = "{";
bool first = true;
- for (auto const& iter : members) {
+ for (auto const& iter: members) {
if (first) {
first = false;
} else {
@@ -44,7 +44,7 @@ JSON::JSON_array::unparse(size_t depth) const
{
std::string result = "[";
bool first = true;
- for (auto const& element : elements) {
+ for (auto const& element: elements) {
if (first) {
first = false;
} else {
@@ -304,7 +304,7 @@ JSON::forEachDictItem(
if (v == nullptr) {
return false;
}
- for (auto const& k : v->members) {
+ for (auto const& k: v->members) {
fn(k.first, JSON(k.second));
}
return true;
@@ -317,7 +317,7 @@ JSON::forEachArrayItem(std::function<void(JSON value)> fn) const
if (v == nullptr) {
return false;
}
- for (auto const& i : v->elements) {
+ for (auto const& i: v->elements) {
fn(JSON(i));
}
return true;
@@ -379,7 +379,7 @@ JSON::checkSchemaInternal(
if (sch_dict && (!pattern_key.empty())) {
auto pattern_schema = sch_dict->members[pattern_key].get();
- for (auto const& iter : this_dict->members) {
+ for (auto const& iter: this_dict->members) {
std::string const& key = iter.first;
checkSchemaInternal(
this_dict->members[key].get(),
@@ -389,7 +389,7 @@ JSON::checkSchemaInternal(
prefix + "." + key);
}
} else if (sch_dict) {
- for (auto& iter : sch_dict->members) {
+ for (auto& iter: sch_dict->members) {
std::string const& key = iter.first;
if (this_dict->members.count(key)) {
checkSchemaInternal(
@@ -409,7 +409,7 @@ JSON::checkSchemaInternal(
}
}
}
- for (auto const& iter : this_dict->members) {
+ for (auto const& iter: this_dict->members) {
std::string const& key = iter.first;
if (sch_dict->members.count(key) == 0) {
QTC::TC("libtests", "JSON key extra in object");
@@ -431,7 +431,7 @@ JSON::checkSchemaInternal(
return false;
}
int i = 0;
- for (auto const& element : this_arr->elements) {
+ for (auto const& element: this_arr->elements) {
checkSchemaInternal(
element.get(),
sch_arr->elements.at(0).get(),
diff --git a/libqpdf/NNTree.cc b/libqpdf/NNTree.cc
index 3ab18190..bfeb15a1 100644
--- a/libqpdf/NNTree.cc
+++ b/libqpdf/NNTree.cc
@@ -640,7 +640,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
bool failed = false;
std::set<QPDFObjGen> seen;
- for (auto i : this->path) {
+ for (auto i: this->path) {
if (i.node.isIndirect()) {
seen.insert(i.node.getObjGen());
}
@@ -881,7 +881,7 @@ NNTreeImpl::repair()
auto new_node = QPDFObjectHandle::newDictionary();
new_node.replaceKey(details.itemsKey(), QPDFObjectHandle::newArray());
NNTreeImpl repl(details, qpdf, new_node, false);
- for (auto const& i : *this) {
+ for (auto const& i: *this) {
repl.insert(i.first, i.second);
}
this->oh.replaceKey("/Kids", new_node.getKey("/Kids"))
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 63feb461..bab30042 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -2436,7 +2436,7 @@ QPDF::replaceForeignIndirectObjects(
QTC::TC("qpdf", "QPDF replace dictionary");
result = QPDFObjectHandle::newDictionary();
std::set<std::string> keys = foreign.getKeys();
- for (auto const& iter : keys) {
+ for (auto const& iter: keys) {
result.replaceKey(
iter,
replaceForeignIndirectObjects(
@@ -2450,7 +2450,7 @@ QPDF::replaceForeignIndirectObjects(
QPDFObjectHandle dict = result.getDict();
QPDFObjectHandle old_dict = foreign.getDict();
std::set<std::string> keys = old_dict.getKeys();
- for (auto const& iter : keys) {
+ for (auto const& iter: keys) {
dict.replaceKey(
iter,
replaceForeignIndirectObjects(
diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc
index 811570b5..435c7666 100644
--- a/libqpdf/QPDFAcroFormDocumentHelper.cc
+++ b/libqpdf/QPDFAcroFormDocumentHelper.cc
@@ -82,7 +82,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(
seen.insert(og);
auto kids = obj.getKey("/Kids");
if (kids.isArray()) {
- for (auto kid : kids.aitems()) {
+ for (auto kid: kids.aitems()) {
queue.push_back(kid);
}
}
@@ -119,7 +119,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(
}
}
- for (auto i : fields) {
+ for (auto i: fields) {
addFormField(i);
}
}
@@ -137,10 +137,10 @@ QPDFAcroFormDocumentHelper::removeFormFields(
return;
}
- for (auto const& og : to_remove) {
+ for (auto const& og: to_remove) {
auto annotations = this->m->field_to_annotations.find(og);
if (annotations != this->m->field_to_annotations.end()) {
- for (auto aoh : annotations->second) {
+ for (auto aoh: annotations->second) {
this->m->annotation_to_field.erase(
aoh.getObjectHandle().getObjGen());
}
@@ -229,7 +229,7 @@ QPDFAcroFormDocumentHelper::getFormFieldsForPage(QPDFPageObjectHelper ph)
std::set<QPDFObjGen> added;
std::vector<QPDFFormFieldObjectHelper> result;
auto widget_annotations = getWidgetAnnotationsForPage(ph);
- for (auto annot : widget_annotations) {
+ for (auto annot: widget_annotations) {
auto field = getFieldForAnnotation(annot);
field = field.getTopLevelField();
auto og = field.getObjectHandle().getObjGen();
@@ -576,21 +576,21 @@ ResourceReplacer::ResourceReplacer(
// We want:
// * to_replace[key][offset] = new_key
- for (auto const& rn_iter : rnames) {
+ for (auto const& rn_iter: rnames) {
std::string const& rtype = rn_iter.first;
auto dr_map_rtype = dr_map.find(rtype);
if (dr_map_rtype == dr_map.end()) {
continue;
}
auto const& key_offsets = rn_iter.second;
- for (auto const& ko_iter : key_offsets) {
+ for (auto const& ko_iter: key_offsets) {
std::string const& old_key = ko_iter.first;
auto dr_map_rtype_old = dr_map_rtype->second.find(old_key);
if (dr_map_rtype_old == dr_map_rtype->second.end()) {
continue;
}
auto const& offsets = ko_iter.second;
- for (auto const& o_iter : offsets) {
+ for (auto const& o_iter: offsets) {
to_replace[old_key][o_iter] = dr_map_rtype_old->second;
}
}
@@ -719,19 +719,19 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
// this to resolve conflicts that may already be in the resource
// dictionary.
auto merge_with = QPDFObjectHandle::newDictionary();
- for (auto const& top_key : dr_map) {
+ for (auto const& top_key: dr_map) {
merge_with.replaceKey(top_key.first, QPDFObjectHandle::newDictionary());
}
resources.mergeResources(merge_with);
// Rename any keys in the resource dictionary that we
// remapped.
- for (auto const& i1 : dr_map) {
+ for (auto const& i1: dr_map) {
std::string const& top_key = i1.first;
auto subdict = resources.getKey(top_key);
if (!subdict.isDictionary()) {
continue;
}
- for (auto const& i2 : i1.second) {
+ for (auto const& i2: i1.second) {
std::string const& old_key = i2.first;
std::string const& new_key = i2.second;
auto existing_new = subdict.getKey(new_key);
@@ -757,7 +757,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
// the stream contents.
resources.mergeResources(merge_with, &dr_map);
// Remove empty subdictionaries
- for (auto iter : resources.ditems()) {
+ for (auto iter: resources.ditems()) {
if (iter.second.isDictionary() && (iter.second.getKeys().size() == 0)) {
resources.removeKey(iter.first);
}
@@ -911,7 +911,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
// Now do the actual copies.
std::set<QPDFObjGen> added_new_fields;
- for (auto annot : old_annots.aitems()) {
+ for (auto annot: old_annots.aitems()) {
if (annot.isStream()) {
annot.warnIfPossible("ignoring annotation that's a stream");
continue;
@@ -1101,12 +1101,12 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
return dict.replaceKeyAndGet(key, old.copyStream());
};
if (apdict.isDictionary()) {
- for (auto& ap : apdict.ditems()) {
+ for (auto& ap: apdict.ditems()) {
if (ap.second.isStream()) {
streams.push_back(
replace_stream(apdict, ap.first, ap.second));
} else if (ap.second.isDictionary()) {
- for (auto& ap2 : ap.second.ditems()) {
+ for (auto& ap2: ap.second.ditems()) {
if (ap2.second.isStream()) {
streams.push_back(
// line-break
@@ -1120,7 +1120,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
// Now we can safely mutate the annotation and its appearance
// streams.
- for (auto& stream : streams) {
+ for (auto& stream: streams) {
auto dict = stream.getDict();
auto omatrix = dict.getKey("/Matrix");
QPDFMatrix apcm;
@@ -1172,7 +1172,7 @@ QPDFAcroFormDocumentHelper::fixCopiedAnnotations(
to_page.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots));
addAndRenameFormFields(new_fields);
if (added_fields) {
- for (auto f : new_fields) {
+ for (auto f: new_fields) {
added_fields->insert(f.getObjGen());
}
}
diff --git a/libqpdf/QPDFArgParser.cc b/libqpdf/QPDFArgParser.cc
index 207946b8..8cd53efa 100644
--- a/libqpdf/QPDFArgParser.cc
+++ b/libqpdf/QPDFArgParser.cc
@@ -381,7 +381,7 @@ QPDFArgParser::readArgsFromFile(std::string const& filename)
QTC::TC("libtests", "QPDFArgParser read args from file");
lines = QUtil::read_lines_from_file(filename.c_str());
}
- for (auto const& line : lines) {
+ for (auto const& line: lines) {
this->m->new_argv.push_back(QUtil::make_shared_cstr(line));
}
}
@@ -636,7 +636,7 @@ QPDFArgParser::addChoicesToCompletions(
void
QPDFArgParser::addOptionsToCompletions(option_table_t& option_table)
{
- for (auto& iter : option_table) {
+ for (auto& iter: option_table) {
std::string const& arg = iter.first;
if (arg == "--") {
continue;
@@ -797,7 +797,7 @@ QPDFArgParser::getTopHelp(std::ostringstream& msg)
<< " --help=all\" to see all available help." << std::endl
<< std::endl
<< "Topics:" << std::endl;
- for (auto const& i : this->m->help_topics) {
+ for (auto const& i: this->m->help_topics) {
msg << " " << i.first << ": " << i.second.short_text << std::endl;
}
}
@@ -807,7 +807,7 @@ QPDFArgParser::getAllHelp(std::ostringstream& msg)
{
getTopHelp(msg);
auto show = [this, &msg](std::map<std::string, HelpTopic>& topics) {
- for (auto const& i : topics) {
+ for (auto const& i: topics) {
auto const& topic = i.first;
msg << std::endl
<< "== " << topic << " (" << i.second.short_text
@@ -832,7 +832,7 @@ QPDFArgParser::getTopicHelp(
}
if (!ht.options.empty()) {
msg << std::endl << "Related options:" << std::endl;
- for (auto const& i : ht.options) {
+ for (auto const& i: ht.options) {
msg << " " << i << ": " << this->m->option_help[i].short_text
<< std::endl;
}
diff --git a/libqpdf/QPDFCryptoProvider.cc b/libqpdf/QPDFCryptoProvider.cc
index 6d147d4d..06942f88 100644
--- a/libqpdf/QPDFCryptoProvider.cc
+++ b/libqpdf/QPDFCryptoProvider.cc
@@ -106,7 +106,7 @@ QPDFCryptoProvider::getRegisteredImpls()
{
std::set<std::string> result;
QPDFCryptoProvider& p = getInstance();
- for (auto const& iter : p.m->providers) {
+ for (auto const& iter: p.m->providers) {
result.insert(iter.first);
}
return result;
diff --git a/libqpdf/QPDFEmbeddedFileDocumentHelper.cc b/libqpdf/QPDFEmbeddedFileDocumentHelper.cc
index 4b61dfe3..847a9786 100644
--- a/libqpdf/QPDFEmbeddedFileDocumentHelper.cc
+++ b/libqpdf/QPDFEmbeddedFileDocumentHelper.cc
@@ -92,7 +92,7 @@ QPDFEmbeddedFileDocumentHelper::getEmbeddedFiles()
{
std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>> result;
if (this->m->embedded_files) {
- for (auto const& i : *(this->m->embedded_files)) {
+ for (auto const& i: *(this->m->embedded_files)) {
result[i.first] =
std::make_shared<QPDFFileSpecObjectHelper>(i.second);
}
diff --git a/libqpdf/QPDFFileSpecObjectHelper.cc b/libqpdf/QPDFFileSpecObjectHelper.cc
index 446ff131..f9c19e3c 100644
--- a/libqpdf/QPDFFileSpecObjectHelper.cc
+++ b/libqpdf/QPDFFileSpecObjectHelper.cc
@@ -36,7 +36,7 @@ QPDFFileSpecObjectHelper::getDescription()
std::string
QPDFFileSpecObjectHelper::getFilename()
{
- for (auto const& i : name_keys) {
+ for (auto const& i: name_keys) {
auto k = this->oh.getKey(i);
if (k.isString()) {
return k.getUTF8Value();
@@ -49,7 +49,7 @@ std::map<std::string, std::string>
QPDFFileSpecObjectHelper::getFilenames()
{
std::map<std::string, std::string> result;
- for (auto const& i : name_keys) {
+ for (auto const& i: name_keys) {
auto k = this->oh.getKey(i);
if (k.isString()) {
result[i] = k.getUTF8Value();
@@ -68,7 +68,7 @@ QPDFFileSpecObjectHelper::getEmbeddedFileStream(std::string const& key)
if (!key.empty()) {
return ef.getKey(key);
}
- for (auto const& i : name_keys) {
+ for (auto const& i: name_keys) {
auto k = ef.getKey(i);
if (k.isStream()) {
return k;
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc
index 08b5b9d7..e0cc783f 100644
--- a/libqpdf/QPDFJob.cc
+++ b/libqpdf/QPDFJob.cc
@@ -940,7 +940,7 @@ QPDFJob::doShowPages(QPDF& pdf)
std::map<std::string, QPDFObjectHandle> images = ph.getImages();
if (!images.empty()) {
cout << " images:" << std::endl;
- for (auto const& iter2 : images) {
+ for (auto const& iter2: images) {
std::string const& name = iter2.first;
QPDFObjectHandle image = iter2.second;
QPDFObjectHandle dict = image.getDict();
@@ -954,7 +954,7 @@ QPDFJob::doShowPages(QPDF& pdf)
cout << " content:" << std::endl;
std::vector<QPDFObjectHandle> content = ph.getPageContents();
- for (auto& iter2 : content) {
+ for (auto& iter2: content) {
cout << " " << iter2.unparse() << std::endl;
}
}
@@ -965,7 +965,7 @@ QPDFJob::doListAttachments(QPDF& pdf)
{
QPDFEmbeddedFileDocumentHelper efdh(pdf);
if (efdh.hasEmbeddedFiles()) {
- for (auto const& i : efdh.getEmbeddedFiles()) {
+ for (auto const& i: efdh.getEmbeddedFiles()) {
std::string const& key = i.first;
auto efoh = i.second;
*(this->m->cout)
@@ -979,12 +979,12 @@ QPDFJob::doListAttachments(QPDF& pdf)
cout << " preferred name: " << efoh->getFilename()
<< std::endl;
cout << " all names:" << std::endl;
- for (auto const& i2 : efoh->getFilenames()) {
+ for (auto const& i2: efoh->getFilenames()) {
cout << " " << i2.first << " -> " << i2.second
<< std::endl;
}
cout << " all data streams:" << std::endl;
- for (auto i2 : efoh->getEmbeddedFileStreams().ditems()) {
+ for (auto i2: efoh->getEmbeddedFileStreams().ditems()) {
cout << " " << i2.first << " -> "
<< i2.second.getObjGen() << std::endl;
}
@@ -1032,7 +1032,7 @@ std::set<QPDFObjGen>
QPDFJob::getWantedJSONObjects()
{
std::set<QPDFObjGen> wanted_og;
- for (auto const& iter : m->json_objects) {
+ for (auto const& iter: m->json_objects) {
bool trailer;
int obj = 0;
int gen = 0;
@@ -1077,7 +1077,7 @@ QPDFJob::doJSONObjectinfo(QPDF& pdf, JSON& j)
std::set<QPDFObjGen> wanted_og = getWantedJSONObjects();
JSON j_objectinfo =
j.addDictionaryMember("objectinfo", JSON::makeDictionary());
- for (auto& obj : pdf.getAllObjects()) {
+ for (auto& obj: pdf.getAllObjects()) {
if (all_objects || wanted_og.count(obj.getObjGen())) {
auto j_details = j_objectinfo.addDictionaryMember(
obj.unparse(), JSON::makeDictionary());
@@ -1116,7 +1116,7 @@ QPDFJob::doJSONPages(QPDF& pdf, JSON& j)
j_page.addDictionaryMember("object", page.getJSON());
JSON j_images = j_page.addDictionaryMember("images", JSON::makeArray());
std::map<std::string, QPDFObjectHandle> images = ph.getImages();
- for (auto const& iter2 : images) {
+ for (auto const& iter2: images) {
JSON j_image = j_images.addArrayElement(JSON::makeDictionary());
j_image.addDictionaryMember("name", JSON::makeString(iter2.first));
QPDFObjectHandle image = iter2.second;
@@ -1152,7 +1152,7 @@ QPDFJob::doJSONPages(QPDF& pdf, JSON& j)
JSON j_contents =
j_page.addDictionaryMember("contents", JSON::makeArray());
std::vector<QPDFObjectHandle> content = ph.getPageContents();
- for (auto& iter2 : content) {
+ for (auto& iter2: content) {
j_contents.addArrayElement(iter2.getJSON());
}
j_page.addDictionaryMember(
@@ -1419,7 +1419,7 @@ QPDFJob::doJSONAttachments(QPDF& pdf, JSON& j)
JSON j_attachments =
j.addDictionaryMember("attachments", JSON::makeDictionary());
QPDFEmbeddedFileDocumentHelper efdh(pdf);
- for (auto const& iter : efdh.getEmbeddedFiles()) {
+ for (auto const& iter: efdh.getEmbeddedFiles()) {
std::string const& key = iter.first;
auto fsoh = iter.second;
auto j_details =
@@ -2099,7 +2099,7 @@ QPDFJob::addAttachments(QPDF& pdf)
maybe_set_pagemode(pdf, "/UseAttachments");
QPDFEmbeddedFileDocumentHelper efdh(pdf);
std::vector<std::string> duplicated_keys;
- for (auto const& to_add : m->attachments_to_add) {
+ for (auto const& to_add: m->attachments_to_add) {
if ((!to_add.replace) && efdh.getEmbeddedFile(to_add.key)) {
duplicated_keys.push_back(to_add.key);
continue;
@@ -2125,7 +2125,7 @@ QPDFJob::addAttachments(QPDF& pdf)
if (!duplicated_keys.empty()) {
std::string message;
- for (auto const& k : duplicated_keys) {
+ for (auto const& k: duplicated_keys) {
if (!message.empty()) {
message += ", ";
}
@@ -2144,7 +2144,7 @@ QPDFJob::copyAttachments(QPDF& pdf)
maybe_set_pagemode(pdf, "/UseAttachments");
QPDFEmbeddedFileDocumentHelper efdh(pdf);
std::vector<std::string> duplicates;
- for (auto const& to_copy : m->attachments_to_copy) {
+ for (auto const& to_copy: m->attachments_to_copy) {
doIfVerbose([&](std::ostream& cout, std::string const& prefix) {
cout << prefix << ": copying attachments from " << to_copy.path
<< std::endl;
@@ -2153,7 +2153,7 @@ QPDFJob::copyAttachments(QPDF& pdf)
processFile(to_copy.path.c_str(), to_copy.password.c_str(), false);
QPDFEmbeddedFileDocumentHelper other_efdh(*other);
auto other_attachments = other_efdh.getEmbeddedFiles();
- for (auto const& iter : other_attachments) {
+ for (auto const& iter: other_attachments) {
std::string new_key = to_copy.prefix + iter.first;
if (efdh.getEmbeddedFile(new_key)) {
duplicates.push_back(
@@ -2177,7 +2177,7 @@ QPDFJob::copyAttachments(QPDF& pdf)
if (!duplicates.empty()) {
std::string message;
- for (auto const& i : duplicates) {
+ for (auto const& i: duplicates) {
if (!message.empty()) {
message += "; ";
}
@@ -2223,7 +2223,7 @@ QPDFJob::handleTransformations(QPDF& pdf)
QPDFPageObjectHelper& ph(*iter);
QPDFObjectHandle page = ph.getObjectHandle();
std::map<std::string, QPDFObjectHandle> images = ph.getImages();
- for (auto& iter2 : images) {
+ for (auto& iter2: images) {
std::string name = iter2.first;
QPDFObjectHandle& image = iter2.second;
ImageOptimizer* io = new ImageOptimizer(
@@ -2268,7 +2268,7 @@ QPDFJob::handleTransformations(QPDF& pdf)
}
if (m->flatten_rotation) {
make_afdh();
- for (auto& page : dh.getAllPages()) {
+ for (auto& page: dh.getAllPages()) {
page.flattenRotation(afdh.get());
}
}
@@ -2277,7 +2277,7 @@ QPDFJob::handleTransformations(QPDF& pdf)
}
if (!m->attachments_to_remove.empty()) {
QPDFEmbeddedFileDocumentHelper efdh(pdf);
- for (auto const& key : m->attachments_to_remove) {
+ for (auto const& key: m->attachments_to_remove) {
if (efdh.removeEmbeddedFile(key)) {
doIfVerbose([&](std::ostream& cout, std::string const& prefix) {
cout << prefix << ": removed attachment " << key
@@ -2386,7 +2386,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF& pdf)
resources_seen.insert(xobject_og);
}
if (xobject.isDictionary()) {
- for (auto const& k : xobject.getKeys()) {
+ for (auto const& k: xobject.getKeys()) {
QPDFObjectHandle xobj = xobject.getKey(k);
if (xobj.isFormXObject()) {
queue.push_back(xobj);
@@ -2443,7 +2443,7 @@ QPDFJob::handlePageSpecs(
// some portable heuristic based on OS limits, just hard-code
// this at a given number and allow users to override.
std::set<std::string> filenames;
- for (auto& page_spec : m->page_specs) {
+ for (auto& page_spec: m->page_specs) {
filenames.insert(page_spec.filename);
}
m->keep_files_open = (filenames.size() <= m->keep_files_open_threshold);
@@ -2707,7 +2707,7 @@ QPDFJob::handlePageSpecs(
for (size_t pageno = 0; pageno < orig_pages.size(); ++pageno) {
auto page = orig_pages.at(pageno);
if (selected_from_orig.count(QIntC::to_int(pageno))) {
- for (auto field : this_afdh->getFormFieldsForPage(page)) {
+ for (auto field: this_afdh->getFormFieldsForPage(page)) {
QTC::TC("qpdf", "QPDFJob pages keeping field from original");
referenced_fields.insert(field.getObjectHandle().getObjGen());
}
@@ -2726,7 +2726,7 @@ QPDFJob::handlePageSpecs(
if (fields.isIndirect()) {
new_fields = pdf.makeIndirectObject(new_fields);
}
- for (auto const& field : fields.aitems()) {
+ for (auto const& field: fields.aitems()) {
if (referenced_fields.count(field.getObjGen())) {
new_fields.appendItem(field);
}
diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc
index 969af7db..a6fb5df7 100644
--- a/libqpdf/QPDFJob_argv.cc
+++ b/libqpdf/QPDFJob_argv.cc
@@ -167,7 +167,7 @@ ArgParser::argShowCrypto()
auto crypto = QPDFCryptoProvider::getRegisteredImpls();
std::string default_crypto = QPDFCryptoProvider::getDefaultProvider();
std::cout << default_crypto << std::endl;
- for (auto const& iter : crypto) {
+ for (auto const& iter: crypto) {
if (iter != default_crypto) {
std::cout << iter << std::endl;
}
diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc
index e529439a..fcdeb666 100644
--- a/libqpdf/QPDFJob_json.cc
+++ b/libqpdf/QPDFJob_json.cc
@@ -583,7 +583,7 @@ QPDFJob::initializeFromJson(std::string const& json, bool partial)
if (!j.checkSchema(JOB_SCHEMA, JSON::f_optional, errors)) {
std::ostringstream msg;
msg << this->m->message_prefix << ": job json has errors:";
- for (auto const& error : errors) {
+ for (auto const& error: errors) {
msg << std::endl << " " << error;
}
throw std::runtime_error(msg.str());
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index 9bdf1a64..c156e627 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -949,7 +949,7 @@ void
QPDFObjectHandle::setArrayFromVector(std::vector<QPDFObjectHandle> const& items)
{
if (isArray()) {
- for (auto const& item : items) {
+ for (auto const& item: items) {
checkOwnership(item);
}
dynamic_cast<QPDF_Array*>(obj.get())->setFromVector(items);
@@ -1108,7 +1108,7 @@ QPDFObjectHandle::isOrHasName(std::string const& value)
if (isNameAndEquals(value)) {
return true;
} else if (isArray()) {
- for (auto& item : aitems()) {
+ for (auto& item: aitems()) {
if (item.isNameAndEquals(value)) {
return true;
}
@@ -1123,12 +1123,12 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF& owning_qpdf)
if (!isDictionary()) {
return;
}
- for (auto const& i1 : ditems()) {
+ for (auto const& i1: ditems()) {
QPDFObjectHandle sub = i1.second;
if (!sub.isDictionary()) {
continue;
}
- for (auto i2 : sub.ditems()) {
+ for (auto i2: sub.ditems()) {
std::string const& key = i2.first;
QPDFObjectHandle val = i2.second;
if (!val.isIndirect()) {
@@ -1150,7 +1150,7 @@ QPDFObjectHandle::mergeResources(
auto make_og_to_name = [](QPDFObjectHandle& dict,
std::map<QPDFObjGen, std::string>& og_to_name) {
- for (auto i : dict.ditems()) {
+ for (auto i: dict.ditems()) {
if (i.second.isIndirect()) {
og_to_name[i.second.getObjGen()] = i.first;
}
@@ -1159,7 +1159,7 @@ QPDFObjectHandle::mergeResources(
// This algorithm is described in comments in QPDFObjectHandle.hh
// above the declaration of mergeResources.
- for (auto o_top : other.ditems()) {
+ for (auto o_top: other.ditems()) {
std::string const& rtype = o_top.first;
QPDFObjectHandle other_val = o_top.second;
if (hasKey(rtype)) {
@@ -1178,7 +1178,7 @@ QPDFObjectHandle::mergeResources(
std::set<std::string> rnames;
int min_suffix = 1;
bool initialized_maps = false;
- for (auto ov_iter : other_val.ditems()) {
+ for (auto ov_iter: other_val.ditems()) {
std::string const& key = ov_iter.first;
QPDFObjectHandle rval = ov_iter.second;
if (!this_val.hasKey(key)) {
@@ -1212,12 +1212,12 @@ QPDFObjectHandle::mergeResources(
}
} else if (this_val.isArray() && other_val.isArray()) {
std::set<std::string> scalars;
- for (auto this_item : this_val.aitems()) {
+ for (auto this_item: this_val.aitems()) {
if (this_item.isScalar()) {
scalars.insert(this_item.unparse());
}
}
- for (auto other_item : other_val.aitems()) {
+ for (auto other_item: other_val.aitems()) {
if (other_item.isScalar()) {
if (scalars.count(other_item.unparse()) == 0) {
QTC::TC("qpdf", "QPDFObjectHandle merge array");
@@ -2950,7 +2950,7 @@ QPDFObjectHandle::copyStream()
QPDFObjectHandle result = newStream(this->getOwningQPDF());
QPDFObjectHandle dict = result.getDict();
QPDFObjectHandle old_dict = getDict();
- for (auto& iter : QPDFDictItems(old_dict)) {
+ for (auto& iter: QPDFDictItems(old_dict)) {
if (iter.second.isIndirect()) {
dict.replaceKey(iter.first, iter.second);
} else {
diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc
index ce0bcc38..59b9b45f 100644
--- a/libqpdf/QPDFPageObjectHelper.cc
+++ b/libqpdf/QPDFPageObjectHelper.cc
@@ -81,7 +81,7 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
dict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"))
.replaceKey("/Subtype", QPDFObjectHandle::newName("/Image"));
std::set<std::string> keys = odict.getKeys();
- for (auto key : keys) {
+ for (auto key: keys) {
QPDFObjectHandle value = odict.getKey(key);
if (key == "/BPC") {
key = "/BitsPerComponent";
@@ -142,7 +142,7 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
} else if (value.isArray()) {
filters = value.getArrayAsVector();
}
- for (auto& iter : filters) {
+ for (auto& iter: filters) {
std::string name;
if (iter.isName()) {
name = iter.getName();
@@ -334,7 +334,7 @@ QPDFPageObjectHelper::forEachXObject(
QPDFObjectHandle resources = ph.getAttribute("/Resources", false);
if (resources.isDictionary() && resources.hasKey("/XObject")) {
QPDFObjectHandle xobj_dict = resources.getKey("/XObject");
- for (auto const& key : xobj_dict.getKeys()) {
+ for (auto const& key: xobj_dict.getKeys()) {
QPDFObjectHandle obj = xobj_dict.getKey(key);
if ((!selector) || selector(obj)) {
action(obj, xobj_dict, key);
@@ -594,7 +594,7 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
std::set<std::string> known_names;
std::vector<std::string> to_filter = {"/Font", "/XObject"};
if (resources.isDictionary()) {
- for (auto const& iter : to_filter) {
+ for (auto const& iter: to_filter) {
QPDFObjectHandle dict = resources.getKey(iter);
if (dict.isDictionary()) {
dict = resources.replaceKeyAndGet(iter, dict.shallowCopy());
@@ -607,8 +607,8 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
std::set<std::string> local_unresolved;
auto names_by_rtype = rf.getNamesByResourceType();
- for (auto const& i1 : to_filter) {
- for (auto const& n_iter : names_by_rtype[i1]) {
+ for (auto const& i1: to_filter) {
+ for (auto const& n_iter: names_by_rtype[i1]) {
std::string const& name = n_iter.first;
if (!known_names.count(name)) {
unresolved.insert(name);
@@ -647,8 +647,8 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
return false;
}
- for (auto& dict : rdicts) {
- for (auto const& key : dict.getKeys()) {
+ for (auto& dict: rdicts) {
+ for (auto const& key: dict.getKeys()) {
if (is_page && unresolved.count(key)) {
// This name is referenced by some nested form
// xobject, so don't remove it.
@@ -946,7 +946,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
"/TrimBox",
"/ArtBox",
};
- for (auto const& boxkey : boxes) {
+ for (auto const& boxkey: boxes) {
auto box = this->oh.getKey(boxkey);
if (!box.isRectangle()) {
continue;
@@ -1049,7 +1049,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
afdh->transformAnnotations(
annots, new_annots, new_fields, old_fields, cm);
afdh->removeFormFields(old_fields);
- for (auto const& f : new_fields) {
+ for (auto const& f: new_fields) {
afdh->addFormField(QPDFFormFieldObjectHelper(f));
}
this->oh.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots));
@@ -1115,7 +1115,7 @@ QPDFPageObjectHelper::copyAnnotations(
annots =
this->oh.replaceKeyAndGet("/Annots", QPDFObjectHandle::newArray());
}
- for (auto const& annot : new_annots) {
+ for (auto const& annot: new_annots) {
annots.appendItem(annot);
}
}
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index d06a82b0..962a8a6c 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -2252,7 +2252,7 @@ QPDFWriter::initializeSpecialStreams()
contents_objects.push_back(contents.getObjGen());
}
- for (auto const& c : contents_objects) {
+ for (auto const& c: contents_objects) {
this->m->contents_to_page_seq[c] = num;
this->m->normalized_streams.insert(c);
}
@@ -2287,7 +2287,7 @@ QPDFWriter::preserveObjectStreams()
"qpdf",
"QPDFWriter preserve object streams",
this->m->preserve_unreferenced_objects ? 0 : 1);
- for (auto iter : omap) {
+ for (auto iter: omap) {
QPDFObjGen og(iter.first, 0);
if (eligible.count(og) || this->m->preserve_unreferenced_objects) {
this->m->object_to_object_stream[og] = iter.second;
@@ -2380,7 +2380,7 @@ QPDFWriter::prepareFileForWrite()
this->m->pdf.fixDanglingReferences(true);
QPDFObjectHandle root = this->m->pdf.getRoot();
- for (auto const& key : root.getKeys()) {
+ for (auto const& key: root.getKeys()) {
QPDFObjectHandle oh = root.getKey(key);
if ((key == "/Extensions") && (oh.isDictionary())) {
bool extensions_indirect = false;
diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc
index 46cc4893..0567f66b 100644
--- a/libqpdf/QPDF_Array.cc
+++ b/libqpdf/QPDF_Array.cc
@@ -138,7 +138,7 @@ QPDF_Array::getElementsForShallowCopy() const
void
QPDF_Array::addExplicitElementsToList(std::list<QPDFObjectHandle>& l) const
{
- for (auto const& iter : this->elements) {
+ for (auto const& iter: this->elements) {
l.push_back(iter.second);
}
}
diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc
index c3343b21..e5b88027 100644
--- a/libqpdf/QPDF_Dictionary.cc
+++ b/libqpdf/QPDF_Dictionary.cc
@@ -24,7 +24,7 @@ std::string
QPDF_Dictionary::unparse()
{
std::string result = "<< ";
- for (auto& iter : this->items) {
+ for (auto& iter: this->items) {
if (!iter.second.isNull()) {
result += QPDF_Name::normalizeName(iter.first) + " " +
iter.second.unparse() + " ";
@@ -38,7 +38,7 @@ JSON
QPDF_Dictionary::getJSON()
{
JSON j = JSON::makeDictionary();
- for (auto& iter : this->items) {
+ for (auto& iter: this->items) {
if (!iter.second.isNull()) {
j.addDictionaryMember(
QPDF_Name::normalizeName(iter.first), iter.second.getJSON());
@@ -96,7 +96,7 @@ std::set<std::string>
QPDF_Dictionary::getKeys()
{
std::set<std::string> result;
- for (auto& iter : this->items) {
+ for (auto& iter: this->items) {
if (!iter.second.isNull()) {
result.insert(iter.first);
}
diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc
index 9e1c1ca6..313eb835 100644
--- a/libqpdf/QPDF_Stream.cc
+++ b/libqpdf/QPDF_Stream.cc
@@ -34,7 +34,7 @@ namespace
return true;
}
bool filterable = true;
- for (auto const& key : decode_parms.getKeys()) {
+ for (auto const& key: decode_parms.getKeys()) {
if (((key == "/Type") || (key == "/Name")) &&
((!decode_parms.hasKey("/Type")) ||
decode_parms.isDictionaryOfType(
@@ -311,7 +311,7 @@ QPDF_Stream::filterable(
bool filterable = true;
- for (auto& filter_name : filter_names) {
+ for (auto& filter_name: filter_names) {
if (filter_abbreviations.count(filter_name)) {
QTC::TC("qpdf", "QPDF_Stream expand filter abbreviation");
filter_name = filter_abbreviations[filter_name];
diff --git a/libqpdf/SF_FlateLzwDecode.cc b/libqpdf/SF_FlateLzwDecode.cc
index f753ffd8..dc76a329 100644
--- a/libqpdf/SF_FlateLzwDecode.cc
+++ b/libqpdf/SF_FlateLzwDecode.cc
@@ -27,7 +27,7 @@ SF_FlateLzwDecode::setDecodeParms(QPDFObjectHandle decode_parms)
bool filterable = true;
std::set<std::string> keys = decode_parms.getKeys();
- for (auto const& key : keys) {
+ for (auto const& key: keys) {
QPDFObjectHandle value = decode_parms.getKey(key);
if (key == "/Predictor") {
if (value.isInteger()) {
diff --git a/libqpdf/SparseOHArray.cc b/libqpdf/SparseOHArray.cc
index 738ab44d..4a9be809 100644
--- a/libqpdf/SparseOHArray.cc
+++ b/libqpdf/SparseOHArray.cc
@@ -51,7 +51,7 @@ SparseOHArray::remove_last()
void
SparseOHArray::releaseResolved()
{
- for (auto& iter : this->elements) {
+ for (auto& iter: this->elements) {
QPDFObjectHandle::ReleaseResolver::releaseResolved(iter.second);
}
}
@@ -76,7 +76,7 @@ SparseOHArray::erase(size_t idx)
throw std::logic_error("bounds error erasing item from SparseOHArray");
}
decltype(this->elements) dest;
- for (auto const& iter : this->elements) {
+ for (auto const& iter: this->elements) {
if (iter.first < idx) {
dest.insert(iter);
} else if (iter.first > idx) {
@@ -97,7 +97,7 @@ SparseOHArray::insert(size_t idx, QPDFObjectHandle oh)
append(oh);
} else {
decltype(this->elements) dest;
- for (auto const& iter : this->elements) {
+ for (auto const& iter: this->elements) {
if (iter.first < idx) {
dest.insert(iter);
} else {
diff --git a/libtests/cxx11.cc b/libtests/cxx11.cc
index fbf3cc38..4c2c2cb6 100644
--- a/libtests/cxx11.cc
+++ b/libtests/cxx11.cc
@@ -122,7 +122,7 @@ do_iteration()
std::vector<int> v = {1, 2, 3, 4};
assert(v.size() == 4);
int sum = 0;
- for (auto& i : v) {
+ for (auto& i: v) {
sum += i;
}
assert(10 == sum);
@@ -299,7 +299,7 @@ do_smart_pointers()
auto p1 = make_c(1);
C::check(1, 1, 1);
auto p2 = make_c_array({2, 3, 4, 5});
- for (auto i : {1, 2, 3, 4, 5}) {
+ for (auto i: {1, 2, 3, 4, 5}) {
C::check(5, i, 1);
}
{
diff --git a/libtests/nntree.cc b/libtests/nntree.cc
index f999e2e7..2296a27c 100644
--- a/libtests/nntree.cc
+++ b/libtests/nntree.cc
@@ -61,7 +61,7 @@ test_bsearch()
auto mk = [&q](std::vector<int> const& v) {
auto nums = QPDFObjectHandle::newArray();
- for (auto i : v) {
+ for (auto i: v) {
nums.appendItem(QPDFObjectHandle::newInteger(i))
.appendItem(QPDFObjectHandle::newString(
"-" + QUtil::int_to_string(i) + "-"));
@@ -199,7 +199,7 @@ test_depth()
QPDFNameTreeObjectHelper nh(n0, q);
std::cout << "--- forward ---" << std::endl;
- for (auto i : nh) {
+ for (auto i: nh) {
std::cout << i.first << " -> " << i.second.unparse() << std::endl;
}
std::cout << "--- backward ---" << std::endl;
diff --git a/qpdf/fix-qdf.cc b/qpdf/fix-qdf.cc
index 4fd5bf93..756b8c5d 100644
--- a/qpdf/fix-qdf.cc
+++ b/qpdf/fix-qdf.cc
@@ -112,7 +112,7 @@ QdfFixer::processLines(std::list<std::string>& lines)
static std::regex re_dict_end("^>>\n$");
lineno = 0;
- for (auto const& line : lines) {
+ for (auto const& line: lines) {
++lineno;
last_offset = offset;
offset += QIntC::to_offset(line.length());
@@ -151,7 +151,7 @@ QdfFixer::processLines(std::list<std::string>& lines)
// index. Make sure we get at least 1 byte even if
// there are no object streams.
int max_objects = 1;
- for (auto const& e : xref) {
+ for (auto const& e: xref) {
if ((e.getType() == 2) &&
(e.getObjStreamIndex() > max_objects)) {
max_objects = e.getObjStreamIndex();
@@ -218,7 +218,7 @@ QdfFixer::processLines(std::list<std::string>& lines)
writeBinary(0, 1);
writeBinary(0, xref_f1_nbytes);
writeBinary(0, xref_f2_nbytes);
- for (auto const& x : xref) {
+ for (auto const& x: xref) {
unsigned long long f1 = 0;
unsigned long long f2 = 0;
unsigned int type = QIntC::to_uint(x.getType());
@@ -268,7 +268,7 @@ QdfFixer::processLines(std::list<std::string>& lines)
} else if (state == st_at_xref) {
auto n = xref.size();
std::cout << "0 " << 1 + n << "\n0000000000 65535 f \n";
- for (auto const& e : xref) {
+ for (auto const& e: xref) {
std::cout << QUtil::int_to_string(e.getOffset(), 10)
<< " 00000 n \n";
}
@@ -322,7 +322,7 @@ QdfFixer::writeOstream()
auto onum = ostream_id;
std::string offsets;
auto n = ostream_offsets.size();
- for (auto iter : ostream_offsets) {
+ for (auto iter: ostream_offsets) {
iter -= QIntC::to_offset(first);
++onum;
offsets += QUtil::int_to_string(onum) + " " +
@@ -341,11 +341,11 @@ QdfFixer::writeOstream()
dict_data += ">>\n";
offset_adjust += QIntC::to_offset(dict_data.length());
std::cout << dict_data << "stream\n" << offsets;
- for (auto const& o : ostream) {
+ for (auto const& o: ostream) {
std::cout << o;
}
- for (auto const& o : ostream_discarded) {
+ for (auto const& o: ostream_discarded) {
offset -= QIntC::to_offset(o.length());
}
offset += offset_adjust;
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 00d87d6a..e0e77cfe 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -235,7 +235,7 @@ test_0_1(QPDF& pdf, char const* arg2)
std::cout << "/QTest is an array with " << qtest.getArrayNItems()
<< " items" << std::endl;
int i = 0;
- for (auto& iter : qtest.aitems()) {
+ for (auto& iter: qtest.aitems()) {
QTC::TC(
"qpdf", "main QTest array indirect", iter.isIndirect() ? 1 : 0);
std::cout << " item " << i << " is "
@@ -246,7 +246,7 @@ test_0_1(QPDF& pdf, char const* arg2)
} else if (qtest.isDictionary()) {
QTC::TC("qpdf", "main QTest dictionary");
std::cout << "/QTest is a dictionary" << std::endl;
- for (auto& iter : qtest.ditems()) {
+ for (auto& iter: qtest.ditems()) {
QTC::TC(
"qpdf",
"main QTest dictionary indirect",
@@ -393,7 +393,7 @@ test_5(QPDF& pdf, char const* arg2)
std::cout << " images:" << std::endl;
std::map<std::string, QPDFObjectHandle> images = page.getImages();
- for (auto const& iter2 : images) {
+ for (auto const& iter2: images) {
std::string const& name = iter2.first;
QPDFObjectHandle image = iter2.second;
QPDFObjectHandle dict = image.getDict();
@@ -405,7 +405,7 @@ test_5(QPDF& pdf, char const* arg2)
std::cout << " content:" << std::endl;
std::vector<QPDFObjectHandle> content = page.getPageContents();
- for (auto& iter2 : content) {
+ for (auto& iter2: content) {
std::cout << " " << iter2.unparse() << std::endl;
}
@@ -1663,12 +1663,12 @@ test_46(QPDF& pdf, char const* arg2)
// number-tree.pdf
QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest");
QPDFNumberTreeObjectHelper ntoh(qtest, pdf);
- for (auto& iter : ntoh) {
+ for (auto& iter: ntoh) {
std::cout << iter.first << " " << iter.second.getStringValue()
<< std::endl;
}
QPDFNumberTreeObjectHelper::idx_map ntoh_map = ntoh.getAsMap();
- for (auto& iter : ntoh_map) {
+ for (auto& iter: ntoh_map) {
std::cout << iter.first << " " << iter.second.getStringValue()
<< std::endl;
}
@@ -1724,7 +1724,7 @@ test_46(QPDF& pdf, char const* arg2)
assert(iter2->first == 3);
iter2.insertAfter(4, QPDFObjectHandle::newString("4!"));
assert(iter2->first == 4);
- for (auto& i : new2) {
+ for (auto& i: new2) {
std::cout << i.first << " " << i.second.unparse() << std::endl;
}
@@ -1737,12 +1737,12 @@ test_46(QPDF& pdf, char const* arg2)
std::cout << "/Bad2" << std::endl;
auto bad2 =
QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad2"), pdf);
- for (auto& i : bad2) {
+ for (auto& i: bad2) {
std::cout << i.first << " " << i.second.unparse() << std::endl;
}
std::vector<std::string> empties = {"/Empty1", "/Empty2"};
- for (auto const& k : empties) {
+ for (auto const& k: empties) {
std::cout << k << std::endl;
auto empty =
QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey(k), pdf);
@@ -1777,14 +1777,14 @@ test_46(QPDF& pdf, char const* arg2)
std::cout << "/Bad3, no repair" << std::endl;
auto bad3_oh = pdf.getTrailer().getKey("/Bad3");
auto bad3 = QPDFNumberTreeObjectHelper(bad3_oh, pdf, false);
- for (auto& i : bad3) {
+ for (auto& i: bad3) {
std::cout << i.first << " " << i.second.unparse() << std::endl;
}
assert(!bad3_oh.getKey("/Kids").getArrayItem(0).isIndirect());
std::cout << "/Bad3, repair" << std::endl;
bad3 = QPDFNumberTreeObjectHelper(bad3_oh, pdf, true);
- for (auto& i : bad3) {
+ for (auto& i: bad3) {
std::cout << i.first << " " << i.second.unparse() << std::endl;
}
assert(bad3_oh.getKey("/Kids").getArrayItem(0).isIndirect());
@@ -1793,7 +1793,7 @@ test_46(QPDF& pdf, char const* arg2)
auto bad4 =
QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad4"), pdf);
bad4.insert(5, QPDFObjectHandle::newString("5"));
- for (auto& i : bad4) {
+ for (auto& i: bad4) {
std::cout << i.first << " " << i.second.unparse() << std::endl;
}
@@ -1826,12 +1826,12 @@ test_48(QPDF& pdf, char const* arg2)
// name-tree.pdf
QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest");
QPDFNameTreeObjectHelper ntoh(qtest, pdf);
- for (auto& iter : ntoh) {
+ for (auto& iter: ntoh) {
std::cout << iter.first << " -> " << iter.second.getStringValue()
<< std::endl;
}
std::map<std::string, QPDFObjectHandle> ntoh_map = ntoh.getAsMap();
- for (auto& iter : ntoh_map) {
+ for (auto& iter: ntoh_map) {
std::cout << iter.first << " -> " << iter.second.getStringValue()
<< std::endl;
}
@@ -1884,12 +1884,12 @@ test_48(QPDF& pdf, char const* arg2)
assert(iter2->first == "3");
iter2.insertAfter("4", QPDFObjectHandle::newString("4!"));
assert(iter2->first == "4");
- for (auto& i : new2) {
+ for (auto& i: new2) {
std::cout << i.first << " " << i.second.unparse() << std::endl;
}
std::vector<std::string> empties = {"/Empty1", "/Empty2"};
- for (auto const& k : empties) {
+ for (auto const& k: empties) {
std::cout << k << std::endl;
auto empty = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey(k), pdf);
assert(empty.begin() == empty.end());
@@ -1915,14 +1915,14 @@ test_48(QPDF& pdf, char const* arg2)
std::cout << "/Bad1 -- wrong key type" << std::endl;
auto bad1 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
assert(bad1.find("G", true)->first == "A");
- for (auto const& i : bad1) {
+ for (auto const& i: bad1) {
std::cout << i.first << std::endl;
}
std::cout << "/Bad2 -- invalid kid" << std::endl;
auto bad2 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad2"), pdf);
assert(bad2.find("G", true)->first == "B");
- for (auto const& i : bad2) {
+ for (auto const& i: bad2) {
std::cout << i.first << std::endl;
}
@@ -1933,7 +1933,7 @@ test_48(QPDF& pdf, char const* arg2)
std::cout << "/Bad4 -- invalid kid" << std::endl;
auto bad4 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad4"), pdf);
assert(bad4.find("F", true)->first == "C");
- for (auto const& i : bad4) {
+ for (auto const& i: bad4) {
std::cout << i.first << std::endl;
}
@@ -2230,9 +2230,9 @@ test_60(QPDF& pdf, char const* arg2)
std::map<std::string, std::map<std::string, std::string>> conflicts;
auto show_conflicts = [&](std::string const& msg) {
std::cout << msg << std::endl;
- for (auto const& i1 : conflicts) {
+ for (auto const& i1: conflicts) {
std::cout << i1.first << ":" << std::endl;
- for (auto const& i2 : i1.second) {
+ for (auto const& i2: i1.second) {
std::cout << " " << i2.first << " -> " << i2.second
<< std::endl;
}
@@ -2510,19 +2510,19 @@ test_71(QPDF& pdf, char const* arg2)
std::cout << "--- non-recursive, all, from fx1 ---" << std::endl;
fx1.forEachXObject(false, show);
std::cout << "--- get images, page ---" << std::endl;
- for (auto& i : page.getImages()) {
+ for (auto& i: page.getImages()) {
std::cout << i.first << " -> " << i.second.unparse() << std::endl;
}
std::cout << "--- get images, fx ---" << std::endl;
- for (auto& i : fx1.getImages()) {
+ for (auto& i: fx1.getImages()) {
std::cout << i.first << " -> " << i.second.unparse() << std::endl;
}
std::cout << "--- get form XObjects, page ---" << std::endl;
- for (auto& i : page.getFormXObjects()) {
+ for (auto& i: page.getFormXObjects()) {
std::cout << i.first << " -> " << i.second.unparse() << std::endl;
}
std::cout << "--- get form XObjects, fx ---" << std::endl;
- for (auto& i : fx1.getFormXObjects()) {
+ for (auto& i: fx1.getFormXObjects()) {
std::cout << i.first << " -> " << i.second.unparse() << std::endl;
}
}
@@ -2591,7 +2591,7 @@ test_74(QPDF& pdf, char const* arg2)
check_split1(15);
check_split1(35);
check_split1(125);
- for (auto const& i : split1) {
+ for (auto const& i: split1) {
std::cout << i.first << std::endl;
}
@@ -2605,7 +2605,7 @@ test_74(QPDF& pdf, char const* arg2)
assert(i->first == k);
};
check_split2(split2, "C");
- for (auto const& i : split2) {
+ for (auto const& i: split2) {
std::cout << i.first << std::endl;
}
@@ -2615,7 +2615,7 @@ test_74(QPDF& pdf, char const* arg2)
split3.setSplitThreshold(4);
check_split2(split3, "P");
check_split2(split3, "\xcf\x80");
- for (auto& i : split3) {
+ for (auto& i: split3) {
std::cout << i.first << " " << i.second.unparse() << std::endl;
}
@@ -2722,7 +2722,7 @@ test_76(QPDF& pdf, char const* arg2)
QUtil::hex_encode(efs2.getChecksum()) ==
"2fce9c8228e360ba9b04a1bd1bf63d6b");
- for (auto iter : efdh.getEmbeddedFiles()) {
+ for (auto iter: efdh.getEmbeddedFiles()) {
std::cout << iter.first << " -> " << iter.second->getFilename()
<< std::endl;
}
@@ -2831,7 +2831,7 @@ test_79(QPDF& pdf, char const* arg2)
"/Originals", QPDFObjectHandle::newArray(streams));
int i = 0;
- for (auto orig : streams) {
+ for (auto orig: streams) {
++i;
auto istr = QUtil::int_to_string(i);
auto orig_data = orig.getStreamData();
@@ -2879,7 +2879,7 @@ test_80(QPDF& pdf, char const* arg2)
// Use defaults for from_qpdf and from_afdh.
afdh.transformAnnotations(
old_annots, new_annots, new_fields, old_fields, m);
- for (auto const& annot : new_annots) {
+ for (auto const& annot: new_annots) {
old_annots.appendItem(annot);
}
afdh.addAndRenameFormFields(new_fields);