From a9b5ebef1f19ae50deee68401dd090c0f5587400 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sun, 9 Feb 2025 14:44:49 +0000 Subject: [PATCH] Minor code formatting fixes --- libqpdf/InputSource.cc | 3 +-- libqpdf/NNTree.cc | 3 +-- libqpdf/Pl_AES_PDF.cc | 4 +--- libqpdf/Pl_ASCIIHexDecoder.cc | 8 +++----- libqpdf/QPDF.cc | 7 ++----- libqpdf/QPDFFormFieldObjectHelper.cc | 3 +-- libqpdf/QPDFJob.cc | 8 ++------ libqpdf/QPDFObjectHandle.cc | 3 +-- libqpdf/QPDFPageObjectHelper.cc | 3 +-- libqpdf/QPDFWriter.cc | 3 +-- libqpdf/QPDF_linearization.cc | 54 +++++++++++++++--------------------------------------- libqpdf/QPDF_optimization.cc | 3 +-- 12 files changed, 30 insertions(+), 72 deletions(-) diff --git a/libqpdf/InputSource.cc b/libqpdf/InputSource.cc index 8055330..405494e 100644 --- a/libqpdf/InputSource.cc +++ b/libqpdf/InputSource.cc @@ -58,8 +58,7 @@ InputSource::findFirst(char const* start_chars, qpdf_offset_t offset, size_t len size_t size = sizeof(buf) - 1; if ((strlen(start_chars) < 1) || (strlen(start_chars) > size)) { throw std::logic_error( - "InputSource::findSource called with" - " too small or too large of a character sequence"); + "InputSource::findSource called with too small or too large of a character sequence"); } char* p = nullptr; diff --git a/libqpdf/NNTree.cc b/libqpdf/NNTree.cc index b71f8a1..ac06512 100644 --- a/libqpdf/NNTree.cc +++ b/libqpdf/NNTree.cc @@ -63,8 +63,7 @@ NNTreeIterator::updateIValue(bool allow_invalid) if (!okay) { if (!allow_invalid) { throw std::logic_error( - "attempt made to dereference an invalid" - " name/number tree iterator"); + "attempt made to dereference an invalid name/number tree iterator"); } this->ivalue.first = QPDFObjectHandle(); this->ivalue.second = QPDFObjectHandle(); diff --git a/libqpdf/Pl_AES_PDF.cc b/libqpdf/Pl_AES_PDF.cc index 2236486..303f9c8 100644 --- a/libqpdf/Pl_AES_PDF.cc +++ b/libqpdf/Pl_AES_PDF.cc @@ -111,9 +111,7 @@ Pl_AES_PDF::finish() // However, we have encountered files for which the output is not a multiple of the // block size. In this case, pad with zeroes and hope for the best. if (this->offset >= this->buf_size) { - throw std::logic_error( - "buffer overflow in AES encryption" - " pipeline"); + throw std::logic_error("buffer overflow in AES encryption pipeline"); } std::memset(this->inbuf + this->offset, 0, this->buf_size - this->offset); this->offset = this->buf_size; diff --git a/libqpdf/Pl_ASCIIHexDecoder.cc b/libqpdf/Pl_ASCIIHexDecoder.cc index dd2cd46..3f80cf4 100644 --- a/libqpdf/Pl_ASCIIHexDecoder.cc +++ b/libqpdf/Pl_ASCIIHexDecoder.cc @@ -4,6 +4,8 @@ #include #include +using namespace std::literals; + Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) : Pipeline(identifier, next) { @@ -46,11 +48,7 @@ Pl_ASCIIHexDecoder::write(unsigned char const* buf, size_t len) char t[2]; t[0] = ch; t[1] = 0; - throw std::runtime_error( - std::string( - "character out of range" - " during base Hex decode: ") + - t); + throw std::runtime_error("character out of range during base Hex decode: "s + t); } break; } diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 430a7c5..d38f4d7 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -1390,9 +1390,7 @@ QPDF::showXRefTable() break; default: - throw std::logic_error( - "unknown cross-reference table type while" - " showing xref_table"); + throw std::logic_error("unknown cross-reference table type while showing xref_table"); break; } m->log->info("\n"); @@ -2296,8 +2294,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign) ObjCopier& obj_copier = m->object_copiers[other.m->unique_id]; if (!obj_copier.visiting.empty()) { throw std::logic_error( - "obj_copier.visiting is not empty" - " at the beginning of copyForeignObject"); + "obj_copier.visiting is not empty at the beginning of copyForeignObject"); } // Make sure we have an object in this file for every referenced object in the old file. diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc index b333202..77d1e84 100644 --- a/libqpdf/QPDFFormFieldObjectHelper.cc +++ b/libqpdf/QPDFFormFieldObjectHelper.cc @@ -752,8 +752,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& ao QPDFObjectHandle::Rectangle rect = aoh.getRect(); QPDFObjectHandle::Rectangle bbox(0, 0, rect.urx - rect.llx, rect.ury - rect.lly); QPDFObjectHandle dict = QPDFObjectHandle::parse( - "<< /Resources << /ProcSet [ /PDF /Text ] >>" - " /Type /XObject /Subtype /Form >>"); + "<< /Resources << /ProcSet [ /PDF /Text ] >> /Type /XObject /Subtype /Form >>"); dict.replaceKey("/BBox", QPDFObjectHandle::newFromRectangle(bbox)); AS = QPDFObjectHandle::newStream(oh().getOwningQPDF(), "/Tx BMC\nEMC\n"); AS.replaceDict(dict); diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index f0e229d..6bd93aa 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -618,9 +618,7 @@ QPDFJob::checkConfiguration() usage("no output file may be given for this option"); } if (m->check_requires_password && m->check_is_encrypted) { - usage( - "--requires-password and --is-encrypted may not be given" - " together"); + usage("--requires-password and --is-encrypted may not be given together"); } if (m->encrypt && (!m->allow_insecure) && @@ -3142,9 +3140,7 @@ QPDFJob::writeJSON(QPDF& pdf) fp = std::make_shared("json output", fc->f); } else if ((m->json_stream_data == qpdf_sj_file) && m->json_stream_prefix.empty()) { QTC::TC("qpdf", "QPDFJob need json-stream-prefix for stdout"); - usage( - "please specify --json-stream-prefix since the input file " - "name is unknown"); + usage("please specify --json-stream-prefix since the input file name is unknown"); } else { QTC::TC("qpdf", "QPDFJob write json to stdout"); m->log->saveToStandardOutput(true); diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index df791f3..36fc942 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -1258,8 +1258,7 @@ QPDFObjectHandle::getUniqueResourceName( // The number of candidates we test is more than the // number of keys we're checking against. throw std::logic_error( - "unable to find unconflicting name in" - " QPDFObjectHandle::getUniqueResourceName"); + "unable to find unconflicting name in QPDFObjectHandle::getUniqueResourceName"); } // Dictionary mutators are in QPDF_Dictionary.cc diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc index 1e22778..5a06935 100644 --- a/libqpdf/QPDFPageObjectHelper.cc +++ b/libqpdf/QPDFPageObjectHelper.cc @@ -718,8 +718,7 @@ QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations) QPDFObjectHandle bbox = getTrimBox(false).shallowCopy(); if (!bbox.isRectangle()) { oh().warnIfPossible( - "bounding box is invalid; form" - " XObject created from page will not work"); + "bounding box is invalid; form XObject created from page will not work"); } newdict.replaceKey("/BBox", bbox); auto provider = diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index edad06f..a981d91 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1013,8 +1013,7 @@ QPDFWriter::pushMD5Pipeline(PipelinePopper& pp) if (!m->id2.empty()) { // Can't happen in the code throw std::logic_error( - "Deterministic ID computation enabled after ID" - " generation has already occurred."); + "Deterministic ID computation enabled after ID generation has already occurred."); } qpdf_assert_debug(m->deterministic_id); qpdf_assert_debug(m->md5_pipeline == nullptr); diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index 01b1c77..ac9abfa 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -167,9 +167,7 @@ QPDF::readLinearizationData() // that prevent loading. if (!isLinearized()) { - throw std::logic_error( - "called readLinearizationData for file" - " that is not linearized"); + throw std::logic_error("called readLinearizationData for file that is not linearized"); } // /L is read and stored in linp by isLinearized() @@ -468,8 +466,7 @@ QPDF::checkLinearizationInternal() if (m->file->tell() != m->first_xref_item_offset) { QTC::TC("qpdf", "QPDF err /T mismatch"); linearizationWarning( - "space before first xref item (/T) mismatch " - "(computed = " + + "space before first xref item (/T) mismatch (computed = " + std::to_string(m->first_xref_item_offset) + "; file = " + std::to_string(m->file->tell())); } @@ -694,9 +691,7 @@ QPDF::checkHPageOffset( for (size_t i = 0; i < toS(he.nshared_objects); ++i) { int idx = he.shared_identifiers.at(i); if (shared_idx_to_obj.count(idx) == 0) { - stopOnError( - "unable to get object for item in" - " shared objects hint table"); + stopOnError("unable to get object for item in shared objects hint table"); } hint_shared.insert(shared_idx_to_obj[idx]); } @@ -759,15 +754,12 @@ QPDF::checkHSharedObject(std::vector const& pages, std::mappart8.empty()) { - linearizationWarning( - "part 8 is empty but nshared_total > " - "nshared_first_page"); + linearizationWarning("part 8 is empty but nshared_total > nshared_first_page"); } else { int obj = m->part8.at(0).getObjectID(); if (obj != so.first_shared_obj) { linearizationWarning( - "first shared object number mismatch: " - "hint table = " + + "first shared object number mismatch: hint table = " + std::to_string(so.first_shared_obj) + "; computed = " + std::to_string(obj)); } @@ -846,9 +838,7 @@ QPDF::checkHOutlines() std::to_string(table_length) + "; computed = " + std::to_string(length)); } } else { - linearizationWarning( - "incorrect first object number in outline " - "hints table."); + linearizationWarning("incorrect first object number in outline hints table."); } } else { linearizationWarning("incorrect object count in outline hint table"); @@ -1131,9 +1121,7 @@ QPDF::calculateLinearizationData(T const& object_stream_data) break; case ObjUser::ou_bad: - stopOnError( - "INTERNAL ERROR: QPDF::calculateLinearizationData: " - "invalid user type"); + stopOnError("INTERNAL ERROR: QPDF::calculateLinearizationData: invalid user type"); break; } } @@ -1196,9 +1184,7 @@ QPDF::calculateLinearizationData(T const& object_stream_data) // Part 4: open document objects. We don't care about the order. if (lc_root.size() != 1) { - stopOnError( - "found other than one root while" - " calculating linearization data"); + stopOnError("found other than one root while calculating linearization data"); } m->part4.push_back(getObject(*(lc_root.begin()))); for (auto const& og: lc_open_document) { @@ -1255,8 +1241,7 @@ QPDF::calculateLinearizationData(T const& object_stream_data) QPDFObjGen page_og(pages.at(i).getObjGen()); if (!lc_other_page_private.count(page_og)) { stopOnError( - "INTERNAL ERROR: " - "QPDF::calculateLinearizationData: page object for page " + + "INTERNAL ERROR: QPDF::calculateLinearizationData: page object for page " + std::to_string(i) + " not in lc_other_page_private"); } lc_other_page_private.erase(page_og); @@ -1269,9 +1254,7 @@ QPDF::calculateLinearizationData(T const& object_stream_data) ObjUser ou(ObjUser::ou_page, toI(i)); if (m->obj_user_to_objects.count(ou) == 0) { - stopOnError( - "found unreferenced page while" - " calculating linearization data"); + stopOnError("found unreferenced page while calculating linearization data"); } for (auto const& og: m->obj_user_to_objects[ou]) { if (lc_other_page_private.count(og)) { @@ -1284,9 +1267,8 @@ QPDF::calculateLinearizationData(T const& object_stream_data) // That should have covered all part7 objects. if (!lc_other_page_private.empty()) { stopOnError( - "INTERNAL ERROR:" - " QPDF::calculateLinearizationData: lc_other_page_private is " - "not empty after generation of part7"); + "INTERNAL ERROR: QPDF::calculateLinearizationData:" + " lc_other_page_private is not empty after generation of part7"); } // Part 8: other pages' shared objects @@ -1307,9 +1289,7 @@ QPDF::calculateLinearizationData(T const& object_stream_data) std::set pages_ogs = m->obj_user_to_objects[ObjUser(ObjUser::ou_root_key, "/Pages")]; if (pages_ogs.empty()) { - stopOnError( - "found empty pages tree while" - " calculating linearization data"); + stopOnError("found empty pages tree while calculating linearization data"); } for (auto const& og: pages_ogs) { if (lc_other.count(og)) { @@ -1418,9 +1398,7 @@ QPDF::calculateLinearizationData(T const& object_stream_data) CHPageOffsetEntry& pe = m->c_page_offset_data.entries.at(i); ObjUser ou(ObjUser::ou_page, toI(i)); if (m->obj_user_to_objects.count(ou) == 0) { - stopOnError( - "found unreferenced page while" - " calculating linearization data"); + stopOnError("found unreferenced page while calculating linearization data"); } for (auto const& og: m->obj_user_to_objects[ou]) { if ((m->object_to_obj_users[og].size() > 1) && (obj_to_index.count(og.getObj()) > 0)) { @@ -1759,9 +1737,7 @@ QPDF::writeHSharedObject(BitWriter& w) for (size_t i = 0; i < toS(nitems); ++i) { // If signature were present, we'd have to write a 128-bit hash. if (entries.at(i).signature_present != 0) { - stopOnError( - "found unexpected signature present" - " while writing linearization data"); + stopOnError("found unexpected signature present while writing linearization data"); } } write_vector_int(w, nitems, entries, t.nbits_nobjects, &HSharedObjectEntry::nobjects_minus_one); diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc index 65916c7..19de4f4 100644 --- a/libqpdf/QPDF_optimization.cc +++ b/libqpdf/QPDF_optimization.cc @@ -168,8 +168,7 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys) warn_skipped_keys); if (!key_ancestors.empty()) { throw std::logic_error( - "key_ancestors not empty after" - " pushing inherited attributes to pages"); + "key_ancestors not empty after pushing inherited attributes to pages"); } m->pushed_inherited_attributes_to_pages = true; m->ever_pushed_inherited_attributes_to_pages = true; -- libgit2 0.21.4