Commit 92d3cbecd4ea375d8de95bffc0fe8651c698f568
1 parent
66198f44
Fix warnings reported by -Wshadow=local (fixes #431)
Showing
14 changed files
with
98 additions
and
114 deletions
examples/pdf-invert-images.cc
| ... | ... | @@ -160,11 +160,9 @@ int main(int argc, char* argv[]) |
| 160 | 160 | // Get all images on the page. |
| 161 | 161 | std::map<std::string, QPDFObjectHandle> images = |
| 162 | 162 | page.getPageImages(); |
| 163 | - for (std::map<std::string, QPDFObjectHandle>::iterator iter = | |
| 164 | - images.begin(); | |
| 165 | - iter != images.end(); ++iter) | |
| 163 | + for (auto& iter2: images) | |
| 166 | 164 | { |
| 167 | - QPDFObjectHandle& image = (*iter).second; | |
| 165 | + QPDFObjectHandle& image = iter2.second; | |
| 168 | 166 | QPDFObjectHandle image_dict = image.getDict(); |
| 169 | 167 | QPDFObjectHandle color_space = |
| 170 | 168 | image_dict.getKey("/ColorSpace"); | ... | ... |
examples/pdf-mod-info.cc
examples/pdf-split-pages.cc
| ... | ... | @@ -15,7 +15,6 @@ |
| 15 | 15 | #include <string> |
| 16 | 16 | #include <cstring> |
| 17 | 17 | |
| 18 | -static char const* whoami = 0; | |
| 19 | 18 | static bool static_id = false; |
| 20 | 19 | |
| 21 | 20 | static void process(char const* whoami, |
| ... | ... | @@ -50,7 +49,7 @@ static void process(char const* whoami, |
| 50 | 49 | } |
| 51 | 50 | } |
| 52 | 51 | |
| 53 | -void usage() | |
| 52 | +void usage(char const* whoami) | |
| 54 | 53 | { |
| 55 | 54 | std::cerr << "Usage: " << whoami << " infile outprefix" << std::endl; |
| 56 | 55 | exit(2); |
| ... | ... | @@ -58,7 +57,7 @@ void usage() |
| 58 | 57 | |
| 59 | 58 | int main(int argc, char* argv[]) |
| 60 | 59 | { |
| 61 | - whoami = QUtil::getWhoami(argv[0]); | |
| 60 | + char const* whoami = QUtil::getWhoami(argv[0]); | |
| 62 | 61 | |
| 63 | 62 | // For libtool's sake.... |
| 64 | 63 | if (strncmp(whoami, "lt-", 3) == 0) |
| ... | ... | @@ -75,7 +74,7 @@ int main(int argc, char* argv[]) |
| 75 | 74 | |
| 76 | 75 | if (argc != 3) |
| 77 | 76 | { |
| 78 | - usage(); | |
| 77 | + usage(whoami); | |
| 79 | 78 | } |
| 80 | 79 | try |
| 81 | 80 | { | ... | ... |
libqpdf/Pl_DCT.cc
| ... | ... | @@ -302,8 +302,9 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b) |
| 302 | 302 | unsigned int width = cinfo->image_width * |
| 303 | 303 | QIntC::to_uint(cinfo->input_components); |
| 304 | 304 | size_t expected_size = |
| 305 | - cinfo->image_height * cinfo->image_width * | |
| 306 | - QIntC::to_uint(cinfo->input_components); | |
| 305 | + QIntC::to_size(cinfo->image_height) * | |
| 306 | + QIntC::to_size(cinfo->image_width) * | |
| 307 | + QIntC::to_size(cinfo->input_components); | |
| 307 | 308 | if (b->getSize() != expected_size) |
| 308 | 309 | { |
| 309 | 310 | throw std::runtime_error( | ... | ... |
libqpdf/QPDFObjectHandle.cc
| ... | ... | @@ -1607,12 +1607,12 @@ QPDFObjectHandle::pipeContentStreams( |
| 1607 | 1607 | std::string og = |
| 1608 | 1608 | QUtil::int_to_string(stream.getObjectID()) + " " + |
| 1609 | 1609 | QUtil::int_to_string(stream.getGeneration()); |
| 1610 | - std::string description = "content stream object " + og; | |
| 1610 | + std::string w_description = "content stream object " + og; | |
| 1611 | 1611 | if (! stream.pipeStreamData(p, 0, qpdf_dl_specialized)) |
| 1612 | 1612 | { |
| 1613 | 1613 | QTC::TC("qpdf", "QPDFObjectHandle errors in parsecontent"); |
| 1614 | 1614 | throw QPDFExc(qpdf_e_damaged_pdf, "content stream", |
| 1615 | - description, 0, | |
| 1615 | + w_description, 0, | |
| 1616 | 1616 | "errors while decoding content stream"); |
| 1617 | 1617 | } |
| 1618 | 1618 | } |
| ... | ... | @@ -1685,13 +1685,13 @@ QPDFObjectHandle::parseContentStream_data( |
| 1685 | 1685 | ParserCallbacks* callbacks, |
| 1686 | 1686 | QPDF* context) |
| 1687 | 1687 | { |
| 1688 | - size_t length = stream_data->getSize(); | |
| 1688 | + size_t stream_length = stream_data->getSize(); | |
| 1689 | 1689 | PointerHolder<InputSource> input = |
| 1690 | 1690 | new BufferInputSource(description, stream_data.getPointer()); |
| 1691 | 1691 | QPDFTokenizer tokenizer; |
| 1692 | 1692 | tokenizer.allowEOF(); |
| 1693 | 1693 | bool empty = false; |
| 1694 | - while (QIntC::to_size(input->tell()) < length) | |
| 1694 | + while (QIntC::to_size(input->tell()) < stream_length) | |
| 1695 | 1695 | { |
| 1696 | 1696 | // Read a token and seek to the beginning. The offset we get |
| 1697 | 1697 | // from this process is the beginning of the next | ... | ... |
libqpdf/QPDFPageObjectHelper.cc
| ... | ... | @@ -76,10 +76,8 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict) |
| 76 | 76 | dict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject")); |
| 77 | 77 | dict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Image")); |
| 78 | 78 | std::set<std::string> keys = odict.getKeys(); |
| 79 | - for (std::set<std::string>::iterator iter = keys.begin(); | |
| 80 | - iter != keys.end(); ++iter) | |
| 79 | + for (auto key: keys) | |
| 81 | 80 | { |
| 82 | - std::string key = *iter; | |
| 83 | 81 | QPDFObjectHandle value = odict.getKey(key); |
| 84 | 82 | if (key == "/BPC") |
| 85 | 83 | { |
| ... | ... | @@ -176,14 +174,12 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict) |
| 176 | 174 | { |
| 177 | 175 | filters = value.getArrayAsVector(); |
| 178 | 176 | } |
| 179 | - for (std::vector<QPDFObjectHandle>::iterator iter = | |
| 180 | - filters.begin(); | |
| 181 | - iter != filters.end(); ++iter) | |
| 177 | + for (auto& iter: filters) | |
| 182 | 178 | { |
| 183 | 179 | std::string name; |
| 184 | - if ((*iter).isName()) | |
| 180 | + if (iter.isName()) | |
| 185 | 181 | { |
| 186 | - name = (*iter).getName(); | |
| 182 | + name = iter.getName(); | |
| 187 | 183 | } |
| 188 | 184 | if (name == "/AHx") |
| 189 | 185 | { |
| ... | ... | @@ -219,7 +215,7 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict) |
| 219 | 215 | } |
| 220 | 216 | if (! name.empty()) |
| 221 | 217 | { |
| 222 | - *iter = QPDFObjectHandle::newName(name); | |
| 218 | + iter = QPDFObjectHandle::newName(name); | |
| 223 | 219 | } |
| 224 | 220 | } |
| 225 | 221 | if (value.isName() && (filters.size() == 1)) | ... | ... |
libqpdf/QPDFTokenizer.cc
| ... | ... | @@ -175,8 +175,8 @@ QPDFTokenizer::resolveLiteral() |
| 175 | 175 | num[0] = this->m->val.at(i+1); |
| 176 | 176 | num[1] = this->m->val.at(i+2); |
| 177 | 177 | num[2] = '\0'; |
| 178 | - char ch = static_cast<char>(strtol(num, 0, 16)); | |
| 179 | - if (ch == '\0') | |
| 178 | + char ch2 = static_cast<char>(strtol(num, 0, 16)); | |
| 179 | + if (ch2 == '\0') | |
| 180 | 180 | { |
| 181 | 181 | this->m->type = tt_bad; |
| 182 | 182 | QTC::TC("qpdf", "QPDFTokenizer null in name"); |
| ... | ... | @@ -186,7 +186,7 @@ QPDFTokenizer::resolveLiteral() |
| 186 | 186 | } |
| 187 | 187 | else |
| 188 | 188 | { |
| 189 | - nval.append(1, ch); | |
| 189 | + nval.append(1, ch2); | |
| 190 | 190 | } |
| 191 | 191 | i += 2; |
| 192 | 192 | } |
| ... | ... | @@ -719,7 +719,7 @@ QPDFTokenizer::findEI(PointerHolder<InputSource> input) |
| 719 | 719 | for (std::string::iterator iter = value.begin(); |
| 720 | 720 | iter != value.end(); ++iter) |
| 721 | 721 | { |
| 722 | - char ch = *iter; | |
| 722 | + signed char ch = *iter; | |
| 723 | 723 | if (((ch >= 'a') && (ch <= 'z')) || |
| 724 | 724 | ((ch >= 'A') && (ch <= 'Z')) || |
| 725 | 725 | (ch == '*')) |
| ... | ... | @@ -729,8 +729,10 @@ QPDFTokenizer::findEI(PointerHolder<InputSource> input) |
| 729 | 729 | // alphabetic characters. |
| 730 | 730 | found_alpha = true; |
| 731 | 731 | } |
| 732 | - else if (((ch < 32) && (! isSpace(ch))) || (ch > 127)) | |
| 732 | + else if ((ch < 32) && (! isSpace(ch))) | |
| 733 | 733 | { |
| 734 | + // ch is signed, so characters outside of | |
| 735 | + // 7-bit will be < 0. | |
| 734 | 736 | found_non_printable = true; |
| 735 | 737 | break; |
| 736 | 738 | } | ... | ... |
libqpdf/QPDFWriter.cc
| ... | ... | @@ -1790,14 +1790,14 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, |
| 1790 | 1790 | } |
| 1791 | 1791 | } |
| 1792 | 1792 | bool normalize = false; |
| 1793 | - bool compress = false; | |
| 1793 | + bool compress_stream = false; | |
| 1794 | 1794 | bool uncompress = false; |
| 1795 | 1795 | if (is_metadata && |
| 1796 | 1796 | ((! this->m->encrypted) || (this->m->encrypt_metadata == false))) |
| 1797 | 1797 | { |
| 1798 | 1798 | QTC::TC("qpdf", "QPDFWriter not compressing metadata"); |
| 1799 | 1799 | filter = true; |
| 1800 | - compress = false; | |
| 1800 | + compress_stream = false; | |
| 1801 | 1801 | uncompress = true; |
| 1802 | 1802 | } |
| 1803 | 1803 | else if (this->m->normalize_content && |
| ... | ... | @@ -1808,7 +1808,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, |
| 1808 | 1808 | } |
| 1809 | 1809 | else if (filter && this->m->compress_streams) |
| 1810 | 1810 | { |
| 1811 | - compress = true; | |
| 1811 | + compress_stream = true; | |
| 1812 | 1812 | QTC::TC("qpdf", "QPDFWriter compressing uncompressed stream"); |
| 1813 | 1813 | } |
| 1814 | 1814 | |
| ... | ... | @@ -1825,7 +1825,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, |
| 1825 | 1825 | object.pipeStreamData( |
| 1826 | 1826 | this->m->pipeline, |
| 1827 | 1827 | (((filter && normalize) ? qpdf_ef_normalize : 0) | |
| 1828 | - ((filter && compress) ? qpdf_ef_compress : 0)), | |
| 1828 | + ((filter && compress_stream) ? qpdf_ef_compress : 0)), | |
| 1829 | 1829 | (filter |
| 1830 | 1830 | ? (uncompress ? qpdf_dl_all : this->m->stream_decode_level) |
| 1831 | 1831 | : qpdf_dl_none), false, (attempt == 1)); |
| ... | ... | @@ -1845,7 +1845,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, |
| 1845 | 1845 | } |
| 1846 | 1846 | else |
| 1847 | 1847 | { |
| 1848 | - compress = false; | |
| 1848 | + compress_stream = false; | |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | 1851 | this->m->cur_stream_length = stream_data->getSize(); |
| ... | ... | @@ -1856,7 +1856,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level, |
| 1856 | 1856 | } |
| 1857 | 1857 | adjustAESStreamLength(this->m->cur_stream_length); |
| 1858 | 1858 | unparseObject(stream_dict, 0, flags, |
| 1859 | - this->m->cur_stream_length, compress); | |
| 1859 | + this->m->cur_stream_length, compress_stream); | |
| 1860 | 1860 | unsigned char last_char = '\0'; |
| 1861 | 1861 | writeString("\nstream\n"); |
| 1862 | 1862 | { |
| ... | ... | @@ -2330,11 +2330,10 @@ QPDFWriter::initializeSpecialStreams() |
| 2330 | 2330 | contents_objects.push_back(contents.getObjGen()); |
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | - for (std::vector<QPDFObjGen>::iterator iter = contents_objects.begin(); | |
| 2334 | - iter != contents_objects.end(); ++iter) | |
| 2333 | + for (auto const& c: contents_objects) | |
| 2335 | 2334 | { |
| 2336 | - this->m->contents_to_page_seq[*iter] = num; | |
| 2337 | - this->m->normalized_streams.insert(*iter); | |
| 2335 | + this->m->contents_to_page_seq[c] = num; | |
| 2336 | + this->m->normalized_streams.insert(c); | |
| 2338 | 2337 | } |
| 2339 | 2338 | } |
| 2340 | 2339 | } |
| ... | ... | @@ -3462,9 +3461,9 @@ QPDFWriter::writeLinearized() |
| 3462 | 3461 | else |
| 3463 | 3462 | { |
| 3464 | 3463 | // Make the file size the same. |
| 3465 | - qpdf_offset_t pos = this->m->pipeline->getCount(); | |
| 3466 | 3464 | writePad( |
| 3467 | - QIntC::to_int(second_xref_end + hint_length - 1 - pos)); | |
| 3465 | + QIntC::to_int(second_xref_end + hint_length - | |
| 3466 | + 1 - this->m->pipeline->getCount())); | |
| 3468 | 3467 | writeString("\n"); |
| 3469 | 3468 | |
| 3470 | 3469 | // If this assertion fails, maybe we didn't have |
| ... | ... | @@ -3507,7 +3506,7 @@ QPDFWriter::writeLinearized() |
| 3507 | 3506 | |
| 3508 | 3507 | // Save hint offset since it will be set to zero by |
| 3509 | 3508 | // calling openObject. |
| 3510 | - qpdf_offset_t hint_offset = this->m->xref[hint_id].getOffset(); | |
| 3509 | + qpdf_offset_t hint_offset1 = this->m->xref[hint_id].getOffset(); | |
| 3511 | 3510 | |
| 3512 | 3511 | // Write hint stream to a buffer |
| 3513 | 3512 | { |
| ... | ... | @@ -3519,12 +3518,12 @@ QPDFWriter::writeLinearized() |
| 3519 | 3518 | hint_length = QIntC::to_offset(hint_buffer->getSize()); |
| 3520 | 3519 | |
| 3521 | 3520 | // Restore hint offset |
| 3522 | - this->m->xref[hint_id] = QPDFXRefEntry(1, hint_offset, 0); | |
| 3521 | + this->m->xref[hint_id] = QPDFXRefEntry(1, hint_offset1, 0); | |
| 3523 | 3522 | if (lin_pass1_file) |
| 3524 | 3523 | { |
| 3525 | 3524 | // Write some debugging information |
| 3526 | 3525 | fprintf(lin_pass1_file, "%% hint_offset=%s\n", |
| 3527 | - QUtil::int_to_string(hint_offset).c_str()); | |
| 3526 | + QUtil::int_to_string(hint_offset1).c_str()); | |
| 3528 | 3527 | fprintf(lin_pass1_file, "%% hint_length=%s\n", |
| 3529 | 3528 | QUtil::int_to_string(hint_length).c_str()); |
| 3530 | 3529 | fprintf(lin_pass1_file, "%% second_xref_offset=%s\n", | ... | ... |
libqpdf/QPDF_Stream.cc
| ... | ... | @@ -555,12 +555,14 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp, |
| 555 | 555 | to_delete.push_back(pipeline); |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - for (std::vector<std::string>::reverse_iterator iter = filters.rbegin(); | |
| 559 | - iter != filters.rend(); ++iter) | |
| 558 | + for (std::vector<std::string>::reverse_iterator f_iter = | |
| 559 | + filters.rbegin(); | |
| 560 | + f_iter != filters.rend(); ++f_iter) | |
| 560 | 561 | { |
| 561 | - std::string const& filter = *iter; | |
| 562 | + std::string const& filter_name = *f_iter; | |
| 562 | 563 | |
| 563 | - if ((filter == "/FlateDecode") || (filter == "/LZWDecode")) | |
| 564 | + if ((filter_name == "/FlateDecode") || | |
| 565 | + (filter_name == "/LZWDecode")) | |
| 564 | 566 | { |
| 565 | 567 | if ((predictor >= 10) && (predictor <= 15)) |
| 566 | 568 | { |
| ... | ... | @@ -584,39 +586,39 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp, |
| 584 | 586 | } |
| 585 | 587 | } |
| 586 | 588 | |
| 587 | - if (filter == "/Crypt") | |
| 589 | + if (filter_name == "/Crypt") | |
| 588 | 590 | { |
| 589 | 591 | // Ignore -- handled by pipeStreamData |
| 590 | 592 | } |
| 591 | - else if (filter == "/FlateDecode") | |
| 593 | + else if (filter_name == "/FlateDecode") | |
| 592 | 594 | { |
| 593 | 595 | pipeline = new Pl_Flate("stream inflate", |
| 594 | 596 | pipeline, Pl_Flate::a_inflate); |
| 595 | 597 | to_delete.push_back(pipeline); |
| 596 | 598 | } |
| 597 | - else if (filter == "/ASCII85Decode") | |
| 599 | + else if (filter_name == "/ASCII85Decode") | |
| 598 | 600 | { |
| 599 | 601 | pipeline = new Pl_ASCII85Decoder("ascii85 decode", pipeline); |
| 600 | 602 | to_delete.push_back(pipeline); |
| 601 | 603 | } |
| 602 | - else if (filter == "/ASCIIHexDecode") | |
| 604 | + else if (filter_name == "/ASCIIHexDecode") | |
| 603 | 605 | { |
| 604 | 606 | pipeline = new Pl_ASCIIHexDecoder("asciiHex decode", pipeline); |
| 605 | 607 | to_delete.push_back(pipeline); |
| 606 | 608 | } |
| 607 | - else if (filter == "/LZWDecode") | |
| 609 | + else if (filter_name == "/LZWDecode") | |
| 608 | 610 | { |
| 609 | 611 | pipeline = new Pl_LZWDecoder("lzw decode", pipeline, |
| 610 | 612 | early_code_change); |
| 611 | 613 | to_delete.push_back(pipeline); |
| 612 | 614 | } |
| 613 | - else if (filter == "/RunLengthDecode") | |
| 615 | + else if (filter_name == "/RunLengthDecode") | |
| 614 | 616 | { |
| 615 | 617 | pipeline = new Pl_RunLength("runlength decode", pipeline, |
| 616 | 618 | Pl_RunLength::a_decode); |
| 617 | 619 | to_delete.push_back(pipeline); |
| 618 | 620 | } |
| 619 | - else if (filter == "/DCTDecode") | |
| 621 | + else if (filter_name == "/DCTDecode") | |
| 620 | 622 | { |
| 621 | 623 | pipeline = new Pl_DCT("DCT decode", pipeline); |
| 622 | 624 | to_delete.push_back(pipeline); | ... | ... |
libqpdf/QPDF_encryption.cc
| ... | ... | @@ -322,10 +322,10 @@ hash_V5(std::string const& password, |
| 322 | 322 | int next_hash = ((E_mod_3 == 0) ? 256 : |
| 323 | 323 | (E_mod_3 == 1) ? 384 : |
| 324 | 324 | 512); |
| 325 | - Pl_SHA2 hash(next_hash); | |
| 326 | - hash.write(QUtil::unsigned_char_pointer(E), E.length()); | |
| 327 | - hash.finish(); | |
| 328 | - K = hash.getRawDigest(); | |
| 325 | + Pl_SHA2 sha2(next_hash); | |
| 326 | + sha2.write(QUtil::unsigned_char_pointer(E), E.length()); | |
| 327 | + sha2.finish(); | |
| 328 | + K = sha2.getRawDigest(); | |
| 329 | 329 | |
| 330 | 330 | if (round_number >= 64) |
| 331 | 331 | { | ... | ... |
libqpdf/QPDF_linearization.cc
| ... | ... | @@ -374,9 +374,9 @@ QPDF::readHintStream(Pipeline& pl, qpdf_offset_t offset, size_t length) |
| 374 | 374 | QTC::TC("qpdf", "QPDF hint table length indirect"); |
| 375 | 375 | // Force resolution |
| 376 | 376 | (void) length_obj.getIntValue(); |
| 377 | - ObjCache& oc = this->m->obj_cache[length_obj.getObjGen()]; | |
| 378 | - min_end_offset = oc.end_before_space; | |
| 379 | - max_end_offset = oc.end_after_space; | |
| 377 | + ObjCache& oc2 = this->m->obj_cache[length_obj.getObjGen()]; | |
| 378 | + min_end_offset = oc2.end_before_space; | |
| 379 | + max_end_offset = oc2.end_after_space; | |
| 380 | 380 | } |
| 381 | 381 | else |
| 382 | 382 | { | ... | ... |
libqpdf/QUtil.cc
| ... | ... | @@ -812,7 +812,7 @@ QUtil::toUTF8(unsigned long uval) |
| 812 | 812 | // maximum value that will fit in the current number of bytes |
| 813 | 813 | unsigned char maxval = 0x3f; // six bits |
| 814 | 814 | |
| 815 | - while (uval > maxval) | |
| 815 | + while (uval > QIntC::to_ulong(maxval)) | |
| 816 | 816 | { |
| 817 | 817 | // Assign low six bits plus 10000000 to lowest unused |
| 818 | 818 | // byte position, then shift |
| ... | ... | @@ -2163,12 +2163,12 @@ QUtil::win_ansi_to_utf8(std::string const& val) |
| 2163 | 2163 | for (unsigned int i = 0; i < len; ++i) |
| 2164 | 2164 | { |
| 2165 | 2165 | unsigned char ch = static_cast<unsigned char>(val.at(i)); |
| 2166 | - unsigned short val = ch; | |
| 2166 | + unsigned short ch_short = ch; | |
| 2167 | 2167 | if ((ch >= 128) && (ch <= 160)) |
| 2168 | 2168 | { |
| 2169 | - val = win_ansi_to_unicode[ch - 128]; | |
| 2169 | + ch_short = win_ansi_to_unicode[ch - 128]; | |
| 2170 | 2170 | } |
| 2171 | - result += QUtil::toUTF8(val); | |
| 2171 | + result += QUtil::toUTF8(ch_short); | |
| 2172 | 2172 | } |
| 2173 | 2173 | return result; |
| 2174 | 2174 | } |
| ... | ... | @@ -2181,12 +2181,12 @@ QUtil::mac_roman_to_utf8(std::string const& val) |
| 2181 | 2181 | for (unsigned int i = 0; i < len; ++i) |
| 2182 | 2182 | { |
| 2183 | 2183 | unsigned char ch = static_cast<unsigned char>(val.at(i)); |
| 2184 | - unsigned short val = ch; | |
| 2184 | + unsigned short ch_short = ch; | |
| 2185 | 2185 | if (ch >= 128) |
| 2186 | 2186 | { |
| 2187 | - val = mac_roman_to_unicode[ch - 128]; | |
| 2187 | + ch_short = mac_roman_to_unicode[ch - 128]; | |
| 2188 | 2188 | } |
| 2189 | - result += QUtil::toUTF8(val); | |
| 2189 | + result += QUtil::toUTF8(ch_short); | |
| 2190 | 2190 | } |
| 2191 | 2191 | return result; |
| 2192 | 2192 | } |
| ... | ... | @@ -2199,12 +2199,12 @@ QUtil::pdf_doc_to_utf8(std::string const& val) |
| 2199 | 2199 | for (unsigned int i = 0; i < len; ++i) |
| 2200 | 2200 | { |
| 2201 | 2201 | unsigned char ch = static_cast<unsigned char>(val.at(i)); |
| 2202 | - unsigned short val = ch; | |
| 2202 | + unsigned short ch_short = ch; | |
| 2203 | 2203 | if ((ch >= 128) && (ch <= 160)) |
| 2204 | 2204 | { |
| 2205 | - val = pdf_doc_to_unicode[ch - 128]; | |
| 2205 | + ch_short = pdf_doc_to_unicode[ch - 128]; | |
| 2206 | 2206 | } |
| 2207 | - result += QUtil::toUTF8(val); | |
| 2207 | + result += QUtil::toUTF8(ch_short); | |
| 2208 | 2208 | } |
| 2209 | 2209 | return result; |
| 2210 | 2210 | } | ... | ... |
qpdf/qpdf.cc
| ... | ... | @@ -3610,13 +3610,10 @@ static void do_show_pages(QPDF& pdf, Options& o) |
| 3610 | 3610 | if (! images.empty()) |
| 3611 | 3611 | { |
| 3612 | 3612 | std::cout << " images:" << std::endl; |
| 3613 | - for (std::map<std::string, | |
| 3614 | - QPDFObjectHandle>::iterator | |
| 3615 | - iter = images.begin(); | |
| 3616 | - iter != images.end(); ++iter) | |
| 3613 | + for (auto const& iter2: images) | |
| 3617 | 3614 | { |
| 3618 | - std::string const& name = (*iter).first; | |
| 3619 | - QPDFObjectHandle image = (*iter).second; | |
| 3615 | + std::string const& name = iter2.first; | |
| 3616 | + QPDFObjectHandle image = iter2.second; | |
| 3620 | 3617 | QPDFObjectHandle dict = image.getDict(); |
| 3621 | 3618 | int width = |
| 3622 | 3619 | dict.getKey("/Width").getIntValueAsInt(); |
| ... | ... | @@ -3633,11 +3630,9 @@ static void do_show_pages(QPDF& pdf, Options& o) |
| 3633 | 3630 | std::cout << " content:" << std::endl; |
| 3634 | 3631 | std::vector<QPDFObjectHandle> content = |
| 3635 | 3632 | ph.getPageContents(); |
| 3636 | - for (std::vector<QPDFObjectHandle>::iterator iter = | |
| 3637 | - content.begin(); | |
| 3638 | - iter != content.end(); ++iter) | |
| 3633 | + for (auto& iter2: content) | |
| 3639 | 3634 | { |
| 3640 | - std::cout << " " << (*iter).unparse() << std::endl; | |
| 3635 | + std::cout << " " << iter2.unparse() << std::endl; | |
| 3641 | 3636 | } |
| 3642 | 3637 | } |
| 3643 | 3638 | } |
| ... | ... | @@ -3738,14 +3733,12 @@ static void do_json_pages(QPDF& pdf, Options& o, JSON& j) |
| 3738 | 3733 | "images", JSON::makeArray()); |
| 3739 | 3734 | std::map<std::string, QPDFObjectHandle> images = |
| 3740 | 3735 | ph.getPageImages(); |
| 3741 | - for (std::map<std::string, QPDFObjectHandle>::iterator iter = | |
| 3742 | - images.begin(); | |
| 3743 | - iter != images.end(); ++iter) | |
| 3736 | + for (auto const& iter2: images) | |
| 3744 | 3737 | { |
| 3745 | 3738 | JSON j_image = j_images.addArrayElement(JSON::makeDictionary()); |
| 3746 | 3739 | j_image.addDictionaryMember( |
| 3747 | - "name", JSON::makeString((*iter).first)); | |
| 3748 | - QPDFObjectHandle image = (*iter).second; | |
| 3740 | + "name", JSON::makeString(iter2.first)); | |
| 3741 | + QPDFObjectHandle image = iter2.second; | |
| 3749 | 3742 | QPDFObjectHandle dict = image.getDict(); |
| 3750 | 3743 | j_image.addDictionaryMember("object", image.getJSON()); |
| 3751 | 3744 | j_image.addDictionaryMember( |
| ... | ... | @@ -3783,10 +3776,9 @@ static void do_json_pages(QPDF& pdf, Options& o, JSON& j) |
| 3783 | 3776 | JSON j_contents = j_page.addDictionaryMember( |
| 3784 | 3777 | "contents", JSON::makeArray()); |
| 3785 | 3778 | std::vector<QPDFObjectHandle> content = ph.getPageContents(); |
| 3786 | - for (std::vector<QPDFObjectHandle>::iterator iter = content.begin(); | |
| 3787 | - iter != content.end(); ++iter) | |
| 3779 | + for (auto& iter2: content) | |
| 3788 | 3780 | { |
| 3789 | - j_contents.addArrayElement((*iter).getJSON()); | |
| 3781 | + j_contents.addArrayElement(iter2.getJSON()); | |
| 3790 | 3782 | } |
| 3791 | 3783 | j_page.addDictionaryMember( |
| 3792 | 3784 | "label", pldh.getLabelForPage(pageno).getJSON()); |
| ... | ... | @@ -4761,12 +4753,10 @@ static void handle_transformations(QPDF& pdf, Options& o) |
| 4761 | 4753 | QPDFObjectHandle page = ph.getObjectHandle(); |
| 4762 | 4754 | std::map<std::string, QPDFObjectHandle> images = |
| 4763 | 4755 | ph.getPageImages(); |
| 4764 | - for (std::map<std::string, QPDFObjectHandle>::iterator iter = | |
| 4765 | - images.begin(); | |
| 4766 | - iter != images.end(); ++iter) | |
| 4756 | + for (auto& iter2: images) | |
| 4767 | 4757 | { |
| 4768 | - std::string name = (*iter).first; | |
| 4769 | - QPDFObjectHandle& image = (*iter).second; | |
| 4758 | + std::string name = iter2.first; | |
| 4759 | + QPDFObjectHandle& image = iter2.second; | |
| 4770 | 4760 | ImageOptimizer* io = new ImageOptimizer(o, image); |
| 4771 | 4761 | PointerHolder<QPDFObjectHandle::StreamDataProvider> sdp(io); |
| 4772 | 4762 | if (io->evaluate("image " + name + " on page " + | ... | ... |
qpdf/test_driver.cc
| ... | ... | @@ -347,10 +347,10 @@ void runtest(int n, char const* filename1, char const* arg2) |
| 347 | 347 | else if (qtest.isArray()) |
| 348 | 348 | { |
| 349 | 349 | QTC::TC("qpdf", "main QTest array"); |
| 350 | - int n = qtest.getArrayNItems(); | |
| 350 | + int nitems = qtest.getArrayNItems(); | |
| 351 | 351 | std::cout << "/QTest is an array with " |
| 352 | - << n << " items" << std::endl; | |
| 353 | - for (int i = 0; i < n; ++i) | |
| 352 | + << nitems << " items" << std::endl; | |
| 353 | + for (int i = 0; i < nitems; ++i) | |
| 354 | 354 | { |
| 355 | 355 | QTC::TC("qpdf", "main QTest array indirect", |
| 356 | 356 | qtest.getArrayItem(i).isIndirect() ? 1 : 0); |
| ... | ... | @@ -510,11 +510,10 @@ void runtest(int n, char const* filename1, char const* arg2) |
| 510 | 510 | std::cout << " images:" << std::endl; |
| 511 | 511 | std::map<std::string, QPDFObjectHandle> images = |
| 512 | 512 | page.getPageImages(); |
| 513 | - for (std::map<std::string, QPDFObjectHandle>::iterator iter = | |
| 514 | - images.begin(); iter != images.end(); ++iter) | |
| 513 | + for (auto const& iter2: images) | |
| 515 | 514 | { |
| 516 | - std::string const& name = (*iter).first; | |
| 517 | - QPDFObjectHandle image = (*iter).second; | |
| 515 | + std::string const& name = iter2.first; | |
| 516 | + QPDFObjectHandle image = iter2.second; | |
| 518 | 517 | QPDFObjectHandle dict = image.getDict(); |
| 519 | 518 | long long width = dict.getKey("/Width").getIntValue(); |
| 520 | 519 | long long height = dict.getKey("/Height").getIntValue(); |
| ... | ... | @@ -525,10 +524,9 @@ void runtest(int n, char const* filename1, char const* arg2) |
| 525 | 524 | |
| 526 | 525 | std::cout << " content:" << std::endl; |
| 527 | 526 | std::vector<QPDFObjectHandle> content = page.getPageContents(); |
| 528 | - for (std::vector<QPDFObjectHandle>::iterator iter = content.begin(); | |
| 529 | - iter != content.end(); ++iter) | |
| 527 | + for (auto& iter2: content) | |
| 530 | 528 | { |
| 531 | - std::cout << " " << (*iter).unparse() << std::endl; | |
| 529 | + std::cout << " " << iter2.unparse() << std::endl; | |
| 532 | 530 | } |
| 533 | 531 | |
| 534 | 532 | std::cout << "end page " << pageno << std::endl; |
| ... | ... | @@ -539,8 +537,8 @@ void runtest(int n, char const* filename1, char const* arg2) |
| 539 | 537 | if (qstrings.isArray()) |
| 540 | 538 | { |
| 541 | 539 | std::cout << "QStrings:" << std::endl; |
| 542 | - int n = qstrings.getArrayNItems(); | |
| 543 | - for (int i = 0; i < n; ++i) | |
| 540 | + int nitems = qstrings.getArrayNItems(); | |
| 541 | + for (int i = 0; i < nitems; ++i) | |
| 544 | 542 | { |
| 545 | 543 | std::cout << qstrings.getArrayItem(i).getUTF8Value() |
| 546 | 544 | << std::endl; |
| ... | ... | @@ -551,8 +549,8 @@ void runtest(int n, char const* filename1, char const* arg2) |
| 551 | 549 | if (qnumbers.isArray()) |
| 552 | 550 | { |
| 553 | 551 | std::cout << "QNumbers:" << std::endl; |
| 554 | - int n = qnumbers.getArrayNItems(); | |
| 555 | - for (int i = 0; i < n; ++i) | |
| 552 | + int nitems = qnumbers.getArrayNItems(); | |
| 553 | + for (int i = 0; i < nitems; ++i) | |
| 556 | 554 | { |
| 557 | 555 | std::cout << QUtil::double_to_string( |
| 558 | 556 | qnumbers.getArrayItem(i).getNumericValue(), 3) |
| ... | ... | @@ -1853,8 +1851,8 @@ void runtest(int n, char const* filename1, char const* arg2) |
| 1853 | 1851 | // button-set*.pdf are designed for this test case. |
| 1854 | 1852 | QPDFObjectHandle acroform = pdf.getRoot().getKey("/AcroForm"); |
| 1855 | 1853 | QPDFObjectHandle fields = acroform.getKey("/Fields"); |
| 1856 | - int n = fields.getArrayNItems(); | |
| 1857 | - for (int i = 0; i < n; ++i) | |
| 1854 | + int nitems = fields.getArrayNItems(); | |
| 1855 | + for (int i = 0; i < nitems; ++i) | |
| 1858 | 1856 | { |
| 1859 | 1857 | QPDFObjectHandle field = fields.getArrayItem(i); |
| 1860 | 1858 | QPDFObjectHandle T = field.getKey("/T"); |
| ... | ... | @@ -1900,8 +1898,8 @@ void runtest(int n, char const* filename1, char const* arg2) |
| 1900 | 1898 | // generating testing. |
| 1901 | 1899 | QPDFObjectHandle acroform = pdf.getRoot().getKey("/AcroForm"); |
| 1902 | 1900 | QPDFObjectHandle fields = acroform.getKey("/Fields"); |
| 1903 | - int n = fields.getArrayNItems(); | |
| 1904 | - for (int i = 0; i < n; ++i) | |
| 1901 | + int nitems = fields.getArrayNItems(); | |
| 1902 | + for (int i = 0; i < nitems; ++i) | |
| 1905 | 1903 | { |
| 1906 | 1904 | QPDFObjectHandle field = fields.getArrayItem(i); |
| 1907 | 1905 | QPDFObjectHandle T = field.getKey("/T"); | ... | ... |