Commit a9b5ebef1f19ae50deee68401dd090c0f5587400

Authored by m-holger
1 parent f84bf977

Minor code formatting fixes

libqpdf/InputSource.cc
... ... @@ -58,8 +58,7 @@ InputSource::findFirst(char const* start_chars, qpdf_offset_t offset, size_t len
58 58 size_t size = sizeof(buf) - 1;
59 59 if ((strlen(start_chars) < 1) || (strlen(start_chars) > size)) {
60 60 throw std::logic_error(
61   - "InputSource::findSource called with"
62   - " too small or too large of a character sequence");
  61 + "InputSource::findSource called with too small or too large of a character sequence");
63 62 }
64 63  
65 64 char* p = nullptr;
... ...
libqpdf/NNTree.cc
... ... @@ -63,8 +63,7 @@ NNTreeIterator::updateIValue(bool allow_invalid)
63 63 if (!okay) {
64 64 if (!allow_invalid) {
65 65 throw std::logic_error(
66   - "attempt made to dereference an invalid"
67   - " name/number tree iterator");
  66 + "attempt made to dereference an invalid name/number tree iterator");
68 67 }
69 68 this->ivalue.first = QPDFObjectHandle();
70 69 this->ivalue.second = QPDFObjectHandle();
... ...
libqpdf/Pl_AES_PDF.cc
... ... @@ -111,9 +111,7 @@ Pl_AES_PDF::finish()
111 111 // However, we have encountered files for which the output is not a multiple of the
112 112 // block size. In this case, pad with zeroes and hope for the best.
113 113 if (this->offset >= this->buf_size) {
114   - throw std::logic_error(
115   - "buffer overflow in AES encryption"
116   - " pipeline");
  114 + throw std::logic_error("buffer overflow in AES encryption pipeline");
117 115 }
118 116 std::memset(this->inbuf + this->offset, 0, this->buf_size - this->offset);
119 117 this->offset = this->buf_size;
... ...
libqpdf/Pl_ASCIIHexDecoder.cc
... ... @@ -4,6 +4,8 @@
4 4 #include <cctype>
5 5 #include <stdexcept>
6 6  
  7 +using namespace std::literals;
  8 +
7 9 Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) :
8 10 Pipeline(identifier, next)
9 11 {
... ... @@ -46,11 +48,7 @@ Pl_ASCIIHexDecoder::write(unsigned char const* buf, size_t len)
46 48 char t[2];
47 49 t[0] = ch;
48 50 t[1] = 0;
49   - throw std::runtime_error(
50   - std::string(
51   - "character out of range"
52   - " during base Hex decode: ") +
53   - t);
  51 + throw std::runtime_error("character out of range during base Hex decode: "s + t);
54 52 }
55 53 break;
56 54 }
... ...
libqpdf/QPDF.cc
... ... @@ -1390,9 +1390,7 @@ QPDF::showXRefTable()
1390 1390 break;
1391 1391  
1392 1392 default:
1393   - throw std::logic_error(
1394   - "unknown cross-reference table type while"
1395   - " showing xref_table");
  1393 + throw std::logic_error("unknown cross-reference table type while showing xref_table");
1396 1394 break;
1397 1395 }
1398 1396 m->log->info("\n");
... ... @@ -2296,8 +2294,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign)
2296 2294 ObjCopier& obj_copier = m->object_copiers[other.m->unique_id];
2297 2295 if (!obj_copier.visiting.empty()) {
2298 2296 throw std::logic_error(
2299   - "obj_copier.visiting is not empty"
2300   - " at the beginning of copyForeignObject");
  2297 + "obj_copier.visiting is not empty at the beginning of copyForeignObject");
2301 2298 }
2302 2299  
2303 2300 // Make sure we have an object in this file for every referenced object in the old file.
... ...
libqpdf/QPDFFormFieldObjectHelper.cc
... ... @@ -752,8 +752,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper&amp; ao
752 752 QPDFObjectHandle::Rectangle rect = aoh.getRect();
753 753 QPDFObjectHandle::Rectangle bbox(0, 0, rect.urx - rect.llx, rect.ury - rect.lly);
754 754 QPDFObjectHandle dict = QPDFObjectHandle::parse(
755   - "<< /Resources << /ProcSet [ /PDF /Text ] >>"
756   - " /Type /XObject /Subtype /Form >>");
  755 + "<< /Resources << /ProcSet [ /PDF /Text ] >> /Type /XObject /Subtype /Form >>");
