diff options
author | m-holger <m-holger@kubitscheck.org> | 2022-07-13 15:24:19 +0200 |
---|---|---|
committer | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2022-10-01 17:17:39 +0200 |
commit | cb0a6be983b7e4ee2784991273777579dcb90b9d (patch) | |
tree | 5f07ee022874b651f0c36016cb5df10cd32ffffe | |
parent | 5ccab4be03701744f9795b37b4e5835b1a7b1c1d (diff) | |
download | qpdf-cb0a6be983b7e4ee2784991273777579dcb90b9d.tar.zst |
Code tidy: use QPDF::toS and QPDF::toI where possible
-rw-r--r-- | libqpdf/QPDF.cc | 2 | ||||
-rw-r--r-- | libqpdf/QPDF_encryption.cc | 6 | ||||
-rw-r--r-- | libqpdf/QPDF_linearization.cc | 8 | ||||
-rw-r--r-- | libqpdf/QPDF_pages.cc | 14 |
4 files changed, 13 insertions, 17 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index b0a972f1..57e3f592 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -1911,7 +1911,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) int num = QUtil::string_to_int(tnum.getValue().c_str()); long long offset = QUtil::string_to_int(toffset.getValue().c_str()); - offsets[num] = QIntC::to_int(offset + first); + offsets[num] = toI(offset + first); } // To avoid having to read the object stream multiple times, store diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc index 1042d04b..2e5ddefb 100644 --- a/libqpdf/QPDF_encryption.cc +++ b/libqpdf/QPDF_encryption.cc @@ -422,11 +422,9 @@ QPDF::compute_encryption_key_from_password( md5.encodeDataIncrementally(bytes, 4); } MD5::Digest digest; - int key_len = - std::min(QIntC::to_int(sizeof(digest)), data.getLengthBytes()); + int key_len = std::min(toI(sizeof(digest)), data.getLengthBytes()); iterate_md5_digest(md5, digest, ((data.getR() >= 3) ? 50 : 0), key_len); - return std::string( - reinterpret_cast<char*>(digest), QIntC::to_size(key_len)); + return std::string(reinterpret_cast<char*>(digest), toS(key_len)); } static void diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index 2444b317..888b4262 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -128,8 +128,7 @@ QPDF::isLinearized() (t2.getType() == QPDFTokenizer::tt_integer) && (t3 == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "obj")) && (t4.getType() == QPDFTokenizer::tt_dict_open)) { - lindict_obj = - QIntC::to_int(QUtil::string_to_ll(t1.getValue().c_str())); + lindict_obj = toI(QUtil::string_to_ll(t1.getValue().c_str())); } } @@ -143,8 +142,7 @@ QPDF::isLinearized() } QPDFObjectHandle linkey = candidate.getKey("/Linearized"); - if (!(linkey.isNumber() && - (QIntC::to_int(floor(linkey.getNumericValue())) == 1))) { + if (!(linkey.isNumber() && (toI(floor(linkey.getNumericValue())) == 1))) { return false; } @@ -1797,7 +1795,7 @@ QPDF::calculateHSharedObject( soe.push_back(HSharedObjectEntry()); soe.at(i).delta_group_length = length; } - if (soe.size() != QIntC::to_size(cso.nshared_total)) { + if (soe.size() != toS(cso.nshared_total)) { stopOnError("soe has wrong size after initialization"); } diff --git a/libqpdf/QPDF_pages.cc b/libqpdf/QPDF_pages.cc index cd05366e..b73e48e1 100644 --- a/libqpdf/QPDF_pages.cc +++ b/libqpdf/QPDF_pages.cc @@ -238,7 +238,7 @@ QPDF::insertPage(QPDFObjectHandle newpage, int pos) QTC::TC("qpdf", "QPDF insert indirect page"); } - if ((pos < 0) || (QIntC::to_size(pos) > this->m->all_pages.size())) { + if ((pos < 0) || (toS(pos) > m->all_pages.size())) { throw std::runtime_error( "QPDF::insertPage called with pos out of range"); } @@ -247,9 +247,9 @@ QPDF::insertPage(QPDFObjectHandle newpage, int pos) "qpdf", "QPDF insert page", (pos == 0) ? 0 : // insert at beginning - (pos == QIntC::to_int(this->m->all_pages.size())) ? 1 - : // at end - 2); // insert in middle + (pos == toI(m->all_pages.size())) ? 1 + : // at end + 2); // insert in middle auto og = newpage.getObjGen(); if (this->m->pageobj_to_pages_pos.count(og)) { @@ -279,9 +279,9 @@ QPDF::removePage(QPDFObjectHandle page) "qpdf", "QPDF remove page", (pos == 0) ? 0 : // remove at beginning - (pos == QIntC::to_int(this->m->all_pages.size() - 1)) ? 1 - : // end - 2); // remove in middle + (pos == toI(m->all_pages.size() - 1)) ? 1 + : // end + 2); // remove in middle QPDFObjectHandle pages = getRoot().getKey("/Pages"); QPDFObjectHandle kids = pages.getKey("/Kids"); |