Commit cb0a6be983b7e4ee2784991273777579dcb90b9d

Authored by m-holger
Committed by Jay Berkenbilt
1 parent 5ccab4be

Code tidy: use QPDF::toS and QPDF::toI where possible

libqpdf/QPDF.cc
... ... @@ -1911,7 +1911,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1911 1911  
1912 1912 int num = QUtil::string_to_int(tnum.getValue().c_str());
1913 1913 long long offset = QUtil::string_to_int(toffset.getValue().c_str());
1914   - offsets[num] = QIntC::to_int(offset + first);
  1914 + offsets[num] = toI(offset + first);
1915 1915 }
1916 1916  
1917 1917 // To avoid having to read the object stream multiple times, store
... ...
libqpdf/QPDF_encryption.cc
... ... @@ -422,11 +422,9 @@ QPDF::compute_encryption_key_from_password(
422 422 md5.encodeDataIncrementally(bytes, 4);
423 423 }
424 424 MD5::Digest digest;
425   - int key_len =
426   - std::min(QIntC::to_int(sizeof(digest)), data.getLengthBytes());
  425 + int key_len = std::min(toI(sizeof(digest)), data.getLengthBytes());
427 426 iterate_md5_digest(md5, digest, ((data.getR() >= 3) ? 50 : 0), key_len);
428   - return std::string(
429   - reinterpret_cast<char*>(digest), QIntC::to_size(key_len));
  427 + return std::string(reinterpret_cast<char*>(digest), toS(key_len));
430 428 }
431 429  
432 430 static void
... ...
libqpdf/QPDF_linearization.cc
... ... @@ -128,8 +128,7 @@ QPDF::isLinearized()
128 128 (t2.getType() == QPDFTokenizer::tt_integer) &&
129 129 (t3 == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "obj")) &&
130 130 (t4.getType() == QPDFTokenizer::tt_dict_open)) {
131   - lindict_obj =
132   - QIntC::to_int(QUtil::string_to_ll(t1.getValue().c_str()));
  131 + lindict_obj = toI(QUtil::string_to_ll(t1.getValue().c_str()));
133 132 }
134 133 }
135 134  
... ... @@ -143,8 +142,7 @@ QPDF::isLinearized()
143 142 }
144 143  
145 144 QPDFObjectHandle linkey = candidate.getKey("/Linearized");
146   - if (!(linkey.isNumber() &&
147   - (QIntC::to_int(floor(linkey.getNumericValue())) == 1))) {
  145 + if (!(linkey.isNumber() && (toI(floor(linkey.getNumericValue())) == 1))) {
148 146 return false;
149 147 }
150 148  
... ... @@ -1797,7 +1795,7 @@ QPDF::calculateHSharedObject(
1797 1795 soe.push_back(HSharedObjectEntry());
1798 1796 soe.at(i).delta_group_length = length;
1799 1797 }
1800   - if (soe.size() != QIntC::to_size(cso.nshared_total)) {
  1798 + if (soe.size() != toS(cso.nshared_total)) {
1801 1799 stopOnError("soe has wrong size after initialization");
1802 1800 }
1803 1801  
... ...
libqpdf/QPDF_pages.cc
... ... @@ -238,7 +238,7 @@ QPDF::insertPage(QPDFObjectHandle newpage, int pos)
238 238 QTC::TC("qpdf", "QPDF insert indirect page");
239 239 }
240 240  
241   - if ((pos < 0) || (QIntC::to_size(pos) > this->m->all_pages.size())) {
  241 + if ((pos < 0) || (toS(pos) > m->all_pages.size())) {
242 242 throw std::runtime_error(
243 243 "QPDF::insertPage called with pos out of range");
244 244 }
... ... @@ -247,9 +247,9 @@ QPDF::insertPage(QPDFObjectHandle newpage, int pos)
247 247 "qpdf",
248 248 "QPDF insert page",
249 249 (pos == 0) ? 0 : // insert at beginning
250   - (pos == QIntC::to_int(this->m->all_pages.size())) ? 1
251   - : // at end
252   - 2); // insert in middle
  250 + (pos == toI(m->all_pages.size())) ? 1
  251 + : // at end
  252 + 2); // insert in middle
253 253  
254 254 auto og = newpage.getObjGen();
255 255 if (this->m->pageobj_to_pages_pos.count(og)) {
... ... @@ -279,9 +279,9 @@ QPDF::removePage(QPDFObjectHandle page)
279 279 "qpdf",
280 280 "QPDF remove page",
281 281 (pos == 0) ? 0 : // remove at beginning
282   - (pos == QIntC::to_int(this->m->all_pages.size() - 1)) ? 1
283   - : // end
284   - 2); // remove in middle
  282 + (pos == toI(m->all_pages.size() - 1)) ? 1
  283 + : // end
  284 + 2); // remove in middle
285 285  
286 286 QPDFObjectHandle pages = getRoot().getKey("/Pages");
287 287 QPDFObjectHandle kids = pages.getKey("/Kids");
... ...