aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
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 /libqpdf
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
Diffstat (limited to 'libqpdf')
-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
19 files changed, 97 insertions, 97 deletions
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 {