757 756 dict.replaceKey("/BBox", QPDFObjectHandle::newFromRectangle(bbox));
758 757 AS = QPDFObjectHandle::newStream(oh().getOwningQPDF(), "/Tx BMC\nEMC\n");
759 758 AS.replaceDict(dict);
... ...
libqpdf/QPDFJob.cc
... ... @@ -618,9 +618,7 @@ QPDFJob::checkConfiguration()
618 618 usage("no output file may be given for this option");
619 619 }
620 620 if (m->check_requires_password && m->check_is_encrypted) {
621   - usage(
622   - "--requires-password and --is-encrypted may not be given"
623   - " together");
  621 + usage("--requires-password and --is-encrypted may not be given together");
624 622 }
625 623  
626 624 if (m->encrypt && (!m->allow_insecure) &&
... ... @@ -3142,9 +3140,7 @@ QPDFJob::writeJSON(QPDF&amp; pdf)
3142 3140 fp = std::make_shared<Pl_StdioFile>("json output", fc->f);
3143 3141 } else if ((m->json_stream_data == qpdf_sj_file) && m->json_stream_prefix.empty()) {
3144 3142 QTC::TC("qpdf", "QPDFJob need json-stream-prefix for stdout");
3145   - usage(
3146   - "please specify --json-stream-prefix since the input file "
3147   - "name is unknown");
  3143 + usage("please specify --json-stream-prefix since the input file name is unknown");
3148 3144 } else {
3149 3145 QTC::TC("qpdf", "QPDFJob write json to stdout");
3150 3146 m->log->saveToStandardOutput(true);
... ...
libqpdf/QPDFObjectHandle.cc
... ... @@ -1258,8 +1258,7 @@ QPDFObjectHandle::getUniqueResourceName(
1258 1258 // The number of candidates we test is more than the
1259 1259 // number of keys we're checking against.
1260 1260 throw std::logic_error(
1261   - "unable to find unconflicting name in"
1262   - " QPDFObjectHandle::getUniqueResourceName");
  1261 + "unable to find unconflicting name in QPDFObjectHandle::getUniqueResourceName");
1263 1262 }
1264 1263  
1265 1264 // Dictionary mutators are in QPDF_Dictionary.cc
... ...
libqpdf/QPDFPageObjectHelper.cc
... ... @@ -718,8 +718,7 @@ QPDFPageObjectHelper::getFormXObjectForPage(bool handle_transformations)
718 718 QPDFObjectHandle bbox = getTrimBox(false).shallowCopy();
719 719 if (!bbox.isRectangle()) {
720 720 oh().warnIfPossible(
721   - "bounding box is invalid; form"
722   - " XObject created from page will not work");
  721 + "bounding box is invalid; form XObject created from page will not work");
723 722 }
724 723 newdict.replaceKey("/BBox", bbox);
725 724 auto provider =
... ...
libqpdf/QPDFWriter.cc
... ... @@ -1013,8 +1013,7 @@ QPDFWriter::pushMD5Pipeline(PipelinePopper&amp; pp)
1013 1013 if (!m->id2.empty()) {
1014 1014 // Can't happen in the code
1015 1015 throw std::logic_error(
1016   - "Deterministic ID computation enabled after ID"
1017   - " generation has already occurred.");
  1016 + "Deterministic ID computation enabled after ID generation has already occurred.");
