2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-10-31 19:02:30 +00:00

Code tidy - Clang-Tidy rule modernize-return-braced-init-list

This commit is contained in:
m-holger 2023-05-27 21:04:32 +01:00
parent acd0acf169
commit 320bbb9854
14 changed files with 67 additions and 69 deletions

View File

@ -81,7 +81,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
static QPDFOutlineObjectHelper static QPDFOutlineObjectHelper
create(QPDFObjectHandle oh, QPDFOutlineDocumentHelper& dh, int depth) create(QPDFObjectHandle oh, QPDFOutlineDocumentHelper& dh, int depth)
{ {
return QPDFOutlineObjectHelper(oh, dh, depth); return {oh, dh, depth};
} }
}; };

View File

@ -37,7 +37,7 @@ InputSource::readLine(size_t max_line_length)
if (line_length < max_line_length) { if (line_length < max_line_length) {
buf[line_length] = '\0'; buf[line_length] = '\0';
} }
return std::string(buf); return {buf};
} }
bool bool

View File

@ -269,7 +269,7 @@ JSON::encode_string(std::string const& str)
JSON JSON
JSON::makeDictionary() JSON::makeDictionary()
{ {
return JSON(std::make_unique<JSON_dictionary>()); return {std::make_unique<JSON_dictionary>()};
} }
JSON JSON
@ -299,7 +299,7 @@ JSON::checkDictionaryKeySeen(std::string const& key)
JSON JSON
JSON::makeArray() JSON::makeArray()
{ {
return JSON(std::make_unique<JSON_array>()); return {std::make_unique<JSON_array>()};
} }
JSON JSON
@ -320,43 +320,43 @@ JSON::addArrayElement(JSON const& val)
JSON JSON
JSON::makeString(std::string const& utf8) JSON::makeString(std::string const& utf8)
{ {
return JSON(std::make_unique<JSON_string>(utf8)); return {std::make_unique<JSON_string>(utf8)};
} }
JSON JSON
JSON::makeInt(long long int value) JSON::makeInt(long long int value)
{ {
return JSON(std::make_unique<JSON_number>(value)); return {std::make_unique<JSON_number>(value)};
} }
JSON JSON
JSON::makeReal(double value) JSON::makeReal(double value)
{ {
return JSON(std::make_unique<JSON_number>(value)); return {std::make_unique<JSON_number>(value)};
} }
JSON JSON
JSON::makeNumber(std::string const& encoded) JSON::makeNumber(std::string const& encoded)
{ {
return JSON(std::make_unique<JSON_number>(encoded)); return {std::make_unique<JSON_number>(encoded)};
} }
JSON JSON
JSON::makeBool(bool value) JSON::makeBool(bool value)
{ {
return JSON(std::make_unique<JSON_bool>(value)); return {std::make_unique<JSON_bool>(value)};
} }
JSON JSON
JSON::makeNull() JSON::makeNull()
{ {
return JSON(std::make_unique<JSON_null>()); return {std::make_unique<JSON_null>()};
} }
JSON JSON
JSON::makeBlob(std::function<void(Pipeline*)> fn) JSON::makeBlob(std::function<void(Pipeline*)> fn)
{ {
return JSON(std::make_unique<JSON_blob>(fn)); return {std::make_unique<JSON_blob>(fn)};
} }
bool bool

View File

@ -689,7 +689,7 @@ NNTreeImpl::begin()
NNTreeImpl::iterator NNTreeImpl::iterator
NNTreeImpl::end() NNTreeImpl::end()
{ {
return iterator(*this); return {*this};
} }
NNTreeImpl::iterator NNTreeImpl::iterator

View File

@ -2212,7 +2212,7 @@ QPDF::getVersionAsPDFVersion()
minor = QUtil::string_to_int(match[2].str().c_str()); minor = QUtil::string_to_int(match[2].str().c_str());
} }
return PDFVersion(major, minor, extension_level); return {major, minor, extension_level};
} }
std::string std::string
@ -2483,7 +2483,7 @@ QPDF::damagedPDF(
qpdf_offset_t offset, qpdf_offset_t offset,
std::string const& message) std::string const& message)
{ {
return QPDFExc(qpdf_e_damaged_pdf, input->getName(), object, offset, message); return {qpdf_e_damaged_pdf, input->getName(), object, offset, message};
} }
// Return an exception of type qpdf_e_damaged_pdf. The object is taken from // Return an exception of type qpdf_e_damaged_pdf. The object is taken from
@ -2499,7 +2499,7 @@ QPDF::damagedPDF(
QPDFExc QPDFExc
QPDF::damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message) QPDF::damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message)
{ {
return QPDFExc(qpdf_e_damaged_pdf, m->file->getName(), object, offset, message); return {qpdf_e_damaged_pdf, m->file->getName(), object, offset, message};
} }
// Return an exception of type qpdf_e_damaged_pdf. The filename is taken from m->file and the // Return an exception of type qpdf_e_damaged_pdf. The filename is taken from m->file and the

