Fix warnings reported by -Wshadow=local (fixes #431)

This commit is contained in:
Jay Berkenbilt 2020-04-16 11:43:37 -04:00
parent 66198f447f
commit 92d3cbecd4
14 changed files with 98 additions and 114 deletions

View File

@ -160,11 +160,9 @@ int main(int argc, char* argv[])
// Get all images on the page. // Get all images on the page.
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images =
page.getPageImages(); page.getPageImages();
for (std::map<std::string, QPDFObjectHandle>::iterator iter = for (auto& iter2: images)
images.begin();
iter != images.end(); ++iter)
{ {
QPDFObjectHandle& image = (*iter).second; QPDFObjectHandle& image = iter2.second;
QPDFObjectHandle image_dict = image.getDict(); QPDFObjectHandle image_dict = image.getDict();
QPDFObjectHandle color_space = QPDFObjectHandle color_space =
image_dict.getKey("/ColorSpace"); image_dict.getKey("/ColorSpace");

View File

@ -46,8 +46,7 @@ void dumpInfoDict(QPDF& pdf,
{ {
QPDFObjectHandle elt = info.getKey(*it); QPDFObjectHandle elt = info.getKey(*it);
std::string val; std::string val;
if (false) {} if (elt.isString())
else if (elt.isString())
{ {
val = elt.getStringValue(); val = elt.getStringValue();
} }

View File

@ -15,7 +15,6 @@
#include <string> #include <string>
#include <cstring> #include <cstring>
static char const* whoami = 0;
static bool static_id = false; static bool static_id = false;
static void process(char const* whoami, static void process(char const* whoami,
@ -50,7 +49,7 @@ static void process(char const* whoami,
} }
} }
void usage() void usage(char const* whoami)
{ {
std::cerr << "Usage: " << whoami << " infile outprefix" << std::endl; std::cerr << "Usage: " << whoami << " infile outprefix" << std::endl;
exit(2); exit(2);
@ -58,7 +57,7 @@ void usage()
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
whoami = QUtil::getWhoami(argv[0]); char const* whoami = QUtil::getWhoami(argv[0]);
// For libtool's sake.... // For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0) if (strncmp(whoami, "lt-", 3) == 0)
@ -75,7 +74,7 @@ int main(int argc, char* argv[])
if (argc != 3) if (argc != 3)
{ {
usage(); usage(whoami);
} }
try try
{ {

View File

@ -302,8 +302,9 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
unsigned int width = cinfo->image_width * unsigned int width = cinfo->image_width *
QIntC::to_uint(cinfo->input_components); QIntC::to_uint(cinfo->input_components);
size_t expected_size = size_t expected_size =
cinfo->image_height * cinfo->image_width * QIntC::to_size(cinfo->image_height) *
QIntC::to_uint(cinfo->input_components); QIntC::to_size(cinfo->image_width) *
QIntC::to_size(cinfo->input_components);
if (b->getSize() != expected_size) if (b->getSize() != expected_size)
{ {
throw std::runtime_error( throw std::runtime_error(

View File

@ -1607,12 +1607,12 @@ QPDFObjectHandle::pipeContentStreams(
std::string og = std::string og =
QUtil::int_to_string(stream.getObjectID()) + " " + QUtil::int_to_string(stream.getObjectID()) + " " +
QUtil::int_to_string(stream.getGeneration()); QUtil::int_to_string(stream.getGeneration());
std::string description = "content stream object " + og; std::string w_description = "content stream object " + og;
if (! stream.pipeStreamData(p, 0, qpdf_dl_specialized)) if (! stream.pipeStreamData(p, 0, qpdf_dl_specialized))
{ {
QTC::TC("qpdf", "QPDFObjectHandle errors in parsecontent"); QTC::TC("qpdf", "QPDFObjectHandle errors in parsecontent");
throw QPDFExc(qpdf_e_damaged_pdf, "content stream", throw QPDFExc(qpdf_e_damaged_pdf, "content stream",
description, 0, w_description, 0,
"errors while decoding content stream"); "errors while decoding content stream");
} }
} }
@ -1685,13 +1685,13 @@ QPDFObjectHandle::parseContentStream_data(
ParserCallbacks* callbacks, ParserCallbacks* callbacks,
QPDF* context) QPDF* context)
{ {
size_t length = stream_data->getSize(); size_t stream_length = stream_data->getSize();
PointerHolder<InputSource> input = PointerHolder<InputSource> input =
new BufferInputSource(description, stream_data.getPointer()); new BufferInputSource(description, stream_data.getPointer());
QPDFTokenizer tokenizer; QPDFTokenizer tokenizer;
tokenizer.allowEOF(); tokenizer.allowEOF();
bool empty = false; bool empty = false;
while (QIntC::to_size(input->tell()) < length) while (QIntC::to_size(input->tell()) < stream_length)
{ {
// Read a token and seek to the beginning. The offset we get // Read a token and seek to the beginning. The offset we get
// from this process is the beginning of the next // from this process is the beginning of the next

View File

@ -76,10 +76,8 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
dict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject")); dict.replaceKey("/Type", QPDFObjectHandle::newName("/XObject"));
dict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Image")); dict.replaceKey("/Subtype", QPDFObjectHandle::newName("/Image"));
std::set<std::string> keys = odict.getKeys(); std::set<std::string> keys = odict.getKeys();
for (std::set<std::string>::iterator iter = keys.begin(); for (auto key: keys)
iter != keys.end(); ++iter)
{ {
std::string key = *iter;
QPDFObjectHandle value = odict.getKey(key); QPDFObjectHandle value = odict.getKey(key);
if (key == "/BPC") if (key == "/BPC")
{ {
@ -176,14 +174,12 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
{ {
filters = value.getArrayAsVector(); filters = value.getArrayAsVector();
} }
for (std::vector<QPDFObjectHandle>::iterator iter = for (auto& iter: filters)
filters.begin();
iter != filters.end(); ++iter)
{ {
std::string name; std::string name;
if ((*iter).isName()) if (iter.isName())
{ {
name = (*iter).getName(); name = iter.getName();
} }
if (name == "/AHx") if (name == "/AHx")
{ {
@ -219,7 +215,7 @@ InlineImageTracker::convertIIDict(QPDFObjectHandle odict)
} }
if (! name.empty()) if (! name.empty())
{ {
*iter = QPDFObjectHandle::newName(name); iter = QPDFObjectHandle::newName(name);
} }
} }
if (value.isName() && (filters.size() == 1)) if (value.isName() && (filters.size() == 1))

View File

@ -175,8 +175,8 @@ QPDFTokenizer::resolveLiteral()
num[0] = this->m->val.at(i+1); num[0] = this->m->val.at(i+1);
num[1] = this->m->val.at(i+2); num[1] = this->m->val.at(i+2);
num[2] = '\0'; num[2] = '\0';
char ch = static_cast<char>(strtol(num, 0, 16)); char ch2 = static_cast<char>(strtol(num, 0, 16));
if (ch == '\0') if (ch2 == '\0')
{ {
this->m->type = tt_bad; this->m->type = tt_bad;
QTC::TC("qpdf", "QPDFTokenizer null in name"); QTC::TC("qpdf", "QPDFTokenizer null in name");
@ -186,7 +186,7 @@ QPDFTokenizer::resolveLiteral()
} }
else else
{ {
nval.append(1, ch); nval.append(1, ch2);
} }
i += 2; i += 2;
} }
@ -719,7 +719,7 @@ QPDFTokenizer::findEI(PointerHolder<InputSource> input)
for (std::string::iterator iter = value.begin(); for (std::string::iterator iter = value.begin();
iter != value.end(); ++iter) iter != value.end(); ++iter)
{ {
char ch = *iter; signed char ch = *iter;
if (((ch >= 'a') && (ch <= 'z')) || if (((ch >= 'a') && (ch <= 'z')) ||
((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'A') && (ch <= 'Z')) ||
(ch == '*')) (ch == '*'))
@ -729,8 +729,10 @@ QPDFTokenizer::findEI(PointerHolder<InputSource> input)
// alphabetic characters. // alphabetic characters.
found_alpha = true; found_alpha = true;
} }
else if (((ch < 32) && (! isSpace(ch))) || (ch > 127)) else if ((ch < 32) && (! isSpace(ch)))
{ {
// ch is signed, so characters outside of
// 7-bit will be < 0.
found_non_printable = true; found_non_printable = true;
break; break;
} }

View File

@ -1790,14 +1790,14 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
} }
} }
bool normalize = false; bool normalize = false;
bool compress = false; bool compress_stream = false;
bool uncompress = false; bool uncompress = false;
if (is_metadata && if (is_metadata &&
((! this->m->encrypted) || (this->m->encrypt_metadata == false))) ((! this->m->encrypted) || (this->m->encrypt_metadata == false)))
{ {
QTC::TC("qpdf", "QPDFWriter not compressing metadata"); QTC::TC("qpdf", "QPDFWriter not compressing metadata");
filter = true; filter = true;
compress = false; compress_stream = false;
uncompress = true; uncompress = true;
} }
else if (this->m->normalize_content && else if (this->m->normalize_content &&
@ -1808,7 +1808,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
} }
else if (filter && this->m->compress_streams) else if (filter && this->m->compress_streams)
{ {
compress = true; compress_stream = true;
QTC::TC("qpdf", "QPDFWriter compressing uncompressed stream"); QTC::TC("qpdf", "QPDFWriter compressing uncompressed stream");
} }
@ -1825,7 +1825,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
object.pipeStreamData( object.pipeStreamData(
this->m->pipeline, this->m->pipeline,
(((filter && normalize) ? qpdf_ef_normalize : 0) | (((filter && normalize) ? qpdf_ef_normalize : 0) |
((filter && compress) ? qpdf_ef_compress : 0)), ((filter && compress_stream) ? qpdf_ef_compress : 0)),
(filter (filter
? (uncompress ? qpdf_dl_all : this->m->stream_decode_level) ? (uncompress ? qpdf_dl_all : this->m->stream_decode_level)
: qpdf_dl_none), false, (attempt == 1)); : qpdf_dl_none), false, (attempt == 1));
@ -1845,7 +1845,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
} }
else else
{ {
compress = false; compress_stream = false;
} }
this->m->cur_stream_length = stream_data->getSize(); this->m->cur_stream_length = stream_data->getSize();
@ -1856,7 +1856,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
} }
adjustAESStreamLength(this->m->cur_stream_length); adjustAESStreamLength(this->m->cur_stream_length);
unparseObject(stream_dict, 0, flags, unparseObject(stream_dict, 0, flags,
this->m->cur_stream_length, compress); this->m->cur_stream_length, compress_stream);
unsigned char last_char = '\0'; unsigned char last_char = '\0';
writeString("\nstream\n"); writeString("\nstream\n");
{ {
@ -2330,11 +2330,10 @@ QPDFWriter::initializeSpecialStreams()
contents_objects.push_back(contents.getObjGen()); contents_objects.push_back(contents.getObjGen());
} }
for (std::vector<QPDFObjGen>::iterator iter = contents_objects.begin(); for (auto const& c: contents_objects)
iter != contents_objects.end(); ++iter)
{ {
this->m->contents_to_page_seq[*iter] = num; this->m->contents_to_page_seq[c] = num;
this->m->normalized_streams.insert(*iter); this->m->normalized_streams.insert(c);
} }
} }
} }
@ -3462,9 +3461,9 @@ QPDFWriter::writeLinearized()
else else
{ {
// Make the file size the same. // Make the file size the same.
qpdf_offset_t pos = this->m->pipeline->getCount();
writePad( writePad(
QIntC::to_int(second_xref_end + hint_length - 1 - pos)); QIntC::to_int(second_xref_end + hint_length -
1 - this->m->pipeline->getCount()));
writeString("\n"); writeString("\n");
// If this assertion fails, maybe we didn't have // If this assertion fails, maybe we didn't have
@ -3507,7 +3506,7 @@ QPDFWriter::writeLinearized()
// Save hint offset since it will be set to zero by // Save hint offset since it will be set to zero by
// calling openObject. // calling openObject.
qpdf_offset_t hint_offset = this->m->xref[hint_id].getOffset(); qpdf_offset_t hint_offset1 = this->m->xref[hint_id].getOffset();
// Write hint stream to a buffer // Write hint stream to a buffer
{ {
@ -3519,12 +3518,12 @@ QPDFWriter::writeLinearized()
hint_length = QIntC::to_offset(hint_buffer->getSize()); hint_length = QIntC::to_offset(hint_buffer->getSize());
// Restore hint offset // Restore hint offset
this->m->xref[hint_id] = QPDFXRefEntry(1, hint_offset, 0); this->m->xref[hint_id] = QPDFXRefEntry(1, hint_offset1, 0);
if (lin_pass1_file) if (lin_pass1_file)
{ {
// Write some debugging information // Write some debugging information
fprintf(lin_pass1_file, "%% hint_offset=%s\n", fprintf(lin_pass1_file, "%% hint_offset=%s\n",
QUtil::int_to_string(hint_offset).c_str()); QUtil::int_to_string(hint_offset1).c_str());
fprintf(lin_pass1_file, "%% hint_length=%s\n", fprintf(lin_pass1_file, "%% hint_length=%s\n",
QUtil::int_to_string(hint_length).c_str()); QUtil::int_to_string(hint_length).c_str());
fprintf(lin_pass1_file, "%% second_xref_offset=%s\n", fprintf(lin_pass1_file, "%% second_xref_offset=%s\n",

View File

@ -555,12 +555,14 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp,
to_delete.push_back(pipeline); to_delete.push_back(pipeline);
} }
for (std::vector<std::string>::reverse_iterator iter = filters.rbegin(); for (std::vector<std::string>::reverse_iterator f_iter =
iter != filters.rend(); ++iter) filters.rbegin();
f_iter != filters.rend(); ++f_iter)
{ {
std::string const& filter = *iter; std::string const& filter_name = *f_iter;
if ((filter == "/FlateDecode") || (filter == "/LZWDecode")) if ((filter_name == "/FlateDecode") ||
(filter_name == "/LZWDecode"))
{ {
if ((predictor >= 10) && (predictor <= 15)) if ((predictor >= 10) && (predictor <= 15))
{ {
@ -584,39 +586,39 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline, bool* filterp,
} }
} }
if (filter == "/Crypt") if (filter_name == "/Crypt")
{ {
// Ignore -- handled by pipeStreamData // Ignore -- handled by pipeStreamData
} }
else if (filter == "/FlateDecode") else if (filter_name == "/FlateDecode")
{ {
pipeline = new Pl_Flate("stream inflate", pipeline = new Pl_Flate("stream inflate",
pipeline, Pl_Flate::a_inflate); pipeline, Pl_Flate::a_inflate);
to_delete.push_back(pipeline); to_delete.push_back(pipeline);
} }
else if (filter == "/ASCII85Decode") else if (filter_name == "/ASCII85Decode")
{ {
pipeline = new Pl_ASCII85Decoder("ascii85 decode", pipeline); pipeline = new Pl_ASCII85Decoder("ascii85 decode", pipeline);
to_delete.push_back(pipeline); to_delete.push_back(pipeline);
} }
else if (filter == "/ASCIIHexDecode") else if (filter_name == "/ASCIIHexDecode")
{ {
pipeline = new Pl_ASCIIHexDecoder("asciiHex decode", pipeline); pipeline = new Pl_ASCIIHexDecoder("asciiHex decode", pipeline);
to_delete.push_back(pipeline); to_delete.push_back(pipeline);
} }
else if (filter == "/LZWDecode") else if (filter_name == "/LZWDecode")
{ {
pipeline = new Pl_LZWDecoder("lzw decode", pipeline, pipeline = new Pl_LZWDecoder("lzw decode", pipeline,
early_code_change); early_code_change);
to_delete.push_back(pipeline); to_delete.push_back(pipeline);
} }
else if (filter == "/RunLengthDecode") else if (filter_name == "/RunLengthDecode")
{ {
pipeline = new Pl_RunLength("runlength decode", pipeline, pipeline = new Pl_RunLength("runlength decode", pipeline,
Pl_RunLength::a_decode); Pl_RunLength::a_decode);
to_delete.push_back(pipeline); to_delete.push_back(pipeline);
} }
else if (filter == "/DCTDecode") else if (filter_name == "/DCTDecode")
{ {
pipeline = new Pl_DCT("DCT decode", pipeline); pipeline = new Pl_DCT("DCT decode", pipeline);
to_delete.push_back(pipeline); to_delete.push_back(pipeline);

View File

@ -322,10 +322,10 @@ hash_V5(std::string const& password,
int next_hash = ((E_mod_3 == 0) ? 256 : int next_hash = ((E_mod_3 == 0) ? 256 :
(E_mod_3 == 1) ? 384 : (E_mod_3 == 1) ? 384 :
512); 512);
Pl_SHA2 hash(next_hash); Pl_SHA2 sha2(next_hash);
hash.write(QUtil::unsigned_char_pointer(E), E.length()); sha2.write(QUtil::unsigned_char_pointer(E), E.length());
hash.finish(); sha2.finish();
K = hash.getRawDigest(); K = sha2.getRawDigest();
if (round_number >= 64) if (round_number >= 64)
{ {

View File

@ -374,9 +374,9 @@ QPDF::readHintStream(Pipeline& pl, qpdf_offset_t offset, size_t length)
QTC::TC("qpdf", "QPDF hint table length indirect"); QTC::TC("qpdf", "QPDF hint table length indirect");
// Force resolution // Force resolution
(void) length_obj.getIntValue(); (void) length_obj.getIntValue();
ObjCache& oc = this->m->obj_cache[length_obj.getObjGen()]; ObjCache& oc2 = this->m->obj_cache[length_obj.getObjGen()];
min_end_offset = oc.end_before_space; min_end_offset = oc2.end_before_space;
max_end_offset = oc.end_after_space; max_end_offset = oc2.end_after_space;
} }
else else
{ {

View File

@ -812,7 +812,7 @@ QUtil::toUTF8(unsigned long uval)
// maximum value that will fit in the current number of bytes // maximum value that will fit in the current number of bytes
unsigned char maxval = 0x3f; // six bits unsigned char maxval = 0x3f; // six bits
while (uval > maxval) while (uval > QIntC::to_ulong(maxval))
{ {
// Assign low six bits plus 10000000 to lowest unused // Assign low six bits plus 10000000 to lowest unused
// byte position, then shift // byte position, then shift
@ -2163,12 +2163,12 @@ QUtil::win_ansi_to_utf8(std::string const& val)
for (unsigned int i = 0; i < len; ++i) for (unsigned int i = 0; i < len; ++i)
{ {
unsigned char ch = static_cast<unsigned char>(val.at(i)); unsigned char ch = static_cast<unsigned char>(val.at(i));
unsigned short val = ch; unsigned short ch_short = ch;
if ((ch >= 128) && (ch <= 160)) if ((ch >= 128) && (ch <= 160))
{ {
val = win_ansi_to_unicode[ch - 128]; ch_short = win_ansi_to_unicode[ch - 128];
} }
result += QUtil::toUTF8(val); result += QUtil::toUTF8(ch_short);
} }
return result; return result;
} }
@ -2181,12 +2181,12 @@ QUtil::mac_roman_to_utf8(std::string const& val)
for (unsigned int i = 0; i < len; ++i) for (unsigned int i = 0; i < len; ++i)
{ {
unsigned char ch = static_cast<unsigned char>(val.at(i)); unsigned char ch = static_cast<unsigned char>(val.at(i));
unsigned short val = ch; unsigned short ch_short = ch;
if (ch >= 128) if (ch >= 128)
{ {
val = mac_roman_to_unicode[ch - 128]; ch_short = mac_roman_to_unicode[ch - 128];
} }
result += QUtil::toUTF8(val); result += QUtil::toUTF8(ch_short);
} }
return result; return result;
} }
@ -2199,12 +2199,12 @@ QUtil::pdf_doc_to_utf8(std::string const& val)
for (unsigned int i = 0; i < len; ++i) for (unsigned int i = 0; i < len; ++i)
{ {
unsigned char ch = static_cast<unsigned char>(val.at(i)); unsigned char ch = static_cast<unsigned char>(val.at(i));
unsigned short val = ch; unsigned short ch_short = ch;
if ((ch >= 128) && (ch <= 160)) if ((ch >= 128) && (ch <= 160))
{ {
val = pdf_doc_to_unicode[ch - 128]; ch_short = pdf_doc_to_unicode[ch - 128];
} }
result += QUtil::toUTF8(val); result += QUtil::toUTF8(ch_short);
} }
return result; return result;
} }

View File

@ -3610,13 +3610,10 @@ static void do_show_pages(QPDF& pdf, Options& o)
if (! images.empty()) if (! images.empty())
{ {
std::cout << " images:" << std::endl; std::cout << " images:" << std::endl;
for (std::map<std::string, for (auto const& iter2: images)
QPDFObjectHandle>::iterator
iter = images.begin();
iter != images.end(); ++iter)
{ {
std::string const& name = (*iter).first; std::string const& name = iter2.first;
QPDFObjectHandle image = (*iter).second; QPDFObjectHandle image = iter2.second;
QPDFObjectHandle dict = image.getDict(); QPDFObjectHandle dict = image.getDict();
int width = int width =
dict.getKey("/Width").getIntValueAsInt(); dict.getKey("/Width").getIntValueAsInt();
@ -3633,11 +3630,9 @@ static void do_show_pages(QPDF& pdf, Options& o)
std::cout << " content:" << std::endl; std::cout << " content:" << std::endl;
std::vector<QPDFObjectHandle> content = std::vector<QPDFObjectHandle> content =
ph.getPageContents(); ph.getPageContents();
for (std::vector<QPDFObjectHandle>::iterator iter = for (auto& iter2: content)
content.begin();
iter != content.end(); ++iter)
{ {
std::cout << " " << (*iter).unparse() << std::endl; std::cout << " " << iter2.unparse() << std::endl;
} }
} }
} }
@ -3738,14 +3733,12 @@ static void do_json_pages(QPDF& pdf, Options& o, JSON& j)
"images", JSON::makeArray()); "images", JSON::makeArray());
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images =
ph.getPageImages(); ph.getPageImages();
for (std::map<std::string, QPDFObjectHandle>::iterator iter = for (auto const& iter2: images)
images.begin();
iter != images.end(); ++iter)
{ {
JSON j_image = j_images.addArrayElement(JSON::makeDictionary()); JSON j_image = j_images.addArrayElement(JSON::makeDictionary());
j_image.addDictionaryMember( j_image.addDictionaryMember(
"name", JSON::makeString((*iter).first)); "name", JSON::makeString(iter2.first));
QPDFObjectHandle image = (*iter).second; QPDFObjectHandle image = iter2.second;
QPDFObjectHandle dict = image.getDict(); QPDFObjectHandle dict = image.getDict();
j_image.addDictionaryMember("object", image.getJSON()); j_image.addDictionaryMember("object", image.getJSON());
j_image.addDictionaryMember( j_image.addDictionaryMember(
@ -3783,10 +3776,9 @@ static void do_json_pages(QPDF& pdf, Options& o, JSON& j)
JSON j_contents = j_page.addDictionaryMember( JSON j_contents = j_page.addDictionaryMember(
"contents", JSON::makeArray()); "contents", JSON::makeArray());
std::vector<QPDFObjectHandle> content = ph.getPageContents(); std::vector<QPDFObjectHandle> content = ph.getPageContents();
for (std::vector<QPDFObjectHandle>::iterator iter = content.begin(); for (auto& iter2: content)
iter != content.end(); ++iter)
{ {
j_contents.addArrayElement((*iter).getJSON()); j_contents.addArrayElement(iter2.getJSON());
} }
j_page.addDictionaryMember( j_page.addDictionaryMember(
"label", pldh.getLabelForPage(pageno).getJSON()); "label", pldh.getLabelForPage(pageno).getJSON());
@ -4761,12 +4753,10 @@ static void handle_transformations(QPDF& pdf, Options& o)
QPDFObjectHandle page = ph.getObjectHandle(); QPDFObjectHandle page = ph.getObjectHandle();
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images =
ph.getPageImages(); ph.getPageImages();
for (std::map<std::string, QPDFObjectHandle>::iterator iter = for (auto& iter2: images)
images.begin();
iter != images.end(); ++iter)
{ {
std::string name = (*iter).first; std::string name = iter2.first;
QPDFObjectHandle& image = (*iter).second; QPDFObjectHandle& image = iter2.second;
ImageOptimizer* io = new ImageOptimizer(o, image); ImageOptimizer* io = new ImageOptimizer(o, image);
PointerHolder<QPDFObjectHandle::StreamDataProvider> sdp(io); PointerHolder<QPDFObjectHandle::StreamDataProvider> sdp(io);
if (io->evaluate("image " + name + " on page " + if (io->evaluate("image " + name + " on page " +

View File

@ -347,10 +347,10 @@ void runtest(int n, char const* filename1, char const* arg2)
else if (qtest.isArray()) else if (qtest.isArray())
{ {
QTC::TC("qpdf", "main QTest array"); QTC::TC("qpdf", "main QTest array");
int n = qtest.getArrayNItems(); int nitems = qtest.getArrayNItems();
std::cout << "/QTest is an array with " std::cout << "/QTest is an array with "
<< n << " items" << std::endl; << nitems << " items" << std::endl;
for (int i = 0; i < n; ++i) for (int i = 0; i < nitems; ++i)
{ {
QTC::TC("qpdf", "main QTest array indirect", QTC::TC("qpdf", "main QTest array indirect",
qtest.getArrayItem(i).isIndirect() ? 1 : 0); qtest.getArrayItem(i).isIndirect() ? 1 : 0);
@ -510,11 +510,10 @@ void runtest(int n, char const* filename1, char const* arg2)
std::cout << " images:" << std::endl; std::cout << " images:" << std::endl;
std::map<std::string, QPDFObjectHandle> images = std::map<std::string, QPDFObjectHandle> images =
page.getPageImages(); page.getPageImages();
for (std::map<std::string, QPDFObjectHandle>::iterator iter = for (auto const& iter2: images)
images.begin(); iter != images.end(); ++iter)
{ {
std::string const& name = (*iter).first; std::string const& name = iter2.first;
QPDFObjectHandle image = (*iter).second; QPDFObjectHandle image = iter2.second;
QPDFObjectHandle dict = image.getDict(); QPDFObjectHandle dict = image.getDict();
long long width = dict.getKey("/Width").getIntValue(); long long width = dict.getKey("/Width").getIntValue();
long long height = dict.getKey("/Height").getIntValue(); long long height = dict.getKey("/Height").getIntValue();
@ -525,10 +524,9 @@ void runtest(int n, char const* filename1, char const* arg2)
std::cout << " content:" << std::endl; std::cout << " content:" << std::endl;
std::vector<QPDFObjectHandle> content = page.getPageContents(); std::vector<QPDFObjectHandle> content = page.getPageContents();
for (std::vector<QPDFObjectHandle>::iterator iter = content.begin(); for (auto& iter2: content)
iter != content.end(); ++iter)
{ {
std::cout << " " << (*iter).unparse() << std::endl; std::cout << " " << iter2.unparse() << std::endl;
} }
std::cout << "end page " << pageno << std::endl; std::cout << "end page " << pageno << std::endl;
@ -539,8 +537,8 @@ void runtest(int n, char const* filename1, char const* arg2)
if (qstrings.isArray()) if (qstrings.isArray())
{ {
std::cout << "QStrings:" << std::endl; std::cout << "QStrings:" << std::endl;
int n = qstrings.getArrayNItems(); int nitems = qstrings.getArrayNItems();
for (int i = 0; i < n; ++i) for (int i = 0; i < nitems; ++i)
{ {
std::cout << qstrings.getArrayItem(i).getUTF8Value() std::cout << qstrings.getArrayItem(i).getUTF8Value()
<< std::endl; << std::endl;
@ -551,8 +549,8 @@ void runtest(int n, char const* filename1, char const* arg2)
if (qnumbers.isArray()) if (qnumbers.isArray())
{ {
std::cout << "QNumbers:" << std::endl; std::cout << "QNumbers:" << std::endl;
int n = qnumbers.getArrayNItems(); int nitems = qnumbers.getArrayNItems();
for (int i = 0; i < n; ++i) for (int i = 0; i < nitems; ++i)
{ {
std::cout << QUtil::double_to_string( std::cout << QUtil::double_to_string(
qnumbers.getArrayItem(i).getNumericValue(), 3) qnumbers.getArrayItem(i).getNumericValue(), 3)
@ -1853,8 +1851,8 @@ void runtest(int n, char const* filename1, char const* arg2)
// button-set*.pdf are designed for this test case. // button-set*.pdf are designed for this test case.
QPDFObjectHandle acroform = pdf.getRoot().getKey("/AcroForm"); QPDFObjectHandle acroform = pdf.getRoot().getKey("/AcroForm");
QPDFObjectHandle fields = acroform.getKey("/Fields"); QPDFObjectHandle fields = acroform.getKey("/Fields");
int n = fields.getArrayNItems(); int nitems = fields.getArrayNItems();
for (int i = 0; i < n; ++i) for (int i = 0; i < nitems; ++i)
{ {
QPDFObjectHandle field = fields.getArrayItem(i); QPDFObjectHandle field = fields.getArrayItem(i);
QPDFObjectHandle T = field.getKey("/T"); QPDFObjectHandle T = field.getKey("/T");
@ -1900,8 +1898,8 @@ void runtest(int n, char const* filename1, char const* arg2)
// generating testing. // generating testing.
QPDFObjectHandle acroform = pdf.getRoot().getKey("/AcroForm"); QPDFObjectHandle acroform = pdf.getRoot().getKey("/AcroForm");
QPDFObjectHandle fields = acroform.getKey("/Fields"); QPDFObjectHandle fields = acroform.getKey("/Fields");
int n = fields.getArrayNItems(); int nitems = fields.getArrayNItems();
for (int i = 0; i < n; ++i) for (int i = 0; i < nitems; ++i)
{ {
QPDFObjectHandle field = fields.getArrayItem(i); QPDFObjectHandle field = fields.getArrayItem(i);
QPDFObjectHandle T = field.getKey("/T"); QPDFObjectHandle T = field.getKey("/T");