1018 1017 }
1019 1018 qpdf_assert_debug(m->deterministic_id);
1020 1019 qpdf_assert_debug(m->md5_pipeline == nullptr);
... ...
libqpdf/QPDF_linearization.cc
... ... @@ -167,9 +167,7 @@ QPDF::readLinearizationData()
167 167 // that prevent loading.
168 168  
169 169 if (!isLinearized()) {
170   - throw std::logic_error(
171   - "called readLinearizationData for file"
172   - " that is not linearized");
  170 + throw std::logic_error("called readLinearizationData for file that is not linearized");
173 171 }
174 172  
175 173 // /L is read and stored in linp by isLinearized()
... ... @@ -468,8 +466,7 @@ QPDF::checkLinearizationInternal()
468 466 if (m->file->tell() != m->first_xref_item_offset) {
469 467 QTC::TC("qpdf", "QPDF err /T mismatch");
470 468 linearizationWarning(
471   - "space before first xref item (/T) mismatch "
472   - "(computed = " +
  469 + "space before first xref item (/T) mismatch (computed = " +
473 470 std::to_string(m->first_xref_item_offset) +
474 471 "; file = " + std::to_string(m->file->tell()));
475 472 }
... ... @@ -694,9 +691,7 @@ QPDF::checkHPageOffset(
694 691 for (size_t i = 0; i < toS(he.nshared_objects); ++i) {
695 692 int idx = he.shared_identifiers.at(i);
696 693 if (shared_idx_to_obj.count(idx) == 0) {
697   - stopOnError(
698   - "unable to get object for item in"
699   - " shared objects hint table");
  694 + stopOnError("unable to get object for item in shared objects hint table");
700 695 }
701 696 hint_shared.insert(shared_idx_to_obj[idx]);
702 697 }
... ... @@ -759,15 +754,12 @@ QPDF::checkHSharedObject(std::vector&lt;QPDFObjectHandle&gt; const&amp; pages, std::map&lt;in
759 754 if (i == so.nshared_first_page) {
760 755 QTC::TC("qpdf", "QPDF lin check shared past first page");
761 756 if (m->part8.empty()) {
762   - linearizationWarning(
763   - "part 8 is empty but nshared_total > "
764   - "nshared_first_page");
  757 + linearizationWarning("part 8 is empty but nshared_total > nshared_first_page");
765 758 } else {
766 759 int obj = m->part8.at(0).getObjectID();
767 760 if (obj != so.first_shared_obj) {
768 761 linearizationWarning(
769   - "first shared object number mismatch: "
770   - "hint table = " +
  762 + "first shared object number mismatch: hint table = " +
771 763 std::to_string(so.first_shared_obj) +
772 764 "; computed = " + std::to_string(obj));
773 765 }
... ... @@ -846,9 +838,7 @@ QPDF::checkHOutlines()
846 838 std::to_string(table_length) + "; computed = " + std::to_string(length));
847 839 }
848 840 } else {
849   - linearizationWarning(
850   - "incorrect first object number in outline "
851   - "hints table.");
  841 + linearizationWarning("incorrect first object number in outline hints table.");
852 842 }
853 843 } else {
854 844 linearizationWarning("incorrect object count in outline hint table");
... ... @@ -1131,9 +1121,7 @@ QPDF::calculateLinearizationData(T const&amp; object_stream_data)
1131 1121 break;
1132 1122  
1133 1123 case ObjUser::ou_bad:
1134   - stopOnError(
1135   - "INTERNAL ERROR: QPDF::calculateLinearizationData: "
1136   - "invalid user type");
  1124 + stopOnError("INTERNAL ERROR: QPDF::calculateLinearizationData: invalid user type");
1137 1125 break;
1138 1126 }
1139 1127 }
... ... @@ -1196,9 +1184,7 @@ QPDF::calculateLinearizationData(T const&amp; object_stream_data)
1196 1184 // Part 4: open document objects. We don't care about the order.
1197 1185  
1198 1186 if (lc_root.size() != 1) {
1199   - stopOnError(
1200   - "found other than one root while"
1201   - " calculating linearization data");
  1187 + stopOnError("found other than one root while calculating linearization data");
1202 1188 }
1203 1189 m->part4.push_back(getObject(*(lc_root.begin())));
1204 1190 for (auto const& og: lc_open_document) {
... ... @@ -1255,8 +1241,7 @@ QPDF::calculateLinearizationData(T const&amp; object_stream_data)
1255 1241 QPDFObjGen page_og(pages.at(i).getObjGen());
1256 1242 if (!lc_other_page_private.count(page_og)) {
1257 1243 stopOnError(
1258   - "INTERNAL ERROR: "
1259   - "QPDF::calculateLinearizationData: page object for page " +
  1244 + "INTERNAL ERROR: QPDF::calculateLinearizationData: page object for page " +
1260 1245 std::to_string(i) + " not in lc_other_page_private");
1261 1246 }
1262 1247 lc_other_page_private.erase(page_og);
... ... @@ -1269,9 +1254,7 @@ QPDF::calculateLinearizationData(T const&amp; object_stream_data)
1269 1254  
1270 1255 ObjUser ou(ObjUser::ou_page, toI(i));
1271 1256 if (m->obj_user_to_objects.count(ou) == 0) {
1272   - stopOnError(
1273   - "found unreferenced page while"
1274   - " calculating linearization data");
  1257 + stopOnError("found unreferenced page while calculating linearization data");
1275 1258 }
1276 1259 for (auto const& og: m->obj_user_to_objects[ou]) {
1277 1260 if (lc_other_page_private.count(og)) {
... ... @@ -1284,9 +1267,8 @@ QPDF::calculateLinearizationData(T const&amp; object_stream_data)
1284 1267 // That should have covered all part7 objects.
1285 1268 if (!lc_other_page_private.empty()) {
1286 1269 stopOnError(
1287   - "INTERNAL ERROR:"
1288   - " QPDF::calculateLinearizationData: lc_other_page_private is "
1289   - "not empty after generation of part7");
  1270 + "INTERNAL ERROR: QPDF::calculateLinearizationData:"
  1271 + " lc_other_page_private is not empty after generation of part7");
1290 1272 }
1291 1273  
1292 1274 // Part 8: other pages' shared objects
... ... @@ -1307,9 +1289,7 @@ QPDF::calculateLinearizationData(T const&amp; object_stream_data)
1307 1289 std::set<QPDFObjGen> pages_ogs =
1308 1290 m->obj_user_to_objects[ObjUser(ObjUser::ou_root_key, "/Pages")];
1309 1291 if (pages_ogs.empty()) {
1310   - stopOnError(
1311   - "found empty pages tree while"
1312   - " calculating linearization data");
  1292 + stopOnError("found empty pages tree while calculating linearization data");
1313 1293 }
1314 1294 for (auto const& og: pages_ogs) {
1315 1295 if (lc_other.count(og)) {
... ... @@ -1418,9 +1398,7 @@ QPDF::calculateLinearizationData(T const&amp; object_stream_data)
1418 1398 CHPageOffsetEntry& pe = m->c_page_offset_data.entries.at(i);
1419 1399 ObjUser ou(ObjUser::ou_page, toI(i));
1420 1400 if (m->obj_user_to_objects.count(ou) == 0) {
1421   - stopOnError(
1422   - "found unreferenced page while"
1423   - " calculating linearization data");
  1401 + stopOnError("found unreferenced page while calculating linearization data");
1424 1402 }
1425 1403 for (auto const& og: m->obj_user_to_objects[ou]) {
1426 1404 if ((m->object_to_obj_users[og].size() > 1) && (obj_to_index.count(og.getObj()) > 0)) {
... ... @@ -1759,9 +1737,7 @@ QPDF::writeHSharedObject(BitWriter&amp; w)
1759 1737 for (size_t i = 0; i < toS(nitems); ++i) {
1760 1738 // If signature were present, we'd have to write a 128-bit hash.
1761 1739 if (entries.at(i).signature_present != 0) {
1762   - stopOnError(
1763   - "found unexpected signature present"
1764   - " while writing linearization data");
  1740 + stopOnError("found unexpected signature present while writing linearization data");
1765 1741 }
1766 1742 }
1767 1743 write_vector_int(w, nitems, entries, t.nbits_nobjects, &HSharedObjectEntry::nobjects_minus_one);
... ...
libqpdf/QPDF_optimization.cc
... ... @@ -168,8 +168,7 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys)
168 168 warn_skipped_keys);
169 169 if (!key_ancestors.empty()) {
170 170 throw std::logic_error(
171   - "key_ancestors not empty after"
172   - " pushing inherited attributes to pages");
  171 + "key_ancestors not empty after pushing inherited attributes to pages");
173 172 }
174 173 m->pushed_inherited_attributes_to_pages = true;
175 174 m->ever_pushed_inherited_attributes_to_pages = true;
... ...