View File

@ -194,7 +194,7 @@ QPDFCrypto_openssl::MD5_digest(MD5_Digest d)
std::string std::string
QPDFCrypto_openssl::SHA2_digest() QPDFCrypto_openssl::SHA2_digest()
{ {
return std::string(reinterpret_cast<char*>(md_out), sha2_bits / 8); return {reinterpret_cast<char*>(md_out), sha2_bits / 8};
} }
void void

View File

@ -428,7 +428,7 @@ QPDFJob::parseNumrange(char const* range, int max)
} catch (std::runtime_error& e) { } catch (std::runtime_error& e) {
usage(e.what()); usage(e.what());
} }
return std::vector<int>(); return {};
} }
std::unique_ptr<QPDF> std::unique_ptr<QPDF>

View File

@ -57,7 +57,7 @@ QPDFMatrix::unparse() const
QPDFObjectHandle::Matrix QPDFObjectHandle::Matrix
QPDFMatrix::getAsMatrix() const QPDFMatrix::getAsMatrix() const
{ {
return QPDFObjectHandle::Matrix(a, b, c, d, e, f); return {a, b, c, d, e, f};
} }
void void
@ -124,11 +124,11 @@ QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const
transform(r.llx, r.ury, tx.at(1), ty.at(1)); transform(r.llx, r.ury, tx.at(1), ty.at(1));
transform(r.urx, r.lly, tx.at(2), ty.at(2)); transform(r.urx, r.lly, tx.at(2), ty.at(2));
transform(r.urx, r.ury, tx.at(3), ty.at(3)); transform(r.urx, r.ury, tx.at(3), ty.at(3));
return QPDFObjectHandle::Rectangle( return {
*std::min_element(tx.begin(), tx.end()), *std::min_element(tx.begin(), tx.end()),
*std::min_element(ty.begin(), ty.end()), *std::min_element(ty.begin(), ty.end()),
*std::max_element(tx.begin(), tx.end()), *std::max_element(tx.begin(), tx.end()),
*std::max_element(ty.begin(), ty.end())); *std::max_element(ty.begin(), ty.end())};
} }
bool bool

View File

