Commit 7f023701dd843749cf878baabeb3d33917fda62f

Authored by Jay Berkenbilt
1 parent 2878c186

Formatting: remove space in range-style for loops

Change .clang-format and commit automated changes from a fresh run of
format-code
.clang-format
... ... @@ -44,4 +44,7 @@ KeepEmptyLinesAtTheStartOfBlocks: false
44 44 NamespaceIndentation: All
45 45 PointerAlignment: Left
46 46 PPIndentWidth: 1
  47 +SpaceBeforeCaseColon: false
  48 +SpaceBeforeCtorInitializerColon: true
47 49 SpaceBeforeInheritanceColon: false
  50 +SpaceBeforeRangeBasedForLoopColon: false
... ...
examples/pdf-bookmarks.cc
... ... @@ -53,7 +53,7 @@ generate_page_map(QPDF& qpdf)
53 53 {
54 54 QPDFPageDocumentHelper dh(qpdf);
55 55 int n = 0;
56   - for (auto const& page : dh.getAllPages()) {
  56 + for (auto const& page: dh.getAllPages()) {
57 57 page_map[page.getObjectHandle().getObjGen()] = ++n;
58 58 }
59 59 }
... ... @@ -69,7 +69,7 @@ show_bookmark_details(QPDFOutlineObjectHelper outline, std::vector<int> numbers)
69 69  
70 70 case st_numbers:
71 71 QTC::TC("examples", "pdf-bookmarks numbers");
72   - for (auto const& number : numbers) {
  72 + for (auto const& number: numbers) {
73 73 std::cout << number << ".";
74 74 }
75 75 std::cout << " ";
... ... @@ -130,7 +130,7 @@ extract_bookmarks(
130 130 // is, so we count up to zero.
131 131 numbers.push_back(
132 132 (style == st_lines) ? -QIntC::to_int(outlines.size()) : 0);
133   - for (auto& outline : outlines) {
  133 + for (auto& outline: outlines) {
134 134 ++(numbers.back());
135 135 show_bookmark_details(outline, numbers);
136 136 extract_bookmarks(outline.getKids(), numbers);
... ...
examples/pdf-count-strings.cc
... ... @@ -82,7 +82,7 @@ main(int argc, char* argv[])
82 82 QPDF pdf;
83 83 pdf.processFile(infilename);
84 84 int pageno = 0;
85   - for (auto& page : QPDFPageDocumentHelper(pdf).getAllPages()) {
  85 + for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) {
86 86 ++pageno;
87 87 // Pass the contents of a page through our string counter.
88 88 // If it's an even page, capture the output. This
... ...
examples/pdf-create.cc
... ... @@ -253,7 +253,7 @@ check(
253 253 }
254 254 size_t pageno = 1;
255 255 bool errors = false;
256   - for (auto& page : pages) {
  256 + for (auto& page: pages) {
257 257 auto images = page.getImages();
258 258 if (images.size() != 1) {
259 259 throw std::logic_error("incorrect number of images on page");
... ... @@ -368,8 +368,8 @@ create_pdf(char const* filename)
368 368 filters.push_back("/DCTDecode");
369 369 filters.push_back("/RunLengthDecode");
370 370 QPDFPageDocumentHelper dh(pdf);
371   - for (auto const& color_space : color_spaces) {
372   - for (auto const& filter : filters) {
  371 + for (auto const& color_space: color_spaces) {
  372 + for (auto const& filter: filters) {
373 373 add_page(dh, font, color_space, filter);
374 374 }
375 375 }
... ...
examples/pdf-custom-filter.cc
... ... @@ -357,7 +357,7 @@ StreamReplacer::registerStream(
357 357 this->copied_streams[og] = stream.copyStream();
358 358 // Update the stream dictionary with any changes.
359 359 auto dict = stream.getDict();
360   - for (auto const& k : dict_updates.getKeys()) {
  360 + for (auto const& k: dict_updates.getKeys()) {
361 361 dict.replaceKey(k, dict_updates.getKey(k));
362 362 }
363 363 // Create the key stream that will be referenced from
... ... @@ -414,7 +414,7 @@ process(
414 414 StreamReplacer* replacer = new StreamReplacer(&qpdf);
415 415 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> p(replacer);
416 416  
417   - for (auto& o : qpdf.getAllObjects()) {
  417 + for (auto& o: qpdf.getAllObjects()) {
418 418 if (o.isStream()) {
419 419 // Call registerStream for every stream. Only ones that
420 420 // registerStream decides to replace will actually be
... ...
examples/pdf-double-page-size.cc
... ... @@ -37,7 +37,7 @@ doubleBoxSize(QPDFPageObjectHelper&amp; page, char const* box_name)
37 37 " is not an array of four elements");
38 38 }
39 39 std::vector<QPDFObjectHandle> doubled;
40   - for (auto& item : box.aitems()) {
  40 + for (auto& item: box.aitems()) {
41 41 doubled.push_back(
42 42 QPDFObjectHandle::newReal(item.getNumericValue() * 2.0, 2));
43 43 }
... ... @@ -73,7 +73,7 @@ main(int argc, char* argv[])
73 73 QPDF qpdf;
74 74 qpdf.processFile(infilename, password);
75 75  
76   - for (auto& page : QPDFPageDocumentHelper(qpdf).getAllPages()) {
  76 + for (auto& page: QPDFPageDocumentHelper(qpdf).getAllPages()) {
77 77 // Prepend the buffer to the page's contents
78 78 page.addPageContents(
79 79 QPDFObjectHandle::newStream(&qpdf, content), true);
... ...
examples/pdf-invert-images.cc
... ... @@ -137,7 +137,7 @@ main(int argc, char* argv[])
137 137 QPDFPageObjectHelper& page(*iter);
138 138 // Get all images on the page.
139 139 std::map<std::string, QPDFObjectHandle> images = page.getImages();
140   - for (auto& iter2 : images) {
  140 + for (auto& iter2: images) {
141 141 QPDFObjectHandle& image = iter2.second;
142 142 QPDFObjectHandle image_dict = image.getDict();
143 143 QPDFObjectHandle color_space = image_dict.getKey("/ColorSpace");
... ...
examples/pdf-mod-info.cc
... ... @@ -31,7 +31,7 @@ dumpInfoDict(
31 31 {
32 32 QPDFObjectHandle trailer = pdf.getTrailer();
33 33 if (trailer.hasKey("/Info")) {
34   - for (auto& it : trailer.getKey("/Info").ditems()) {
  34 + for (auto& it: trailer.getKey("/Info").ditems()) {
35 35 std::string val;
36 36 if (it.second.isString()) {
37 37 val = it.second.getStringValue();
... ...
examples/pdf-name-number-tree.cc
... ... @@ -77,7 +77,7 @@ main(int argc, char* argv[])
77 77  
78 78 // Use range-for iteration
79 79 std::cout << "Name tree items:" << std::endl;
80   - for (auto i : name_tree) {
  80 + for (auto i: name_tree) {
81 81 std::cout << " " << i.first << " -> " << i.second.unparse()
82 82 << std::endl;
83 83 }
... ... @@ -86,7 +86,7 @@ main(int argc, char* argv[])
86 86 // look at it using dictionary and array iterators.
87 87 std::cout << "Keys in name tree object:" << std::endl;
88 88 QPDFObjectHandle names;
89   - for (auto const& i : name_tree_oh.ditems()) {
  89 + for (auto const& i: name_tree_oh.ditems()) {
90 90 std::cout << i.first << std::endl;
91 91 if (i.first == "/Names") {
92 92 names = i.second;
... ... @@ -94,7 +94,7 @@ main(int argc, char* argv[])
94 94 }
95 95 // Values in names array:
96 96 std::cout << "Values in names:" << std::endl;
97   - for (auto& i : names.aitems()) {
  97 + for (auto& i: names.aitems()) {
98 98 std::cout << " " << i.unparse() << std::endl;
99 99 }
100 100  
... ... @@ -149,7 +149,7 @@ main(int argc, char* argv[])
149 149 }
150 150 std::cout << "Numbers:" << std::endl;
151 151 int n = 1;
152   - for (auto& i : number_tree) {
  152 + for (auto& i: number_tree) {
153 153 std::cout << i.first << " -> " << i.second.getUTF8Value();
154 154 if (n % 5) {
155 155 std::cout << ", ";
... ... @@ -172,7 +172,7 @@ main(int argc, char* argv[])
172 172 }
173 173 std::cout << "Numbers after filtering:" << std::endl;
174 174 n = 1;
175   - for (auto& i : number_tree) {
  175 + for (auto& i: number_tree) {
176 176 std::cout << i.first << " -> " << i.second.getUTF8Value();
177 177 if (n % 5) {
178 178 std::cout << ", ";
... ...
libqpdf/JSON.cc
... ... @@ -20,7 +20,7 @@ JSON::JSON_dictionary::unparse(size_t depth) const
20 20 {
21 21 std::string result = "{";
22 22 bool first = true;
23   - for (auto const& iter : members) {
  23 + for (auto const& iter: members) {
24 24 if (first) {
25 25 first = false;
26 26 } else {
... ... @@ -44,7 +44,7 @@ JSON::JSON_array::unparse(size_t depth) const
44 44 {
45 45 std::string result = "[";
46 46 bool first = true;
47   - for (auto const& element : elements) {
  47 + for (auto const& element: elements) {
48 48 if (first) {
49 49 first = false;
50 50 } else {
... ... @@ -304,7 +304,7 @@ JSON::forEachDictItem(
304 304 if (v == nullptr) {
305 305 return false;
306 306 }
307   - for (auto const& k : v->members) {
  307 + for (auto const& k: v->members) {
308 308 fn(k.first, JSON(k.second));
309 309 }
310 310 return true;
... ... @@ -317,7 +317,7 @@ JSON::forEachArrayItem(std::function&lt;void(JSON value)&gt; fn) const
317 317 if (v == nullptr) {
318 318 return false;
319 319 }
320   - for (auto const& i : v->elements) {
  320 + for (auto const& i: v->elements) {
321 321 fn(JSON(i));
322 322 }
323 323 return true;
... ... @@ -379,7 +379,7 @@ JSON::checkSchemaInternal(
379 379  
380 380 if (sch_dict && (!pattern_key.empty())) {
381 381 auto pattern_schema = sch_dict->members[pattern_key].get();
382   - for (auto const& iter : this_dict->members) {
  382 + for (auto const& iter: this_dict->members) {
383 383 std::string const& key = iter.first;
384 384 checkSchemaInternal(
385 385 this_dict->members[key].get(),
... ... @@ -389,7 +389,7 @@ JSON::checkSchemaInternal(
389 389 prefix + "." + key);
390 390 }
391 391 } else if (sch_dict) {
392   - for (auto& iter : sch_dict->members) {
  392 + for (auto& iter: sch_dict->members) {
393 393 std::string const& key = iter.first;
394 394 if (this_dict->members.count(key)) {
395 395 checkSchemaInternal(
... ... @@ -409,7 +409,7 @@ JSON::checkSchemaInternal(
409 409 }
410 410 }
411 411 }
412   - for (auto const& iter : this_dict->members) {
  412 + for (auto const& iter: this_dict->members) {
413 413 std::string const& key = iter.first;
414 414 if (sch_dict->members.count(key) == 0) {
415 415 QTC::TC("libtests", "JSON key extra in object");
... ... @@ -431,7 +431,7 @@ JSON::checkSchemaInternal(
431 431 return false;
432 432 }
433 433 int i = 0;
434   - for (auto const& element : this_arr->elements) {
  434 + for (auto const& element: this_arr->elements) {
435 435 checkSchemaInternal(
436 436 element.get(),
437 437 sch_arr->elements.at(0).get(),
... ...
libqpdf/NNTree.cc
... ... @@ -640,7 +640,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
640 640 bool failed = false;
641 641  
642 642 std::set<QPDFObjGen> seen;
643   - for (auto i : this->path) {
  643 + for (auto i: this->path) {
644 644 if (i.node.isIndirect()) {
645 645 seen.insert(i.node.getObjGen());
646 646 }
... ... @@ -881,7 +881,7 @@ NNTreeImpl::repair()
881 881 auto new_node = QPDFObjectHandle::newDictionary();
882 882 new_node.replaceKey(details.itemsKey(), QPDFObjectHandle::newArray());
883 883 NNTreeImpl repl(details, qpdf, new_node, false);
884   - for (auto const& i : *this) {
  884 + for (auto const& i: *this) {
885 885 repl.insert(i.first, i.second);
886 886 }
887 887 this->oh.replaceKey("/Kids", new_node.getKey("/Kids"))
... ...
libqpdf/QPDF.cc
... ... @@ -2436,7 +2436,7 @@ QPDF::replaceForeignIndirectObjects(
2436 2436 QTC::TC("qpdf", "QPDF replace dictionary");
2437 2437 result = QPDFObjectHandle::newDictionary();
2438 2438 std::set<std::string> keys = foreign.getKeys();
2439   - for (auto const& iter : keys) {
  2439 + for (auto const& iter: keys) {
2440 2440 result.replaceKey(
2441 2441 iter,
2442 2442 replaceForeignIndirectObjects(
... ... @@ -2450,7 +2450,7 @@ QPDF::replaceForeignIndirectObjects(
2450 2450 QPDFObjectHandle dict = result.getDict();
2451 2451 QPDFObjectHandle old_dict = foreign.getDict();
2452 2452 std::set<std::string> keys = old_dict.getKeys();
2453   - for (auto const& iter : keys) {
  2453 + for (auto const& iter: keys) {
2454 2454 dict.replaceKey(
2455 2455 iter,
2456 2456 replaceForeignIndirectObjects(
... ...
libqpdf/QPDFAcroFormDocumentHelper.cc
... ... @@ -82,7 +82,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(
82 82 seen.insert(og);
83 83 auto kids = obj.getKey("/Kids");
84 84 if (kids.isArray()) {
85   - for (auto kid : kids.aitems()) {
  85 + for (auto kid: kids.aitems()) {
86 86 queue.push_back(kid);
87 87 }
88 88 }
... ... @@ -119,7 +119,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(
119 119 }
120 120 }
121 121  
122   - for (auto i : fields) {
  122 + for (auto i: fields) {
123 123 addFormField(i);
124 124 }
125 125 }
... ... @@ -137,10 +137,10 @@ QPDFAcroFormDocumentHelper::removeFormFields(
137 137 return;
138 138 }
139 139  
140   - for (auto const& og : to_remove) {
  140 + for (auto const& og: to_remove) {
141 141 auto annotations = this->m->field_to_annotations.find(og);
142 142 if (annotations != this->m->field_to_annotations.end()) {
143   - for (auto aoh : annotations->second) {
  143 + for (auto aoh: annotations->second) {
144 144 this->m->annotation_to_field.erase(
145 145 aoh.getObjectHandle().getObjGen());
146 146 }
... ... @@ -229,7 +229,7 @@ QPDFAcroFormDocumentHelper::getFormFieldsForPage(QPDFPageObjectHelper ph)
229 229 std::set<QPDFObjGen> added;
230 230 std::vector<QPDFFormFieldObjectHelper> result;
231 231 auto widget_annotations = getWidgetAnnotationsForPage(ph);
232   - for (auto annot : widget_annotations) {
  232 + for (auto annot: widget_annotations) {
233 233 auto field = getFieldForAnnotation(annot);
234 234 field = field.getTopLevelField();
235 235 auto og = field.getObjectHandle().getObjGen();
... ... @@ -576,21 +576,21 @@ ResourceReplacer::ResourceReplacer(
576 576 // We want:
577 577 // * to_replace[key][offset] = new_key
578 578  
579   - for (auto const& rn_iter : rnames) {
  579 + for (auto const& rn_iter: rnames) {
580 580 std::string const& rtype = rn_iter.first;
581 581 auto dr_map_rtype = dr_map.find(rtype);
582 582 if (dr_map_rtype == dr_map.end()) {
583 583 continue;
584 584 }
585 585 auto const& key_offsets = rn_iter.second;
586   - for (auto const& ko_iter : key_offsets) {
  586 + for (auto const& ko_iter: key_offsets) {
587 587 std::string const& old_key = ko_iter.first;
588 588 auto dr_map_rtype_old = dr_map_rtype->second.find(old_key);
589 589 if (dr_map_rtype_old == dr_map_rtype->second.end()) {
590 590 continue;
591 591 }
592 592 auto const& offsets = ko_iter.second;
593   - for (auto const& o_iter : offsets) {
  593 + for (auto const& o_iter: offsets) {
594 594 to_replace[old_key][o_iter] = dr_map_rtype_old->second;
595 595 }
596 596 }
... ... @@ -719,19 +719,19 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
719 719 // this to resolve conflicts that may already be in the resource
720 720 // dictionary.
721 721 auto merge_with = QPDFObjectHandle::newDictionary();
722   - for (auto const& top_key : dr_map) {
  722 + for (auto const& top_key: dr_map) {
723 723 merge_with.replaceKey(top_key.first, QPDFObjectHandle::newDictionary());
724 724 }
725 725 resources.mergeResources(merge_with);
726 726 // Rename any keys in the resource dictionary that we
727 727 // remapped.
728   - for (auto const& i1 : dr_map) {
  728 + for (auto const& i1: dr_map) {
729 729 std::string const& top_key = i1.first;
730 730 auto subdict = resources.getKey(top_key);
731 731 if (!subdict.isDictionary()) {
732 732 continue;
733 733 }
734   - for (auto const& i2 : i1.second) {
  734 + for (auto const& i2: i1.second) {
735 735 std::string const& old_key = i2.first;
736 736 std::string const& new_key = i2.second;
737 737 auto existing_new = subdict.getKey(new_key);
... ... @@ -757,7 +757,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
757 757 // the stream contents.
758 758 resources.mergeResources(merge_with, &dr_map);
759 759 // Remove empty subdictionaries
760   - for (auto iter : resources.ditems()) {
  760 + for (auto iter: resources.ditems()) {
761 761 if (iter.second.isDictionary() && (iter.second.getKeys().size() == 0)) {
762 762 resources.removeKey(iter.first);
763 763 }
... ... @@ -911,7 +911,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
911 911 // Now do the actual copies.
912 912  
913 913 std::set<QPDFObjGen> added_new_fields;
914   - for (auto annot : old_annots.aitems()) {
  914 + for (auto annot: old_annots.aitems()) {
915 915 if (annot.isStream()) {
916 916 annot.warnIfPossible("ignoring annotation that's a stream");
917 917 continue;
... ... @@ -1101,12 +1101,12 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
1101 1101 return dict.replaceKeyAndGet(key, old.copyStream());
1102 1102 };
1103 1103 if (apdict.isDictionary()) {
1104   - for (auto& ap : apdict.ditems()) {
  1104 + for (auto& ap: apdict.ditems()) {
1105 1105 if (ap.second.isStream()) {
1106 1106 streams.push_back(
1107 1107 replace_stream(apdict, ap.first, ap.second));
1108 1108 } else if (ap.second.isDictionary()) {
1109   - for (auto& ap2 : ap.second.ditems()) {
  1109 + for (auto& ap2: ap.second.ditems()) {
1110 1110 if (ap2.second.isStream()) {
1111 1111 streams.push_back(
1112 1112 // line-break
... ... @@ -1120,7 +1120,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
1120 1120  
1121 1121 // Now we can safely mutate the annotation and its appearance
1122 1122 // streams.
1123   - for (auto& stream : streams) {
  1123 + for (auto& stream: streams) {
1124 1124 auto dict = stream.getDict();
1125 1125 auto omatrix = dict.getKey("/Matrix");
1126 1126 QPDFMatrix apcm;
... ... @@ -1172,7 +1172,7 @@ QPDFAcroFormDocumentHelper::fixCopiedAnnotations(
1172 1172 to_page.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots));
1173 1173 addAndRenameFormFields(new_fields);
1174 1174 if (added_fields) {
1175   - for (auto f : new_fields) {
  1175 + for (auto f: new_fields) {
1176 1176 added_fields->insert(f.getObjGen());
1177 1177 }
1178 1178 }
... ...
libqpdf/QPDFArgParser.cc
... ... @@ -381,7 +381,7 @@ QPDFArgParser::readArgsFromFile(std::string const&amp; filename)
381 381 QTC::TC("libtests", "QPDFArgParser read args from file");
382 382 lines = QUtil::read_lines_from_file(filename.c_str());
383 383 }
384   - for (auto const& line : lines) {
  384 + for (auto const& line: lines) {
385 385 this->m->new_argv.push_back(QUtil::make_shared_cstr(line));
386 386 }
387 387 }
... ... @@ -636,7 +636,7 @@ QPDFArgParser::addChoicesToCompletions(
636 636 void
637 637 QPDFArgParser::addOptionsToCompletions(option_table_t& option_table)
638 638 {
639   - for (auto& iter : option_table) {
  639 + for (auto& iter: option_table) {
640 640 std::string const& arg = iter.first;
641 641 if (arg == "--") {
642 642 continue;
... ... @@ -797,7 +797,7 @@ QPDFArgParser::getTopHelp(std::ostringstream&amp; msg)
797 797 << " --help=all\" to see all available help." << std::endl
798 798 << std::endl
799 799 << "Topics:" << std::endl;
800   - for (auto const& i : this->m->help_topics) {
  800 + for (auto const& i: this->m->help_topics) {
801 801 msg << " " << i.first << ": " << i.second.short_text << std::endl;
802 802 }
803 803 }
... ... @@ -807,7 +807,7 @@ QPDFArgParser::getAllHelp(std::ostringstream&amp; msg)
807 807 {
808 808 getTopHelp(msg);
809 809 auto show = [this, &msg](std::map<std::string, HelpTopic>& topics) {
810   - for (auto const& i : topics) {
  810 + for (auto const& i: topics) {
811 811 auto const& topic = i.first;
812 812 msg << std::endl
813 813 << "== " << topic << " (" << i.second.short_text
... ... @@ -832,7 +832,7 @@ QPDFArgParser::getTopicHelp(
832 832 }
833 833 if (!ht.options.empty()) {
834 834 msg << std::endl << "Related options:" << std::endl;
835   - for (auto const& i : ht.options) {
  835 + for (auto const& i: ht.options) {
836 836 msg << " " << i << ": " << this->m->option_help[i].short_text
837 837 << std::endl;
838 838 }
... ...
libqpdf/QPDFCryptoProvider.cc
... ... @@ -106,7 +106,7 @@ QPDFCryptoProvider::getRegisteredImpls()
106 106 {
107 107 std::set<std::string> result;
108 108 QPDFCryptoProvider& p = getInstance();
109   - for (auto const& iter : p.m->providers) {
  109 + for (auto const& iter: p.m->providers) {
110 110 result.insert(iter.first);
111 111 }
112 112 return result;
... ...
libqpdf/QPDFEmbeddedFileDocumentHelper.cc
... ... @@ -92,7 +92,7 @@ QPDFEmbeddedFileDocumentHelper::getEmbeddedFiles()
92 92 {
93 93 std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>> result;
94 94 if (this->m->embedded_files) {
95   - for (auto const& i : *(this->m->embedded_files)) {
  95 + for (auto const& i: *(this->m->embedded_files)) {
96 96 result[i.first] =
97 97 std::make_shared<QPDFFileSpecObjectHelper>(i.second);
98 98 }
... ...
libqpdf/QPDFFileSpecObjectHelper.cc
... ... @@ -36,7 +36,7 @@ QPDFFileSpecObjectHelper::getDescription()
36 36 std::string
37 37 QPDFFileSpecObjectHelper::getFilename()
38 38 {
39   - for (auto const& i : name_keys) {
  39 + for (auto const& i: name_keys) {
40 40 auto k = this->oh.getKey(i);
41 41 if (k.isString()) {
42 42 return k.getUTF8Value();
... ... @@ -49,7 +49,7 @@ std::map&lt;std::string, std::string&gt;
49 49 QPDFFileSpecObjectHelper::getFilenames()
50 50 {
51 51 std::map<std::string, std::string> result;
52   - for (auto const& i : name_keys) {
  52 + for (auto const& i: name_keys) {
53 53 auto k = this->oh.getKey(i);
54 54 if (k.isString()) {
55 55 result[i] = k.getUTF8Value();
... ... @@ -68,7 +68,7 @@ QPDFFileSpecObjectHelper::getEmbeddedFileStream(std::string const&amp; key)
68 68 if (!key.empty()) {
69 69 return ef.getKey(key);
70 70 }
71   - for (auto const& i : name_keys) {
  71 + for (auto const& i: name_keys) {
72 72 auto k = ef.getKey(i);
73 73 if (k.isStream()) {
74 74 return k;
... ...
libqpdf/QPDFJob.cc
... ... @@ -940,7 +940,7 @@ QPDFJob::doShowPages(QPDF&amp; pdf)
940 940 std::map<std::string, QPDFObjectHandle> images = ph.getImages();
941 941 if (!images.empty()) {
942 942 cout << " images:" << std::endl;
943   - for (auto const& iter2 : images) {
  943 + for (auto const& iter2: images) {
944 944 std::string const& name = iter2.first;
945 945 QPDFObjectHandle image = iter2.second;
946 946 QPDFObjectHandle dict = image.getDict();
... ... @@ -954,7 +954,7 @@ QPDFJob::doShowPages(QPDF&amp; pdf)
954 954  
955 955 cout << " content:" << std::endl;
956 956 std::vector<QPDFObjectHandle> content = ph.getPageContents();
957   - for (auto& iter2 : content) {
  957 + for (auto& iter2: content) {
958 958 cout << " " << iter2.unparse() << std::endl;
959 959 }
960 960 }
... ... @@ -965,7 +965,7 @@ QPDFJob::doListAttachments(QPDF&amp; pdf)
965 965 {
966 966 QPDFEmbeddedFileDocumentHelper efdh(pdf);
967 967 if (efdh.hasEmbeddedFiles()) {
968   - for (auto const& i : efdh.getEmbeddedFiles()) {
  968 + for (auto const& i: efdh.getEmbeddedFiles()) {
969 969 std::string const& key = i.first;
970 970 auto efoh = i.second;
971 971 *(this->m->cout)
... ... @@ -979,12 +979,12 @@ QPDFJob::doListAttachments(QPDF&amp; pdf)
979 979 cout << " preferred name: " << efoh->getFilename()
980 980 << std::endl;
981 981 cout << " all names:" << std::endl;
982   - for (auto const& i2 : efoh->getFilenames()) {
  982 + for (auto const& i2: efoh->getFilenames()) {
983 983 cout << " " << i2.first << " -> " << i2.second
984 984 << std::endl;
985 985 }
986 986 cout << " all data streams:" << std::endl;
987   - for (auto i2 : efoh->getEmbeddedFileStreams().ditems()) {
  987 + for (auto i2: efoh->getEmbeddedFileStreams().ditems()) {
988 988 cout << " " << i2.first << " -> "
989 989 << i2.second.getObjGen() << std::endl;
990 990 }
... ... @@ -1032,7 +1032,7 @@ std::set&lt;QPDFObjGen&gt;
1032 1032 QPDFJob::getWantedJSONObjects()
1033 1033 {
1034 1034 std::set<QPDFObjGen> wanted_og;
1035   - for (auto const& iter : m->json_objects) {
  1035 + for (auto const& iter: m->json_objects) {
1036 1036 bool trailer;
1037 1037 int obj = 0;
1038 1038 int gen = 0;
... ... @@ -1077,7 +1077,7 @@ QPDFJob::doJSONObjectinfo(QPDF&amp; pdf, JSON&amp; j)
1077 1077 std::set<QPDFObjGen> wanted_og = getWantedJSONObjects();
1078 1078 JSON j_objectinfo =
1079 1079 j.addDictionaryMember("objectinfo", JSON::makeDictionary());
1080   - for (auto& obj : pdf.getAllObjects()) {
  1080 + for (auto& obj: pdf.getAllObjects()) {
1081 1081 if (all_objects || wanted_og.count(obj.getObjGen())) {
1082 1082 auto j_details = j_objectinfo.addDictionaryMember(
1083 1083 obj.unparse(), JSON::makeDictionary());
... ... @@ -1116,7 +1116,7 @@ QPDFJob::doJSONPages(QPDF&amp; pdf, JSON&amp; j)
1116 1116 j_page.addDictionaryMember("object", page.getJSON());
1117 1117 JSON j_images = j_page.addDictionaryMember("images", JSON::makeArray());
1118 1118 std::map<std::string, QPDFObjectHandle> images = ph.getImages();
1119   - for (auto const& iter2 : images) {
  1119 + for (auto const& iter2: images) {
1120 1120 JSON j_image = j_images.addArrayElement(JSON::makeDictionary());
1121 1121 j_image.addDictionaryMember("name", JSON::makeString(iter2.first));
1122 1122 QPDFObjectHandle image = iter2.second;
... ... @@ -1152,7 +1152,7 @@ QPDFJob::doJSONPages(QPDF&amp; pdf, JSON&amp; j)
1152 1152 JSON j_contents =
1153 1153 j_page.addDictionaryMember("contents", JSON::makeArray());
1154 1154 std::vector<QPDFObjectHandle> content = ph.getPageContents();
1155   - for (auto& iter2 : content) {
  1155 + for (auto& iter2: content) {
1156 1156 j_contents.addArrayElement(iter2.getJSON());
1157 1157 }
1158 1158 j_page.addDictionaryMember(
... ... @@ -1419,7 +1419,7 @@ QPDFJob::doJSONAttachments(QPDF&amp; pdf, JSON&amp; j)
1419 1419 JSON j_attachments =
1420 1420 j.addDictionaryMember("attachments", JSON::makeDictionary());
1421 1421 QPDFEmbeddedFileDocumentHelper efdh(pdf);
1422   - for (auto const& iter : efdh.getEmbeddedFiles()) {
  1422 + for (auto const& iter: efdh.getEmbeddedFiles()) {
1423 1423 std::string const& key = iter.first;
1424 1424 auto fsoh = iter.second;
1425 1425 auto j_details =
... ... @@ -2099,7 +2099,7 @@ QPDFJob::addAttachments(QPDF&amp; pdf)
2099 2099 maybe_set_pagemode(pdf, "/UseAttachments");
2100 2100 QPDFEmbeddedFileDocumentHelper efdh(pdf);
2101 2101 std::vector<std::string> duplicated_keys;
2102   - for (auto const& to_add : m->attachments_to_add) {
  2102 + for (auto const& to_add: m->attachments_to_add) {
2103 2103 if ((!to_add.replace) && efdh.getEmbeddedFile(to_add.key)) {
2104 2104 duplicated_keys.push_back(to_add.key);
2105 2105 continue;
... ... @@ -2125,7 +2125,7 @@ QPDFJob::addAttachments(QPDF&amp; pdf)
2125 2125  
2126 2126 if (!duplicated_keys.empty()) {
2127 2127 std::string message;
2128   - for (auto const& k : duplicated_keys) {
  2128 + for (auto const& k: duplicated_keys) {
2129 2129 if (!message.empty()) {
2130 2130 message += ", ";
2131 2131 }
... ... @@ -2144,7 +2144,7 @@ QPDFJob::copyAttachments(QPDF&amp; pdf)
2144 2144 maybe_set_pagemode(pdf, "/UseAttachments");
2145 2145 QPDFEmbeddedFileDocumentHelper efdh(pdf);
2146 2146 std::vector<std::string> duplicates;
2147   - for (auto const& to_copy : m->attachments_to_copy) {
  2147 + for (auto const& to_copy: m->attachments_to_copy) {
2148 2148 doIfVerbose([&](std::ostream& cout, std::string const& prefix) {
2149 2149 cout << prefix << ": copying attachments from " << to_copy.path
2150 2150 << std::endl;
... ... @@ -2153,7 +2153,7 @@ QPDFJob::copyAttachments(QPDF&amp; pdf)
2153 2153 processFile(to_copy.path.c_str(), to_copy.password.c_str(), false);
2154 2154 QPDFEmbeddedFileDocumentHelper other_efdh(*other);
2155 2155 auto other_attachments = other_efdh.getEmbeddedFiles();
2156   - for (auto const& iter : other_attachments) {
  2156 + for (auto const& iter: other_attachments) {
2157 2157 std::string new_key = to_copy.prefix + iter.first;
2158 2158 if (efdh.getEmbeddedFile(new_key)) {
2159 2159 duplicates.push_back(
... ... @@ -2177,7 +2177,7 @@ QPDFJob::copyAttachments(QPDF&amp; pdf)
2177 2177  
2178 2178 if (!duplicates.empty()) {
2179 2179 std::string message;
2180   - for (auto const& i : duplicates) {
  2180 + for (auto const& i: duplicates) {
2181 2181 if (!message.empty()) {
2182 2182 message += "; ";
2183 2183 }
... ... @@ -2223,7 +2223,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2223 2223 QPDFPageObjectHelper& ph(*iter);
2224 2224 QPDFObjectHandle page = ph.getObjectHandle();
2225 2225 std::map<std::string, QPDFObjectHandle> images = ph.getImages();
2226   - for (auto& iter2 : images) {
  2226 + for (auto& iter2: images) {
2227 2227 std::string name = iter2.first;
2228 2228 QPDFObjectHandle& image = iter2.second;
2229 2229 ImageOptimizer* io = new ImageOptimizer(
... ... @@ -2268,7 +2268,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2268 2268 }
2269 2269 if (m->flatten_rotation) {
2270 2270 make_afdh();
2271   - for (auto& page : dh.getAllPages()) {
  2271 + for (auto& page: dh.getAllPages()) {
2272 2272 page.flattenRotation(afdh.get());
2273 2273 }
2274 2274 }
... ... @@ -2277,7 +2277,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2277 2277 }
2278 2278 if (!m->attachments_to_remove.empty()) {
2279 2279 QPDFEmbeddedFileDocumentHelper efdh(pdf);
2280   - for (auto const& key : m->attachments_to_remove) {
  2280 + for (auto const& key: m->attachments_to_remove) {
2281 2281 if (efdh.removeEmbeddedFile(key)) {
2282 2282 doIfVerbose([&](std::ostream& cout, std::string const& prefix) {
2283 2283 cout << prefix << ": removed attachment " << key
... ... @@ -2386,7 +2386,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2386 2386 resources_seen.insert(xobject_og);
2387 2387 }
2388 2388 if (xobject.isDictionary()) {
2389   - for (auto const& k : xobject.getKeys()) {
  2389 + for (auto const& k: xobject.getKeys()) {
2390 2390 QPDFObjectHandle xobj = xobject.getKey(k);
2391 2391 if (xobj.isFormXObject()) {
2392 2392 queue.push_back(xobj);
... ... @@ -2443,7 +2443,7 @@ QPDFJob::handlePageSpecs(
2443 2443 // some portable heuristic based on OS limits, just hard-code
2444 2444 // this at a given number and allow users to override.
2445 2445 std::set<std::string> filenames;
2446   - for (auto& page_spec : m->page_specs) {
  2446 + for (auto& page_spec: m->page_specs) {
2447 2447 filenames.insert(page_spec.filename);
2448 2448 }
2449 2449 m->keep_files_open = (filenames.size() <= m->keep_files_open_threshold);
... ... @@ -2707,7 +2707,7 @@ QPDFJob::handlePageSpecs(
2707 2707 for (size_t pageno = 0; pageno < orig_pages.size(); ++pageno) {
2708 2708 auto page = orig_pages.at(pageno);
2709 2709 if (selected_from_orig.count(QIntC::to_int(pageno))) {
2710   - for (auto field : this_afdh->getFormFieldsForPage(page)) {
  2710 + for (auto field: this_afdh->getFormFieldsForPage(page)) {
2711 2711 QTC::TC("qpdf", "QPDFJob pages keeping field from original");
2712 2712 referenced_fields.insert(field.getObjectHandle().getObjGen());
2713 2713 }
... ... @@ -2726,7 +2726,7 @@ QPDFJob::handlePageSpecs(
2726 2726 if (fields.isIndirect()) {
2727 2727 new_fields = pdf.makeIndirectObject(new_fields);
2728 2728 }
2729   - for (auto const& field : fields.aitems()) {
  2729 + for (auto const& field: fields.aitems()) {
2730 2730 if (referenced_fields.count(field.getObjGen())) {
2731 2731 new_fields.appendItem(field);
2732 2732 }
... ...
libqpdf/QPDFJob_argv.cc
... ... @@ -167,7 +167,7 @@ ArgParser::argShowCrypto()
167 167 auto crypto = QPDFCryptoProvider::getRegisteredImpls();
168 168 std::string default_crypto = QPDFCryptoProvider::getDefaultProvider();
169 169 std::cout << default_crypto << std::endl;
170   - for (auto const& iter : crypto) {
  170 + for (auto const& iter: crypto) {
171 171 if (iter != default_crypto) {
172 172 std::cout << iter << std::endl;
173 173 }
... ...
libqpdf/QPDFJob_json.cc
... ... @@ -583,7 +583,7 @@ QPDFJob::initializeFromJson(std::string const&amp; json, bool partial)
583 583 if (!j.checkSchema(JOB_SCHEMA, JSON::f_optional, errors)) {
584 584 std::ostringstream msg;
585 585 msg << this->m->message_prefix << ": job json has errors:";
586   - for (auto const& error : errors) {
  586 + for (auto const& error: errors) {
587 587 msg << std::endl << " " << error;
588 588 }
589 589 throw std::runtime_error(msg.str());
... ...
libqpdf/QPDFObjectHandle.cc
... ... @@ -949,7 +949,7 @@ void
949 949 QPDFObjectHandle::setArrayFromVector(std::vector<QPDFObjectHandle> const& items)
950 950 {
951 951 if (isArray()) {
952   - for (auto const& item : items) {
  952 + for (auto const& item: items) {
953 953 checkOwnership(item);
954 954 }
955 955 dynamic_cast<QPDF_Array*>(obj.get())->setFromVector(items);
... ... @@ -1108,7 +1108,7 @@ QPDFObjectHandle::isOrHasName(std::string const&amp; value)
1108 1108 if (isNameAndEquals(value)) {
1109 1109 return true;
1110 1110 } else if (isArray()) {
1111   - for (auto& item : aitems()) {
  1111 + for (auto& item: aitems()) {
1112 1112 if (item.isNameAndEquals(value)) {
1113 1113 return true;
1114 1114 }
... ... @@ -1123,12 +1123,12 @@ QPDFObjectHandle::makeResourcesIndirect(QPDF&amp; owning_qpdf)
1123 1123 if (!isDictionary()) {
1124 1124 return;
1125 1125 }
1126   - for (auto const& i1 : ditems()) {
  1126 + for (auto const& i1: ditems()) {
1127 1127 QPDFObjectHandle sub = i1.second;
1128 1128 if (!sub.isDictionary()) {
1129 1129 continue;
1130 1130 }
1131   - for (auto i2 : sub.ditems()) {
  1131 + for (auto i2: sub.ditems()) {
1132 1132 std::string const& key = i2.first;
1133 1133 QPDFObjectHandle val = i2.second;
1134 1134 if (!val.isIndirect()) {
... ... @@ -1150,7 +1150,7 @@ QPDFObjectHandle::mergeResources(
1150 1150  
1151 1151 auto make_og_to_name = [](QPDFObjectHandle& dict,
1152 1152 std::map<QPDFObjGen, std::string>& og_to_name) {
1153   - for (auto i : dict.ditems()) {
  1153 + for (auto i: dict.ditems()) {
1154 1154 if (i.second.isIndirect()) {
1155 1155 og_to_name[i.second.getObjGen()] = i.first;
1156 1156 }
... ... @@ -1159,7 +1159,7 @@ QPDFObjectHandle::mergeResources(
1159 1159  
1160 1160 // This algorithm is described in comments in QPDFObjectHandle.hh
1161 1161 // above the declaration of mergeResources.
1162   - for (auto o_top : other.ditems()) {
  1162 + for (auto o_top: other.ditems()) {
1163 1163 std::string const& rtype = o_top.first;
1164 1164 QPDFObjectHandle other_val = o_top.second;
1165 1165 if (hasKey(rtype)) {
... ... @@ -1178,7 +1178,7 @@ QPDFObjectHandle::mergeResources(
1178 1178 std::set<std::string> rnames;
1179 1179 int min_suffix = 1;
1180 1180 bool initialized_maps = false;
1181   - for (auto ov_iter : other_val.ditems()) {
  1181 + for (auto ov_iter: other_val.ditems()) {
1182 1182 std::string const& key = ov_iter.first;
1183 1183 QPDFObjectHandle rval = ov_iter.second;
1184 1184 if (!this_val.hasKey(key)) {
... ... @@ -1212,12 +1212,12 @@ QPDFObjectHandle::mergeResources(
1212 1212 }
1213 1213 } else if (this_val.isArray() && other_val.isArray()) {
1214 1214 std::set<std::string> scalars;
1215   - for (auto this_item : this_val.aitems()) {
  1215 + for (auto this_item: this_val.aitems()) {
1216 1216 if (this_item.isScalar()) {
1217 1217 scalars.insert(this_item.unparse());
1218 1218 }
1219 1219 }
1220   - for (auto other_item : other_val.aitems()) {
  1220 + for (auto other_item: other_val.aitems()) {
1221 1221 if (other_item.isScalar()) {
1222 1222 if (scalars.count(other_item.unparse()) == 0) {
1223 1223 QTC::TC("qpdf", "QPDFObjectHandle merge array");
... ... @@ -2950,7 +2950,7 @@ QPDFObjectHandle::copyStream()
2950 2950 QPDFObjectHandle result = newStream(this->getOwningQPDF());
2951 2951 QPDFObjectHandle dict = result.getDict();
2952 2952 QPDFObjectHandle old_dict = getDict();
2953   - for (auto& iter : QPDFDictItems(old_dict)) {
  2953 + for (auto& iter: QPDFDictItems(old_dict)) {
2954 2954 if (iter.second.isIndirect()) {
2955 2955 dict.replaceKey(iter.first, iter.second);
2956 2956 } else {
... ...
libqpdf/QPDFPageObjectHelper.cc
... ... @@ -81,7 +81,7 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
81 81 dict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"))
82 82 .replaceKey("/Subtype", QPDFObjectHandle::newName("/Image"));
83 83 std::set<std::string> keys = odict.getKeys();
84   - for (auto key : keys) {
  84 + for (auto key: keys) {
85 85 QPDFObjectHandle value = odict.getKey(key);
86 86 if (key == "/BPC") {
87 87 key = "/BitsPerComponent";
... ... @@ -142,7 +142,7 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
142 142 } else if (value.isArray()) {
143 143 filters = value.getArrayAsVector();
144 144 }
145   - for (auto& iter : filters) {
  145 + for (auto& iter: filters) {
146 146 std::string name;
147 147 if (iter.isName()) {
148 148 name = iter.getName();
... ... @@ -334,7 +334,7 @@ QPDFPageObjectHelper::forEachXObject(
334 334 QPDFObjectHandle resources = ph.getAttribute("/Resources", false);
335 335 if (resources.isDictionary() && resources.hasKey("/XObject")) {
336 336 QPDFObjectHandle xobj_dict = resources.getKey("/XObject");
337   - for (auto const& key : xobj_dict.getKeys()) {
  337 + for (auto const& key: xobj_dict.getKeys()) {
338 338 QPDFObjectHandle obj = xobj_dict.getKey(key);
339 339 if ((!selector) || selector(obj)) {
340 340 action(obj, xobj_dict, key);
... ... @@ -594,7 +594,7 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
594 594 std::set<std::string> known_names;
595 595 std::vector<std::string> to_filter = {"/Font", "/XObject"};
596 596 if (resources.isDictionary()) {
597   - for (auto const& iter : to_filter) {
  597 + for (auto const& iter: to_filter) {
598 598 QPDFObjectHandle dict = resources.getKey(iter);
599 599 if (dict.isDictionary()) {
600 600 dict = resources.replaceKeyAndGet(iter, dict.shallowCopy());
... ... @@ -607,8 +607,8 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
607 607  
608 608 std::set<std::string> local_unresolved;
609 609 auto names_by_rtype = rf.getNamesByResourceType();
610   - for (auto const& i1 : to_filter) {
611   - for (auto const& n_iter : names_by_rtype[i1]) {
  610 + for (auto const& i1: to_filter) {
  611 + for (auto const& n_iter: names_by_rtype[i1]) {
612 612 std::string const& name = n_iter.first;
613 613 if (!known_names.count(name)) {
614 614 unresolved.insert(name);
... ... @@ -647,8 +647,8 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
647 647 return false;
648 648 }
649 649  
650   - for (auto& dict : rdicts) {
651   - for (auto const& key : dict.getKeys()) {
  650 + for (auto& dict: rdicts) {
  651 + for (auto const& key: dict.getKeys()) {
652 652 if (is_page && unresolved.count(key)) {
653 653 // This name is referenced by some nested form
654 654 // xobject, so don't remove it.
... ... @@ -946,7 +946,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
946 946 "/TrimBox",
947 947 "/ArtBox",
948 948 };
949   - for (auto const& boxkey : boxes) {
  949 + for (auto const& boxkey: boxes) {
950 950 auto box = this->oh.getKey(boxkey);
951 951 if (!box.isRectangle()) {
952 952 continue;
... ... @@ -1049,7 +1049,7 @@ QPDFPageObjectHelper::flattenRotation(QPDFAcroFormDocumentHelper* afdh)
1049 1049 afdh->transformAnnotations(
1050 1050 annots, new_annots, new_fields, old_fields, cm);
1051 1051 afdh->removeFormFields(old_fields);
1052   - for (auto const& f : new_fields) {
  1052 + for (auto const& f: new_fields) {
1053 1053 afdh->addFormField(QPDFFormFieldObjectHelper(f));
1054 1054 }
1055 1055 this->oh.replaceKey("/Annots", QPDFObjectHandle::newArray(new_annots));
... ... @@ -1115,7 +1115,7 @@ QPDFPageObjectHelper::copyAnnotations(
1115 1115 annots =
1116 1116 this->oh.replaceKeyAndGet("/Annots", QPDFObjectHandle::newArray());
1117 1117 }
1118   - for (auto const& annot : new_annots) {
  1118 + for (auto const& annot: new_annots) {
1119 1119 annots.appendItem(annot);
1120 1120 }
1121 1121 }
... ...
libqpdf/QPDFWriter.cc
... ... @@ -2252,7 +2252,7 @@ QPDFWriter::initializeSpecialStreams()
2252 2252 contents_objects.push_back(contents.getObjGen());
2253 2253 }
2254 2254  
2255   - for (auto const& c : contents_objects) {
  2255 + for (auto const& c: contents_objects) {
2256 2256 this->m->contents_to_page_seq[c] = num;
2257 2257 this->m->normalized_streams.insert(c);
2258 2258 }
... ... @@ -2287,7 +2287,7 @@ QPDFWriter::preserveObjectStreams()
2287 2287 "qpdf",
2288 2288 "QPDFWriter preserve object streams",
2289 2289 this->m->preserve_unreferenced_objects ? 0 : 1);
2290   - for (auto iter : omap) {
  2290 + for (auto iter: omap) {
2291 2291 QPDFObjGen og(iter.first, 0);
2292 2292 if (eligible.count(og) || this->m->preserve_unreferenced_objects) {
2293 2293 this->m->object_to_object_stream[og] = iter.second;
... ... @@ -2380,7 +2380,7 @@ QPDFWriter::prepareFileForWrite()
2380 2380  
2381 2381 this->m->pdf.fixDanglingReferences(true);
2382 2382 QPDFObjectHandle root = this->m->pdf.getRoot();
2383   - for (auto const& key : root.getKeys()) {
  2383 + for (auto const& key: root.getKeys()) {
2384 2384 QPDFObjectHandle oh = root.getKey(key);
2385 2385 if ((key == "/Extensions") && (oh.isDictionary())) {
2386 2386 bool extensions_indirect = false;
... ...
libqpdf/QPDF_Array.cc
... ... @@ -138,7 +138,7 @@ QPDF_Array::getElementsForShallowCopy() const
138 138 void
139 139 QPDF_Array::addExplicitElementsToList(std::list<QPDFObjectHandle>& l) const
140 140 {
141   - for (auto const& iter : this->elements) {
  141 + for (auto const& iter: this->elements) {
142 142 l.push_back(iter.second);
143 143 }
144 144 }
... ...
libqpdf/QPDF_Dictionary.cc
... ... @@ -24,7 +24,7 @@ std::string
24 24 QPDF_Dictionary::unparse()
25 25 {
26 26 std::string result = "<< ";
27   - for (auto& iter : this->items) {
  27 + for (auto& iter: this->items) {
28 28 if (!iter.second.isNull()) {
29 29 result += QPDF_Name::normalizeName(iter.first) + " " +
30 30 iter.second.unparse() + " ";
... ... @@ -38,7 +38,7 @@ JSON
38 38 QPDF_Dictionary::getJSON()
39 39 {
40 40 JSON j = JSON::makeDictionary();
41   - for (auto& iter : this->items) {
  41 + for (auto& iter: this->items) {
42 42 if (!iter.second.isNull()) {
43 43 j.addDictionaryMember(
44 44 QPDF_Name::normalizeName(iter.first), iter.second.getJSON());
... ... @@ -96,7 +96,7 @@ std::set&lt;std::string&gt;
96 96 QPDF_Dictionary::getKeys()
97 97 {
98 98 std::set<std::string> result;
99   - for (auto& iter : this->items) {
  99 + for (auto& iter: this->items) {
100 100 if (!iter.second.isNull()) {
101 101 result.insert(iter.first);
102 102 }
... ...
libqpdf/QPDF_Stream.cc
... ... @@ -34,7 +34,7 @@ namespace
34 34 return true;
35 35 }
36 36 bool filterable = true;
37   - for (auto const& key : decode_parms.getKeys()) {
  37 + for (auto const& key: decode_parms.getKeys()) {
38 38 if (((key == "/Type") || (key == "/Name")) &&
39 39 ((!decode_parms.hasKey("/Type")) ||
40 40 decode_parms.isDictionaryOfType(
... ... @@ -311,7 +311,7 @@ QPDF_Stream::filterable(
311 311  
312 312 bool filterable = true;
313 313  
314   - for (auto& filter_name : filter_names) {
  314 + for (auto& filter_name: filter_names) {
315 315 if (filter_abbreviations.count(filter_name)) {
316 316 QTC::TC("qpdf", "QPDF_Stream expand filter abbreviation");
317 317 filter_name = filter_abbreviations[filter_name];
... ...
libqpdf/SF_FlateLzwDecode.cc
... ... @@ -27,7 +27,7 @@ SF_FlateLzwDecode::setDecodeParms(QPDFObjectHandle decode_parms)
27 27  
28 28 bool filterable = true;
29 29 std::set<std::string> keys = decode_parms.getKeys();
30   - for (auto const& key : keys) {
  30 + for (auto const& key: keys) {
31 31 QPDFObjectHandle value = decode_parms.getKey(key);
32 32 if (key == "/Predictor") {
33 33 if (value.isInteger()) {
... ...
libqpdf/SparseOHArray.cc
... ... @@ -51,7 +51,7 @@ SparseOHArray::remove_last()
51 51 void
52 52 SparseOHArray::releaseResolved()
53 53 {
54   - for (auto& iter : this->elements) {
  54 + for (auto& iter: this->elements) {
55 55 QPDFObjectHandle::ReleaseResolver::releaseResolved(iter.second);
56 56 }
57 57 }
... ... @@ -76,7 +76,7 @@ SparseOHArray::erase(size_t idx)
76 76 throw std::logic_error("bounds error erasing item from SparseOHArray");
77 77 }
78 78 decltype(this->elements) dest;
79   - for (auto const& iter : this->elements) {
  79 + for (auto const& iter: this->elements) {
80 80 if (iter.first < idx) {
81 81 dest.insert(iter);
82 82 } else if (iter.first > idx) {
... ... @@ -97,7 +97,7 @@ SparseOHArray::insert(size_t idx, QPDFObjectHandle oh)
97 97 append(oh);
98 98 } else {
99 99 decltype(this->elements) dest;
100   - for (auto const& iter : this->elements) {
  100 + for (auto const& iter: this->elements) {
101 101 if (iter.first < idx) {
102 102 dest.insert(iter);
103 103 } else {
... ...
libtests/cxx11.cc
... ... @@ -122,7 +122,7 @@ do_iteration()
122 122 std::vector<int> v = {1, 2, 3, 4};
123 123 assert(v.size() == 4);
124 124 int sum = 0;
125   - for (auto& i : v) {
  125 + for (auto& i: v) {
126 126 sum += i;
127 127 }
128 128 assert(10 == sum);
... ... @@ -299,7 +299,7 @@ do_smart_pointers()
299 299 auto p1 = make_c(1);
300 300 C::check(1, 1, 1);
301 301 auto p2 = make_c_array({2, 3, 4, 5});
302   - for (auto i : {1, 2, 3, 4, 5}) {
  302 + for (auto i: {1, 2, 3, 4, 5}) {
303 303 C::check(5, i, 1);
304 304 }
305 305 {
... ...
libtests/nntree.cc
... ... @@ -61,7 +61,7 @@ test_bsearch()
61 61  
62 62 auto mk = [&q](std::vector<int> const& v) {
63 63 auto nums = QPDFObjectHandle::newArray();
64   - for (auto i : v) {
  64 + for (auto i: v) {
65 65 nums.appendItem(QPDFObjectHandle::newInteger(i))
66 66 .appendItem(QPDFObjectHandle::newString(
67 67 "-" + QUtil::int_to_string(i) + "-"));
... ... @@ -199,7 +199,7 @@ test_depth()
199 199  
200 200 QPDFNameTreeObjectHelper nh(n0, q);
201 201 std::cout << "--- forward ---" << std::endl;
202   - for (auto i : nh) {
  202 + for (auto i: nh) {
203 203 std::cout << i.first << " -> " << i.second.unparse() << std::endl;
204 204 }
205 205 std::cout << "--- backward ---" << std::endl;
... ...
qpdf/fix-qdf.cc
... ... @@ -112,7 +112,7 @@ QdfFixer::processLines(std::list&lt;std::string&gt;&amp; lines)
112 112 static std::regex re_dict_end("^>>\n$");
113 113  
114 114 lineno = 0;
115   - for (auto const& line : lines) {
  115 + for (auto const& line: lines) {
116 116 ++lineno;
117 117 last_offset = offset;
118 118 offset += QIntC::to_offset(line.length());
... ... @@ -151,7 +151,7 @@ QdfFixer::processLines(std::list&lt;std::string&gt;&amp; lines)
151 151 // index. Make sure we get at least 1 byte even if
152 152 // there are no object streams.
153 153 int max_objects = 1;
154   - for (auto const& e : xref) {
  154 + for (auto const& e: xref) {
155 155 if ((e.getType() == 2) &&
156 156 (e.getObjStreamIndex() > max_objects)) {
157 157 max_objects = e.getObjStreamIndex();
... ... @@ -218,7 +218,7 @@ QdfFixer::processLines(std::list&lt;std::string&gt;&amp; lines)
218 218 writeBinary(0, 1);
219 219 writeBinary(0, xref_f1_nbytes);
220 220 writeBinary(0, xref_f2_nbytes);
221   - for (auto const& x : xref) {
  221 + for (auto const& x: xref) {
222 222 unsigned long long f1 = 0;
223 223 unsigned long long f2 = 0;
224 224 unsigned int type = QIntC::to_uint(x.getType());
... ... @@ -268,7 +268,7 @@ QdfFixer::processLines(std::list&lt;std::string&gt;&amp; lines)
268 268 } else if (state == st_at_xref) {
269 269 auto n = xref.size();
270 270 std::cout << "0 " << 1 + n << "\n0000000000 65535 f \n";
271   - for (auto const& e : xref) {
  271 + for (auto const& e: xref) {
272 272 std::cout << QUtil::int_to_string(e.getOffset(), 10)
273 273 << " 00000 n \n";
274 274 }
... ... @@ -322,7 +322,7 @@ QdfFixer::writeOstream()
322 322 auto onum = ostream_id;
323 323 std::string offsets;
324 324 auto n = ostream_offsets.size();
325   - for (auto iter : ostream_offsets) {
  325 + for (auto iter: ostream_offsets) {
326 326 iter -= QIntC::to_offset(first);
327 327 ++onum;
328 328 offsets += QUtil::int_to_string(onum) + " " +
... ... @@ -341,11 +341,11 @@ QdfFixer::writeOstream()
341 341 dict_data += ">>\n";
342 342 offset_adjust += QIntC::to_offset(dict_data.length());
343 343 std::cout << dict_data << "stream\n" << offsets;
344   - for (auto const& o : ostream) {
  344 + for (auto const& o: ostream) {
345 345 std::cout << o;
346 346 }
347 347  
348   - for (auto const& o : ostream_discarded) {
  348 + for (auto const& o: ostream_discarded) {
349 349 offset -= QIntC::to_offset(o.length());
350 350 }
351 351 offset += offset_adjust;
... ...
qpdf/test_driver.cc
... ... @@ -235,7 +235,7 @@ test_0_1(QPDF&amp; pdf, char const* arg2)
235 235 std::cout << "/QTest is an array with " << qtest.getArrayNItems()
236 236 << " items" << std::endl;
237 237 int i = 0;
238   - for (auto& iter : qtest.aitems()) {
  238 + for (auto& iter: qtest.aitems()) {
239 239 QTC::TC(
240 240 "qpdf", "main QTest array indirect", iter.isIndirect() ? 1 : 0);
241 241 std::cout << " item " << i << " is "
... ... @@ -246,7 +246,7 @@ test_0_1(QPDF&amp; pdf, char const* arg2)
246 246 } else if (qtest.isDictionary()) {
247 247 QTC::TC("qpdf", "main QTest dictionary");
248 248 std::cout << "/QTest is a dictionary" << std::endl;
249   - for (auto& iter : qtest.ditems()) {
  249 + for (auto& iter: qtest.ditems()) {
250 250 QTC::TC(
251 251 "qpdf",
252 252 "main QTest dictionary indirect",
... ... @@ -393,7 +393,7 @@ test_5(QPDF&amp; pdf, char const* arg2)
393 393  
394 394 std::cout << " images:" << std::endl;
395 395 std::map<std::string, QPDFObjectHandle> images = page.getImages();
396   - for (auto const& iter2 : images) {
  396 + for (auto const& iter2: images) {
397 397 std::string const& name = iter2.first;
398 398 QPDFObjectHandle image = iter2.second;
399 399 QPDFObjectHandle dict = image.getDict();
... ... @@ -405,7 +405,7 @@ test_5(QPDF&amp; pdf, char const* arg2)
405 405  
406 406 std::cout << " content:" << std::endl;
407 407 std::vector<QPDFObjectHandle> content = page.getPageContents();
408   - for (auto& iter2 : content) {
  408 + for (auto& iter2: content) {
409 409 std::cout << " " << iter2.unparse() << std::endl;
410 410 }
411 411  
... ... @@ -1663,12 +1663,12 @@ test_46(QPDF&amp; pdf, char const* arg2)
1663 1663 // number-tree.pdf
1664 1664 QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest");
1665 1665 QPDFNumberTreeObjectHelper ntoh(qtest, pdf);
1666   - for (auto& iter : ntoh) {
  1666 + for (auto& iter: ntoh) {
1667 1667 std::cout << iter.first << " " << iter.second.getStringValue()
1668 1668 << std::endl;
1669 1669 }
1670 1670 QPDFNumberTreeObjectHelper::idx_map ntoh_map = ntoh.getAsMap();
1671   - for (auto& iter : ntoh_map) {
  1671 + for (auto& iter: ntoh_map) {
1672 1672 std::cout << iter.first << " " << iter.second.getStringValue()
1673 1673 << std::endl;
1674 1674 }
... ... @@ -1724,7 +1724,7 @@ test_46(QPDF&amp; pdf, char const* arg2)
1724 1724 assert(iter2->first == 3);
1725 1725 iter2.insertAfter(4, QPDFObjectHandle::newString("4!"));
1726 1726 assert(iter2->first == 4);
1727   - for (auto& i : new2) {
  1727 + for (auto& i: new2) {
1728 1728 std::cout << i.first << " " << i.second.unparse() << std::endl;
1729 1729 }
1730 1730  
... ... @@ -1737,12 +1737,12 @@ test_46(QPDF&amp; pdf, char const* arg2)
1737 1737 std::cout << "/Bad2" << std::endl;
1738 1738 auto bad2 =
1739 1739 QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad2"), pdf);
1740   - for (auto& i : bad2) {
  1740 + for (auto& i: bad2) {
1741 1741 std::cout << i.first << " " << i.second.unparse() << std::endl;
1742 1742 }
1743 1743  
1744 1744 std::vector<std::string> empties = {"/Empty1", "/Empty2"};
1745   - for (auto const& k : empties) {
  1745 + for (auto const& k: empties) {
1746 1746 std::cout << k << std::endl;
1747 1747 auto empty =
1748 1748 QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey(k), pdf);
... ... @@ -1777,14 +1777,14 @@ test_46(QPDF&amp; pdf, char const* arg2)
1777 1777 std::cout << "/Bad3, no repair" << std::endl;
1778 1778 auto bad3_oh = pdf.getTrailer().getKey("/Bad3");
1779 1779 auto bad3 = QPDFNumberTreeObjectHelper(bad3_oh, pdf, false);
1780   - for (auto& i : bad3) {
  1780 + for (auto& i: bad3) {
1781 1781 std::cout << i.first << " " << i.second.unparse() << std::endl;
1782 1782 }
1783 1783 assert(!bad3_oh.getKey("/Kids").getArrayItem(0).isIndirect());
1784 1784  
1785 1785 std::cout << "/Bad3, repair" << std::endl;
1786 1786 bad3 = QPDFNumberTreeObjectHelper(bad3_oh, pdf, true);
1787   - for (auto& i : bad3) {
  1787 + for (auto& i: bad3) {
1788 1788 std::cout << i.first << " " << i.second.unparse() << std::endl;
1789 1789 }
1790 1790 assert(bad3_oh.getKey("/Kids").getArrayItem(0).isIndirect());
... ... @@ -1793,7 +1793,7 @@ test_46(QPDF&amp; pdf, char const* arg2)
1793 1793 auto bad4 =
1794 1794 QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad4"), pdf);
1795 1795 bad4.insert(5, QPDFObjectHandle::newString("5"));
1796   - for (auto& i : bad4) {
  1796 + for (auto& i: bad4) {
1797 1797 std::cout << i.first << " " << i.second.unparse() << std::endl;
1798 1798 }
1799 1799  
... ... @@ -1826,12 +1826,12 @@ test_48(QPDF&amp; pdf, char const* arg2)
1826 1826 // name-tree.pdf
1827 1827 QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest");
1828 1828 QPDFNameTreeObjectHelper ntoh(qtest, pdf);
1829   - for (auto& iter : ntoh) {
  1829 + for (auto& iter: ntoh) {
1830 1830 std::cout << iter.first << " -> " << iter.second.getStringValue()
1831 1831 << std::endl;
1832 1832 }
1833 1833 std::map<std::string, QPDFObjectHandle> ntoh_map = ntoh.getAsMap();
1834   - for (auto& iter : ntoh_map) {
  1834 + for (auto& iter: ntoh_map) {
1835 1835 std::cout << iter.first << " -> " << iter.second.getStringValue()
1836 1836 << std::endl;
1837 1837 }
... ... @@ -1884,12 +1884,12 @@ test_48(QPDF&amp; pdf, char const* arg2)
1884 1884 assert(iter2->first == "3");
1885 1885 iter2.insertAfter("4", QPDFObjectHandle::newString("4!"));
1886 1886 assert(iter2->first == "4");
1887   - for (auto& i : new2) {
  1887 + for (auto& i: new2) {
1888 1888 std::cout << i.first << " " << i.second.unparse() << std::endl;
1889 1889 }
1890 1890  
1891 1891 std::vector<std::string> empties = {"/Empty1", "/Empty2"};
1892   - for (auto const& k : empties) {
  1892 + for (auto const& k: empties) {
1893 1893 std::cout << k << std::endl;
1894 1894 auto empty = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey(k), pdf);
1895 1895 assert(empty.begin() == empty.end());
... ... @@ -1915,14 +1915,14 @@ test_48(QPDF&amp; pdf, char const* arg2)
1915 1915 std::cout << "/Bad1 -- wrong key type" << std::endl;
1916 1916 auto bad1 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
1917 1917 assert(bad1.find("G", true)->first == "A");
1918   - for (auto const& i : bad1) {
  1918 + for (auto const& i: bad1) {
1919 1919 std::cout << i.first << std::endl;
1920 1920 }
1921 1921  
1922 1922 std::cout << "/Bad2 -- invalid kid" << std::endl;
1923 1923 auto bad2 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad2"), pdf);
1924 1924 assert(bad2.find("G", true)->first == "B");
1925   - for (auto const& i : bad2) {
  1925 + for (auto const& i: bad2) {
1926 1926 std::cout << i.first << std::endl;
1927 1927 }
1928 1928  
... ... @@ -1933,7 +1933,7 @@ test_48(QPDF&amp; pdf, char const* arg2)
1933 1933 std::cout << "/Bad4 -- invalid kid" << std::endl;
1934 1934 auto bad4 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad4"), pdf);
1935 1935 assert(bad4.find("F", true)->first == "C");
1936   - for (auto const& i : bad4) {
  1936 + for (auto const& i: bad4) {
1937 1937 std::cout << i.first << std::endl;
1938 1938 }
1939 1939  
... ... @@ -2230,9 +2230,9 @@ test_60(QPDF&amp; pdf, char const* arg2)
2230 2230 std::map<std::string, std::map<std::string, std::string>> conflicts;
2231 2231 auto show_conflicts = [&](std::string const& msg) {
2232 2232 std::cout << msg << std::endl;
2233   - for (auto const& i1 : conflicts) {
  2233 + for (auto const& i1: conflicts) {
2234 2234 std::cout << i1.first << ":" << std::endl;
2235   - for (auto const& i2 : i1.second) {
  2235 + for (auto const& i2: i1.second) {
2236 2236 std::cout << " " << i2.first << " -> " << i2.second
2237 2237 << std::endl;
2238 2238 }
... ... @@ -2510,19 +2510,19 @@ test_71(QPDF&amp; pdf, char const* arg2)
2510 2510 std::cout << "--- non-recursive, all, from fx1 ---" << std::endl;
2511 2511 fx1.forEachXObject(false, show);
2512 2512 std::cout << "--- get images, page ---" << std::endl;
2513   - for (auto& i : page.getImages()) {
  2513 + for (auto& i: page.getImages()) {
2514 2514 std::cout << i.first << " -> " << i.second.unparse() << std::endl;
2515 2515 }
2516 2516 std::cout << "--- get images, fx ---" << std::endl;
2517   - for (auto& i : fx1.getImages()) {
  2517 + for (auto& i: fx1.getImages()) {
2518 2518 std::cout << i.first << " -> " << i.second.unparse() << std::endl;
2519 2519 }
2520 2520 std::cout << "--- get form XObjects, page ---" << std::endl;
2521   - for (auto& i : page.getFormXObjects()) {
  2521 + for (auto& i: page.getFormXObjects()) {
2522 2522 std::cout << i.first << " -> " << i.second.unparse() << std::endl;
2523 2523 }
2524 2524 std::cout << "--- get form XObjects, fx ---" << std::endl;
2525   - for (auto& i : fx1.getFormXObjects()) {
  2525 + for (auto& i: fx1.getFormXObjects()) {
2526 2526 std::cout << i.first << " -> " << i.second.unparse() << std::endl;
2527 2527 }
2528 2528 }
... ... @@ -2591,7 +2591,7 @@ test_74(QPDF&amp; pdf, char const* arg2)
2591 2591 check_split1(15);
2592 2592 check_split1(35);
2593 2593 check_split1(125);
2594   - for (auto const& i : split1) {
  2594 + for (auto const& i: split1) {
2595 2595 std::cout << i.first << std::endl;
2596 2596 }
2597 2597  
... ... @@ -2605,7 +2605,7 @@ test_74(QPDF&amp; pdf, char const* arg2)
2605 2605 assert(i->first == k);
2606 2606 };
2607 2607 check_split2(split2, "C");
2608   - for (auto const& i : split2) {
  2608 + for (auto const& i: split2) {
2609 2609 std::cout << i.first << std::endl;
2610 2610 }
2611 2611  
... ... @@ -2615,7 +2615,7 @@ test_74(QPDF&amp; pdf, char const* arg2)
2615 2615 split3.setSplitThreshold(4);
2616 2616 check_split2(split3, "P");
2617 2617 check_split2(split3, "\xcf\x80");
2618   - for (auto& i : split3) {
  2618 + for (auto& i: split3) {
2619 2619 std::cout << i.first << " " << i.second.unparse() << std::endl;
2620 2620 }
2621 2621  
... ... @@ -2722,7 +2722,7 @@ test_76(QPDF&amp; pdf, char const* arg2)
2722 2722 QUtil::hex_encode(efs2.getChecksum()) ==
2723 2723 "2fce9c8228e360ba9b04a1bd1bf63d6b");
2724 2724  
2725   - for (auto iter : efdh.getEmbeddedFiles()) {
  2725 + for (auto iter: efdh.getEmbeddedFiles()) {
2726 2726 std::cout << iter.first << " -> " << iter.second->getFilename()
2727 2727 << std::endl;
2728 2728 }
... ... @@ -2831,7 +2831,7 @@ test_79(QPDF&amp; pdf, char const* arg2)
2831 2831 "/Originals", QPDFObjectHandle::newArray(streams));
2832 2832  
2833 2833 int i = 0;
2834   - for (auto orig : streams) {
  2834 + for (auto orig: streams) {
2835 2835 ++i;
2836 2836 auto istr = QUtil::int_to_string(i);
2837 2837 auto orig_data = orig.getStreamData();
... ... @@ -2879,7 +2879,7 @@ test_80(QPDF&amp; pdf, char const* arg2)
2879 2879 // Use defaults for from_qpdf and from_afdh.
2880 2880 afdh.transformAnnotations(
2881 2881 old_annots, new_annots, new_fields, old_fields, m);
2882   - for (auto const& annot : new_annots) {
  2882 + for (auto const& annot: new_annots) {
2883 2883 old_annots.appendItem(annot);
2884 2884 }
2885 2885 afdh.addAndRenameFormFields(new_fields);
... ...