@ -54,8 +54,7 @@ QPDFNameTreeObjectHelper::QPDFNameTreeObjectHelper(QPDFObjectHandle oh, QPDF& q,
QPDFNameTreeObjectHelper QPDFNameTreeObjectHelper
QPDFNameTreeObjectHelper::newEmpty(QPDF& qpdf, bool auto_repair) QPDFNameTreeObjectHelper::newEmpty(QPDF& qpdf, bool auto_repair)
{ {
return QPDFNameTreeObjectHelper( return {qpdf.makeIndirectObject("<< /Names [] >>"_qpdf), qpdf, auto_repair};
qpdf.makeIndirectObject("<< /Names [] >>"_qpdf), qpdf, auto_repair);
} }
QPDFNameTreeObjectHelper::iterator::iterator(std::shared_ptr<NNTreeIterator> const& i) : QPDFNameTreeObjectHelper::iterator::iterator(std::shared_ptr<NNTreeIterator> const& i) :
@ -135,33 +134,33 @@ QPDFNameTreeObjectHelper::iterator::remove()
QPDFNameTreeObjectHelper::iterator QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::begin() const QPDFNameTreeObjectHelper::begin() const
{ {
return iterator(std::make_shared<NNTreeIterator>(m->impl->begin())); return {std::make_shared<NNTreeIterator>(m->impl->begin())};
} }
QPDFNameTreeObjectHelper::iterator QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::end() const QPDFNameTreeObjectHelper::end() const
{ {
return iterator(std::make_shared<NNTreeIterator>(m->impl->end())); return {std::make_shared<NNTreeIterator>(m->impl->end())};
} }
QPDFNameTreeObjectHelper::iterator QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::last() const QPDFNameTreeObjectHelper::last() const
{ {
return iterator(std::make_shared<NNTreeIterator>(m->impl->last())); return {std::make_shared<NNTreeIterator>(m->impl->last())};
} }
QPDFNameTreeObjectHelper::iterator QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::find(std::string const& key, bool return_prev_if_not_found) QPDFNameTreeObjectHelper::find(std::string const& key, bool return_prev_if_not_found)
{ {
auto i = m->impl->find(QPDFObjectHandle::newUnicodeString(key), return_prev_if_not_found); auto i = m->impl->find(QPDFObjectHandle::newUnicodeString(key), return_prev_if_not_found);
return iterator(std::make_shared<NNTreeIterator>(i)); return {std::make_shared<NNTreeIterator>(i)};
} }
QPDFNameTreeObjectHelper::iterator QPDFNameTreeObjectHelper::iterator
QPDFNameTreeObjectHelper::insert(std::string const& key, QPDFObjectHandle value) QPDFNameTreeObjectHelper::insert(std::string const& key, QPDFObjectHandle value)
{ {
auto i = m->impl->insert(QPDFObjectHandle::newUnicodeString(key), value); auto i = m->impl->insert(QPDFObjectHandle::newUnicodeString(key), value);
return iterator(std::make_shared<NNTreeIterator>(i)); return {std::make_shared<NNTreeIterator>(i)};
} }
bool bool

View File

@ -56,8 +56,7 @@ QPDFNumberTreeObjectHelper::QPDFNumberTreeObjectHelper(
QPDFNumberTreeObjectHelper QPDFNumberTreeObjectHelper
QPDFNumberTreeObjectHelper::newEmpty(QPDF& qpdf, bool auto_repair) QPDFNumberTreeObjectHelper::newEmpty(QPDF& qpdf, bool auto_repair)
{ {
return QPDFNumberTreeObjectHelper( return {qpdf.makeIndirectObject("<< /Nums [] >>"_qpdf), qpdf, auto_repair};
qpdf.makeIndirectObject("<< /Nums [] >>"_qpdf), qpdf, auto_repair);
} }
QPDFNumberTreeObjectHelper::iterator::iterator(std::shared_ptr<NNTreeIterator> const& i) : QPDFNumberTreeObjectHelper::iterator::iterator(std::shared_ptr<NNTreeIterator> const& i) :
@ -137,33 +136,33 @@ QPDFNumberTreeObjectHelper::iterator::remove()
QPDFNumberTreeObjectHelper::iterator QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::begin() const QPDFNumberTreeObjectHelper::begin() const
{ {
return iterator(std::make_shared<NNTreeIterator>(m->impl->begin())); return {std::make_shared<NNTreeIterator>(m->impl->begin())};
} }
QPDFNumberTreeObjectHelper::iterator QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::end() const QPDFNumberTreeObjectHelper::end() const
{ {
return iterator(std::make_shared<NNTreeIterator>(m->impl->end())); return {std::make_shared<NNTreeIterator>(m->impl->end())};
} }
QPDFNumberTreeObjectHelper::iterator QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::last() const QPDFNumberTreeObjectHelper::last() const
{ {
return iterator(std::make_shared<NNTreeIterator>(m->impl->last())); return {std::make_shared<NNTreeIterator>(m->impl->last())};
} }
QPDFNumberTreeObjectHelper::iterator QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::find(numtree_number key, bool return_prev_if_not_found) QPDFNumberTreeObjectHelper::find(numtree_number key, bool return_prev_if_not_found)
{ {
auto i = m->impl->find(QPDFObjectHandle::newInteger(key), return_prev_if_not_found); auto i = m->impl->find(QPDFObjectHandle::newInteger(key), return_prev_if_not_found);
return iterator(std::make_shared<NNTreeIterator>(i)); return {std::make_shared<NNTreeIterator>(i)};
} }
QPDFNumberTreeObjectHelper::iterator QPDFNumberTreeObjectHelper::iterator
QPDFNumberTreeObjectHelper::insert(numtree_number key, QPDFObjectHandle value) QPDFNumberTreeObjectHelper::insert(numtree_number key, QPDFObjectHandle value)
{ {
auto i = m->impl->insert(QPDFObjectHandle::newInteger(key), value); auto i = m->impl->insert(QPDFObjectHandle::newInteger(key), value);
return iterator(std::make_shared<NNTreeIterator>(i)); return {std::make_shared<NNTreeIterator>(i)};
} }
bool bool

View File

@ -752,7 +752,7 @@ QPDFObjectHandle::getValueAsInlineImage(std::string& value)
QPDFObjectHandle::QPDFArrayItems QPDFObjectHandle::QPDFArrayItems
QPDFObjectHandle::aitems() QPDFObjectHandle::aitems()
{ {
return QPDFArrayItems(*this); return *this;
} }
int int
@ -826,11 +826,11 @@ QPDFObjectHandle::getArrayAsRectangle()
return {}; return {};
} }
} }
return Rectangle( return {
std::min(items[0], items[2]), std::min(items[0], items[2]),
std::min(items[1], items[3]), std::min(items[1], items[3]),
std::max(items[0], items[2]), std::max(items[0], items[2]),
std::max(items[1], items[3])); std::max(items[1], items[3])};
} }
return {}; return {};
} }
@ -848,7 +848,7 @@ QPDFObjectHandle::getArrayAsMatrix()
return {}; return {};
} }
} }
return Matrix(items[0], items[1], items[2], items[3], items[4], items[5]); return {items[0], items[1], items[2], items[3], items[4], items[5]};
} }
return {}; return {};
} }
@ -959,7 +959,7 @@ QPDFObjectHandle::eraseItemAndGetOld(int at)
QPDFObjectHandle::QPDFDictItems QPDFObjectHandle::QPDFDictItems
QPDFObjectHandle::ditems() QPDFObjectHandle::ditems()
{ {
return QPDFDictItems(*this); return {*this};
} }
bool bool
@ -1862,61 +1862,61 @@ QPDFObjectHandle::getParsedOffset()
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newBool(bool value) QPDFObjectHandle::newBool(bool value)
{ {
return QPDFObjectHandle(QPDF_Bool::create(value)); return {QPDF_Bool::create(value)};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newNull() QPDFObjectHandle::newNull()
{ {
return QPDFObjectHandle(QPDF_Null::create()); return {QPDF_Null::create()};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newInteger(long long value) QPDFObjectHandle::newInteger(long long value)
{ {
return QPDFObjectHandle(QPDF_Integer::create(value)); return {QPDF_Integer::create(value)};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newReal(std::string const& value) QPDFObjectHandle::newReal(std::string const& value)
{ {
return QPDFObjectHandle(QPDF_Real::create(value)); return {QPDF_Real::create(value)};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newReal(double value, int decimal_places, bool trim_trailing_zeroes) QPDFObjectHandle::newReal(double value, int decimal_places, bool trim_trailing_zeroes)
{ {
return QPDFObjectHandle(QPDF_Real::create(value, decimal_places, trim_trailing_zeroes)); return {QPDF_Real::create(value, decimal_places, trim_trailing_zeroes)};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newName(std::string const& name) QPDFObjectHandle::newName(std::string const& name)
{ {
return QPDFObjectHandle(QPDF_Name::create(name)); return {QPDF_Name::create(name)};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newString(std::string const& str) QPDFObjectHandle::newString(std::string const& str)
{ {
return QPDFObjectHandle(QPDF_String::create(str)); return {QPDF_String::create(str)};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newUnicodeString(std::string const& utf8_str) QPDFObjectHandle::newUnicodeString(std::string const& utf8_str)
{ {
return QPDFObjectHandle(QPDF_String::create_utf16(utf8_str)); return {QPDF_String::create_utf16(utf8_str)};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newOperator(std::string const& value) QPDFObjectHandle::newOperator(std::string const& value)
{ {
return QPDFObjectHandle(QPDF_Operator::create(value)); return {QPDF_Operator::create(value)};
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newInlineImage(std::string const& value) QPDFObjectHandle::newInlineImage(std::string const& value)
{ {
return QPDFObjectHandle(QPDF_InlineImage::create(value)); return {QPDF_InlineImage::create(value)};
} }
QPDFObjectHandle QPDFObjectHandle
@ -1928,7 +1928,7 @@ QPDFObjectHandle::newArray()
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newArray(std::vector<QPDFObjectHandle> const& items) QPDFObjectHandle::newArray(std::vector<QPDFObjectHandle> const& items)
{ {
return QPDFObjectHandle(QPDF_Array::create(items)); return {QPDF_Array::create(items)};
} }
QPDFObjectHandle QPDFObjectHandle
@ -1995,7 +1995,7 @@ QPDFObjectHandle::newDictionary()
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newDictionary(std::map<std::string, QPDFObjectHandle> const& items) QPDFObjectHandle::newDictionary(std::map<std::string, QPDFObjectHandle> const& items)
{ {
return QPDFObjectHandle(QPDF_Dictionary::create(items)); return {QPDF_Dictionary::create(items)};
} }
QPDFObjectHandle QPDFObjectHandle
@ -2060,7 +2060,7 @@ QPDFObjectHandle::shallowCopy()
if (!dereference()) { if (!dereference()) {
throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle"); throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle");
} }
return QPDFObjectHandle(obj->copy()); return {obj->copy()};
} }
QPDFObjectHandle QPDFObjectHandle
@ -2069,7 +2069,7 @@ QPDFObjectHandle::unsafeShallowCopy()
if (!dereference()) { if (!dereference()) {
throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle"); throw std::logic_error("operation attempted on uninitialized QPDFObjectHandle");
} }
return QPDFObjectHandle(obj->copy(true)); return {obj->copy(true)};
} }
void void
@ -2471,13 +2471,13 @@ QPDFObjectHandle::QPDFDictItems::iterator::Members::Members(QPDFObjectHandle& oh
QPDFObjectHandle::QPDFDictItems::iterator QPDFObjectHandle::QPDFDictItems::iterator
QPDFObjectHandle::QPDFDictItems::begin() QPDFObjectHandle::QPDFDictItems::begin()
{ {
return iterator(oh, true); return {oh, true};
} }
QPDFObjectHandle::QPDFDictItems::iterator QPDFObjectHandle::QPDFDictItems::iterator
QPDFObjectHandle::QPDFDictItems::end() QPDFObjectHandle::QPDFDictItems::end()
{ {
return iterator(oh, false); return {oh, false};
} }
QPDFObjectHandle::QPDFArrayItems::QPDFArrayItems(QPDFObjectHandle const& oh) : QPDFObjectHandle::QPDFArrayItems::QPDFArrayItems(QPDFObjectHandle const& oh) :
@ -2551,13 +2551,13 @@ QPDFObjectHandle::QPDFArrayItems::iterator::Members::Members(QPDFObjectHandle& o
QPDFObjectHandle::QPDFArrayItems::iterator QPDFObjectHandle::QPDFArrayItems::iterator
QPDFObjectHandle::QPDFArrayItems::begin() QPDFObjectHandle::QPDFArrayItems::begin()
{ {
return iterator(oh, true); return {oh, true};
} }
QPDFObjectHandle::QPDFArrayItems::iterator QPDFObjectHandle::QPDFArrayItems::iterator
QPDFObjectHandle::QPDFArrayItems::end() QPDFObjectHandle::QPDFArrayItems::end()
{ {
return iterator(oh, false); return {oh, false};
} }
QPDFObjGen QPDFObjGen

View File

@ -662,7 +662,7 @@ QPDFPageObjectHelper::shallowCopyPage()
QPDF& qpdf = QPDF& qpdf =
this->oh.getQPDF("QPDFPageObjectHelper::shallowCopyPage called with a direct object"); this->oh.getQPDF("QPDFPageObjectHelper::shallowCopyPage called with a direct object");
QPDFObjectHandle new_page = this->oh.shallowCopy(); QPDFObjectHandle new_page = this->oh.shallowCopy();
return QPDFPageObjectHelper(qpdf.makeIndirectObject(new_page)); return {qpdf.makeIndirectObject(new_page)};
} }
QPDFObjectHandle::Matrix QPDFObjectHandle::Matrix
@ -758,7 +758,7 @@ QPDFPageObjectHelper::getMatrixForFormXObjectPlacement(
QPDFObjectHandle fdict = fo.getDict(); QPDFObjectHandle fdict = fo.getDict();
QPDFObjectHandle bbox_obj = fdict.getKey("/BBox"); QPDFObjectHandle bbox_obj = fdict.getKey("/BBox");
if (!bbox_obj.isRectangle()) { if (!bbox_obj.isRectangle()) {
return QPDFMatrix(); return {};
} }
QPDFMatrix wmatrix; // work matrix QPDFMatrix wmatrix; // work matrix
@ -793,7 +793,7 @@ QPDFPageObjectHelper::getMatrixForFormXObjectPlacement(
// Calculate a scale factor, if needed. Shrink or expand if needed and allowed. // Calculate a scale factor, if needed. Shrink or expand if needed and allowed.
if ((T.urx == T.llx) || (T.ury == T.lly)) { if ((T.urx == T.llx) || (T.ury == T.lly)) {
// avoid division by zero // avoid division by zero
return QPDFMatrix(); return {};
} }
double rect_w = rect.urx - rect.llx; double rect_w = rect.urx - rect.llx;
double rect_h = rect.ury - rect.lly; double rect_h = rect.ury - rect.lly;

View File

@ -164,7 +164,7 @@ pad_or_truncate_password_V4(std::string const& password)
{ {
char k1[key_bytes]; char k1[key_bytes];
pad_or_truncate_password_V4(password, k1); pad_or_truncate_password_V4(password, k1);
return std::string(k1, key_bytes); return {k1, key_bytes};
} }
static std::string static std::string
@ -235,7 +235,7 @@ process_with_aes(
} else { } else {
outlength = std::min(outlength, bufp->getSize()); outlength = std::min(outlength, bufp->getSize());
} }
return std::string(reinterpret_cast<char*>(bufp->getBuffer()), outlength); return {reinterpret_cast<char*>(bufp->getBuffer()), outlength};
} }
static std::string static std::string
@ -355,7 +355,7 @@ QPDF::compute_data_key(
md5.encodeDataIncrementally(result.c_str(), result.length()); md5.encodeDataIncrementally(result.c_str(), result.length());
MD5::Digest digest; MD5::Digest digest;
md5.digest(digest); md5.digest(digest);
return std::string(reinterpret_cast<char*>(digest), std::min(result.length(), toS(16))); return {reinterpret_cast<char*>(digest), std::min(result.length(), toS(16))};
} }
std::string std::string
@ -401,7 +401,7 @@ QPDF::compute_encryption_key_from_password(std::string const& password, Encrypti
MD5::Digest digest; MD5::Digest digest;
int key_len = std::min(toI(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); iterate_md5_digest(md5, digest, ((data.getR() >= 3) ? 50 : 0), key_len);
return std::string(reinterpret_cast<char*>(digest), toS(key_len)); return {reinterpret_cast<char*>(digest), toS(key_len)};
} }
static void static void
@ -448,7 +448,7 @@ compute_O_value(
data.getLengthBytes(), data.getLengthBytes(),
(data.getR() >= 3) ? 20 : 1, (data.getR() >= 3) ? 20 : 1,
false); false);
return std::string(upass, key_bytes); return {upass, key_bytes};
} }
static std::string static std::string
@ -467,7 +467,7 @@ compute_U_value_R2(std::string const& user_password, QPDF::EncryptionData const&
data.getLengthBytes(), data.getLengthBytes(),
1, 1,
false); false);
return std::string(udata, key_bytes); return {udata, key_bytes};
} }
static std::string static std::string
@ -496,7 +496,7 @@ compute_U_value_R3(std::string const& user_password, QPDF::EncryptionData const&
for (unsigned int i = sizeof(MD5::Digest); i < key_bytes; ++i) { for (unsigned int i = sizeof(MD5::Digest); i < key_bytes; ++i) {
result[i] = static_cast<char>((i * i) % 0xff); result[i] = static_cast<char>((i * i) % 0xff);
} }
return std::string(result, key_bytes); return {result, key_bytes};
} }
static std::string static std::string

View File

@ -903,14 +903,14 @@ QUtil::get_current_qpdf_time()
// Don't know how to get timezone on this platform // Don't know how to get timezone on this platform
int tzoff = 0; int tzoff = 0;
# endif # endif
return QPDFTime( return {
static_cast<int>(ltime.tm_year + 1900), static_cast<int>(ltime.tm_year + 1900),
static_cast<int>(ltime.tm_mon + 1), static_cast<int>(ltime.tm_mon + 1),
static_cast<int>(ltime.tm_mday), static_cast<int>(ltime.tm_mday),
static_cast<int>(ltime.tm_hour), static_cast<int>(ltime.tm_hour),
static_cast<int>(ltime.tm_min), static_cast<int>(ltime.tm_min),
static_cast<int>(ltime.tm_sec), static_cast<int>(ltime.tm_sec),
tzoff); tzoff};
#endif #endif
} }