Commit 60965d5f4d608bdccc2ffd4e8753e12cbbbd71d2

Authored by Jay Berkenbilt
1 parent 6b077332

Rerun clang-format

Showing 196 changed files with 2596 additions and 5616 deletions

Too many changes.

To preserve performance only 100 of 196 files are displayed.

examples/pdf-attach-file.cc
... ... @@ -71,8 +71,7 @@ process(
71 71  
72 72 // Create a file spec.
73 73 std::string key = QUtil::path_basename(attachment);
74   - std::cout << whoami << ": attaching " << attachment << " as " << key
75   - << std::endl;
  74 + std::cout << whoami << ": attaching " << attachment << " as " << key << std::endl;
76 75 auto fs = QPDFFileSpecObjectHelper::createFileSpec(q, key, attachment);
77 76  
78 77 if (mimetype) {
... ...
examples/pdf-bookmarks.cc
... ... @@ -23,16 +23,12 @@ static std::map&lt;QPDFObjGen, int&gt; page_map;
23 23 void
24 24 usage()
25 25 {
26   - std::cerr
27   - << "Usage: " << whoami << " [options] file.pdf [password]" << std::endl
28   - << "Options:" << std::endl
29   - << " --numbers give bookmarks outline-style numbers"
30   - << std::endl
31   - << " --lines draw lines to show bookmark hierarchy"
32   - << std::endl
33   - << " --show-open indicate whether a bookmark is initially open"
34   - << std::endl
35   - << " --show-targets show target if possible" << std::endl;
  26 + std::cerr << "Usage: " << whoami << " [options] file.pdf [password]" << std::endl
  27 + << "Options:" << std::endl
  28 + << " --numbers give bookmarks outline-style numbers" << std::endl
  29 + << " --lines draw lines to show bookmark hierarchy" << std::endl
  30 + << " --show-open indicate whether a bookmark is initially open" << std::endl
  31 + << " --show-targets show target if possible" << std::endl;
36 32 exit(2);
37 33 }
38 34  
... ... @@ -120,16 +116,14 @@ show_bookmark_details(QPDFOutlineObjectHelper outline, std::vector&lt;int&gt; numbers)
120 116 }
121 117  
122 118 void
123   -extract_bookmarks(
124   - std::vector<QPDFOutlineObjectHelper> outlines, std::vector<int>& numbers)
  119 +extract_bookmarks(std::vector<QPDFOutlineObjectHelper> outlines, std::vector<int>& numbers)
125 120 {
126 121 // For style == st_numbers, numbers.at(n) contains the numerical
127 122 // label for the outline, so we count up from 1.
128 123 // For style == st_lines, numbers.at(n) == 0 indicates the last
129 124 // outline at level n, and we don't otherwise care what the value
130 125 // is, so we count up to zero.
131   - numbers.push_back(
132   - (style == st_lines) ? -QIntC::to_int(outlines.size()) : 0);
  126 + numbers.push_back((style == st_lines) ? -QIntC::to_int(outlines.size()) : 0);
133 127 for (auto& outline: outlines) {
134 128 ++(numbers.back());
135 129 show_bookmark_details(outline, numbers);
... ... @@ -196,8 +190,7 @@ main(int argc, char* argv[])
196 190 std::cout << filename << " has no bookmarks" << std::endl;
197 191 }
198 192 } catch (std::exception& e) {
199   - std::cerr << whoami << " processing file " << filename << ": "
200   - << e.what() << std::endl;
  193 + std::cerr << whoami << " processing file " << filename << ": " << e.what() << std::endl;
201 194 exit(2);
202 195 }
203 196  
... ...
examples/pdf-c-objects.c
... ... @@ -33,8 +33,7 @@ modify_file(qpdf_data qpdf)
33 33 qpdf_oh_remove_key(qpdf, root, "/OpenAction");
34 34 /* 0 is never a valid qpdf_oh */
35 35 qpdf_oh pagemode = 0;
36   - if (qpdf_oh_is_dictionary(
37   - qpdf, qpdf_oh_get_key(qpdf, root, "/PageLabels"))) {
  36 + if (qpdf_oh_is_dictionary(qpdf, qpdf_oh_get_key(qpdf, root, "/PageLabels"))) {
38 37 pagemode = qpdf_oh_new_name(qpdf, "/UseOutlines");
39 38 } else {
40 39 pagemode = qpdf_oh_new_null(qpdf);
... ... @@ -71,8 +70,7 @@ main(int argc, char* argv[])
71 70 password = argv[2];
72 71 outfile = argv[3];
73 72  
74   - if (((qpdf_read(qpdf, infile, password) & QPDF_ERRORS) == 0) &&
75   - modify_file(qpdf) &&
  73 + if (((qpdf_read(qpdf, infile, password) & QPDF_ERRORS) == 0) && modify_file(qpdf) &&
76 74 ((qpdf_init_write(qpdf, outfile) & QPDF_ERRORS) == 0)) {
77 75 /* Use static ID for testing only. For production, a
78 76 * non-static ID is used. See also
... ... @@ -82,15 +80,11 @@ main(int argc, char* argv[])
82 80 }
83 81 while (qpdf_more_warnings(qpdf)) {
84 82 warnings = 1;
85   - printf(
86   - "warning: %s\n",
87   - qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
  83 + printf("warning: %s\n", qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
88 84 }
89 85 if (qpdf_has_error(qpdf)) {
90 86 errors = 1;
91   - printf(
92   - "error: %s\n",
93   - qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
  87 + printf("error: %s\n", qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
94 88 }
95 89 qpdf_cleanup(&qpdf);
96 90 if (errors) {
... ...
examples/pdf-count-strings.cc
... ... @@ -97,8 +97,7 @@ main(int argc, char* argv[])
97 97 page.filterContents(&counter, &out);
98 98 std::cout << "\n% end " << pageno << std::endl;
99 99 }
100   - std::cout << "Page " << pageno
101   - << ": strings = " << counter.getCount() << std::endl;
  100 + std::cout << "Page " << pageno << ": strings = " << counter.getCount() << std::endl;
102 101 }
103 102 } catch (std::exception& e) {
104 103 std::cerr << whoami << ": " << e.what() << std::endl;
... ...
examples/pdf-create.cc
... ... @@ -41,8 +41,7 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider
41 41 J_COLOR_SPACE j_color_space;
42 42 };
43 43  
44   -ImageProvider::ImageProvider(
45   - std::string const& color_space, std::string const& filter) :
  44 +ImageProvider::ImageProvider(std::string const& color_space, std::string const& filter) :
46 45 width(400),
47 46 stripe_height(80),
48 47 color_space(color_space),
... ... @@ -107,8 +106,7 @@ ImageProvider::provideStreamData(QPDFObjGen const&amp;, Pipeline* pipeline)
107 106 to_delete.push_back(p_new);
108 107 p = p_new.get();
109 108 } else if (filter == "/RunLengthDecode") {
110   - p_new = std::make_shared<Pl_RunLength>(
111   - "image encoder", pipeline, Pl_RunLength::a_encode);
  109 + p_new = std::make_shared<Pl_RunLength>("image encoder", pipeline, Pl_RunLength::a_encode);
112 110 to_delete.push_back(p_new);
113 111 p = p_new.get();
114 112 }
... ... @@ -184,8 +182,7 @@ add_page(
184 182 image.replaceDict(image_dict);
185 183  
186 184 // Provide the stream data.
187   - image.replaceStreamData(
188   - provider, QPDFObjectHandle::parse(filter), QPDFObjectHandle::newNull());
  185 + image.replaceStreamData(provider, QPDFObjectHandle::parse(filter), QPDFObjectHandle::newNull());
189 186  
190 187 // Create direct objects as needed by the page dictionary.
191 188 QPDFObjectHandle procset = "[/PDF /Text /ImageC]"_qpdf;
... ... @@ -202,8 +199,7 @@ add_page(
202 199 resources.replaceKey("/XObject", xobject);
203 200  
204 201 // Create the page content stream
205   - QPDFObjectHandle contents =
206   - createPageContents(pdf, color_space + " with filter " + filter);
  202 + QPDFObjectHandle contents = createPageContents(pdf, color_space + " with filter " + filter);
207 203  
208 204 // Create the page dictionary
209 205 QPDFObjectHandle page = pdf.makeIndirectObject("<<"
... ... @@ -256,8 +252,7 @@ check(
256 252 }
257 253  
258 254 // Check filter and color space.
259   - std::string desired_color_space =
260   - color_spaces[(pageno - 1) / n_color_spaces];
  255 + std::string desired_color_space = color_spaces[(pageno - 1) / n_color_spaces];
261 256 std::string desired_filter = filters[(pageno - 1) % n_filters];
262 257 // In the default mode, QPDFWriter will compress with
263 258 // /FlateDecode if no filters are provided.
... ... @@ -271,16 +266,13 @@ check(
271 266 bool this_errors = false;
272 267 if (!filter.isNameAndEquals(desired_filter)) {
273 268 this_errors = errors = true;
274   - std::cout << "page " << pageno << ": expected filter "
275   - << desired_filter
  269 + std::cout << "page " << pageno << ": expected filter " << desired_filter
276 270 << "; actual filter = " << filter.unparse() << std::endl;
277 271 }
278 272 if (!color_space.isNameAndEquals(desired_color_space)) {
279 273 this_errors = errors = true;
280   - std::cout << "page " << pageno << ": expected color space "
281   - << desired_color_space
282   - << "; actual color space = " << color_space.unparse()
283   - << std::endl;
  274 + std::cout << "page " << pageno << ": expected color space " << desired_color_space
  275 + << "; actual color space = " << color_space.unparse() << std::endl;
284 276 }
285 277  
286 278 if (!this_errors) {
... ... @@ -293,8 +285,7 @@ check(
293 285 std::shared_ptr<Buffer> desired_data(b_p.getBuffer());
294 286  
295 287 if (desired_data->getSize() != actual_data->getSize()) {
296   - std::cout << "page " << pageno << ": image data length mismatch"
297   - << std::endl;
  288 + std::cout << "page " << pageno << ": image data length mismatch" << std::endl;
298 289 this_errors = errors = true;
299 290 } else {
300 291 // Compare bytes. For JPEG, allow a certain number of
... ... @@ -308,8 +299,7 @@ check(
308 299 size_t len = actual_data->getSize();
309 300 unsigned int mismatches = 0;
310 301 int tolerance = (desired_filter == "/DCTDecode" ? 10 : 0);
311   - size_t threshold =
312   - (desired_filter == "/DCTDecode" ? len / 40U : 0);
  302 + size_t threshold = (desired_filter == "/DCTDecode" ? len / 40U : 0);
313 303 for (size_t i = 0; i < len; ++i) {
314 304 int delta = actual_bytes[i] - desired_bytes[i];
315 305 if ((delta > tolerance) || (delta < -tolerance)) {
... ... @@ -317,9 +307,8 @@ check(
317 307 }
318 308 }
319 309 if (mismatches > threshold) {
320   - std::cout << "page " << pageno << ": "
321   - << desired_color_space << ", " << desired_filter
322   - << ": mismatches: " << mismatches << " of " << len
  310 + std::cout << "page " << pageno << ": " << desired_color_space << ", "
  311 + << desired_filter << ": mismatches: " << mismatches << " of " << len
323 312 << std::endl;
324 313 this_errors = errors = true;
325 314 }
... ...
examples/pdf-custom-filter.cc
... ... @@ -132,8 +132,7 @@ SF_XORDecode::setDecodeParms(QPDFObjectHandle decode_parms)
132 132 this->key = buf->getBuffer()[0];
133 133 return true;
134 134 } catch (std::exception& e) {
135   - std::cerr << "Error extracting key for /XORDecode: " << e.what()
136   - << std::endl;
  135 + std::cerr << "Error extracting key for /XORDecode: " << e.what() << std::endl;
137 136 }
138 137 return false;
139 138 }
... ... @@ -203,8 +202,7 @@ class StreamReplacer: public QPDFObjectHandle::StreamDataProvider
203 202 void provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
204 203  
205 204 void registerStream(
206   - QPDFObjectHandle stream,
207   - std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self);
  205 + QPDFObjectHandle stream, std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self);
208 206  
209 207 private:
210 208 bool maybeReplace(
... ... @@ -300,12 +298,10 @@ StreamReplacer::maybeReplace(
300 298 // changes. For example, an image resampler might change the
301 299 // dimensions or other properties of the image.
302 300 dict_updates->replaceKey(
303   - "/OrigLength",
304   - QPDFObjectHandle::newInteger(QIntC::to_longlong(out->getSize())));
  301 + "/OrigLength", QPDFObjectHandle::newInteger(QIntC::to_longlong(out->getSize())));
305 302 // We are also storing the "key" that we will access when
306 303 // writing the data.
307   - this->keys[og] = QIntC::to_uchar(
308   - (og.getObj() * QIntC::to_int(out->getSize())) & 0xff);
  304 + this->keys[og] = QIntC::to_uchar((og.getObj() * QIntC::to_int(out->getSize())) & 0xff);
309 305 }
310 306  
311 307 if (pipeline) {
... ... @@ -319,8 +315,7 @@ StreamReplacer::maybeReplace(
319 315  
320 316 void
321 317 StreamReplacer::registerStream(
322   - QPDFObjectHandle stream,
323   - std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self)
  318 + QPDFObjectHandle stream, std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self)
324 319 {
325 320 QPDFObjGen og(stream.getObjGen());
326 321  
... ... @@ -344,8 +339,7 @@ StreamReplacer::registerStream(
344 339 try {
345 340 should_replace = maybeReplace(og, stream, nullptr, &dict_updates);
346 341 } catch (std::exception& e) {
347   - stream.warnIfPossible(
348   - std::string("exception while attempting to replace: ") + e.what());
  342 + stream.warnIfPossible(std::string("exception while attempting to replace: ") + e.what());
349 343 }
350 344  
351 345 if (should_replace) {
... ... @@ -369,8 +363,7 @@ StreamReplacer::registerStream(
369 363 // /XORDecode filter.
370 364 QPDFObjectHandle decode_parms =
371 365 QPDFObjectHandle::newDictionary({{"/KeyStream", dp_stream}});
372   - stream.replaceStreamData(
373   - self, QPDFObjectHandle::newName("/XORDecode"), decode_parms);
  366 + stream.replaceStreamData(self, QPDFObjectHandle::newName("/XORDecode"), decode_parms);
374 367 // Further, if /ProtectXOR = true, we disable filtering on write
375 368 // so that QPDFWriter will not decode the stream even though we
376 369 // have registered a stream filter for /XORDecode.
... ... @@ -393,14 +386,12 @@ StreamReplacer::provideStreamData(QPDFObjGen const&amp; og, Pipeline* pipeline)
393 386 // Since this only gets called for streams we already
394 387 // determined we are replacing, a false return would indicate
395 388 // a logic error.
396   - throw std::logic_error(
397   - "should_replace return false in provideStreamData");
  389 + throw std::logic_error("should_replace return false in provideStreamData");
398 390 }
399 391 }
400 392  
401 393 static void
402   -process(
403   - char const* infilename, char const* outfilename, bool decode_specialized)
  394 +process(char const* infilename, char const* outfilename, bool decode_specialized)
404 395 {
405 396 QPDF qpdf;
406 397 qpdf.processFile(infilename);
... ... @@ -434,8 +425,7 @@ static void
434 425 usage()
435 426 {
436 427 std::cerr << "\n"
437   - << "Usage: " << whoami
438   - << " [--decode-specialized] infile outfile\n"
  428 + << "Usage: " << whoami << " [--decode-specialized] infile outfile\n"
439 429 << std::endl;
440 430 exit(2);
441 431 }
... ... @@ -468,8 +458,7 @@ main(int argc, char* argv[])
468 458 // decode our streams. This is not a real filter, so no real
469 459 // PDF reading application would be able to interpret it. This
470 460 // is just for illustrative purposes.
471   - QPDF::registerStreamFilter(
472   - "/XORDecode", [] { return std::make_shared<SF_XORDecode>(); });
  461 + QPDF::registerStreamFilter("/XORDecode", [] { return std::make_shared<SF_XORDecode>(); });
473 462 // Do the actual processing.
474 463 process(infilename, outfilename, decode_specialized);
475 464 } catch (std::exception& e) {
... ...
examples/pdf-double-page-size.cc
... ... @@ -13,8 +13,7 @@ static char const* whoami = nullptr;
13 13 void
14 14 usage()
15 15 {
16   - std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]"
17   - << std::endl
  16 + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl
18 17 << "Double size of all pages in infile.pdf;"
19 18 << " write output to outfile.pdf" << std::endl;
20 19 exit(2);
... ... @@ -33,16 +32,13 @@ doubleBoxSize(QPDFPageObjectHelper&amp; page, char const* box_name)
33 32 }
34 33 if (!box.isRectangle()) {
35 34 throw std::runtime_error(
36   - std::string("box ") + box_name +
37   - " is not an array of four elements");
  35 + std::string("box ") + box_name + " is not an array of four elements");
38 36 }
39 37 std::vector<QPDFObjectHandle> doubled;
40 38 for (auto& item: box.aitems()) {
41   - doubled.push_back(
42   - QPDFObjectHandle::newReal(item.getNumericValue() * 2.0, 2));
  39 + doubled.push_back(QPDFObjectHandle::newReal(item.getNumericValue() * 2.0, 2));
43 40 }
44   - page.getObjectHandle().replaceKey(
45   - box_name, QPDFObjectHandle::newArray(doubled));
  41 + page.getObjectHandle().replaceKey(box_name, QPDFObjectHandle::newArray(doubled));
46 42 }
47 43  
48 44 int
... ... @@ -93,11 +89,9 @@ main(int argc, char* argv[])
93 89 w.setStreamDataMode(qpdf_s_uncompress);
94 90 }
95 91 w.write();
96   - std::cout << whoami << ": new file written to " << outfilename
97   - << std::endl;
  92 + std::cout << whoami << ": new file written to " << outfilename << std::endl;
98 93 } catch (std::exception& e) {
99   - std::cerr << whoami << " processing file " << infilename << ": "
100   - << e.what() << std::endl;
  94 + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl;
101 95 exit(2);
102 96 }
103 97  
... ...
examples/pdf-filter-tokens.cc
... ... @@ -22,8 +22,7 @@ void
22 22 usage()
23 23 {
24 24 std::cerr << "Usage: " << whoami << " infile outfile" << std::endl
25   - << "Applies token filters to infile and writes outfile"
26   - << std::endl;
  25 + << "Applies token filters to infile and writes outfile" << std::endl;
27 26 exit(2);
28 27 }
29 28  
... ... @@ -82,17 +81,13 @@ class ColorToGray: public QPDFObjectHandle::TokenFilter
82 81 bool
83 82 ColorToGray::isNumeric(QPDFTokenizer::token_type_e token_type)
84 83 {
85   - return (
86   - (token_type == QPDFTokenizer::tt_integer) ||
87   - (token_type == QPDFTokenizer::tt_real));
  84 + return ((token_type == QPDFTokenizer::tt_integer) || (token_type == QPDFTokenizer::tt_real));
88 85 }
89 86  
90 87 bool
91 88 ColorToGray::isIgnorable(QPDFTokenizer::token_type_e token_type)
92 89 {
93   - return (
94   - (token_type == QPDFTokenizer::tt_space) ||
95   - (token_type == QPDFTokenizer::tt_comment));
  90 + return ((token_type == QPDFTokenizer::tt_space) || (token_type == QPDFTokenizer::tt_comment));
96 91 }
97 92  
98 93 double
... ... @@ -128,8 +123,7 @@ ColorToGray::handleToken(QPDFTokenizer::Token const&amp; token)
128 123 // kinds of operands, replace the command. Flush any additional
129 124 // accumulated tokens to keep the stack only four tokens deep.
130 125  
131   - while ((!this->all_stack.empty()) &&
132   - isIgnorable(this->all_stack.at(0).getType())) {
  126 + while ((!this->all_stack.empty()) && isIgnorable(this->all_stack.at(0).getType())) {
133 127 writeToken(this->all_stack.at(0));
134 128 this->all_stack.pop_front();
135 129 }
... ... @@ -138,8 +132,7 @@ ColorToGray::handleToken(QPDFTokenizer::Token const&amp; token)
138 132 if (!isIgnorable(token_type)) {
139 133 this->stack.push_back(token);
140 134 if ((this->stack.size() == 4) && token.isWord("rg") &&
141   - (isNumeric(this->stack.at(0).getType())) &&
142   - (isNumeric(this->stack.at(1).getType())) &&
  135 + (isNumeric(this->stack.at(0).getType())) && (isNumeric(this->stack.at(1).getType())) &&
143 136 (isNumeric(this->stack.at(2).getType()))) {
144 137 double r = numericValue(this->stack.at(0));
145 138 double g = numericValue(this->stack.at(1));
... ... @@ -195,11 +188,9 @@ main(int argc, char* argv[])
195 188 // applied. See comments on the filters for additional
196 189 // details.
197 190 page.addContentTokenFilter(
198   - std::shared_ptr<QPDFObjectHandle::TokenFilter>(
199   - new StringReverser));
  191 + std::shared_ptr<QPDFObjectHandle::TokenFilter>(new StringReverser));
200 192 page.addContentTokenFilter(
201   - std::shared_ptr<QPDFObjectHandle::TokenFilter>(
202   - new ColorToGray));
  193 + std::shared_ptr<QPDFObjectHandle::TokenFilter>(new ColorToGray));
203 194 }
204 195  
205 196 QPDFWriter w(pdf, outfilename);
... ...
examples/pdf-invert-images.cc
... ... @@ -14,8 +14,7 @@ static char const* whoami = nullptr;
14 14 void
15 15 usage()
16 16 {
17   - std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]"
18   - << std::endl
  17 + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl
19 18 << "Invert some images in infile.pdf;"
20 19 << " write output to outfile.pdf" << std::endl;
21 20 exit(2);
... ... @@ -37,8 +36,7 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider
37 36 void provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
38 37  
39 38 void registerImage(
40   - QPDFObjectHandle image,
41   - std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self);
  39 + QPDFObjectHandle image, std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self);
42 40  
43 41 private:
44 42 std::map<QPDFObjGen, QPDFObjectHandle> copied_images;
... ... @@ -46,8 +44,7 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider
46 44  
47 45 void
48 46 ImageInverter::registerImage(
49   - QPDFObjectHandle image,
50   - std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self)
  47 + QPDFObjectHandle image, std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self)
51 48 {
52 49 // replaceStreamData requires a pointer holder to the stream data
53 50 // provider, but there's no way for us to generate one ourselves,
... ... @@ -76,8 +73,7 @@ ImageInverter::registerImage(
76 73 // filterable in the input QPDF object, so we don't have to deal
77 74 // with it explicitly here. We could explicitly use /DCTDecode and
78 75 // write through a DCT filter if we wanted.
79   - image.replaceStreamData(
80   - self, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
  76 + image.replaceStreamData(self, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
81 77 }
82 78  
83 79 void
... ... @@ -86,8 +82,7 @@ ImageInverter::provideStreamData(QPDFObjGen const&amp; og, Pipeline* pipeline)
86 82 // Use the object and generation number supplied to look up the
87 83 // image data. Then invert the image data and write the inverted
88 84 // data to the pipeline.
89   - std::shared_ptr<Buffer> data =
90   - this->copied_images[og].getStreamData(qpdf_dl_all);
  85 + std::shared_ptr<Buffer> data = this->copied_images[og].getStreamData(qpdf_dl_all);
91 86 size_t size = data->getSize();
92 87 unsigned char* buf = data->getBuffer();
93 88 unsigned char ch;
... ... @@ -133,18 +128,15 @@ main(int argc, char* argv[])
133 128 QPDFObjectHandle& image = iter.second;
134 129 QPDFObjectHandle image_dict = image.getDict();
135 130 QPDFObjectHandle color_space = image_dict.getKey("/ColorSpace");
136   - QPDFObjectHandle bits_per_component =
137   - image_dict.getKey("/BitsPerComponent");
  131 + QPDFObjectHandle bits_per_component = image_dict.getKey("/BitsPerComponent");
138 132  
139 133 // For our example, we can only work with images 8-bit
140 134 // grayscale images that we can fully decode. Use
141 135 // pipeStreamData with a null pipeline to determine
142 136 // whether the image is filterable. Directly inspect
143 137 // keys to determine the image type.
144   - if (image.pipeStreamData(
145   - nullptr, qpdf_ef_compress, qpdf_dl_all) &&
146   - color_space.isNameAndEquals("/DeviceGray") &&
147   - bits_per_component.isInteger() &&
  138 + if (image.pipeStreamData(nullptr, qpdf_ef_compress, qpdf_dl_all) &&
  139 + color_space.isNameAndEquals("/DeviceGray") && bits_per_component.isInteger() &&
148 140 (bits_per_component.getIntValue() == 8)) {
149 141 inv->registerImage(image, p);
150 142 }
... ... @@ -159,11 +151,9 @@ main(int argc, char* argv[])
159 151 w.setStaticID(true); // for testing only
160 152 }
161 153 w.write();
162   - std::cout << whoami << ": new file written to " << outfilename
163   - << std::endl;
  154 + std::cout << whoami << ": new file written to " << outfilename << std::endl;
164 155 } catch (std::exception& e) {
165   - std::cerr << whoami << " processing file " << infilename << ": "
166   - << e.what() << std::endl;
  156 + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl;
167 157 exit(2);
168 158 }
169 159  
... ...
examples/pdf-linearize.c
... ... @@ -61,15 +61,11 @@ main(int argc, char* argv[])
61 61 }
62 62 while (qpdf_more_warnings(qpdf)) {
63 63 warnings = 1;
64   - printf(
65   - "warning: %s\n",
66   - qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
  64 + printf("warning: %s\n", qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
67 65 }
68 66 if (qpdf_has_error(qpdf)) {
69 67 errors = 1;
70   - printf(
71   - "error: %s\n",
72   - qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
  68 + printf("error: %s\n", qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
73 69 }
74 70 qpdf_cleanup(&qpdf);
75 71 if (errors) {
... ...
examples/pdf-mod-info.cc
... ... @@ -16,8 +16,7 @@ static char const* whoami = nullptr;
16 16 void
17 17 usage()
18 18 {
19   - std::cerr << "Usage: " << whoami
20   - << " --in in_file [--out out_file] [--key key [--val val]?]+\n"
  19 + std::cerr << "Usage: " << whoami << " --in in_file [--out out_file] [--key key [--val val]?]+\n"
21 20 << "Modifies/Adds/Removes PDF /Info entries in the in_file\n"
22 21 << "and stores the result in out_file\n"
23 22 << "Special mode: " << whoami << " --dump file\n"
... ... @@ -26,8 +25,7 @@ usage()
26 25 }
27 26  
28 27 void
29   -dumpInfoDict(
30   - QPDF& pdf, std::ostream& os = std::cout, std::string const& sep = ":\t")
  28 +dumpInfoDict(QPDF& pdf, std::ostream& os = std::cout, std::string const& sep = ":\t")
31 29 {
32 30 QPDFObjectHandle trailer = pdf.getTrailer();
33 31 if (trailer.hasKey("/Info")) {
... ... @@ -164,8 +162,7 @@ main(int argc, char* argv[])
164 162 try {
165 163 (void)remove(fl_out);
166 164 QUtil::os_wrapper(
167   - "rename " + fl_tmp + " " + std::string(fl_out),
168   - rename(fl_tmp.c_str(), fl_out));
  165 + "rename " + fl_tmp + " " + std::string(fl_out), rename(fl_tmp.c_str(), fl_out));
169 166 } catch (std::exception& e) {
170 167 std::cerr << e.what() << std::endl;
171 168 exit(2);
... ...
examples/pdf-name-number-tree.cc
... ... @@ -11,8 +11,7 @@ void
11 11 usage()
12 12 {
13 13 std::cerr << "Usage: " << whoami << " outfile.pdf" << std::endl
14   - << "Create some name/number trees and write to a file"
15   - << std::endl;
  14 + << "Create some name/number trees and write to a file" << std::endl;
16 15 exit(2);
17 16 }
18 17  
... ... @@ -61,24 +60,19 @@ main(int argc, char* argv[])
61 60 name_tree.insert("R", QPDFObjectHandle::newUnicodeString("rook"));
62 61 name_tree.insert("B", QPDFObjectHandle::newUnicodeString("bishop"));
63 62 name_tree.insert("N", QPDFObjectHandle::newUnicodeString("knight"));
64   - auto iter =
65   - name_tree.insert("P", QPDFObjectHandle::newUnicodeString("pawn"));
  63 + auto iter = name_tree.insert("P", QPDFObjectHandle::newUnicodeString("pawn"));
66 64 // Look at the iterator
67   - std::cout << "just inserted " << iter->first << " -> "
68   - << iter->second.unparse() << std::endl;
  65 + std::cout << "just inserted " << iter->first << " -> " << iter->second.unparse() << std::endl;
69 66 --iter;
70   - std::cout << "predecessor: " << iter->first << " -> "
71   - << iter->second.unparse() << std::endl;
  67 + std::cout << "predecessor: " << iter->first << " -> " << iter->second.unparse() << std::endl;
72 68 ++iter;
73 69 ++iter;
74   - std::cout << "successor: " << iter->first << " -> "
75   - << iter->second.unparse() << std::endl;
  70 + std::cout << "successor: " << iter->first << " -> " << iter->second.unparse() << std::endl;
76 71  
77 72 // Use range-for iteration
78 73 std::cout << "Name tree items:" << std::endl;
79 74 for (auto i: name_tree) {
80   - std::cout << " " << i.first << " -> " << i.second.unparse()
81   - << std::endl;
  75 + std::cout << " " << i.first << " -> " << i.second.unparse() << std::endl;
82 76 }
83 77  
84 78 // This is a small tree, so everything will be at the root. We can
... ... @@ -107,14 +101,13 @@ main(int argc, char* argv[])
107 101  
108 102 // 10.2 API
109 103 iter = name_tree.find("Q");
110   - std::cout << "Q: " << iter->first << " -> " << iter->second.unparse()
111   - << std::endl;
  104 + std::cout << "Q: " << iter->first << " -> " << iter->second.unparse() << std::endl;
112 105 iter = name_tree.find("W");
113 106 std::cout << "W found: " << (iter != name_tree.end()) << std::endl;
114 107 // Allow find to return predecessor
115 108 iter = name_tree.find("W", true);
116   - std::cout << "W's predecessor: " << iter->first << " -> "
117   - << iter->second.unparse() << std::endl;
  109 + std::cout << "W's predecessor: " << iter->first << " -> " << iter->second.unparse()
  110 + << std::endl;
118 111  
119 112 // We can also remove items
120 113 std::cout << "Remove P: " << name_tree.remove("P", &obj) << std::endl;
... ... @@ -124,8 +117,8 @@ main(int argc, char* argv[])
124 117 iter = name_tree.find("K");
125 118 std::cout << "Find K: " << iter->second.unparse() << std::endl;
126 119 iter.remove();
127   - std::cout << "Iter after removing K: " << iter->first << " -> "
128   - << iter->second.unparse() << std::endl;
  120 + std::cout << "Iter after removing K: " << iter->first << " -> " << iter->second.unparse()
  121 + << std::endl;
129 122 std::cout << "Has K?: " << name_tree.hasName("K") << std::endl;
130 123  
131 124 // Illustrate some more advanced usage using number trees. These
... ... @@ -142,8 +135,7 @@ main(int argc, char* argv[])
142 135 example.replaceKey("/NumberTree", number_tree_oh);
143 136 auto iter2 = number_tree.begin();
144 137 for (int i = 7; i <= 350; i += 7) {
145   - iter2.insertAfter(
146   - i, QPDFObjectHandle::newString("-" + std::to_string(i) + "-"));
  138 + iter2.insertAfter(i, QPDFObjectHandle::newString("-" + std::to_string(i) + "-"));
147 139 }
148 140 std::cout << "Numbers:" << std::endl;
149 141 int n = 1;
... ...
examples/pdf-overlay-page.cc
... ... @@ -31,8 +31,7 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile)
31 31 stamppdf.processFile(stampfile);
32 32  
33 33 // Get first page from other file
34   - QPDFPageObjectHelper stamp_page_1 =
35   - QPDFPageDocumentHelper(stamppdf).getAllPages().at(0);
  34 + QPDFPageObjectHelper stamp_page_1 = QPDFPageDocumentHelper(stamppdf).getAllPages().at(0);
36 35 // Convert page to a form XObject
37 36 QPDFObjectHandle foreign_fo = stamp_page_1.getFormXObjectForPage();
38 37 // Copy form XObject to the input file
... ... @@ -48,8 +47,8 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile)
48 47 // Generate content to place the form XObject centered within
49 48 // destination page's trim box.
50 49 QPDFMatrix m;
51   - std::string content = ph.placeFormXObject(
52   - stamp_fo, name, ph.getTrimBox().getArrayAsRectangle(), m);
  50 + std::string content =
  51 + ph.placeFormXObject(stamp_fo, name, ph.getTrimBox().getArrayAsRectangle(), m);
53 52 if (!content.empty()) {
54 53 // Append the content to the page's content. Surround the
55 54 // original content with q...Q to the new content from the
... ...
examples/pdf-parse-content.cc
... ... @@ -35,11 +35,9 @@ ParserCallbacks::contentSize(size_t size)
35 35 }
36 36  
37 37 void
38   -ParserCallbacks::handleObject(
39   - QPDFObjectHandle obj, size_t offset, size_t length)
  38 +ParserCallbacks::handleObject(QPDFObjectHandle obj, size_t offset, size_t length)
40 39 {
41   - std::cout << obj.getTypeName() << ", offset=" << offset
42   - << ", length=" << length << ": ";
  40 + std::cout << obj.getTypeName() << ", offset=" << offset << ", length=" << length << ": ";
43 41 if (obj.isInlineImage()) {
44 42 std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << std::endl;
45 43 } else {
... ... @@ -67,8 +65,7 @@ main(int argc, char* argv[])
67 65 try {
68 66 QPDF pdf;
69 67 pdf.processFile(filename);
70   - std::vector<QPDFPageObjectHelper> pages =
71   - QPDFPageDocumentHelper(pdf).getAllPages();
  68 + std::vector<QPDFPageObjectHelper> pages = QPDFPageDocumentHelper(pdf).getAllPages();
72 69 if ((pageno < 1) || (QIntC::to_size(pageno) > pages.size())) {
73 70 usage();
74 71 }
... ...
examples/pdf-set-form-values.cc
... ... @@ -11,10 +11,8 @@ static char const* whoami = nullptr;
11 11 void
12 12 usage()
13 13 {
14   - std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf value"
15   - << std::endl
16   - << "Set the value of all text fields to a specified value"
17   - << std::endl;
  14 + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf value" << std::endl
  15 + << "Set the value of all text fields to a specified value" << std::endl;
18 16 exit(2);
19 17 }
20 18  
... ... @@ -55,8 +53,7 @@ main(int argc, char* argv[])
55 53 for (auto& annot: afdh.getWidgetAnnotationsForPage(page)) {
56 54 // For each annotation, find its associated field. If
57 55 // it's a text field, set its value.
58   - QPDFFormFieldObjectHelper ffh =
59   - afdh.getFieldForAnnotation(annot);
  56 + QPDFFormFieldObjectHelper ffh = afdh.getFieldForAnnotation(annot);
60 57 if (ffh.getFieldType() == "/Tx") {
61 58 // Set the value. Passing false as the second
62 59 // value prevents qpdf from setting
... ... @@ -79,8 +76,7 @@ main(int argc, char* argv[])
79 76 w.setStaticID(true); // for testing only
80 77 w.write();
81 78 } catch (std::exception& e) {
82   - std::cerr << whoami << " processing file " << infilename << ": "
83   - << e.what() << std::endl;
  79 + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl;
84 80 exit(2);
85 81 }
86 82  
... ...
examples/pdf-split-pages.cc
... ... @@ -22,13 +22,11 @@ process(char const* whoami, char const* infile, std::string outprefix)
22 22 {
23 23 QPDF inpdf;
24 24 inpdf.processFile(infile);
25   - std::vector<QPDFPageObjectHelper> pages =
26   - QPDFPageDocumentHelper(inpdf).getAllPages();
  25 + std::vector<QPDFPageObjectHelper> pages = QPDFPageDocumentHelper(inpdf).getAllPages();
27 26 int pageno_len = QIntC::to_int(std::to_string(pages.size()).length());
28 27 int pageno = 0;
29 28 for (auto& page: pages) {
30   - std::string outfile =
31   - outprefix + QUtil::int_to_string(++pageno, pageno_len) + ".pdf";
  29 + std::string outfile = outprefix + QUtil::int_to_string(++pageno, pageno_len) + ".pdf";
32 30 QPDF outpdf;
33 31 outpdf.emptyPDF();
34 32 QPDFPageDocumentHelper(outpdf).addPage(page, false);
... ...
examples/qpdfjob-c-save-attachment.c
... ... @@ -83,8 +83,7 @@ main(int argc, char* argv[])
83 83 * saved data. You can use other qpdf logger functions to capture
84 84 * informational output, warnings, and errors.
85 85 */
86   - qpdflogger_set_save(
87   - l, qpdf_log_dest_custom, save_to_file, (void*)outfile, 0);
  86 + qpdflogger_set_save(l, qpdf_log_dest_custom, save_to_file, (void*)outfile, 0);
88 87 qpdflogger_cleanup(&l);
89 88 j = qpdfjob_init();
90 89 status = (qpdfjob_initialize_from_argv(j, j_argv) || qpdfjob_run(j));
... ...
examples/qpdfjob-remove-annotations.cc
... ... @@ -20,15 +20,10 @@ usageExit(std::string const&amp; msg)
20 20 << whoami << ": " << msg << std::endl
21 21 << std::endl
22 22 << "For help:" << std::endl
23   - << " " << whoami << " --help=usage usage information"
24   - << std::endl
25   - << " " << whoami << " --help=topic help on a topic"
26   - << std::endl
27   - << " " << whoami << " --help=--option help on an option"
28   - << std::endl
29   - << " " << whoami
30   - << " --help general help and a topic list"
31   - << std::endl
  23 + << " " << whoami << " --help=usage usage information" << std::endl
  24 + << " " << whoami << " --help=topic help on a topic" << std::endl
  25 + << " " << whoami << " --help=--option help on an option" << std::endl
  26 + << " " << whoami << " --help general help and a topic list" << std::endl
32 27 << std::endl;
33 28 exit(QPDFJob::EXIT_ERROR);
34 29 }
... ...
examples/qpdfjob-save-attachment.cc
... ... @@ -14,8 +14,7 @@ main(int argc, char* argv[])
14 14 auto whoami = QUtil::getWhoami(argv[0]);
15 15  
16 16 if (argc != 4) {
17   - std::cerr << "Usage: " << whoami << " file attachment-key outfile"
18   - << std::endl;
  17 + std::cerr << "Usage: " << whoami << " file attachment-key outfile" << std::endl;
19 18 exit(2);
20 19 }
21 20  
... ...
fuzz/qpdf_fuzzer.cc
... ... @@ -53,8 +53,8 @@ FuzzHelper::FuzzHelper(unsigned char const* data, size_t size) :
53 53 std::shared_ptr<QPDF>
54 54 FuzzHelper::getQpdf()
55 55 {
56   - auto is = std::shared_ptr<InputSource>(
57   - new BufferInputSource("fuzz input", &this->input_buffer));
  56 + auto is =
  57 + std::shared_ptr<InputSource>(new BufferInputSource("fuzz input", &this->input_buffer));
58 58 auto qpdf = QPDF::create();
59 59 qpdf->processInputSource(is);
60 60 return qpdf;
... ... @@ -99,8 +99,7 @@ FuzzHelper::testWrite()
99 99 w = getWriter(q);
100 100 w->setStaticID(true);
101 101 w->setLinearization(true);
102   - w->setR6EncryptionParameters(
103   - "u", "o", true, true, true, true, true, true, qpdf_r3p_full, true);
  102 + w->setR6EncryptionParameters("u", "o", true, true, true, true, true, true, qpdf_r3p_full, true);
104 103 doWrite(w);
105 104  
106 105 q = getQpdf();
... ...
fuzz/standalone_fuzz_target_runner.cc
... ... @@ -11,8 +11,7 @@ main(int argc, char** argv)
11 11 std::shared_ptr<char> file_buf;
12 12 size_t size = 0;
13 13 QUtil::read_file_into_memory(argv[i], file_buf, size);
14   - LLVMFuzzerTestOneInput(
15   - reinterpret_cast<unsigned char*>(file_buf.get()), size);
  14 + LLVMFuzzerTestOneInput(reinterpret_cast<unsigned char*>(file_buf.get()), size);
16 15 std::cout << argv[i] << " successful" << std::endl;
17 16 }
18 17 return 0;
... ...
fuzz/tiffpredictor_fuzzer.cc
... ... @@ -26,8 +26,7 @@ void
26 26 FuzzHelper::doChecks()
27 27 {
28 28 Pl_Discard discard;
29   - Pl_TIFFPredictor p(
30   - "decoder", &discard, Pl_TIFFPredictor::a_decode, 16, 1, 8);
  29 + Pl_TIFFPredictor p("decoder", &discard, Pl_TIFFPredictor::a_decode, 16, 1, 8);
31 30 p.write(const_cast<unsigned char*>(data), size);
32 31 p.finish();
33 32 }
... ...
include/qpdf/BufferInputSource.hh
... ... @@ -31,11 +31,9 @@ class QPDF_DLL_CLASS BufferInputSource: public InputSource
31 31 // If own_memory is true, BufferInputSource will delete the buffer
32 32 // when finished with it. Otherwise, the caller owns the memory.
33 33 QPDF_DLL
34   - BufferInputSource(
35   - std::string const& description, Buffer* buf, bool own_memory = false);
  34 + BufferInputSource(std::string const& description, Buffer* buf, bool own_memory = false);
36 35 QPDF_DLL
37   - BufferInputSource(
38   - std::string const& description, std::string const& contents);
  36 + BufferInputSource(std::string const& description, std::string const& contents);
39 37 QPDF_DLL
40 38 virtual ~BufferInputSource();
41 39 QPDF_DLL
... ...
include/qpdf/Constants.h
... ... @@ -230,9 +230,6 @@ enum pdf_annotation_flag_e {
230 230 };
231 231  
232 232 /* Encryption/password status for QPDFJob */
233   -enum qpdf_encryption_status_e {
234   - qpdf_es_encrypted = 1 << 0,
235   - qpdf_es_password_incorrect = 1 << 1
236   -};
  233 +enum qpdf_encryption_status_e { qpdf_es_encrypted = 1 << 0, qpdf_es_password_incorrect = 1 << 1 };
237 234  
238 235 #endif /* QPDFCONSTANTS_H */
... ...
include/qpdf/InputSource.hh
... ... @@ -69,17 +69,9 @@ class QPDF_DLL_CLASS InputSource
69 69 // methods return true and leave the input source positioned
70 70 // wherever check() left it at the end of the matching pattern.
71 71 QPDF_DLL
72   - bool findFirst(
73   - char const* start_chars,
74   - qpdf_offset_t offset,
75   - size_t len,
76   - Finder& finder);
  72 + bool findFirst(char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder);
77 73 QPDF_DLL
78   - bool findLast(
79   - char const* start_chars,
80   - qpdf_offset_t offset,
81   - size_t len,
82   - Finder& finder);
  74 + bool findLast(char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder);
83 75  
84 76 virtual qpdf_offset_t findAndSkipNextEOL() = 0;
85 77 virtual std::string const& getName() const = 0;
... ... @@ -144,8 +136,7 @@ InputSource::fastTell()
144 136 loadBuffer();
145 137 } else {
146 138 auto curr = tell();
147   - if (curr < this->buf_start ||
148   - curr >= (this->buf_start + this->buf_len)) {
  139 + if (curr < this->buf_start || curr >= (this->buf_start + this->buf_len)) {
149 140 loadBuffer();
150 141 } else {
151 142 this->last_offset = curr;
... ...
include/qpdf/JSON.hh
... ... @@ -104,19 +104,14 @@ class JSON
104 104 // the first item and always set it to false.
105 105 QPDF_DLL
106 106 static void writeDictionaryItem(
107   - Pipeline*,
108   - bool& first,
109   - std::string const& key,
110   - JSON const& value,
111   - size_t depth = 0);
  107 + Pipeline*, bool& first, std::string const& key, JSON const& value, size_t depth = 0);
112 108 // Write just the key of a new dictionary item, useful if writing
113 109 // nested structures. Calls writeNext.
114 110 QPDF_DLL
115   - static void writeDictionaryKey(
116   - Pipeline* p, bool& first, std::string const& key, size_t depth = 0);
  111 + static void
  112 + writeDictionaryKey(Pipeline* p, bool& first, std::string const& key, size_t depth = 0);
117 113 QPDF_DLL
118   - static void writeArrayItem(
119   - Pipeline*, bool& first, JSON const& element, size_t depth = 0);
  114 + static void writeArrayItem(Pipeline*, bool& first, JSON const& element, size_t depth = 0);
120 115 // If writing nested structures incrementally, call writeNext
121 116 // before opening a new array or container in the midst of an
122 117 // existing one. The `first` you pass to writeNext should be the
... ... @@ -188,8 +183,7 @@ class JSON
188 183 QPDF_DLL
189 184 bool isNull() const;
190 185 QPDF_DLL
191   - bool forEachDictItem(
192   - std::function<void(std::string const& key, JSON value)> fn) const;
  186 + bool forEachDictItem(std::function<void(std::string const& key, JSON value)> fn) const;
193 187 QPDF_DLL
194 188 bool forEachArrayItem(std::function<void(JSON value)> fn) const;
195 189  
... ... @@ -239,8 +233,7 @@ class JSON
239 233 f_optional = 1 << 0,
240 234 };
241 235 QPDF_DLL
242   - bool checkSchema(
243   - JSON schema, unsigned long flags, std::list<std::string>& errors);
  236 + bool checkSchema(JSON schema, unsigned long flags, std::list<std::string>& errors);
244 237  
245 238 // Same as passing 0 for flags
246 239 QPDF_DLL
... ... @@ -311,8 +304,7 @@ class JSON
311 304 // methods and decrementing on end methods.
312 305  
313 306 QPDF_DLL
314   - virtual bool
315   - dictionaryItem(std::string const& key, JSON const& value) = 0;
  307 + virtual bool dictionaryItem(std::string const& key, JSON const& value) = 0;
316 308 QPDF_DLL
317 309 virtual bool arrayItem(JSON const& value) = 0;
318 310 };
... ... @@ -339,8 +331,7 @@ class JSON
339 331  
340 332 private:
341 333 static std::string encode_string(std::string const& utf8);
342   - static void
343   - writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter);
  334 + static void writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter);
344 335  
345 336 enum value_type_e {
346 337 vt_none,
... ...
include/qpdf/Pl_Function.hh
... ... @@ -54,15 +54,10 @@ class QPDF_DLL_CLASS Pl_Function: public Pipeline
54 54 // is thrown.
55 55 typedef int (*writer_c_t)(unsigned char const*, size_t, void*);
56 56 QPDF_DLL
57   - Pl_Function(
58   - char const* identifier, Pipeline* next, writer_c_t fn, void* udata);
  57 + Pl_Function(char const* identifier, Pipeline* next, writer_c_t fn, void* udata);
59 58 typedef int (*writer_c_char_t)(char const*, size_t, void*);
60 59 QPDF_DLL
61   - Pl_Function(
62   - char const* identifier,
63   - Pipeline* next,
64   - writer_c_char_t fn,
65   - void* udata);
  60 + Pl_Function(char const* identifier, Pipeline* next, writer_c_char_t fn, void* udata);
66 61  
67 62 QPDF_DLL
68 63 virtual ~Pl_Function();
... ...
include/qpdf/Pl_QPDFTokenizer.hh
... ... @@ -49,9 +49,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
49 49 // provided, any output written by the filter will be discarded.
50 50 QPDF_DLL
51 51 Pl_QPDFTokenizer(
52   - char const* identifier,
53   - QPDFObjectHandle::TokenFilter* filter,
54   - Pipeline* next = nullptr);
  52 + char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
55 53 QPDF_DLL
56 54 virtual ~Pl_QPDFTokenizer();
57 55 QPDF_DLL
... ...
include/qpdf/QIntC.hh
... ... @@ -78,9 +78,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion
78 78 {
79 79 std::ostringstream msg;
80 80 msg.imbue(std::locale::classic());
81   - msg << "integer out of range converting " << i << " from a "
82   - << sizeof(From) << "-byte unsigned type to a " << sizeof(To)
83   - << "-byte unsigned type";
  81 + msg << "integer out of range converting " << i << " from a " << sizeof(From)
  82 + << "-byte unsigned type to a " << sizeof(To) << "-byte unsigned type";
84 83 throw std::range_error(msg.str());
85 84 }
86 85 };
... ... @@ -93,8 +92,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion
93 92 convert(From const& i)
94 93 {
95 94 // From and To are both signed.
96   - if ((i < std::numeric_limits<To>::min()) ||
97   - (i > std::numeric_limits<To>::max())) {
  95 + if ((i < std::numeric_limits<To>::min()) || (i > std::numeric_limits<To>::max())) {
98 96 error(i);
99 97 }
100 98 return static_cast<To>(i);
... ... @@ -105,9 +103,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion
105 103 {
106 104 std::ostringstream msg;
107 105 msg.imbue(std::locale::classic());
108   - msg << "integer out of range converting " << i << " from a "
109   - << sizeof(From) << "-byte signed type to a " << sizeof(To)
110   - << "-byte signed type";
  106 + msg << "integer out of range converting " << i << " from a " << sizeof(From)
  107 + << "-byte signed type to a " << sizeof(To) << "-byte signed type";
111 108 throw std::range_error(msg.str());
112 109 }
113 110 };
... ... @@ -134,9 +131,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion
134 131 {
135 132 std::ostringstream msg;
136 133 msg.imbue(std::locale::classic());
137   - msg << "integer out of range converting " << i << " from a "
138   - << sizeof(From) << "-byte signed type to a " << sizeof(To)
139   - << "-byte unsigned type";
  134 + msg << "integer out of range converting " << i << " from a " << sizeof(From)
  135 + << "-byte signed type to a " << sizeof(To) << "-byte unsigned type";
140 136 throw std::range_error(msg.str());
141 137 }
142 138 };
... ... @@ -150,8 +146,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion
150 146 {
151 147 // From is unsigned, and to is signed. Convert To's max to the
152 148 // unsigned version of To and compare i against that.
153   - auto maxval = static_cast<typename to_u<To>::type>(
154   - std::numeric_limits<To>::max());
  149 + auto maxval = static_cast<typename to_u<To>::type>(std::numeric_limits<To>::max());
155 150 if (i > maxval) {
156 151 error(i);
157 152 }
... ... @@ -163,9 +158,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion
163 158 {
164 159 std::ostringstream msg;
165 160 msg.imbue(std::locale::classic());
166   - msg << "integer out of range converting " << i << " from a "
167   - << sizeof(From) << "-byte unsigned type to a " << sizeof(To)
168   - << "-byte signed type";
  161 + msg << "integer out of range converting " << i << " from a " << sizeof(From)
  162 + << "-byte unsigned type to a " << sizeof(To) << "-byte signed type";
169 163 throw std::range_error(msg.str());
170 164 }
171 165 };
... ... @@ -263,15 +257,12 @@ namespace QIntC // QIntC = qpdf Integer Conversion
263 257 if ((delta > 0) && ((std::numeric_limits<T>::max() - cur) < delta)) {
264 258 std::ostringstream msg;
265 259 msg.imbue(std::locale::classic());
266   - msg << "adding " << delta << " to " << cur
267   - << " would cause an integer overflow";
  260 + msg << "adding " << delta << " to " << cur << " would cause an integer overflow";
268 261 throw std::range_error(msg.str());
269   - } else if (
270   - (delta < 0) && ((std::numeric_limits<T>::min() - cur) > delta)) {
  262 + } else if ((delta < 0) && ((std::numeric_limits<T>::min() - cur) > delta)) {
271 263 std::ostringstream msg;
272 264 msg.imbue(std::locale::classic());
273   - msg << "adding " << delta << " to " << cur
274   - << " would cause an integer underflow";
  265 + msg << "adding " << delta << " to " << cur << " would cause an integer underflow";
275 266 throw std::range_error(msg.str());
276 267 }
277 268 }
... ... @@ -296,12 +287,10 @@ namespace QIntC // QIntC = qpdf Integer Conversion
296 287 msg << "subtracting " << delta << " from " << cur
297 288 << " would cause an integer underflow";
298 289 throw std::range_error(msg.str());
299   - } else if (
300   - (delta < 0) && ((std::numeric_limits<T>::max() + delta) < cur)) {
  290 + } else if ((delta < 0) && ((std::numeric_limits<T>::max() + delta) < cur)) {
301 291 std::ostringstream msg;
302 292 msg.imbue(std::locale::classic());
303   - msg << "subtracting " << delta << " from " << cur
304   - << " would cause an integer overflow";
  293 + msg << "subtracting " << delta << " from " << cur << " would cause an integer overflow";
305 294 throw std::range_error(msg.str());
306 295 }
307 296 }
... ...
include/qpdf/QPDF.hh
... ... @@ -93,10 +93,7 @@ class QPDF
93 93 // responsible for closing the file.
94 94 QPDF_DLL
95 95 void processFile(
96   - char const* description,
97   - FILE* file,
98   - bool close_file,
99   - char const* password = nullptr);
  96 + char const* description, FILE* file, bool close_file, char const* password = nullptr);
100 97  
101 98 // Parse a PDF file loaded into a memory buffer. This works
102 99 // exactly like processFile except that the PDF file is in memory
... ... @@ -104,17 +101,13 @@ class QPDF
104 101 // error message in place of the file name.
105 102 QPDF_DLL
106 103 void processMemoryFile(
107   - char const* description,
108   - char const* buf,
109   - size_t length,
110   - char const* password = nullptr);
  104 + char const* description, char const* buf, size_t length, char const* password = nullptr);
111 105  
112 106 // Parse a PDF file loaded from a custom InputSource. If you have
113 107 // your own method of retrieving a PDF file, you can subclass
114 108 // InputSource and use this method.
115 109 QPDF_DLL
116   - void processInputSource(
117   - std::shared_ptr<InputSource>, char const* password = nullptr);
  110 + void processInputSource(std::shared_ptr<InputSource>, char const* password = nullptr);
118 111  
119 112 // Create a PDF from an input source that contains JSON as written
120 113 // by writeJSON (or qpdf --json-output, version 2 or higher). The
... ... @@ -234,8 +227,7 @@ class QPDF
234 227 // QPDFStreamFilter classes.
235 228 QPDF_DLL
236 229 static void registerStreamFilter(
237   - std::string const& filter_name,
238   - std::function<std::shared_ptr<QPDFStreamFilter>()> factory);
  230 + std::string const& filter_name, std::function<std::shared_ptr<QPDFStreamFilter>()> factory);
239 231  
240 232 // Parameter settings
241 233  
... ... @@ -260,8 +252,7 @@ class QPDF
260 252 // configures a private logger, separating this object from the
261 253 // default logger, and calls setOutputStreams on that logger. See
262 254 // QPDFLogger.hh for additional details.
263   - [[deprecated(
264   - "configure logger from getLogger() or call setLogger()")]] QPDF_DLL void
  255 + [[deprecated("configure logger from getLogger() or call setLogger()")]] QPDF_DLL void
265 256 setOutputStreams(std::ostream* out_stream, std::ostream* err_stream);
266 257  
267 258 // If true, ignore any cross-reference streams in a hybrid file
... ... @@ -481,8 +472,7 @@ class QPDF
481 472 // reserved object. After this call, reserved will be a reference
482 473 // to replacement.
483 474 QPDF_DLL
484   - void
485   - replaceReserved(QPDFObjectHandle reserved, QPDFObjectHandle replacement);
  475 + void replaceReserved(QPDFObjectHandle reserved, QPDFObjectHandle replacement);
486 476  
487 477 // Copy an object from another QPDF to this one. Starting with
488 478 // qpdf version 8.3.0, it is no longer necessary to keep the
... ... @@ -657,8 +647,8 @@ class QPDF
657 647 int encryption_V,
658 648 int encryption_R);
659 649 QPDF_DLL
660   - static std::string compute_encryption_key(
661   - std::string const& password, EncryptionData const& data);
  650 + static std::string
  651 + compute_encryption_key(std::string const& password, EncryptionData const& data);
662 652  
663 653 QPDF_DLL
664 654 static void compute_encryption_O_U(
... ... @@ -843,8 +833,7 @@ class QPDF
843 833 QPDF_DLL
844 834 void addPage(QPDFObjectHandle newpage, bool first);
845 835 QPDF_DLL
846   - void
847   - addPageAt(QPDFObjectHandle newpage, bool before, QPDFObjectHandle refpage);
  836 + void addPageAt(QPDFObjectHandle newpage, bool before, QPDFObjectHandle refpage);
848 837 QPDF_DLL
849 838 void removePage(QPDFObjectHandle page);
850 839 // End legacy page helpers
... ... @@ -866,8 +855,7 @@ class QPDF
866 855 std::vector<QPDFObjectHandle>& part8,
867 856 std::vector<QPDFObjectHandle>& part9)
868 857 {
869   - qpdf.getLinearizedParts(
870   - object_stream_data, part4, part6, part7, part8, part9);
  858 + qpdf.getLinearizedParts(object_stream_data, part4, part6, part7, part8, part9);
871 859 }
872 860  
873 861 static void
... ... @@ -880,8 +868,7 @@ class QPDF
880 868 int& S,
881 869 int& O)
882 870 {
883   - return qpdf.generateHintStream(
884   - xref, lengths, obj_renumber, hint_stream, S, O);
  871 + return qpdf.generateHintStream(xref, lengths, obj_renumber, hint_stream, S, O);
885 872 }
886 873  
887 874 static void
... ... @@ -919,10 +906,7 @@ class QPDF
919 906  
920 907 private:
921 908 static void
922   - copyStreamData(
923   - QPDF* qpdf,
924   - QPDFObjectHandle const& dest,
925   - QPDFObjectHandle const& src)
  909 + copyStreamData(QPDF* qpdf, QPDFObjectHandle const& dest, QPDFObjectHandle const& src)
926 910 {
927 911 qpdf->copyStreamData(dest, src);
928 912 }
... ... @@ -968,13 +952,7 @@ class QPDF
968 952 bool will_retry)
969 953 {
970 954 return qpdf->pipeStreamData(
971   - og,
972   - offset,
973   - length,
974   - dict,
975   - pipeline,
976   - suppress_warnings,
977   - will_retry);
  955 + og, offset, length, dict, pipeline, suppress_warnings, will_retry);
978 956 }
979 957 };
980 958  
... ... @@ -1096,16 +1074,13 @@ class QPDF
1096 1074 Pipeline* pipeline,
1097 1075 bool suppress_warnings,
1098 1076 bool will_retry) override;
1099   - void registerForeignStream(
1100   - QPDFObjGen const& local_og, QPDFObjectHandle foreign_stream);
1101   - void registerForeignStream(
1102   - QPDFObjGen const& local_og, std::shared_ptr<ForeignStreamData>);
  1077 + void registerForeignStream(QPDFObjGen const& local_og, QPDFObjectHandle foreign_stream);
  1078 + void registerForeignStream(QPDFObjGen const& local_og, std::shared_ptr<ForeignStreamData>);
1103 1079  
1104 1080 private:
1105 1081 QPDF& destination_qpdf;
1106 1082 std::map<QPDFObjGen, QPDFObjectHandle> foreign_streams;
1107   - std::map<QPDFObjGen, std::shared_ptr<ForeignStreamData>>
1108   - foreign_stream_data;
  1083 + std::map<QPDFObjGen, std::shared_ptr<ForeignStreamData>> foreign_stream_data;
1109 1084 };
1110 1085  
1111 1086 class StringDecrypter: public QPDFObjectHandle::StringDecrypter
... ... @@ -1148,29 +1123,21 @@ class QPDF
1148 1123 void read_xref(qpdf_offset_t offset);
1149 1124 bool resolveXRefTable();
1150 1125 void reconstruct_xref(QPDFExc& e);
1151   - bool
1152   - parse_xrefFirst(std::string const& line, int& obj, int& num, int& bytes);
1153   - bool parse_xrefEntry(
1154   - std::string const& line, qpdf_offset_t& f1, int& f2, char& type);
  1126 + bool parse_xrefFirst(std::string const& line, int& obj, int& num, int& bytes);
  1127 + bool parse_xrefEntry(std::string const& line, qpdf_offset_t& f1, int& f2, char& type);
1155 1128 qpdf_offset_t read_xrefTable(qpdf_offset_t offset);
1156 1129 qpdf_offset_t read_xrefStream(qpdf_offset_t offset);
1157   - qpdf_offset_t
1158   - processXRefStream(qpdf_offset_t offset, QPDFObjectHandle& xref_stream);
1159   - void insertXrefEntry(
1160   - int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite = false);
1161   - void setLastObjectDescription(
1162   - std::string const& description, QPDFObjGen const& og);
  1130 + qpdf_offset_t processXRefStream(qpdf_offset_t offset, QPDFObjectHandle& xref_stream);
  1131 + void insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite = false);
  1132 + void setLastObjectDescription(std::string const& description, QPDFObjGen const& og);
1163 1133 QPDFObjectHandle readObject(
1164 1134 std::shared_ptr<InputSource>,
1165 1135 std::string const& description,
1166 1136 QPDFObjGen const& og,
1167 1137 bool in_object_stream);
1168 1138 size_t recoverStreamLength(
1169   - std::shared_ptr<InputSource> input,
1170   - QPDFObjGen const& og,
1171   - qpdf_offset_t stream_offset);
1172   - QPDFTokenizer::Token
1173   - readToken(std::shared_ptr<InputSource>, size_t max_len = 0);
  1139 + std::shared_ptr<InputSource> input, QPDFObjGen const& og, qpdf_offset_t stream_offset);
  1140 + QPDFTokenizer::Token readToken(std::shared_ptr<InputSource>, size_t max_len = 0);
1174 1141  
1175 1142 QPDFObjectHandle readObjectAtOffset(
1176 1143 bool attempt_recovery,
... ... @@ -1185,10 +1152,8 @@ class QPDF
1185 1152 QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og);
1186 1153 QPDFObjectHandle reserveStream(QPDFObjGen const& og);
1187 1154 QPDFObjGen nextObjGen();
1188   - QPDFObjectHandle
1189   - newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);
1190   - QPDFObjectHandle
1191   - makeIndirectFromQPDFObject(std::shared_ptr<QPDFObject> const& obj);
  1155 + QPDFObjectHandle newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);
  1156 + QPDFObjectHandle makeIndirectFromQPDFObject(std::shared_ptr<QPDFObject> const& obj);
1192 1157 bool isCached(QPDFObjGen const& og);
1193 1158 bool isUnresolved(QPDFObjGen const& og);
1194 1159 void updateCache(
... ... @@ -1205,10 +1170,7 @@ class QPDF
1205 1170 std::shared_ptr<InputSource> const& input,
1206 1171 qpdf_offset_t offset,
1207 1172 std::string const& message);
1208   - QPDFExc damagedPDF(
1209   - std::string const& object,
1210   - qpdf_offset_t offset,
1211   - std::string const& message);
  1173 + QPDFExc damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message);
1212 1174 QPDFExc damagedPDF(std::string const& object, std::string const& message);
1213 1175 QPDFExc damagedPDF(qpdf_offset_t offset, std::string const& message);
1214 1176 QPDFExc damagedPDF(std::string const& message);
... ... @@ -1223,10 +1185,7 @@ class QPDF
1223 1185 bool suppress_warnings,
1224 1186 bool will_retry);
1225 1187 bool pipeForeignStreamData(
1226   - std::shared_ptr<ForeignStreamData>,
1227   - Pipeline*,
1228   - bool suppress_warnings,
1229   - bool will_retry);
  1188 + std::shared_ptr<ForeignStreamData>, Pipeline*, bool suppress_warnings, bool will_retry);
1230 1189 static bool pipeStreamData(
1231 1190 std::shared_ptr<QPDF::EncryptionParameters> encp,
1232 1191 std::shared_ptr<InputSource> file,
... ... @@ -1269,31 +1228,24 @@ class QPDF
1269 1228 // methods to support page handling
1270 1229  
1271 1230 void getAllPagesInternal(
1272   - QPDFObjectHandle cur_pages,
1273   - QPDFObjGen::set& visited,
1274   - QPDFObjGen::set& seen);
  1231 + QPDFObjectHandle cur_pages, QPDFObjGen::set& visited, QPDFObjGen::set& seen);
1275 1232 void insertPage(QPDFObjectHandle newpage, int pos);
1276 1233 void flattenPagesTree();
1277   - void insertPageobjToPage(
1278   - QPDFObjectHandle const& obj, int pos, bool check_duplicate);
  1234 + void insertPageobjToPage(QPDFObjectHandle const& obj, int pos, bool check_duplicate);
1279 1235  
1280 1236 // methods to support encryption -- implemented in QPDF_encryption.cc
1281 1237 static encryption_method_e
1282 1238 interpretCF(std::shared_ptr<EncryptionParameters> encp, QPDFObjectHandle);
1283 1239 void initializeEncryption();
1284   - static std::string getKeyForObject(
1285   - std::shared_ptr<EncryptionParameters> encp,
1286   - QPDFObjGen const& og,
1287   - bool use_aes);
  1240 + static std::string
  1241 + getKeyForObject(std::shared_ptr<EncryptionParameters> encp, QPDFObjGen const& og, bool use_aes);
1288 1242 void decryptString(std::string&, QPDFObjGen const& og);
1289   - static std::string compute_encryption_key_from_password(
1290   - std::string const& password, EncryptionData const& data);
1291   - static std::string recover_encryption_key_with_password(
1292   - std::string const& password, EncryptionData const& data);
  1243 + static std::string
  1244 + compute_encryption_key_from_password(std::string const& password, EncryptionData const& data);
  1245 + static std::string
  1246 + recover_encryption_key_with_password(std::string const& password, EncryptionData const& data);
1293 1247 static std::string recover_encryption_key_with_password(
1294   - std::string const& password,
1295   - EncryptionData const& data,
1296   - bool& perms_valid);
  1248 + std::string const& password, EncryptionData const& data, bool& perms_valid);
1297 1249 static void decryptStream(
1298 1250 std::shared_ptr<EncryptionParameters> encp,
1299 1251 std::shared_ptr<InputSource> file,
... ... @@ -1304,12 +1256,10 @@ class QPDF
1304 1256 std::vector<std::shared_ptr<Pipeline>>& heap);
1305 1257  
1306 1258 // Methods to support object copying
1307   - void
1308   - reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);
1309   - QPDFObjectHandle replaceForeignIndirectObjects(
1310   - QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);
1311   - void
1312   - copyStreamData(QPDFObjectHandle dest_stream, QPDFObjectHandle src_stream);
  1259 + void reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);
  1260 + QPDFObjectHandle
  1261 + replaceForeignIndirectObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);
  1262 + void copyStreamData(QPDFObjectHandle dest_stream, QPDFObjectHandle src_stream);
1313 1263  
1314 1264 // Linearization Hint table structures.
1315 1265 // Naming conventions:
... ... @@ -1538,14 +1488,7 @@ class QPDF
1538 1488 class ObjUser
1539 1489 {
1540 1490 public:
1541   - enum user_e {
1542   - ou_bad,
1543   - ou_page,
1544   - ou_thumb,
1545   - ou_trailer_key,
1546   - ou_root_key,
1547   - ou_root
1548   - };
  1491 + enum user_e { ou_bad, ou_page, ou_thumb, ou_trailer_key, ou_root_key, ou_root };
1549 1492  
1550 1493 // type is set to ou_bad
1551 1494 ObjUser();
... ... @@ -1598,29 +1541,25 @@ class QPDF
1598 1541 bool checkLinearizationInternal();
1599 1542 void dumpLinearizationDataInternal();
1600 1543 void linearizationWarning(std::string_view);
1601   - QPDFObjectHandle
1602   - readHintStream(Pipeline&, qpdf_offset_t offset, size_t length);
  1544 + QPDFObjectHandle readHintStream(Pipeline&, qpdf_offset_t offset, size_t length);
1603 1545 void readHPageOffset(BitStream);
1604 1546 void readHSharedObject(BitStream);
1605 1547 void readHGeneric(BitStream, HGeneric&);
1606 1548 qpdf_offset_t maxEnd(ObjUser const& ou);
1607 1549 qpdf_offset_t getLinearizationOffset(QPDFObjGen const&);
1608   - QPDFObjectHandle getUncompressedObject(
1609   - QPDFObjectHandle&, std::map<int, int> const& object_stream_data);
  1550 + QPDFObjectHandle
  1551 + getUncompressedObject(QPDFObjectHandle&, std::map<int, int> const& object_stream_data);
1610 1552 int lengthNextN(int first_object, int n);
1611   - void checkHPageOffset(
1612   - std::vector<QPDFObjectHandle> const& pages,
1613   - std::map<int, int>& idx_to_obj);
1614   - void checkHSharedObject(
1615   - std::vector<QPDFObjectHandle> const& pages,
1616   - std::map<int, int>& idx_to_obj);
  1553 + void
  1554 + checkHPageOffset(std::vector<QPDFObjectHandle> const& pages, std::map<int, int>& idx_to_obj);
  1555 + void
  1556 + checkHSharedObject(std::vector<QPDFObjectHandle> const& pages, std::map<int, int>& idx_to_obj);
1617 1557 void checkHOutlines();
1618 1558 void dumpHPageOffset();
1619 1559 void dumpHSharedObject();
1620 1560 void dumpHGeneric(HGeneric&);
1621 1561 qpdf_offset_t adjusted_offset(qpdf_offset_t offset);
1622   - void
1623   - calculateLinearizationData(std::map<int, int> const& object_stream_data);
  1562 + void calculateLinearizationData(std::map<int, int> const& object_stream_data);
1624 1563 void pushOutlinesToPart(
1625 1564 std::vector<QPDFObjectHandle>& part,
1626 1565 std::set<QPDFObjGen>& lc_outlines,
... ... @@ -1648,8 +1587,7 @@ class QPDF
1648 1587  
1649 1588 // Methods to support optimization
1650 1589  
1651   - void
1652   - pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys);
  1590 + void pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys);
1653 1591 void pushInheritedAttributesToPageInternal(
1654 1592 QPDFObjectHandle,
1655 1593 std::map<std::string, std::vector<QPDFObjectHandle>>&,
... ... @@ -1681,11 +1619,7 @@ class QPDF
1681 1619 qpdf_json_stream_data_e,
1682 1620 std::string const& file_prefix);
1683 1621 void writeJSONObject(
1684   - int version,
1685   - Pipeline* p,
1686   - bool& first,
1687   - std::string const& key,
1688   - QPDFObjectHandle&);
  1622 + int version, Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle&);
1689 1623  
1690 1624 // Type conversion helper methods
1691 1625 template <typename T>
... ...
include/qpdf/QPDFAcroFormDocumentHelper.hh
... ... @@ -148,18 +148,15 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
148 148 // underlying object will typically be the same as the underlying
149 149 // object for the field.
150 150 QPDF_DLL
151   - std::vector<QPDFAnnotationObjectHelper>
152   - getAnnotationsForField(QPDFFormFieldObjectHelper);
  151 + std::vector<QPDFAnnotationObjectHelper> getAnnotationsForField(QPDFFormFieldObjectHelper);
153 152  
154 153 // Return annotations of subtype /Widget for a page.
155 154 QPDF_DLL
156   - std::vector<QPDFAnnotationObjectHelper>
157   - getWidgetAnnotationsForPage(QPDFPageObjectHelper);
  155 + std::vector<QPDFAnnotationObjectHelper> getWidgetAnnotationsForPage(QPDFPageObjectHelper);
158 156  
159 157 // Return top-level form fields for a page.
160 158 QPDF_DLL
161   - std::vector<QPDFFormFieldObjectHelper>
162   - getFormFieldsForPage(QPDFPageObjectHelper);
  159 + std::vector<QPDFFormFieldObjectHelper> getFormFieldsForPage(QPDFPageObjectHelper);
163 160  
164 161 // Return the terminal field that is associated with this
165 162 // annotation. If the annotation dictionary is merged with the
... ... @@ -251,10 +248,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
251 248 private:
252 249 void analyze();
253 250 void traverseField(
254   - QPDFObjectHandle field,
255   - QPDFObjectHandle parent,
256   - int depth,
257   - QPDFObjGen::set& visited);
  251 + QPDFObjectHandle field, QPDFObjectHandle parent, int depth, QPDFObjGen::set& visited);
258 252 QPDFObjectHandle getOrCreateAcroForm();
259 253 void adjustInheritedFields(
260 254 QPDFObjectHandle obj,
... ... @@ -264,11 +258,9 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
264 258 int from_default_q);
265 259 void adjustDefaultAppearances(
266 260 QPDFObjectHandle obj,
267   - std::map<std::string, std::map<std::string, std::string>> const&
268   - dr_map);
  261 + std::map<std::string, std::map<std::string, std::string>> const& dr_map);
269 262 void adjustAppearanceStream(
270   - QPDFObjectHandle stream,
271   - std::map<std::string, std::map<std::string, std::string>> dr_map);
  263 + QPDFObjectHandle stream, std::map<std::string, std::map<std::string, std::string>> dr_map);
272 264  
273 265 class Members
274 266 {
... ... @@ -283,8 +275,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
283 275 Members(Members const&) = delete;
284 276  
285 277 bool cache_valid;
286   - std::map<QPDFObjGen, std::vector<QPDFAnnotationObjectHelper>>
287   - field_to_annotations;
  278 + std::map<QPDFObjGen, std::vector<QPDFAnnotationObjectHelper>> field_to_annotations;
288 279 std::map<QPDFObjGen, QPDFFormFieldObjectHelper> annotation_to_field;
289 280 std::map<QPDFObjGen, std::string> field_to_name;
290 281 std::map<std::string, std::set<QPDFObjGen>> name_to_fields;
... ...
include/qpdf/QPDFAnnotationObjectHelper.hh
... ... @@ -76,8 +76,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
76 76 // which appearance stream is desired. If not specified, the
77 77 // appearance state in "/AS" will used.
78 78 QPDF_DLL
79   - QPDFObjectHandle getAppearanceStream(
80   - std::string const& which, std::string const& state = "");
  79 + QPDFObjectHandle getAppearanceStream(std::string const& which, std::string const& state = "");
81 80  
82 81 // Generate text suitable for addition to the containing page's
83 82 // content stream that draws this annotation's appearance stream
... ...
include/qpdf/QPDFCryptoImpl.hh
... ... @@ -77,10 +77,8 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
77 77 virtual void RC4_init(unsigned char const* key_data, int key_len = -1) = 0;
78 78 // out_data = 0 means to encrypt/decrypt in place
79 79 QPDF_DLL
80   - virtual void RC4_process(
81   - unsigned char const* in_data,
82   - size_t len,
83   - unsigned char* out_data = nullptr) = 0;
  80 + virtual void
  81 + RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = nullptr) = 0;
84 82 QPDF_DLL
85 83 virtual void RC4_finalize() = 0;
86 84  
... ... @@ -93,8 +91,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
93 91 bool cbc_mode,
94 92 unsigned char* cbc_block) = 0;
95 93 QPDF_DLL
96   - virtual void
97   - rijndael_process(unsigned char* in_data, unsigned char* out_data) = 0;
  94 + virtual void rijndael_process(unsigned char* in_data, unsigned char* out_data) = 0;
98 95 QPDF_DLL
99 96 virtual void rijndael_finalize() = 0;
100 97 };
... ...
include/qpdf/QPDFCryptoProvider.hh
... ... @@ -78,8 +78,7 @@ class QPDFCryptoProvider
78 78  
79 79 static QPDFCryptoProvider& getInstance();
80 80  
81   - std::shared_ptr<QPDFCryptoImpl>
82   - getImpl_internal(std::string const& name) const;
  81 + std::shared_ptr<QPDFCryptoImpl> getImpl_internal(std::string const& name) const;
83 82 template <typename T>
84 83 void registerImpl_internal(std::string const& name);
85 84 void setDefaultProvider_internal(std::string const& name);
... ...
include/qpdf/QPDFEFStreamObjectHelper.hh
... ... @@ -75,11 +75,9 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper
75 75 // checksum and size are computed automatically and stored. Other
76 76 // parameters may be supplied using setters defined below.
77 77 QPDF_DLL
78   - static QPDFEFStreamObjectHelper
79   - createEFStream(QPDF& qpdf, std::shared_ptr<Buffer> data);
  78 + static QPDFEFStreamObjectHelper createEFStream(QPDF& qpdf, std::shared_ptr<Buffer> data);
80 79 QPDF_DLL
81   - static QPDFEFStreamObjectHelper
82   - createEFStream(QPDF& qpdf, std::string const& data);
  80 + static QPDFEFStreamObjectHelper createEFStream(QPDF& qpdf, std::string const& data);
83 81 // The provider function must write the data to the given
84 82 // pipeline. The function may be called multiple times by the qpdf
85 83 // library. You can pass QUtil::file_provider(filename) as the
... ...
include/qpdf/QPDFEmbeddedFileDocumentHelper.hh
... ... @@ -48,19 +48,16 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper
48 48 bool hasEmbeddedFiles() const;
49 49  
50 50 QPDF_DLL
51   - std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>>
52   - getEmbeddedFiles();
  51 + std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>> getEmbeddedFiles();
53 52  
54 53 // If an embedded file with the given name exists, return a
55 54 // (shared) pointer to it. Otherwise, return nullptr.
56 55 QPDF_DLL
57   - std::shared_ptr<QPDFFileSpecObjectHelper>
58   - getEmbeddedFile(std::string const& name);
  56 + std::shared_ptr<QPDFFileSpecObjectHelper> getEmbeddedFile(std::string const& name);
59 57  
60 58 // Add or replace an attachment
61 59 QPDF_DLL
62   - void replaceEmbeddedFile(
63   - std::string const& name, QPDFFileSpecObjectHelper const&);
  60 + void replaceEmbeddedFile(std::string const& name, QPDFFileSpecObjectHelper const&);
64 61  
65 62 // Remove an embedded file if present. Return value is true if the
66 63 // file was present and was removed. This method not only removes
... ...
include/qpdf/QPDFFileSpecObjectHelper.hh
... ... @@ -77,16 +77,16 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
77 77 // filename, and attach the contents of the specified file as data
78 78 // in an embedded file stream.
79 79 QPDF_DLL
80   - static QPDFFileSpecObjectHelper createFileSpec(
81   - QPDF& qpdf, std::string const& filename, std::string const& fullpath);
  80 + static QPDFFileSpecObjectHelper
  81 + createFileSpec(QPDF& qpdf, std::string const& filename, std::string const& fullpath);
82 82  
83 83 // Create a new filespec as an indirect object with the given
84 84 // unicode filename and embedded file stream. The file name will
85 85 // be used as both /UF and /F. If you need to override, call
86 86 // setFilename.
87 87 QPDF_DLL
88   - static QPDFFileSpecObjectHelper createFileSpec(
89   - QPDF& qpdf, std::string const& filename, QPDFEFStreamObjectHelper);
  88 + static QPDFFileSpecObjectHelper
  89 + createFileSpec(QPDF& qpdf, std::string const& filename, QPDFEFStreamObjectHelper);
90 90  
91 91 QPDF_DLL
92 92 QPDFFileSpecObjectHelper& setDescription(std::string const&);
... ... @@ -96,8 +96,8 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
96 96 // QPDFObjectHandle literally, preserving whatever encoding it
97 97 // might happen to have.
98 98 QPDF_DLL
99   - QPDFFileSpecObjectHelper& setFilename(
100   - std::string const& unicode_name, std::string const& compat_name = "");
  99 + QPDFFileSpecObjectHelper&
  100 + setFilename(std::string const& unicode_name, std::string const& compat_name = "");
101 101  
102 102 private:
103 103 class Members
... ...
include/qpdf/QPDFFormFieldObjectHelper.hh
... ... @@ -183,8 +183,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
183 183 // of a field, use QPDFAcroFormDocumentHelper::setFormFieldName
184 184 // instead.
185 185 QPDF_DLL
186   - void
187   - setFieldAttribute(std::string const& key, std::string const& utf8_value);
  186 + void setFieldAttribute(std::string const& key, std::string const& utf8_value);
188 187  
189 188 // Set /V (field value) to the given value. If need_appearances is
190 189 // true and the field type is either /Tx (text) or /Ch (choice),
... ... @@ -218,8 +217,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
218 217 void setRadioButtonValue(QPDFObjectHandle name);
219 218 void setCheckBoxValue(bool value);
220 219 void generateTextAppearance(QPDFAnnotationObjectHelper&);
221   - QPDFObjectHandle getFontFromResource(
222   - QPDFObjectHandle resources, std::string const& font_name);
  220 + QPDFObjectHandle getFontFromResource(QPDFObjectHandle resources, std::string const& font_name);
223 221  
224 222 class Members
225 223 {
... ...
include/qpdf/QPDFJob.hh
... ... @@ -83,8 +83,7 @@ class QPDFJob
83 83 // about converting arguments to UTF-8. This method will mutate
84 84 // arguments that are passed to it.
85 85 QPDF_DLL
86   - void initializeFromArgv(
87   - char const* const argv[], char const* progname_env = nullptr);
  86 + void initializeFromArgv(char const* const argv[], char const* progname_env = nullptr);
88 87  
89 88 // Initialize a QPDFJob from json. Passing partial = true prevents
90 89 // this method from doing the final checks (calling
... ... @@ -132,8 +131,7 @@ class QPDFJob
132 131 // configures a private logger, separating this object from the
133 132 // default logger, and calls setOutputStreams on that logger. See
134 133 // QPDFLogger.hh for additional details.
135   - [[deprecated(
136   - "configure logger from getLogger() or call setLogger()")]] QPDF_DLL void
  134 + [[deprecated("configure logger from getLogger() or call setLogger()")]] QPDF_DLL void
137 135 setOutputStreams(std::ostream* out_stream, std::ostream* err_stream);
138 136  
139 137 // You can register a custom progress reporter to be called by
... ... @@ -187,10 +185,7 @@ class QPDFJob
187 185  
188 186 struct PageSpec
189 187 {
190   - PageSpec(
191   - std::string const& filename,
192   - char const* password,
193   - std::string const& range);
  188 + PageSpec(std::string const& filename, char const* password, std::string const& range);
194 189  
195 190 std::string filename;
196 191 std::shared_ptr<char> password;
... ... @@ -284,9 +279,7 @@ class QPDFJob
284 279 Config* endPages();
285 280 QPDF_DLL
286 281 PagesConfig* pageSpec(
287   - std::string const& filename,
288   - std::string const& range,
289   - char const* password = nullptr);
  282 + std::string const& filename, std::string const& range, char const* password = nullptr);
290 283  
291 284 #include <qpdf/auto_job_c_pages.hh>
292 285  
... ... @@ -366,10 +359,8 @@ class QPDFJob
366 359 QPDF_DLL
367 360 std::shared_ptr<UOConfig> underlay();
368 361 QPDF_DLL
369   - std::shared_ptr<EncConfig> encrypt(
370   - int keylen,
371   - std::string const& user_password,
372   - std::string const& owner_password);
  362 + std::shared_ptr<EncConfig>
  363 + encrypt(int keylen, std::string const& user_password, std::string const& owner_password);
373 364  
374 365 #include <qpdf/auto_job_c_main.hh>
375 366  
... ... @@ -438,8 +429,7 @@ class QPDFJob
438 429 // If in verbose mode, call the given function, passing in the
439 430 // output stream and message prefix.
440 431 QPDF_DLL
441   - void
442   - doIfVerbose(std::function<void(Pipeline&, std::string const& prefix)> fn);
  432 + void doIfVerbose(std::function<void(Pipeline&, std::string const& prefix)> fn);
443 433  
444 434 // Provide a string that is the help information ("schema" for the
445 435 // qpdf-specific JSON object) for the specified version of JSON
... ... @@ -447,16 +437,14 @@ class QPDFJob
447 437 QPDF_DLL
448 438 static std::string json_out_schema(int version);
449 439  
450   - [[deprecated("use json_out_schema(version)")]] static std::string QPDF_DLL
451   - json_out_schema_v1();
  440 + [[deprecated("use json_out_schema(version)")]] static std::string QPDF_DLL json_out_schema_v1();
452 441  
453 442 // Provide a string that is the help information for specified
454 443 // version of JSON format for QPDFJob.
455 444 QPDF_DLL
456 445 static std::string job_json_schema(int version);
457 446  
458   - [[deprecated("use job_json_schema(version)")]] static std::string QPDF_DLL
459   - job_json_schema_v1();
  447 + [[deprecated("use job_json_schema(version)")]] static std::string QPDF_DLL job_json_schema_v1();
460 448  
461 449 private:
462 450 struct RotationSpec
... ... @@ -497,10 +485,8 @@ class QPDFJob
497 485  
498 486 // Helper functions
499 487 static void usage(std::string const& msg);
500   - static JSON
501   - json_schema(int json_version, std::set<std::string>* keys = nullptr);
502   - static void parse_object_id(
503   - std::string const& objspec, bool& trailer, int& obj, int& gen);
  488 + static JSON json_schema(int json_version, std::set<std::string>* keys = nullptr);
  489 + static void parse_object_id(std::string const& objspec, bool& trailer, int& obj, int& gen);
504 490 void parseRotationParameter(std::string const&);
505 491 std::vector<int> parseNumrange(char const* range, int max);
506 492  
... ... @@ -533,12 +519,10 @@ class QPDFJob
533 519  
534 520 // Transformations
535 521 void setQPDFOptions(QPDF& pdf);
536   - void
537   - handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap);
  522 + void handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap);
538 523 bool shouldRemoveUnreferencedResources(QPDF& pdf);
539 524 void handleRotations(QPDF& pdf);
540   - void
541   - getUOPagenos(UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos);
  525 + void getUOPagenos(UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos);
542 526 void handleUnderOverlay(QPDF& pdf);
543 527 std::string doUnderOverlayForPage(
544 528 QPDF& pdf,
... ... @@ -573,8 +557,7 @@ class QPDFJob
573 557 // JSON
574 558 void doJSON(QPDF& pdf, Pipeline*);
575 559 QPDFObjGen::set getWantedJSONObjects();
576   - void doJSONObject(
577   - Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle&);
  560 + void doJSONObject(Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle&);
578 561 void doJSONObjects(Pipeline* p, bool& first, QPDF& pdf);
579 562 void doJSONObjectinfo(Pipeline* p, bool& first, QPDF& pdf);
580 563 void doJSONPages(Pipeline* p, bool& first, QPDF& pdf);
... ...
include/qpdf/QPDFLogger.hh
... ... @@ -153,8 +153,7 @@ class QPDFLogger
153 153  
154 154 private:
155 155 QPDFLogger();
156   - std::shared_ptr<Pipeline>
157   - throwIfNull(std::shared_ptr<Pipeline>, bool null_okay);
  156 + std::shared_ptr<Pipeline> throwIfNull(std::shared_ptr<Pipeline>, bool null_okay);
158 157  
159 158 class Members
160 159 {
... ...
include/qpdf/QPDFMatrix.hh
... ... @@ -79,8 +79,7 @@ class QPDFMatrix
79 79 // bounds the polygon resulting from transforming the four
80 80 // corners.
81 81 QPDF_DLL
82   - QPDFObjectHandle::Rectangle
83   - transformRectangle(QPDFObjectHandle::Rectangle r) const;
  82 + QPDFObjectHandle::Rectangle transformRectangle(QPDFObjectHandle::Rectangle r) const;
84 83  
85 84 // operator== tests for exact equality, not considering deltas for
86 85 // floating point.
... ...
include/qpdf/QPDFNameTreeObjectHelper.hh
... ... @@ -156,8 +156,7 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper
156 156 // Find the entry with the given key. If return_prev_if_not_found
157 157 // is true and the item is not found, return the next lower item.
158 158 QPDF_DLL
159   - iterator
160   - find(std::string const& key, bool return_prev_if_not_found = false);
  159 + iterator find(std::string const& key, bool return_prev_if_not_found = false);
161 160  
162 161 // Insert a new item. If the key already exists, it is replaced.
163 162 QPDF_DLL
... ...
include/qpdf/QPDFNumberTreeObjectHelper.hh
... ... @@ -45,8 +45,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
45 45 // The qpdf object is required so that this class can issue
46 46 // warnings, attempt repairs, and add indirect objects.
47 47 QPDF_DLL
48   - QPDFNumberTreeObjectHelper(
49   - QPDFObjectHandle, QPDF&, bool auto_repair = true);
  48 + QPDFNumberTreeObjectHelper(QPDFObjectHandle, QPDF&, bool auto_repair = true);
50 49  
51 50 QPDF_DLL
52 51 virtual ~QPDFNumberTreeObjectHelper();
... ... @@ -82,8 +81,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
82 81 // oh to the value with index 3, and set offset to 2 (5 - 3). See
83 82 // also find().
84 83 QPDF_DLL
85   - bool findObjectAtOrBelow(
86   - numtree_number idx, QPDFObjectHandle& oh, numtree_number& offset);
  84 + bool findObjectAtOrBelow(numtree_number idx, QPDFObjectHandle& oh, numtree_number& offset);
87 85  
88 86 class QPDF_DLL_PRIVATE iterator
89 87 {
... ...
include/qpdf/QPDFObjectHandle.hh
... ... @@ -128,22 +128,13 @@ class QPDFObjectHandle
128 128 // version of the method, which should also return a boolean
129 129 // indicating whether it ran without errors.
130 130 QPDF_DLL
131   - virtual void
132   - provideStreamData(QPDFObjGen const& og, Pipeline* pipeline);
  131 + virtual void provideStreamData(QPDFObjGen const& og, Pipeline* pipeline);
133 132 QPDF_DLL
134 133 virtual bool provideStreamData(
135   - QPDFObjGen const& og,
136   - Pipeline* pipeline,
137   - bool suppress_warnings,
138   - bool will_retry);
139   - QPDF_DLL virtual void
140   - provideStreamData(int objid, int generation, Pipeline* pipeline);
  134 + QPDFObjGen const& og, Pipeline* pipeline, bool suppress_warnings, bool will_retry);
  135 + QPDF_DLL virtual void provideStreamData(int objid, int generation, Pipeline* pipeline);
141 136 QPDF_DLL virtual bool provideStreamData(
142   - int objid,
143   - int generation,
144   - Pipeline* pipeline,
145   - bool suppress_warnings,
146   - bool will_retry);
  137 + int objid, int generation, Pipeline* pipeline, bool suppress_warnings, bool will_retry);
147 138 QPDF_DLL
148 139 bool supportsRetry();
149 140  
... ... @@ -246,8 +237,7 @@ class QPDFObjectHandle
246 237 QPDF_DLL
247 238 virtual void handleObject(QPDFObjectHandle);
248 239 QPDF_DLL
249   - virtual void
250   - handleObject(QPDFObjectHandle, size_t offset, size_t length);
  240 + virtual void handleObject(QPDFObjectHandle, size_t offset, size_t length);
251 241  
252 242 virtual void handleEOF() = 0;
253 243  
... ... @@ -408,14 +398,12 @@ class QPDFObjectHandle
408 398 // True if the object is a dictionary of the specified type and
409 399 // subtype, if any.
410 400 QPDF_DLL
411   - bool isDictionaryOfType(
412   - std::string const& type, std::string const& subtype = "");
  401 + bool isDictionaryOfType(std::string const& type, std::string const& subtype = "");
413 402  
414 403 // True if the object is a stream of the specified type and
415 404 // subtype, if any.
416 405 QPDF_DLL
417   - bool
418   - isStreamOfType(std::string const& type, std::string const& subtype = "");
  406 + bool isStreamOfType(std::string const& type, std::string const& subtype = "");
419 407  
420 408 // Public factory methods
421 409  
... ... @@ -433,9 +421,8 @@ class QPDFObjectHandle
433 421 // in the message of any QPDFExc exception thrown for invalid
434 422 // syntax. See also the global `operator ""_qpdf` defined below.
435 423 QPDF_DLL
436   - static QPDFObjectHandle parse(
437   - std::string const& object_str,
438   - std::string const& object_description = "");
  424 + static QPDFObjectHandle
  425 + parse(std::string const& object_str, std::string const& object_description = "");
439 426  
440 427 // Construct an object of any type from a string representation of
441 428 // the object. Indirect object syntax (obj gen R) is allowed and
... ... @@ -447,10 +434,8 @@ class QPDFObjectHandle
447 434 // object, which will just be the first number and will report
448 435 // that there is trailing data at the end of the string.
449 436 QPDF_DLL
450   - static QPDFObjectHandle parse(
451   - QPDF* context,
452   - std::string const& object_str,
453   - std::string const& object_description = "");
  437 + static QPDFObjectHandle
  438 + parse(QPDF* context, std::string const& object_str, std::string const& object_description = "");
454 439  
455 440 // Construct an object as above by reading from the given
456 441 // InputSource at its current position and using the tokenizer you
... ... @@ -480,8 +465,7 @@ class QPDFObjectHandle
480 465 // error messages will also be more useful because the page object
481 466 // information will be known.
482 467 QPDF_DLL
483   - static void parseContentStream(
484   - QPDFObjectHandle stream_or_array, ParserCallbacks* callbacks);
  468 + static void parseContentStream(QPDFObjectHandle stream_or_array, ParserCallbacks* callbacks);
485 469  
486 470 // When called on a stream or stream array that is some page's
487 471 // content streams, do the same as pipePageContents. This method
... ... @@ -500,10 +484,8 @@ class QPDFObjectHandle
500 484 // Pl_Concatenate and then call manualFinish() on the
501 485 // Pl_Concatenate pipeline at the end.
502 486 QPDF_DLL
503   - void pipeContentStreams(
504   - Pipeline* p,
505   - std::string const& description,
506   - std::string& all_description);
  487 + void
  488 + pipeContentStreams(Pipeline* p, std::string const& description, std::string& all_description);
507 489  
508 490 // As of qpdf 8, it is possible to add custom token filters to a
509 491 // stream. The tokenized stream data is passed through the token
... ... @@ -554,8 +536,8 @@ class QPDFObjectHandle
554 536 QPDF_DLL
555 537 static QPDFObjectHandle newReal(std::string const& value);
556 538 QPDF_DLL
557   - static QPDFObjectHandle newReal(
558   - double value, int decimal_places = 0, bool trim_trailing_zeroes = true);
  539 + static QPDFObjectHandle
  540 + newReal(double value, int decimal_places = 0, bool trim_trailing_zeroes = true);
559 541 // Note about name objects: qpdf's internal representation of a
560 542 // PDF name is a sequence of bytes, excluding the NUL character,
561 543 // and starting with a slash. Name objects as represented in the
... ... @@ -591,8 +573,7 @@ class QPDFObjectHandle
591 573 QPDF_DLL
592 574 static QPDFObjectHandle newArray();
593 575 QPDF_DLL
594   - static QPDFObjectHandle
595   - newArray(std::vector<QPDFObjectHandle> const& items);
  576 + static QPDFObjectHandle newArray(std::vector<QPDFObjectHandle> const& items);
596 577 QPDF_DLL
597 578 static QPDFObjectHandle newArray(Rectangle const&);
598 579 QPDF_DLL
... ... @@ -602,8 +583,7 @@ class QPDFObjectHandle
602 583 QPDF_DLL
603 584 static QPDFObjectHandle newDictionary();
604 585 QPDF_DLL
605   - static QPDFObjectHandle
606   - newDictionary(std::map<std::string, QPDFObjectHandle> const& items);
  586 + static QPDFObjectHandle newDictionary(std::map<std::string, QPDFObjectHandle> const& items);
607 587  
608 588 // Create an array from a rectangle. Equivalent to the rectangle
609 589 // form of newArray.
... ... @@ -686,8 +666,7 @@ class QPDFObjectHandle
686 666 // else. To add objects from another qpdf, use copyForeignObject
687 667 // instead.
688 668 QPDF_DLL
689   - void setObjectDescription(
690   - QPDF* owning_qpdf, std::string const& object_description);
  669 + void setObjectDescription(QPDF* owning_qpdf, std::string const& object_description);
691 670 QPDF_DLL
692 671 bool hasObjectDescription();
693 672  
... ... @@ -964,8 +943,7 @@ class QPDFObjectHandle
964 943 QPDF_DLL
965 944 void mergeResources(
966 945 QPDFObjectHandle other,
967   - std::map<std::string, std::map<std::string, std::string>>* conflicts =
968   - nullptr);
  946 + std::map<std::string, std::map<std::string, std::string>>* conflicts = nullptr);
969 947  
970 948 // Get all resource names from a resource dictionary. If this
971 949 // object is a dictionary, this method returns a set of all the
... ... @@ -1118,13 +1096,11 @@ class QPDFObjectHandle
1118 1096 void replaceKey(std::string const& key, QPDFObjectHandle const& value);
1119 1097 // Replace value of key and return the value.
1120 1098 QPDF_DLL
1121   - QPDFObjectHandle
1122   - replaceKeyAndGetNew(std::string const& key, QPDFObjectHandle const& value);
  1099 + QPDFObjectHandle replaceKeyAndGetNew(std::string const& key, QPDFObjectHandle const& value);
1123 1100 // Replace value of key and return the old value, or null if the
1124 1101 // key was previously not present.
1125 1102 QPDF_DLL
1126   - QPDFObjectHandle
1127   - replaceKeyAndGetOld(std::string const& key, QPDFObjectHandle const& value);
  1103 + QPDFObjectHandle replaceKeyAndGetOld(std::string const& key, QPDFObjectHandle const& value);
1128 1104 // Remove key, doing nothing if key does not exist.
1129 1105 QPDF_DLL
1130 1106 void removeKey(std::string const& key);
... ... @@ -1167,8 +1143,7 @@ class QPDFObjectHandle
1167 1143 // Returns filtered (uncompressed) stream data. Throws an
1168 1144 // exception if the stream is filtered and we can't decode it.
1169 1145 QPDF_DLL
1170   - std::shared_ptr<Buffer>
1171   - getStreamData(qpdf_stream_decode_level_e level = qpdf_dl_generalized);
  1146 + std::shared_ptr<Buffer> getStreamData(qpdf_stream_decode_level_e level = qpdf_dl_generalized);
1172 1147  
1173 1148 // Returns unfiltered (raw) stream data.
1174 1149 QPDF_DLL
... ... @@ -1347,8 +1322,7 @@ class QPDFObjectHandle
1347 1322 // returning true if it succeeded without errors.
1348 1323 QPDF_DLL
1349 1324 void replaceStreamData(
1350   - std::function<bool(Pipeline*, bool suppress_warnings, bool will_retry)>
1351   - provider,
  1325 + std::function<bool(Pipeline*, bool suppress_warnings, bool will_retry)> provider,
1352 1326 QPDFObjectHandle const& filter,
1353 1327 QPDFObjectHandle const& decode_parms);
1354 1328  
... ... @@ -1615,15 +1589,14 @@ class QPDFObjectHandle
1615 1589 void makeDirect(QPDFObjGen::set& visited, bool stop_at_streams);
1616 1590 void disconnect();
1617 1591 void setParsedOffset(qpdf_offset_t offset);
1618   - void parseContentStream_internal(
1619   - std::string const& description, ParserCallbacks* callbacks);
  1592 + void parseContentStream_internal(std::string const& description, ParserCallbacks* callbacks);
1620 1593 static void parseContentStream_data(
1621 1594 std::shared_ptr<Buffer>,
1622 1595 std::string const& description,
1623 1596 ParserCallbacks* callbacks,
1624 1597 QPDF* context);
1625   - std::vector<QPDFObjectHandle> arrayOrStreamToStreamArray(
1626   - std::string const& description, std::string& all_description);
  1598 + std::vector<QPDFObjectHandle>
  1599 + arrayOrStreamToStreamArray(std::string const& description, std::string& all_description);
1627 1600 static void warn(QPDF*, QPDFExc const&);
1628 1601 void checkOwnership(QPDFObjectHandle const&) const;
1629 1602  
... ...
include/qpdf/QPDFPageDocumentHelper.hh
... ... @@ -104,10 +104,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
104 104 // Add new page before or after refpage. See comments for addPage
105 105 // for details about what newpage should be.
106 106 QPDF_DLL
107   - void addPageAt(
108   - QPDFPageObjectHelper newpage,
109   - bool before,
110   - QPDFPageObjectHelper refpage);
  107 + void addPageAt(QPDFPageObjectHelper newpage, bool before, QPDFPageObjectHelper refpage);
111 108  
112 109 // Remove page from the pdf.
113 110 QPDF_DLL
... ... @@ -125,8 +122,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
125 122 // comments there in QPDFAnnotationObjectHelper.hh for meanings of
126 123 // those flags.
127 124 QPDF_DLL
128   - void flattenAnnotations(
129   - int required_flags = 0, int forbidden_flags = an_invisible | an_hidden);
  125 + void flattenAnnotations(int required_flags = 0, int forbidden_flags = an_invisible | an_hidden);
130 126  
131 127 private:
132 128 void flattenAnnotationsForPage(
... ...
include/qpdf/QPDFPageObjectHelper.hh
... ... @@ -170,26 +170,22 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
170 170 // Return the effective CropBox. If not defined, fall back to
171 171 // MediaBox
172 172 QPDF_DLL
173   - QPDFObjectHandle
174   - getCropBox(bool copy_if_shared = false, bool copy_if_fallback = false);
  173 + QPDFObjectHandle getCropBox(bool copy_if_shared = false, bool copy_if_fallback = false);
175 174  
176 175 // Return the effective BleedBox. If not defined, fall back to
177 176 // CropBox.
178 177 QPDF_DLL
179   - QPDFObjectHandle
180   - getBleedBox(bool copy_if_shared = false, bool copy_if_fallback = false);
  178 + QPDFObjectHandle getBleedBox(bool copy_if_shared = false, bool copy_if_fallback = false);
181 179  
182 180 // Return the effective TrimBox. If not defined, fall back to
183 181 // CropBox.
184 182 QPDF_DLL
185   - QPDFObjectHandle
186   - getTrimBox(bool copy_if_shared = false, bool copy_if_fallback = false);
  183 + QPDFObjectHandle getTrimBox(bool copy_if_shared = false, bool copy_if_fallback = false);
187 184  
188 185 // Return the effective ArtBox. If not defined, fall back to
189 186 // CropBox.
190 187 QPDF_DLL
191   - QPDFObjectHandle
192   - getArtBox(bool copy_if_shared = false, bool copy_if_fallback = false);
  188 + QPDFObjectHandle getArtBox(bool copy_if_shared = false, bool copy_if_fallback = false);
193 189  
194 190 // Iterate through XObjects, possibly recursing into form
195 191 // XObjects. This works with pages or form XObjects. Call action
... ... @@ -203,26 +199,20 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
203 199 void forEachXObject(
204 200 bool recursive,
205 201 std::function<void(
206   - QPDFObjectHandle& obj,
207   - QPDFObjectHandle& xobj_dict,
208   - std::string const& key)> action,
  202 + QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key)> action,
209 203 std::function<bool(QPDFObjectHandle)> selector = nullptr);
210 204 // Only call action for images
211 205 QPDF_DLL
212 206 void forEachImage(
213 207 bool recursive,
214 208 std::function<void(
215   - QPDFObjectHandle& obj,
216   - QPDFObjectHandle& xobj_dict,
217   - std::string const& key)> action);
  209 + QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key)> action);
218 210 // Only call action for form XObjects
219 211 QPDF_DLL
220 212 void forEachFormXObject(
221 213 bool recursive,
222 214 std::function<void(
223   - QPDFObjectHandle& obj,
224   - QPDFObjectHandle& xobj_dict,
225   - std::string const& key)> action);
  215 + QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key)> action);
226 216  
227 217 // Returns an empty map if there are no images or no resources.
228 218 // Prior to qpdf 8.4.0, this function did not support inherited
... ... @@ -258,8 +248,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
258 248 // only_subtype is non-empty, only include annotations of the
259 249 // given subtype.
260 250 QPDF_DLL
261   - std::vector<QPDFAnnotationObjectHelper>
262   - getAnnotations(std::string const& only_subtype = "");
  251 + std::vector<QPDFAnnotationObjectHelper> getAnnotations(std::string const& only_subtype = "");
263 252  
264 253 // Returns a vector of stream objects representing the content
265 254 // streams for the given page. This routine allows the caller to
... ... @@ -319,13 +308,11 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
319 308 // contents, as happens with addContentTokenFilter. See
320 309 // examples/pdf-count-strings.cc for an example.
321 310 QPDF_DLL
322   - void filterContents(
323   - QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
  311 + void filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
324 312  
325 313 // Old name -- calls filterContents()
326 314 QPDF_DLL
327   - void filterPageContents(
328   - QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
  315 + void filterPageContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
329 316  
330 317 // Pipe a page's contents through the given pipeline. This method
331 318 // works whether the contents are a single stream or an array of
... ... @@ -341,8 +328,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
341 328 // The token filter is applied to the page's contents as a single
342 329 // stream. Also works on form XObjects.
343 330 QPDF_DLL
344   - void addContentTokenFilter(
345   - std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter);
  331 + void addContentTokenFilter(std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter);
346 332  
347 333 // A page's resources dictionary maps names to objects elsewhere
348 334 // in the file. This method walks through a page's contents and
... ... @@ -500,8 +486,8 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
500 486 bool copy_if_shared,
501 487 std::function<QPDFObjectHandle()> get_fallback,
502 488 bool copy_if_fallback);
503   - static bool removeUnreferencedResourcesHelper(
504   - QPDFPageObjectHelper ph, std::set<std::string>& unresolved);
  489 + static bool
  490 + removeUnreferencedResourcesHelper(QPDFPageObjectHelper ph, std::set<std::string>& unresolved);
505 491  
506 492 class Members
507 493 {
... ...
include/qpdf/QPDFSystemError.hh
... ... @@ -48,8 +48,7 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error
48 48  
49 49 private:
50 50 QPDF_DLL_PRIVATE
51   - static std::string
52   - createWhat(std::string const& description, int system_errno);
  51 + static std::string createWhat(std::string const& description, int system_errno);
53 52  
54 53 // This class does not use the Members pattern to avoid needless
55 54 // memory allocations during exception handling.
... ...
include/qpdf/QPDFTokenizer.hh
... ... @@ -104,8 +104,7 @@ class QPDFTokenizer
104 104 {
105 105 // Ignore fields other than type and value
106 106 return (
107   - (this->type != tt_bad) && (this->type == rhs.type) &&
108   - (this->value == rhs.value));
  107 + (this->type != tt_bad) && (this->type == rhs.type) && (this->value == rhs.value));
109 108 }
110 109 bool
111 110 isInteger() const
... ... @@ -216,8 +215,7 @@ class QPDFTokenizer
216 215 // beginning of the token. Returns false if the token is bad
217 216 // or if scanning produced an error message for any reason.
218 217  
219   - bool nextToken(
220   - InputSource& input, std::string const& context, size_t max_len = 0);
  218 + bool nextToken(InputSource& input, std::string const& context, size_t max_len = 0);
221 219  
222 220 // The following methods are only valid after nextToken has been called
223 221 // and until another QPDFTokenizer method is called. They allow the results
... ... @@ -317,8 +315,7 @@ QPDFTokenizer::getType() const noexcept
317 315 inline std::string const&
318 316 QPDFTokenizer::getValue() const noexcept
319 317 {
320   - return (this->type == tt_name || this->type == tt_string) ? this->val
321   - : this->raw_val;
  318 + return (this->type == tt_name || this->type == tt_string) ? this->val : this->raw_val;
322 319 }
323 320 inline std::string const&
324 321 QPDFTokenizer::getRawValue() const noexcept
... ...
include/qpdf/QPDFWriter.hh
... ... @@ -561,16 +561,11 @@ class QPDFWriter
561 561 void writePad(size_t nspaces);
562 562 void assignCompressedObjectNumbers(QPDFObjGen const& og);
563 563 void enqueueObject(QPDFObjectHandle object);
564   - void writeObjectStreamOffsets(
565   - std::vector<qpdf_offset_t>& offsets, int first_obj);
  564 + void writeObjectStreamOffsets(std::vector<qpdf_offset_t>& offsets, int first_obj);
566 565 void writeObjectStream(QPDFObjectHandle object);
567 566 void writeObject(QPDFObjectHandle object, int object_stream_index = -1);
568 567 void writeTrailer(
569   - trailer_e which,
570   - int size,
571   - bool xref_stream,
572   - qpdf_offset_t prev,
573   - int linearization_pass);
  568 + trailer_e which, int size, bool xref_stream, qpdf_offset_t prev, int linearization_pass);
574 569 bool willFilterStream(
575 570 QPDFObjectHandle stream,
576 571 bool& compress_stream,
... ... @@ -601,8 +596,7 @@ class QPDFWriter
601 596 bool allow_modify_other,
602 597 qpdf_r3_print_e print,
603 598 qpdf_r3_modify_e modify);
604   - void
605   - disableIncompatibleEncryption(int major, int minor, int extension_level);
  599 + void disableIncompatibleEncryption(int major, int minor, int extension_level);
606 600 void parseVersion(std::string const& version, int& major, int& minor) const;
607 601 int compareVersions(int major1, int minor1, int major2, int minor2) const;
608 602 void setEncryptionParameters(
... ... @@ -640,8 +634,7 @@ class QPDFWriter
640 634 void doWriteSetup();
641 635 void writeHeader();
642 636 void writeHintStream(int hint_id);
643   - qpdf_offset_t
644   - writeXRefTable(trailer_e which, int first, int last, int size);
  637 + qpdf_offset_t writeXRefTable(trailer_e which, int first, int last, int size);
645 638 qpdf_offset_t writeXRefTable(
646 639 trailer_e which,
647 640 int first,
... ... @@ -693,8 +686,7 @@ class QPDFWriter
693 686 void pushMD5Pipeline(PipelinePopper&);
694 687 void computeDeterministicIDData();
695 688  
696   - void discardGeneration(
697   - std::map<QPDFObjGen, int> const& in, std::map<int, int>& out);
  689 + void discardGeneration(std::map<QPDFObjGen, int> const& in, std::map<int, int>& out);
698 690  
699 691 class Members
700 692 {
... ...
include/qpdf/QUtil.hh
... ... @@ -49,11 +49,9 @@ namespace QUtil
49 49 QPDF_DLL
50 50 std::string int_to_string_base(long long, int base, int length = 0);
51 51 QPDF_DLL
52   - std::string
53   - uint_to_string_base(unsigned long long, int base, int length = 0);
  52 + std::string uint_to_string_base(unsigned long long, int base, int length = 0);
54 53 QPDF_DLL
55   - std::string double_to_string(
56   - double, int decimal_places = 0, bool trim_trailing_zeroes = true);
  54 + std::string double_to_string(double, int decimal_places = 0, bool trim_trailing_zeroes = true);
57 55  
58 56 // These string to number methods throw std::runtime_error on
59 57 // underflow/overflow.
... ... @@ -257,14 +255,7 @@ namespace QUtil
257 255 QPDFTime() = default;
258 256 QPDFTime(QPDFTime const&) = default;
259 257 QPDFTime& operator=(QPDFTime const&) = default;
260   - QPDFTime(
261   - int year,
262   - int month,
263   - int day,
264   - int hour,
265   - int minute,
266   - int second,
267   - int tz_delta) :
  258 + QPDFTime(int year, int month, int day, int hour, int minute, int second, int tz_delta) :
268 259 year(year),
269 260 month(month),
270 261 day(day),
... ... @@ -331,8 +322,7 @@ namespace QUtil
331 322 // to pass a value of pos that is greater than or equal to the
332 323 // length of the string.
333 324 QPDF_DLL
334   - unsigned long get_next_utf8_codepoint(
335   - std::string const& utf8_val, size_t& pos, bool& error);
  325 + unsigned long get_next_utf8_codepoint(std::string const& utf8_val, size_t& pos, bool& error);
336 326  
337 327 // Test whether this is a UTF-16 string. This is indicated by
338 328 // first two bytes being 0xFE 0xFF (big-endian) or 0xFF 0xFE
... ... @@ -360,30 +350,23 @@ namespace QUtil
360 350 QPDF_DLL
361 351 std::string utf8_to_ascii(std::string const& utf8, char unknown_char = '?');
362 352 QPDF_DLL
363   - std::string
364   - utf8_to_win_ansi(std::string const& utf8, char unknown_char = '?');
  353 + std::string utf8_to_win_ansi(std::string const& utf8, char unknown_char = '?');
365 354 QPDF_DLL
366   - std::string
367   - utf8_to_mac_roman(std::string const& utf8, char unknown_char = '?');
  355 + std::string utf8_to_mac_roman(std::string const& utf8, char unknown_char = '?');
368 356 QPDF_DLL
369   - std::string
370   - utf8_to_pdf_doc(std::string const& utf8, char unknown_char = '?');
  357 + std::string utf8_to_pdf_doc(std::string const& utf8, char unknown_char = '?');
371 358  
372 359 // These versions return true if the conversion was successful and
373 360 // false if any unrepresentable characters were found and had to
374 361 // be substituted with the unknown character.
375 362 QPDF_DLL
376   - bool utf8_to_ascii(
377   - std::string const& utf8, std::string& ascii, char unknown_char = '?');
  363 + bool utf8_to_ascii(std::string const& utf8, std::string& ascii, char unknown_char = '?');
378 364 QPDF_DLL
379   - bool utf8_to_win_ansi(
380   - std::string const& utf8, std::string& win, char unknown_char = '?');
  365 + bool utf8_to_win_ansi(std::string const& utf8, std::string& win, char unknown_char = '?');
381 366 QPDF_DLL
382   - bool utf8_to_mac_roman(
383   - std::string const& utf8, std::string& mac, char unknown_char = '?');
  367 + bool utf8_to_mac_roman(std::string const& utf8, std::string& mac, char unknown_char = '?');
384 368 QPDF_DLL
385   - bool utf8_to_pdf_doc(
386   - std::string const& utf8, std::string& pdfdoc, char unknown_char = '?');
  369 + bool utf8_to_pdf_doc(std::string const& utf8, std::string& pdfdoc, char unknown_char = '?');
387 370  
388 371 // Convert a UTF-16 encoded string to UTF-8. Unrepresentable code
389 372 // points are converted to U+FFFD.
... ... @@ -412,10 +395,7 @@ namespace QUtil
412 395 // about everything else) accepts UTF-16LE (as of 10.6.2).
413 396 QPDF_DLL
414 397 void analyze_encoding(
415   - std::string const& str,
416   - bool& has_8bit_chars,
417   - bool& is_valid_utf8,
418   - bool& is_utf16);
  398 + std::string const& str, bool& has_8bit_chars, bool& is_valid_utf8, bool& is_utf16);
419 399  
420 400 // Try to compensate for previously incorrectly encoded strings.
421 401 // We want to compensate for the following errors:
... ... @@ -472,14 +452,11 @@ namespace QUtil
472 452 // Filename is UTF-8 encoded, even on Windows, as described in the
473 453 // comments for safe_fopen.
474 454 QPDF_DLL
475   - std::list<std::string>
476   - read_lines_from_file(char const* filename, bool preserve_eol = false);
  455 + std::list<std::string> read_lines_from_file(char const* filename, bool preserve_eol = false);
477 456 QPDF_DLL
478   - std::list<std::string>
479   - read_lines_from_file(std::istream&, bool preserve_eol = false);
  457 + std::list<std::string> read_lines_from_file(std::istream&, bool preserve_eol = false);
480 458 QPDF_DLL
481   - std::list<std::string>
482   - read_lines_from_file(FILE*, bool preserve_eol = false);
  459 + std::list<std::string> read_lines_from_file(FILE*, bool preserve_eol = false);
483 460 QPDF_DLL
484 461 void read_lines_from_file(
485 462 std::function<bool(char&)> next_char,
... ... @@ -487,8 +464,7 @@ namespace QUtil
487 464 bool preserve_eol = false);
488 465  
489 466 QPDF_DLL
490   - void read_file_into_memory(
491   - char const* filename, std::shared_ptr<char>& file_buf, size_t& size);
  467 + void read_file_into_memory(char const* filename, std::shared_ptr<char>& file_buf, size_t& size);
492 468  
493 469 QPDF_DLL
494 470 std::string read_file_into_string(char const* filename);
... ... @@ -532,8 +508,7 @@ namespace QUtil
532 508 // invoked, convert all UTF-16 encoded strings to UTF-8, and call
533 509 // another main.
534 510 QPDF_DLL
535   - int call_main_from_wmain(
536   - int argc, wchar_t* argv[], std::function<int(int, char*[])> realmain);
  511 + int call_main_from_wmain(int argc, wchar_t* argv[], std::function<int(int, char*[])> realmain);
537 512 QPDF_DLL
538 513 int call_main_from_wmain(
539 514 int argc,
... ... @@ -561,8 +536,7 @@ QUtil::is_hex_digit(char ch)
561 536 inline bool
562 537 QUtil::is_space(char ch)
563 538 {
564   - return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f' ||
565   - ch == '\v';
  539 + return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f' || ch == '\v';
566 540 }
567 541  
568 542 inline bool
... ... @@ -603,8 +577,7 @@ inline std::string
603 577 QUtil::hex_encode_char(char c)
604 578 {
605 579 static auto constexpr hexchars = "0123456789abcdef";
606   - return {
607   - '#', hexchars[static_cast<unsigned char>(c) >> 4], hexchars[c & 0x0f]};
  580 + return {'#', hexchars[static_cast<unsigned char>(c) >> 4], hexchars[c & 0x0f]};
608 581 }
609 582  
610 583 inline constexpr char
... ... @@ -612,8 +585,7 @@ QUtil::hex_decode_char(char digit) noexcept
612 585 {
613 586 return digit <= '9' && digit >= '0'
614 587 ? char(digit - '0')
615   - : (digit >= 'a' ? char(digit - 'a' + 10)
616   - : (digit >= 'A' ? char(digit - 'A' + 10) : '\20'));
  588 + : (digit >= 'a' ? char(digit - 'a' + 10) : (digit >= 'A' ? char(digit - 'A' + 10) : '\20'));
617 589 }
618 590  
619 591 #endif // QUTIL_HH
... ...
include/qpdf/qpdf-c.h
... ... @@ -326,8 +326,7 @@ extern &quot;C&quot; {
326 326 */
327 327 QPDF_DLL
328 328 QPDF_ERROR_CODE
329   - qpdf_create_from_json_data(
330   - qpdf_data qpdf, char const* buffer, unsigned long long size);
  329 + qpdf_create_from_json_data(qpdf_data qpdf, char const* buffer, unsigned long long size);
331 330  
332 331 /* JSON UPDATE FUNCTIONS */
333 332  
... ... @@ -341,8 +340,7 @@ extern &quot;C&quot; {
341 340 qpdf_update_from_json_file(qpdf_data qpdf, char const* filename);
342 341 QPDF_DLL
343 342 QPDF_ERROR_CODE
344   - qpdf_update_from_json_data(
345   - qpdf_data qpdf, char const* buffer, unsigned long long size);
  343 + qpdf_update_from_json_data(qpdf_data qpdf, char const* buffer, unsigned long long size);
346 344  
347 345 /* READ FUNCTIONS */
348 346  
... ... @@ -492,23 +490,19 @@ extern &quot;C&quot; {
492 490 unsigned char const* qpdf_get_buffer(qpdf_data qpdf);
493 491  
494 492 QPDF_DLL
495   - void
496   - qpdf_set_object_stream_mode(qpdf_data qpdf, enum qpdf_object_stream_e mode);
  493 + void qpdf_set_object_stream_mode(qpdf_data qpdf, enum qpdf_object_stream_e mode);
497 494  
498 495 QPDF_DLL
499   - void
500   - qpdf_set_stream_data_mode(qpdf_data qpdf, enum qpdf_stream_data_e mode);
  496 + void qpdf_set_stream_data_mode(qpdf_data qpdf, enum qpdf_stream_data_e mode);
501 497  
502 498 QPDF_DLL
503 499 void qpdf_set_compress_streams(qpdf_data qpdf, QPDF_BOOL value);
504 500  
505 501 QPDF_DLL
506   - void qpdf_set_decode_level(
507   - qpdf_data qpdf, enum qpdf_stream_decode_level_e level);
  502 + void qpdf_set_decode_level(qpdf_data qpdf, enum qpdf_stream_decode_level_e level);
508 503  
509 504 QPDF_DLL
510   - void
511   - qpdf_set_preserve_unreferenced_objects(qpdf_data qpdf, QPDF_BOOL value);
  505 + void qpdf_set_preserve_unreferenced_objects(qpdf_data qpdf, QPDF_BOOL value);
512 506  
513 507 QPDF_DLL
514 508 void qpdf_set_newline_before_endstream(qpdf_data qpdf, QPDF_BOOL value);
... ... @@ -625,8 +619,8 @@ extern &quot;C&quot; {
625 619 void qpdf_force_pdf_version(qpdf_data qpdf, char const* version);
626 620  
627 621 QPDF_DLL
628   - void qpdf_force_pdf_version_and_extension(
629   - qpdf_data qpdf, char const* version, int extension_level);
  622 + void
  623 + qpdf_force_pdf_version_and_extension(qpdf_data qpdf, char const* version, int extension_level);
630 624  
631 625 /* During write, your report_progress function will be called with
632 626 * a value between 0 and 100 representing the approximate write
... ... @@ -640,9 +634,7 @@ extern &quot;C&quot; {
640 634 */
641 635 QPDF_DLL
642 636 void qpdf_register_progress_reporter(
643   - qpdf_data qpdf,
644   - void (*report_progress)(int percent, void* data),
645   - void* data);
  637 + qpdf_data qpdf, void (*report_progress)(int percent, void* data), void* data);
646 638  
647 639 /* Do actual write operation. */
648 640 QPDF_DLL
... ... @@ -733,8 +725,7 @@ extern &quot;C&quot; {
733 725 QPDF_DLL
734 726 qpdf_oh qpdf_make_indirect_object(qpdf_data qpdf, qpdf_oh oh);
735 727 QPDF_DLL
736   - void
737   - qpdf_replace_object(qpdf_data qpdf, int objid, int generation, qpdf_oh oh);
  728 + void qpdf_replace_object(qpdf_data qpdf, int objid, int generation, qpdf_oh oh);
738 729  
739 730 /* Wrappers around QPDFObjectHandle methods. Be sure to read
740 731 * corresponding comments in QPDFObjectHandle.hh to understand
... ... @@ -811,8 +802,7 @@ extern &quot;C&quot; {
811 802 QPDF_DLL
812 803 unsigned long long qpdf_oh_get_uint_value(qpdf_data qpdf, qpdf_oh oh);
813 804 QPDF_DLL
814   - QPDF_BOOL qpdf_oh_get_value_as_ulonglong(
815   - qpdf_data qpdf, qpdf_oh oh, unsigned long long* value);
  805 + QPDF_BOOL qpdf_oh_get_value_as_ulonglong(qpdf_data qpdf, qpdf_oh oh, unsigned long long* value);
816 806 QPDF_DLL
817 807 unsigned int qpdf_oh_get_uint_value_as_uint(qpdf_data qpdf, qpdf_oh oh);
818 808 QPDF_DLL
... ... @@ -822,8 +812,8 @@ extern &quot;C&quot; {
822 812 QPDF_DLL
823 813 char const* qpdf_oh_get_real_value(qpdf_data qpdf, qpdf_oh oh);
824 814 QPDF_DLL
825   - QPDF_BOOL qpdf_oh_get_value_as_real(
826   - qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
  815 + QPDF_BOOL
  816 + qpdf_oh_get_value_as_real(qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
827 817  
828 818 QPDF_DLL
829 819 QPDF_BOOL qpdf_oh_is_number(qpdf_data qpdf, qpdf_oh oh);
... ... @@ -836,8 +826,8 @@ extern &quot;C&quot; {
836 826 QPDF_DLL
837 827 char const* qpdf_oh_get_name(qpdf_data qpdf, qpdf_oh oh);
838 828 QPDF_DLL
839   - QPDF_BOOL qpdf_oh_get_value_as_name(
840   - qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
  829 + QPDF_BOOL
  830 + qpdf_oh_get_value_as_name(qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
841 831  
842 832 /* Return the length of the last string returned. This enables you
843 833 * to retrieve the entire string for cases in which a char*
... ... @@ -858,19 +848,17 @@ extern &quot;C&quot; {
858 848 QPDF_DLL
859 849 char const* qpdf_oh_get_string_value(qpdf_data qpdf, qpdf_oh oh);
860 850 QPDF_DLL
861   - QPDF_BOOL qpdf_oh_get_value_as_string(
862   - qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
  851 + QPDF_BOOL
  852 + qpdf_oh_get_value_as_string(qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
863 853 QPDF_DLL
864 854 char const* qpdf_oh_get_utf8_value(qpdf_data qpdf, qpdf_oh oh);
865 855 QPDF_DLL
866   - QPDF_BOOL qpdf_oh_get_value_as_utf8(
867   - qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
  856 + QPDF_BOOL
  857 + qpdf_oh_get_value_as_utf8(qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
868 858 QPDF_DLL
869   - char const*
870   - qpdf_oh_get_binary_string_value(qpdf_data qpdf, qpdf_oh oh, size_t* length);
  859 + char const* qpdf_oh_get_binary_string_value(qpdf_data qpdf, qpdf_oh oh, size_t* length);
871 860 QPDF_DLL
872   - char const*
873   - qpdf_oh_get_binary_utf8_value(qpdf_data qpdf, qpdf_oh oh, size_t* length);
  861 + char const* qpdf_oh_get_binary_utf8_value(qpdf_data qpdf, qpdf_oh oh, size_t* length);
874 862  
875 863 QPDF_DLL
876 864 int qpdf_oh_get_array_n_items(qpdf_data qpdf, qpdf_oh oh);
... ... @@ -906,8 +894,7 @@ extern &quot;C&quot; {
906 894 QPDF_DLL
907 895 qpdf_oh qpdf_oh_get_key(qpdf_data qpdf, qpdf_oh oh, char const* key);
908 896 QPDF_DLL
909   - qpdf_oh
910   - qpdf_oh_get_key_if_dict(qpdf_data qpdf, qpdf_oh oh, char const* key);
  897 + qpdf_oh qpdf_oh_get_key_if_dict(qpdf_data qpdf, qpdf_oh oh, char const* key);
911 898  
912 899 QPDF_DLL
913 900 QPDF_BOOL
... ... @@ -924,8 +911,7 @@ extern &quot;C&quot; {
924 911 QPDF_DLL
925 912 qpdf_oh qpdf_oh_new_real_from_string(qpdf_data qpdf, char const* value);
926 913 QPDF_DLL
927   - qpdf_oh qpdf_oh_new_real_from_double(
928   - qpdf_data qpdf, double value, int decimal_places);
  914 + qpdf_oh qpdf_oh_new_real_from_double(qpdf_data qpdf, double value, int decimal_places);
929 915 QPDF_DLL
930 916 qpdf_oh qpdf_oh_new_name(qpdf_data qpdf, char const* name);
931 917 QPDF_DLL
... ... @@ -936,11 +922,9 @@ extern &quot;C&quot; {
936 922 * contain atrbitary binary data including embedded null characters.
937 923 */
938 924 QPDF_DLL
939   - qpdf_oh
940   - qpdf_oh_new_binary_string(qpdf_data qpdf, char const* str, size_t length);
  925 + qpdf_oh qpdf_oh_new_binary_string(qpdf_data qpdf, char const* str, size_t length);
941 926 QPDF_DLL
942   - qpdf_oh qpdf_oh_new_binary_unicode_string(
943   - qpdf_data qpdf, char const* str, size_t length);
  927 + qpdf_oh qpdf_oh_new_binary_unicode_string(qpdf_data qpdf, char const* str, size_t length);
944 928 QPDF_DLL
945 929 qpdf_oh qpdf_oh_new_array(qpdf_data qpdf);
946 930 QPDF_DLL
... ... @@ -959,8 +943,7 @@ extern &quot;C&quot; {
959 943 void qpdf_oh_make_direct(qpdf_data qpdf, qpdf_oh oh);
960 944  
961 945 QPDF_DLL
962   - void
963   - qpdf_oh_set_array_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item);
  946 + void qpdf_oh_set_array_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item);
964 947 QPDF_DLL
965 948 void qpdf_oh_insert_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item);
966 949 QPDF_DLL
... ... @@ -969,13 +952,11 @@ extern &quot;C&quot; {
969 952 void qpdf_oh_erase_item(qpdf_data qpdf, qpdf_oh oh, int at);
970 953  
971 954 QPDF_DLL
972   - void qpdf_oh_replace_key(
973   - qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item);
  955 + void qpdf_oh_replace_key(qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item);
974 956 QPDF_DLL
975 957 void qpdf_oh_remove_key(qpdf_data qpdf, qpdf_oh oh, char const* key);
976 958 QPDF_DLL
977   - void qpdf_oh_replace_or_remove_key(
978   - qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item);
  959 + void qpdf_oh_replace_or_remove_key(qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item);
979 960  
980 961 QPDF_DLL
981 962 qpdf_oh qpdf_oh_get_dict(qpdf_data qpdf, qpdf_oh oh);
... ... @@ -1005,8 +986,7 @@ extern &quot;C&quot; {
1005 986 * while `foreign_oh` belongs to `other_qpdf`.
1006 987 */
1007 988 QPDF_DLL
1008   - qpdf_oh qpdf_oh_copy_foreign_object(
1009   - qpdf_data qpdf, qpdf_data other_qpdf, qpdf_oh foreign_oh);
  989 + qpdf_oh qpdf_oh_copy_foreign_object(qpdf_data qpdf, qpdf_data other_qpdf, qpdf_oh foreign_oh);
1010 990  
1011 991 /* STREAM FUNCTIONS */
1012 992  
... ... @@ -1105,19 +1085,12 @@ extern &quot;C&quot; {
1105 1085  
1106 1086 /* addPage() */
1107 1087 QPDF_DLL
1108   - QPDF_ERROR_CODE qpdf_add_page(
1109   - qpdf_data qpdf,
1110   - qpdf_data newpage_qpdf,
1111   - qpdf_oh newpage,
1112   - QPDF_BOOL first);
  1088 + QPDF_ERROR_CODE
  1089 + qpdf_add_page(qpdf_data qpdf, qpdf_data newpage_qpdf, qpdf_oh newpage, QPDF_BOOL first);
1113 1090 /* addPageAt() */
1114 1091 QPDF_DLL
1115 1092 QPDF_ERROR_CODE qpdf_add_page_at(
1116   - qpdf_data qpdf,
1117   - qpdf_data newpage_qpdf,
1118   - qpdf_oh newpage,
1119   - QPDF_BOOL before,
1120   - qpdf_oh refpage);
  1093 + qpdf_data qpdf, qpdf_data newpage_qpdf, qpdf_oh newpage, QPDF_BOOL before, qpdf_oh refpage);
1121 1094 /* removePage() */
1122 1095 QPDF_DLL
1123 1096 QPDF_ERROR_CODE qpdf_remove_page(qpdf_data qpdf, qpdf_oh page);
... ...
include/qpdf/qpdfjob-c.h
... ... @@ -111,8 +111,7 @@ extern &quot;C&quot; {
111 111 * is invalid to call any other functions this job handle.
112 112 */
113 113 QPDF_DLL
114   - int
115   - qpdfjob_initialize_from_argv(qpdfjob_handle j, char const* const argv[]);
  114 + int qpdfjob_initialize_from_argv(qpdfjob_handle j, char const* const argv[]);
116 115  
117 116 #ifndef QPDF_NO_WCHAR_T
118 117 /* This function is the same as qpdfjob_initialize_from_argv
... ... @@ -120,8 +119,7 @@ extern &quot;C&quot; {
120 119 * suitable for calling from a Windows wmain function.
121 120 */
122 121 QPDF_DLL
123   - int qpdfjob_initialize_from_wide_argv(
124   - qpdfjob_handle j, wchar_t const* const argv[]);
  122 + int qpdfjob_initialize_from_wide_argv(qpdfjob_handle j, wchar_t const* const argv[]);
125 123 #endif /* QPDF_NO_WCHAR_T */
126 124  
127 125 /* This function wraps QPDFJob::initializeFromJson. The return
... ... @@ -167,9 +165,7 @@ extern &quot;C&quot; {
167 165 */
168 166 QPDF_DLL
169 167 void qpdfjob_register_progress_reporter(
170   - qpdfjob_handle j,
171   - void (*report_progress)(int percent, void* data),
172   - void* data);
  168 + qpdfjob_handle j, void (*report_progress)(int percent, void* data), void* data);
173 169  
174 170 #ifdef __cplusplus
175 171 }
... ...
include/qpdf/qpdflogger-c.h
... ... @@ -76,22 +76,13 @@ extern &quot;C&quot; {
76 76  
77 77 QPDF_DLL
78 78 void qpdflogger_set_info(
79   - qpdflogger_handle l,
80   - enum qpdf_log_dest_e dest,
81   - qpdf_log_fn_t fn,
82   - void* udata);
  79 + qpdflogger_handle l, enum qpdf_log_dest_e dest, qpdf_log_fn_t fn, void* udata);
83 80 QPDF_DLL
84 81 void qpdflogger_set_warn(
85   - qpdflogger_handle l,
86   - enum qpdf_log_dest_e dest,
87   - qpdf_log_fn_t fn,
88   - void* udata);
  82 + qpdflogger_handle l, enum qpdf_log_dest_e dest, qpdf_log_fn_t fn, void* udata);
89 83 QPDF_DLL
90 84 void qpdflogger_set_error(
91   - qpdflogger_handle l,
92   - enum qpdf_log_dest_e dest,
93   - qpdf_log_fn_t fn,
94   - void* udata);
  85 + qpdflogger_handle l, enum qpdf_log_dest_e dest, qpdf_log_fn_t fn, void* udata);
95 86  
96 87 /* A non-zero value for only_if_not_set means that the save
97 88 * pipeline will only be changed if it is not already set.
... ... @@ -104,8 +95,7 @@ extern &quot;C&quot; {
104 95 void* udata,
105 96 int only_if_not_set);
106 97 QPDF_DLL
107   - void qpdflogger_save_to_standard_output(
108   - qpdflogger_handle l, int only_if_not_set);
  98 + void qpdflogger_save_to_standard_output(qpdflogger_handle l, int only_if_not_set);
109 99  
110 100 /* For testing */
111 101 QPDF_DLL
... ...
libqpdf/AES_PDF_native.cc
... ... @@ -27,11 +27,9 @@ AES_PDF_native::AES_PDF_native(
27 27 std::memcpy(this->key.get(), key, key_bytes);
28 28 std::memset(this->rk.get(), 0, rk_bytes);
29 29 if (encrypt) {
30   - this->nrounds =
31   - rijndaelSetupEncrypt(this->rk.get(), this->key.get(), keybits);
  30 + this->nrounds = rijndaelSetupEncrypt(this->rk.get(), this->key.get(), keybits);
32 31 } else {
33   - this->nrounds =
34   - rijndaelSetupDecrypt(this->rk.get(), this->key.get(), keybits);
  32 + this->nrounds = rijndaelSetupDecrypt(this->rk.get(), this->key.get(), keybits);
35 33 }
36 34 }
37 35  
... ... @@ -46,8 +44,7 @@ AES_PDF_native::update(unsigned char* in_data, unsigned char* out_data)
46 44 }
47 45 rijndaelEncrypt(this->rk.get(), this->nrounds, in_data, out_data);
48 46 if (this->cbc_mode) {
49   - memcpy(
50   - this->cbc_block, out_data, QPDFCryptoImpl::rijndael_buf_size);
  47 + memcpy(this->cbc_block, out_data, QPDFCryptoImpl::rijndael_buf_size);
51 48 }
52 49 } else {
53 50 rijndaelDecrypt(this->rk.get(), this->nrounds, in_data, out_data);
... ...
libqpdf/BitStream.cc
... ... @@ -33,8 +33,7 @@ BitStream::getBits(size_t nbits)
33 33 long long
34 34 BitStream::getBitsSigned(size_t nbits)
35 35 {
36   - unsigned long long bits =
37   - read_bits(this->p, this->bit_offset, this->bits_available, nbits);
  36 + unsigned long long bits = read_bits(this->p, this->bit_offset, this->bits_available, nbits);
38 37 long long result = 0;
39 38 if (static_cast<long long>(bits) > 1LL << (nbits - 1)) {
40 39 result = static_cast<long long>(bits - (1ULL << nbits));
... ... @@ -49,8 +48,7 @@ BitStream::getBitsInt(size_t nbits)
49 48 {
50 49 return static_cast<int>(
51 50 // line-break
52   - QIntC::to_uint(
53   - read_bits(this->p, this->bit_offset, this->bits_available, nbits)));
  51 + QIntC::to_uint(read_bits(this->p, this->bit_offset, this->bits_available, nbits)));
54 52 }
55 53  
56 54 void
... ... @@ -59,8 +57,7 @@ BitStream::skipToNextByte()
59 57 if (bit_offset != 7) {
60 58 size_t bits_to_skip = bit_offset + 1;
61 59 if (bits_available < bits_to_skip) {
62   - throw std::logic_error(
63   - "INTERNAL ERROR: overflow skipping to next byte in bitstream");
  60 + throw std::logic_error("INTERNAL ERROR: overflow skipping to next byte in bitstream");
64 61 }
65 62 bit_offset = 7;
66 63 ++p;
... ...
libqpdf/BufferInputSource.cc
... ... @@ -5,8 +5,7 @@
5 5 #include <cstring>
6 6 #include <sstream>
7 7  
8   -BufferInputSource::BufferInputSource(
9   - std::string const& description, Buffer* buf, bool own_memory) :
  8 +BufferInputSource::BufferInputSource(std::string const& description, Buffer* buf, bool own_memory) :
10 9 own_memory(own_memory),
11 10 description(description),
12 11 buf(buf),
... ... @@ -15,8 +14,7 @@ BufferInputSource::BufferInputSource(
15 14 {
16 15 }
17 16  
18   -BufferInputSource::BufferInputSource(
19   - std::string const& description, std::string const& contents) :
  17 +BufferInputSource::BufferInputSource(std::string const& description, std::string const& contents) :
20 18 own_memory(true),
21 19 description(description),
22 20 buf(new Buffer(contents.length())),
... ... @@ -100,14 +98,12 @@ BufferInputSource::seek(qpdf_offset_t offset, int whence)
100 98 break;
101 99  
102 100 default:
103   - throw std::logic_error(
104   - "INTERNAL ERROR: invalid argument to BufferInputSource::seek");
  101 + throw std::logic_error("INTERNAL ERROR: invalid argument to BufferInputSource::seek");
105 102 break;
106 103 }
107 104  
108 105 if (this->cur_offset < 0) {
109   - throw std::runtime_error(
110   - this->description + ": seek before beginning of buffer");
  106 + throw std::runtime_error(this->description + ": seek before beginning of buffer");
111 107 }
112 108 }
113 109  
... ...
libqpdf/ContentNormalizer.cc
... ... @@ -44,13 +44,11 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const&amp; token)
44 44 // Replacing string and name tokens in this way normalizes
45 45 // their representation as this will automatically handle
46 46 // quoting of unprintable characters, etc.
47   - writeToken(
48   - QPDFTokenizer::Token(QPDFTokenizer::tt_string, token.getValue()));
  47 + writeToken(QPDFTokenizer::Token(QPDFTokenizer::tt_string, token.getValue()));
49 48 break;
50 49  
51 50 case QPDFTokenizer::tt_name:
52   - writeToken(
53   - QPDFTokenizer::Token(QPDFTokenizer::tt_name, token.getValue()));
  51 + writeToken(QPDFTokenizer::Token(QPDFTokenizer::tt_name, token.getValue()));
54 52 break;
55 53  
56 54 default:
... ... @@ -59,10 +57,8 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const&amp; token)
59 57 }
60 58  
61 59 value = token.getRawValue();
62   - if (((token_type == QPDFTokenizer::tt_string) ||
63   - (token_type == QPDFTokenizer::tt_name)) &&
64   - ((value.find('\r') != std::string::npos) ||
65   - (value.find('\n') != std::string::npos))) {
  60 + if (((token_type == QPDFTokenizer::tt_string) || (token_type == QPDFTokenizer::tt_name)) &&
  61 + ((value.find('\r') != std::string::npos) || (value.find('\n') != std::string::npos))) {
66 62 write("\n");
67 63 }
68 64 }
... ...
libqpdf/FileInputSource.cc
... ... @@ -18,8 +18,7 @@ FileInputSource::FileInputSource(char const* filename) :
18 18 {
19 19 }
20 20  
21   -FileInputSource::FileInputSource(
22   - char const* description, FILE* filep, bool close_file) :
  21 +FileInputSource::FileInputSource(char const* description, FILE* filep, bool close_file) :
23 22 close_file(close_file),
24 23 filename(description),
25 24 file(filep)
... ... @@ -104,8 +103,8 @@ FileInputSource::seek(qpdf_offset_t offset, int whence)
104 103 {
105 104 if (QUtil::seek(this->file, offset, whence) == -1) {
106 105 QUtil::throw_system_error(
107   - std::string("seek to ") + this->filename + ", offset " +
108   - std::to_string(offset) + " (" + std::to_string(whence) + ")");
  106 + std::string("seek to ") + this->filename + ", offset " + std::to_string(offset) + " (" +
  107 + std::to_string(whence) + ")");
109 108 }
110 109 }
111 110  
... ...
libqpdf/InputSource.cc
... ... @@ -43,8 +43,7 @@ InputSource::readLine(size_t max_line_length)
43 43 }
44 44  
45 45 bool
46   -InputSource::findFirst(
47   - char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder)
  46 +InputSource::findFirst(char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder)
48 47 {
49 48 // Basic approach: search for the first character of start_chars
50 49 // starting from offset but not going past len (if len != 0). Once
... ... @@ -64,9 +63,8 @@ InputSource::findFirst(
64 63 // so that buf[size] is valid memory.
65 64 size_t size = sizeof(buf) - 1;
66 65 if ((strlen(start_chars) < 1) || (strlen(start_chars) > size)) {
67   - throw std::logic_error(
68   - "InputSource::findSource called with"
69   - " too small or too large of a character sequence");
  66 + throw std::logic_error("InputSource::findSource called with"
  67 + " too small or too large of a character sequence");
70 68 }
71 69  
72 70 char* p = nullptr;
... ... @@ -86,13 +84,10 @@ InputSource::findFirst(
86 84 // If p points to buf[size], since strlen(start_chars) is
87 85 // always >= 1, this overflow test will be correct for that
88 86 // case regardless of start_chars.
89   - if ((p == nullptr) ||
90   - ((p + strlen(start_chars)) > (buf + bytes_read))) {
  87 + if ((p == nullptr) || ((p + strlen(start_chars)) > (buf + bytes_read))) {
91 88 if (p) {
92 89 QTC::TC(
93   - "libtests",
94   - "InputSource read next block",
95   - ((p == buf + bytes_read) ? 0 : 1));
  90 + "libtests", "InputSource read next block", ((p == buf + bytes_read) ? 0 : 1));
96 91 buf_offset += (p - buf);
97 92 }
98 93 this->seek(buf_offset, SEEK_SET);
... ... @@ -102,10 +97,7 @@ InputSource::findFirst(
102 97 // protection against overrun when using string functions.
103 98 bytes_read = this->read(buf, size);
104 99 if (bytes_read < strlen(start_chars)) {
105   - QTC::TC(
106   - "libtests",
107   - "InputSource find EOF",
108   - bytes_read == 0 ? 0 : 1);
  100 + QTC::TC("libtests", "InputSource find EOF", bytes_read == 0 ? 0 : 1);
109 101 return false;
110 102 }
111 103 memset(buf + bytes_read, '\0', 1 + (size - bytes_read));
... ... @@ -115,18 +107,14 @@ InputSource::findFirst(
115 107 // Search for the first character.
116 108 if ((p = static_cast<char*>(
117 109 // line-break
118   - memchr(
119   - p,
120   - start_chars[0],
121   - bytes_read - QIntC::to_size(p - buf)))) != nullptr) {
  110 + memchr(p, start_chars[0], bytes_read - QIntC::to_size(p - buf)))) != nullptr) {
122 111 if (p == buf) {
123 112 QTC::TC("libtests", "InputSource found match at buf[0]");
124 113 }
125 114 // Found first letter.
126 115 if (len != 0) {
127 116 // Make sure it's in range.
128   - size_t p_relative_offset =
129   - QIntC::to_size((p - buf) + (buf_offset - offset));
  117 + size_t p_relative_offset = QIntC::to_size((p - buf) + (buf_offset - offset));
130 118 if (p_relative_offset >= len) {
131 119 // out of range
132 120 QTC::TC("libtests", "InputSource out of range");
... ... @@ -151,14 +139,10 @@ InputSource::findFirst(
151 139 if (finder.check()) {
152 140 return true;
153 141 } else {
154   - QTC::TC(
155   - "libtests",
156   - "InputSource start_chars matched but not check");
  142 + QTC::TC("libtests", "InputSource start_chars matched but not check");
157 143 }
158 144 } else {
159   - QTC::TC(
160   - "libtests",
161   - "InputSource first char matched but not string");
  145 + QTC::TC("libtests", "InputSource first char matched but not string");
162 146 }
163 147 // This occurrence of the first character wasn't a match.
164 148 // Skip over it and keep searching.
... ... @@ -172,8 +156,7 @@ InputSource::findFirst(
172 156 }
173 157  
174 158 bool
175   -InputSource::findLast(
176   - char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder)
  159 +InputSource::findLast(char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder)
177 160 {
178 161 bool found = false;
179 162 qpdf_offset_t after_found_offset = 0;
... ...
libqpdf/InsecureRandomDataProvider.cc
... ... @@ -24,8 +24,7 @@ InsecureRandomDataProvider::random()
24 24 // Seed the random number generator with something simple, but
25 25 // just to be interesting, don't use the unmodified current
26 26 // time. It would be better if this were a more secure seed.
27   - auto seed =
28   - static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc);
  27 + auto seed = static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc);
29 28 #ifdef HAVE_RANDOM
30 29 ::srandom(seed);
31 30 #else
... ...
libqpdf/JSON.cc
... ... @@ -73,8 +73,7 @@ JSON::writeArrayClose(Pipeline* p, bool first, size_t depth)
73 73 }
74 74  
75 75 void
76   -JSON::writeDictionaryKey(
77   - Pipeline* p, bool& first, std::string const& key, size_t depth)
  76 +JSON::writeDictionaryKey(Pipeline* p, bool& first, std::string const& key, size_t depth)
78 77 {
79 78 writeNext(p, first, depth);
80 79 *p << std::string("\"") + key + "\": ";
... ... @@ -82,19 +81,14 @@ JSON::writeDictionaryKey(
82 81  
83 82 void
84 83 JSON::writeDictionaryItem(
85   - Pipeline* p,
86   - bool& first,
87   - std::string const& key,
88   - JSON const& value,
89   - size_t depth)
  84 + Pipeline* p, bool& first, std::string const& key, JSON const& value, size_t depth)
90 85 {
91 86 writeDictionaryKey(p, first, key, depth);
92 87 value.write(p, depth);
93 88 }
94 89  
95 90 void
96   -JSON::writeArrayItem(
97   - Pipeline* p, bool& first, JSON const& element, size_t depth)
  91 +JSON::writeArrayItem(Pipeline* p, bool& first, JSON const& element, size_t depth)
98 92 {
99 93 writeNext(p, first, depth);
100 94 element.write(p, depth);
... ... @@ -283,11 +277,9 @@ JSON
283 277 JSON::addDictionaryMember(std::string const& key, JSON const& val)
284 278 {
285 279 if (auto* obj = dynamic_cast<JSON_dictionary*>(m->value.get())) {
286   - return obj->members[encode_string(key)] =
287   - val.m->value ? val : makeNull();
  280 + return obj->members[encode_string(key)] = val.m->value ? val : makeNull();
288 281 } else {
289   - throw std::runtime_error(
290   - "JSON::addDictionaryMember called on non-dictionary");
  282 + throw std::runtime_error("JSON::addDictionaryMember called on non-dictionary");
291 283 }
292 284 }
293 285  
... ... @@ -296,8 +288,7 @@ JSON::checkDictionaryKeySeen(std::string const&amp; key)
296 288 {
297 289 auto* obj = dynamic_cast<JSON_dictionary*>(m->value.get());
298 290 if (nullptr == obj) {
299   - throw std::logic_error(
300   - "JSON::checkDictionaryKey called on non-dictionary");
  291 + throw std::logic_error("JSON::checkDictionaryKey called on non-dictionary");
301 292 }
302 293 if (obj->parsed_keys.count(key)) {
303 294 return true;
... ... @@ -421,8 +412,7 @@ JSON::isNull() const
421 412 }
422 413  
423 414 bool
424   -JSON::forEachDictItem(
425   - std::function<void(std::string const& key, JSON value)> fn) const
  415 +JSON::forEachDictItem(std::function<void(std::string const& key, JSON value)> fn) const
426 416 {
427 417 auto v = dynamic_cast<JSON_dictionary const*>(m->value.get());
428 418 if (v == nullptr) {
... ... @@ -450,16 +440,13 @@ JSON::forEachArrayItem(std::function&lt;void(JSON value)&gt; fn) const
450 440 bool
451 441 JSON::checkSchema(JSON schema, std::list<std::string>& errors)
452 442 {
453   - return checkSchemaInternal(
454   - m->value.get(), schema.m->value.get(), 0, errors, "");
  443 + return checkSchemaInternal(m->value.get(), schema.m->value.get(), 0, errors, "");
455 444 }
456 445  
457 446 bool
458   -JSON::checkSchema(
459   - JSON schema, unsigned long flags, std::list<std::string>& errors)
  447 +JSON::checkSchema(JSON schema, unsigned long flags, std::list<std::string>& errors)
460 448 {
461   - return checkSchemaInternal(
462   - m->value.get(), schema.m->value.get(), flags, errors, "");
  449 + return checkSchemaInternal(m->value.get(), schema.m->value.get(), flags, errors, "");
463 450 }
464 451  
465 452 bool
... ... @@ -495,8 +482,8 @@ JSON::checkSchemaInternal(
495 482 auto members = sch_dict->members;
496 483 std::string key;
497 484 if ((members.size() == 1) &&
498   - ((key = members.begin()->first, key.length() > 2) &&
499   - (key.at(0) == '<') && (key.at(key.length() - 1) == '>'))) {
  485 + ((key = members.begin()->first, key.length() > 2) && (key.at(0) == '<') &&
  486 + (key.at(key.length() - 1) == '>'))) {
500 487 pattern_key = key;
501 488 }
502 489 }
... ... @@ -565,17 +552,12 @@ JSON::checkSchemaInternal(
565 552 } else {
566 553 QTC::TC("libtests", "JSON schema array for single item");
567 554 checkSchemaInternal(
568   - this_v,
569   - sch_arr->elements.at(0).m->value.get(),
570   - flags,
571   - errors,
572   - prefix);
  555 + this_v, sch_arr->elements.at(0).m->value.get(), flags, errors, prefix);
573 556 }
574 557 } else if (!this_arr || (this_arr->elements.size() != n_elements)) {
575 558 QTC::TC("libtests", "JSON schema array length mismatch");
576 559 errors.push_back(
577   - err_prefix + " is supposed to be an array of length " +
578   - std::to_string(n_elements));
  560 + err_prefix + " is supposed to be an array of length " + std::to_string(n_elements));
579 561 return false;
580 562 } else {
581 563 // A multi-element array in the schema must correspond to
... ... @@ -595,8 +577,7 @@ JSON::checkSchemaInternal(
595 577 }
596 578 } else if (!sch_str) {
597 579 QTC::TC("libtests", "JSON schema other type");
598   - errors.push_back(
599   - err_prefix + " schema value is not dictionary, array, or string");
  580 + errors.push_back(err_prefix + " schema value is not dictionary, array, or string");
600 581 return false;
601 582 }
602 583  
... ... @@ -736,8 +717,7 @@ JSONParser::handle_u_code(
736 717 " surrogate");
737 718 }
738 719 high_offset = 0;
739   - codepoint =
740   - 0x10000U + ((high_surrogate & 0x3FFU) << 10U) + (codepoint & 0x3FF);
  720 + codepoint = 0x10000U + ((high_surrogate & 0x3FFU) << 10U) + (codepoint & 0x3FF);
741 721 result += QUtil::toUTF8(codepoint);
742 722 } else {
743 723 result += QUtil::toUTF8(codepoint);
... ... @@ -760,8 +740,8 @@ JSONParser::tokenError()
760 740 } else if (lex_state == ls_alpha) {
761 741 QTC::TC("libtests", "JSON parse keyword bad character");
762 742 throw std::runtime_error(
763   - "JSON: offset " + std::to_string(offset) +
764   - ": keyword: unexpected character " + std::string(p, 1));
  743 + "JSON: offset " + std::to_string(offset) + ": keyword: unexpected character " +
  744 + std::string(p, 1));
765 745 } else if (lex_state == ls_string) {
766 746 QTC::TC("libtests", "JSON parse control char in string");
767 747 throw std::runtime_error(
... ... @@ -775,8 +755,7 @@ JSONParser::tokenError()
775 755 }
776 756  
777 757 if (*p == '.') {
778   - if (lex_state == ls_number || lex_state == ls_number_e ||
779   - lex_state == ls_number_e_sign) {
  758 + if (lex_state == ls_number || lex_state == ls_number_e || lex_state == ls_number_e_sign) {
780 759 QTC::TC("libtests", "JSON parse point after e");
781 760 throw std::runtime_error(
782 761 "JSON: offset " + std::to_string(offset) +
... ... @@ -790,24 +769,21 @@ JSONParser::tokenError()
790 769 } else if (*p == 'e' || *p == 'E') {
791 770 QTC::TC("libtests", "JSON parse duplicate e");
792 771 throw std::runtime_error(
793   - "JSON: offset " + std::to_string(offset) +
794   - ": numeric literal: e already seen");
  772 + "JSON: offset " + std::to_string(offset) + ": numeric literal: e already seen");
795 773 } else if ((*p == '+') || (*p == '-')) {
796 774 QTC::TC("libtests", "JSON parse unexpected sign");
797 775 throw std::runtime_error(
798   - "JSON: offset " + std::to_string(offset) +
799   - ": numeric literal: unexpected sign");
  776 + "JSON: offset " + std::to_string(offset) + ": numeric literal: unexpected sign");
800 777 } else if (QUtil::is_space(*p) || strchr("{}[]:,", *p)) {
801 778 QTC::TC("libtests", "JSON parse incomplete number");
802 779 throw std::runtime_error(
803   - "JSON: offset " + std::to_string(offset) +
804   - ": numeric literal: incomplete number");
  780 + "JSON: offset " + std::to_string(offset) + ": numeric literal: incomplete number");
805 781  
806 782 } else {
807 783 QTC::TC("libtests", "JSON parse numeric bad character");
808 784 throw std::runtime_error(
809   - "JSON: offset " + std::to_string(offset) +
810   - ": numeric literal: unexpected character " + std::string(p, 1));
  785 + "JSON: offset " + std::to_string(offset) + ": numeric literal: unexpected character " +
  786 + std::string(p, 1));
811 787 }
812 788 throw std::logic_error("JSON::tokenError : unhandled error");
813 789 }
... ... @@ -884,8 +860,7 @@ JSONParser::getToken()
884 860 } else {
885 861 QTC::TC("libtests", "JSON parse null character");
886 862 throw std::runtime_error(
887   - "JSON: control or null character at offset " +
888   - std::to_string(offset));
  863 + "JSON: control or null character at offset " + std::to_string(offset));
889 864 }
890 865 } else if (*p == ',') {
891 866 if (lex_state == ls_top) {
... ... @@ -968,8 +943,8 @@ JSONParser::getToken()
968 943 } else {
969 944 QTC::TC("libtests", "JSON parse bad character");
970 945 throw std::runtime_error(
971   - "JSON: offset " + std::to_string(offset) +
972   - ": unexpected character " + std::string(p, 1));
  946 + "JSON: offset " + std::to_string(offset) + ": unexpected character " +
  947 + std::string(p, 1));
973 948 }
974 949 break;
975 950  
... ... @@ -994,8 +969,7 @@ JSONParser::getToken()
994 969 } else {
995 970 QTC::TC("libtests", "JSON parse leading zero");
996 971 throw std::runtime_error(
997   - "JSON: offset " + std::to_string(offset) +
998   - ": number with leading zero");
  972 + "JSON: offset " + std::to_string(offset) + ": number with leading zero");
999 973 }
1000 974 break;
1001 975  
... ... @@ -1127,20 +1101,14 @@ JSONParser::getToken()
1127 1101 tokenError();
1128 1102 }
1129 1103 if (++u_count == 4) {
1130   - handle_u_code(
1131   - u_value,
1132   - offset - 5,
1133   - high_surrogate,
1134   - high_offset,
1135   - token);
  1104 + handle_u_code(u_value, offset - 5, high_surrogate, high_offset, token);
1136 1105 lex_state = ls_string;
1137 1106 }
1138 1107 ignore();
1139 1108 break;
1140 1109  
1141 1110 default:
1142   - throw std::logic_error(
1143   - "JSONParser::getToken : trying to handle delimiter state");
  1111 + throw std::logic_error("JSONParser::getToken : trying to handle delimiter state");
1144 1112 }
1145 1113 }
1146 1114 }
... ... @@ -1205,19 +1173,16 @@ JSONParser::handleToken()
1205 1173 if (parser_state != ps_dict_after_key) {
1206 1174 QTC::TC("libtests", "JSON parse unexpected :");
1207 1175 throw std::runtime_error(
1208   - "JSON: offset " + std::to_string(offset) +
1209   - ": unexpected colon");
  1176 + "JSON: offset " + std::to_string(offset) + ": unexpected colon");
1210 1177 }
1211 1178 parser_state = ps_dict_after_colon;
1212 1179 return;
1213 1180  
1214 1181 case ls_comma:
1215   - if (!((parser_state == ps_dict_after_item) ||
1216   - (parser_state == ps_array_after_item))) {
  1182 + if (!((parser_state == ps_dict_after_item) || (parser_state == ps_array_after_item))) {
1217 1183 QTC::TC("libtests", "JSON parse unexpected ,");
1218 1184 throw std::runtime_error(
1219   - "JSON: offset " + std::to_string(offset) +
1220   - ": unexpected comma");
  1185 + "JSON: offset " + std::to_string(offset) + ": unexpected comma");
1221 1186 }
1222 1187 if (parser_state == ps_dict_after_item) {
1223 1188 parser_state = ps_dict_after_comma;
... ... @@ -1230,12 +1195,10 @@ JSONParser::handleToken()
1230 1195 return;
1231 1196  
1232 1197 case ls_end_array:
1233   - if (!(parser_state == ps_array_begin ||
1234   - parser_state == ps_array_after_item)) {
  1198 + if (!(parser_state == ps_array_begin || parser_state == ps_array_after_item)) {
1235 1199 QTC::TC("libtests", "JSON parse unexpected ]");
1236 1200 throw std::runtime_error(
1237   - "JSON: offset " + std::to_string(offset) +
1238   - ": unexpected array end delimiter");
  1201 + "JSON: offset " + std::to_string(offset) + ": unexpected array end delimiter");
1239 1202 }
1240 1203 parser_state = stack.back().state;
1241 1204 tos.setEnd(offset);
... ... @@ -1248,12 +1211,10 @@ JSONParser::handleToken()
1248 1211 return;
1249 1212  
1250 1213 case ls_end_dict:
1251   - if (!((parser_state == ps_dict_begin) ||
1252   - (parser_state == ps_dict_after_item))) {
  1214 + if (!((parser_state == ps_dict_begin) || (parser_state == ps_dict_after_item))) {
1253 1215 QTC::TC("libtests", "JSON parse unexpected }");
1254 1216 throw std::runtime_error(
1255   - "JSON: offset " + std::to_string(offset) +
1256   - ": unexpected dictionary end delimiter");
  1217 + "JSON: offset " + std::to_string(offset) + ": unexpected dictionary end delimiter");
1257 1218 }
1258 1219 parser_state = stack.back().state;
1259 1220 tos.setEnd(offset);
... ... @@ -1279,14 +1240,12 @@ JSONParser::handleToken()
1279 1240 } else {
1280 1241 QTC::TC("libtests", "JSON parse invalid keyword");
1281 1242 throw std::runtime_error(
1282   - "JSON: offset " + std::to_string(offset) +
1283   - ": invalid keyword " + token);
  1243 + "JSON: offset " + std::to_string(offset) + ": invalid keyword " + token);
1284 1244 }
1285 1245 break;
1286 1246  
1287 1247 case ls_string:
1288   - if (parser_state == ps_dict_begin ||
1289   - parser_state == ps_dict_after_comma) {
  1248 + if (parser_state == ps_dict_begin || parser_state == ps_dict_after_comma) {
1290 1249 dict_key = token;
1291 1250 dict_key_offset = token_start;
1292 1251 parser_state = ps_dict_after_key;
... ... @@ -1297,8 +1256,7 @@ JSONParser::handleToken()
1297 1256 break;
1298 1257  
1299 1258 default:
1300   - throw std::logic_error(
1301   - "JSONParser::handleToken : non-terminal lexer state encountered");
  1259 + throw std::logic_error("JSONParser::handleToken : non-terminal lexer state encountered");
1302 1260 break;
1303 1261 }
1304 1262  
... ... @@ -1310,16 +1268,14 @@ JSONParser::handleToken()
1310 1268 case ps_dict_after_comma:
1311 1269 QTC::TC("libtests", "JSON parse string as dict key");
1312 1270 throw std::runtime_error(
1313   - "JSON: offset " + std::to_string(offset) +
1314   - ": expect string as dictionary key");
  1271 + "JSON: offset " + std::to_string(offset) + ": expect string as dictionary key");
1315 1272 break;
1316 1273  
1317 1274 case ps_dict_after_colon:
1318 1275 if (tos.checkDictionaryKeySeen(dict_key)) {
1319 1276 QTC::TC("libtests", "JSON parse duplicate key");
1320 1277 throw std::runtime_error(
1321   - "JSON: offset " + std::to_string(dict_key_offset) +
1322   - ": duplicated dictionary key");
  1278 + "JSON: offset " + std::to_string(dict_key_offset) + ": duplicated dictionary key");
1323 1279 }
1324 1280 if (!reactor || !reactor->dictionaryItem(dict_key, item)) {
1325 1281 tos.addDictionaryMember(dict_key, item);
... ... @@ -1346,8 +1302,7 @@ JSONParser::handleToken()
1346 1302  
1347 1303 case ps_dict_after_key:
1348 1304 QTC::TC("libtests", "JSON parse expected colon");
1349   - throw std::runtime_error(
1350   - "JSON: offset " + std::to_string(offset) + ": expected ':'");
  1305 + throw std::runtime_error("JSON: offset " + std::to_string(offset) + ": expected ':'");
1351 1306 break;
1352 1307  
1353 1308 case ps_dict_after_item:
... ... @@ -1363,8 +1318,7 @@ JSONParser::handleToken()
1363 1318 break;
1364 1319  
1365 1320 case ps_done:
1366   - throw std::logic_error(
1367   - "JSONParser::handleToken: unexpected parser state");
  1321 + throw std::logic_error("JSONParser::handleToken: unexpected parser state");
1368 1322 }
1369 1323  
1370 1324 if (item.isDictionary() || item.isArray()) {
... ... @@ -1387,8 +1341,7 @@ JSONParser::handleToken()
1387 1341  
1388 1342 if (stack.size() > 500) {
1389 1343 throw std::runtime_error(
1390   - "JSON: offset " + std::to_string(offset) +
1391   - ": maximum object depth exceeded");
  1344 + "JSON: offset " + std::to_string(offset) + ": maximum object depth exceeded");
1392 1345 }
1393 1346 }
1394 1347 }
... ...
libqpdf/JSONHandler.cc
... ... @@ -53,8 +53,7 @@ JSONHandler::addDictHandlers(json_handler_t start_fn, void_handler_t end_fn)
53 53 }
54 54  
55 55 void
56   -JSONHandler::addDictKeyHandler(
57   - std::string const& key, std::shared_ptr<JSONHandler> dkh)
  56 +JSONHandler::addDictKeyHandler(std::string const& key, std::shared_ptr<JSONHandler> dkh)
58 57 {
59 58 m->h.dict_handlers[key] = dkh;
60 59 }
... ... @@ -67,9 +66,7 @@ JSONHandler::addFallbackDictHandler(std::shared_ptr&lt;JSONHandler&gt; fdh)
67 66  
68 67 void
69 68 JSONHandler::addArrayHandlers(
70   - json_handler_t start_fn,
71   - void_handler_t end_fn,
72   - std::shared_ptr<JSONHandler> ah)
  69 + json_handler_t start_fn, void_handler_t end_fn, std::shared_ptr<JSONHandler> ah)
73 70 {
74 71 m->h.array_start_handler = start_fn;
75 72 m->h.array_end_handler = end_fn;
... ... @@ -108,22 +105,19 @@ JSONHandler::handle(std::string const&amp; path, JSON j)
108 105 if (path_base != ".") {
109 106 path_base += ".";
110 107 }
111   - j.forEachDictItem(
112   - [&path, &path_base, this](std::string const& k, JSON v) {
113   - auto i = m->h.dict_handlers.find(k);
114   - if (i == m->h.dict_handlers.end()) {
115   - if (m->h.fallback_dict_handler.get()) {
116   - m->h.fallback_dict_handler->handle(path_base + k, v);
117   - } else {
118   - QTC::TC("libtests", "JSONHandler unexpected key");
119   - usage(
120   - "JSON handler found unexpected key " + k +
121   - " in object at " + path);
122   - }
  108 + j.forEachDictItem([&path, &path_base, this](std::string const& k, JSON v) {
  109 + auto i = m->h.dict_handlers.find(k);
  110 + if (i == m->h.dict_handlers.end()) {
  111 + if (m->h.fallback_dict_handler.get()) {
  112 + m->h.fallback_dict_handler->handle(path_base + k, v);
123 113 } else {
124   - i->second->handle(path_base + k, v);
  114 + QTC::TC("libtests", "JSONHandler unexpected key");
  115 + usage("JSON handler found unexpected key " + k + " in object at " + path);
125 116 }
126   - });
  117 + } else {
  118 + i->second->handle(path_base + k, v);
  119 + }
  120 + });
127 121 m->h.dict_end_handler(path);
128 122 handled = true;
129 123 }
... ... @@ -131,8 +125,7 @@ JSONHandler::handle(std::string const&amp; path, JSON j)
131 125 m->h.array_start_handler(path, j);
132 126 size_t i = 0;
133 127 j.forEachArrayItem([&i, &path, this](JSON v) {
134   - m->h.array_item_handler->handle(
135   - path + "[" + std::to_string(i) + "]", v);
  128 + m->h.array_item_handler->handle(path + "[" + std::to_string(i) + "]", v);
136 129 ++i;
137 130 });
138 131 m->h.array_end_handler(path);
... ...
libqpdf/MD5.cc
... ... @@ -81,8 +81,7 @@ MD5::encodeFile(char const* filename, qpdf_offset_t up_to_offset)
81 81 // Assume, perhaps incorrectly, that errno was set by the
82 82 // underlying call to read....
83 83 (void)fclose(file);
84   - QUtil::throw_system_error(
85   - std::string("MD5: read error on ") + filename);
  84 + QUtil::throw_system_error(std::string("MD5: read error on ") + filename);
86 85 }
87 86 (void)fclose(file);
88 87  
... ... @@ -115,8 +114,7 @@ MD5::unparse()
115 114 this->crypto->MD5_finalize();
116 115 Digest digest_val;
117 116 digest(digest_val);
118   - return QUtil::hex_encode(
119   - std::string(reinterpret_cast<char*>(digest_val), 16));
  117 + return QUtil::hex_encode(std::string(reinterpret_cast<char*>(digest_val), 16));
120 118 }
121 119  
122 120 std::string
... ... @@ -143,10 +141,7 @@ MD5::checkDataChecksum(char const* const checksum, char const* buf, size_t len)
143 141 }
144 142  
145 143 bool
146   -MD5::checkFileChecksum(
147   - char const* const checksum,
148   - char const* filename,
149   - qpdf_offset_t up_to_offset)
  144 +MD5::checkFileChecksum(char const* const checksum, char const* filename, qpdf_offset_t up_to_offset)
150 145 {
151 146 bool result = false;
152 147 try {
... ...
libqpdf/NNTree.cc
... ... @@ -24,8 +24,7 @@ warn(QPDF&amp; qpdf, QPDFObjectHandle&amp; node, std::string const&amp; msg)
24 24 static void
25 25 error(QPDF& qpdf, QPDFObjectHandle& node, std::string const& msg)
26 26 {
27   - throw QPDFExc(
28   - qpdf_e_damaged_pdf, qpdf.getFilename(), get_description(node), 0, msg);
  27 + throw QPDFExc(qpdf_e_damaged_pdf, qpdf.getFilename(), get_description(node), 0, msg);
29 28 }
30 29  
31 30 NNTreeIterator::NNTreeIterator(NNTreeImpl& impl) :
... ... @@ -76,8 +75,7 @@ NNTreeIterator::updateIValue(bool allow_invalid)
76 75 }
77 76 }
78 77  
79   -NNTreeIterator::PathElement::PathElement(
80   - QPDFObjectHandle const& node, int kid_number) :
  78 +NNTreeIterator::PathElement::PathElement(QPDFObjectHandle const& node, int kid_number) :
81 79 node(node),
82 80 kid_number(kid_number)
83 81 {
... ... @@ -94,16 +92,14 @@ NNTreeIterator::getNextKid(PathElement&amp; pe, bool backward)
94 92 if ((pe.kid_number >= 0) && (pe.kid_number < kids.getArrayNItems())) {
95 93 result = kids.getArrayItem(pe.kid_number);
96 94 if (result.isDictionary() &&
97   - (result.hasKey("/Kids") ||
98   - result.hasKey(impl.details.itemsKey()))) {
  95 + (result.hasKey("/Kids") || result.hasKey(impl.details.itemsKey()))) {
99 96 found = true;
100 97 } else {
101 98 QTC::TC("qpdf", "NNTree skip invalid kid");
102 99 warn(
103 100 impl.qpdf,
104 101 pe.node,
105   - ("skipping over invalid kid at index " +
106   - std::to_string(pe.kid_number)));
  102 + ("skipping over invalid kid at index " + std::to_string(pe.kid_number)));
107 103 }
108 104 } else {
109 105 result = QPDFObjectHandle::newNull();
... ... @@ -131,8 +127,7 @@ NNTreeIterator::increment(bool backward)
131 127 while (valid() && (!found_valid_key)) {
132 128 this->item_number += backward ? -2 : 2;
133 129 auto items = this->node.getKey(impl.details.itemsKey());
134   - if ((this->item_number < 0) ||
135   - (this->item_number >= items.getArrayNItems())) {
  130 + if ((this->item_number < 0) || (this->item_number >= items.getArrayNItems())) {
136 131 bool found = false;
137 132 setItemNumber(QPDFObjectHandle(), -1);
138 133 while (!(found || this->path.empty())) {
... ... @@ -149,18 +144,13 @@ NNTreeIterator::increment(bool backward)
149 144 items = this->node.getKey(impl.details.itemsKey());
150 145 if (this->item_number + 1 >= items.getArrayNItems()) {
151 146 QTC::TC("qpdf", "NNTree skip item at end of short items");
152   - warn(
153   - impl.qpdf,
154   - this->node,
155   - "items array doesn't have enough elements");
156   - } else if (!impl.details.keyValid(
157   - items.getArrayItem(this->item_number))) {
  147 + warn(impl.qpdf, this->node, "items array doesn't have enough elements");
  148 + } else if (!impl.details.keyValid(items.getArrayItem(this->item_number))) {
158 149 QTC::TC("qpdf", "NNTree skip invalid key");
159 150 warn(
160 151 impl.qpdf,
161 152 this->node,
162   - ("item " + std::to_string(this->item_number) +
163   - " has the wrong type"));
  153 + ("item " + std::to_string(this->item_number) + " has the wrong type"));
164 154 } else {
165 155 found_valid_key = true;
166 156 }
... ... @@ -169,8 +159,7 @@ NNTreeIterator::increment(bool backward)
169 159 }
170 160  
171 161 void
172   -NNTreeIterator::resetLimits(
173   - QPDFObjectHandle node, std::list<PathElement>::iterator parent)
  162 +NNTreeIterator::resetLimits(QPDFObjectHandle node, std::list<PathElement>::iterator parent)
174 163 {
175 164 bool done = false;
176 165 while (!done) {
... ... @@ -197,10 +186,8 @@ NNTreeIterator::resetLimits(
197 186 if (first_kid.isDictionary() && last_kid.isDictionary()) {
198 187 auto first_limits = first_kid.getKey("/Limits");
199 188 auto last_limits = last_kid.getKey("/Limits");
200   - if (first_limits.isArray() &&
201   - (first_limits.getArrayNItems() >= 2) &&
202   - last_limits.isArray() &&
203   - (last_limits.getArrayNItems() >= 2)) {
  189 + if (first_limits.isArray() && (first_limits.getArrayNItems() >= 2) &&
  190 + last_limits.isArray() && (last_limits.getArrayNItems() >= 2)) {
204 191 first = first_limits.getArrayItem(0);
205 192 last = last_limits.getArrayItem(1);
206 193 }
... ... @@ -214,8 +201,7 @@ NNTreeIterator::resetLimits(
214 201 if (olimits.isArray() && (olimits.getArrayNItems() == 2)) {
215 202 auto ofirst = olimits.getArrayItem(0);
216 203 auto olast = olimits.getArrayItem(1);
217   - if (impl.details.keyValid(ofirst) &&
218   - impl.details.keyValid(olast) &&
  204 + if (impl.details.keyValid(ofirst) && impl.details.keyValid(olast) &&
219 205 (impl.details.compareKeys(first, ofirst) == 0) &&
220 206 (impl.details.compareKeys(last, olast) == 0)) {
221 207 QTC::TC("qpdf", "NNTree limits didn't change");
... ... @@ -240,8 +226,7 @@ NNTreeIterator::resetLimits(
240 226 }
241 227  
242 228 void
243   -NNTreeIterator::split(
244   - QPDFObjectHandle to_split, std::list<PathElement>::iterator parent)
  229 +NNTreeIterator::split(QPDFObjectHandle to_split, std::list<PathElement>::iterator parent)
245 230 {
246 231 // Split some node along the path to the item pointed to by this
247 232 // iterator, and adjust the iterator so it points to the same
... ... @@ -272,8 +257,7 @@ NNTreeIterator::split(
272 257 // item_number: 0
273 258  
274 259 if (!valid()) {
275   - throw std::logic_error(
276   - "NNTreeIterator::split called an invalid iterator");
  260 + throw std::logic_error("NNTreeIterator::split called an invalid iterator");
277 261 }
278 262  
279 263 // Find the array we actually need to split, which is either this
... ... @@ -335,8 +319,7 @@ NNTreeIterator::split(
335 319 // non-root case so remaining logic can handle them in the
336 320 // same way.
337 321  
338   - auto first_node =
339   - impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
  322 + auto first_node = impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
340 323 first_node.replaceKey(key, first_half);
341 324 QPDFObjectHandle new_kids = QPDFObjectHandle::newArray();
342 325 new_kids.appendItem(first_node);
... ... @@ -371,8 +354,7 @@ NNTreeIterator::split(
371 354 resetLimits(to_split, parent);
372 355  
373 356 // Create a new node to contain the second half
374   - QPDFObjectHandle second_node =
375   - impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
  357 + QPDFObjectHandle second_node = impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
376 358 second_node.replaceKey(key, second_half);
377 359 resetLimits(second_node, parent);
378 360  
... ... @@ -457,10 +439,7 @@ NNTreeIterator::remove()
457 439 auto items = this->node.getKey(impl.details.itemsKey());
458 440 int nitems = items.getArrayNItems();
459 441 if (this->item_number + 2 > nitems) {
460   - error(
461   - impl.qpdf,
462   - this->node,
463   - "found short items array while removing an item");
  442 + error(impl.qpdf, this->node, "found short items array while removing an item");
464 443 }
465 444  
466 445 items.eraseItem(this->item_number);
... ... @@ -491,8 +470,7 @@ NNTreeIterator::remove()
491 470 } else {
492 471 // We already checked to ensure this condition would not
493 472 // happen.
494   - throw std::logic_error(
495   - "NNTreeIterator::remove: item_number > nitems after erase");
  473 + throw std::logic_error("NNTreeIterator::remove: item_number > nitems after erase");
496 474 }
497 475 return;
498 476 }
... ... @@ -549,8 +527,7 @@ NNTreeIterator::remove()
549 527 // empty items array.
550 528 QTC::TC("qpdf", "NNTree non-flat tree is empty after remove");
551 529 element->node.removeKey("/Kids");
552   - element->node.replaceKey(
553   - impl.details.itemsKey(), QPDFObjectHandle::newArray());
  530 + element->node.replaceKey(impl.details.itemsKey(), QPDFObjectHandle::newArray());
554 531 this->path.clear();
555 532 setItemNumber(impl.oh, -1);
556 533 done = true;
... ... @@ -645,20 +622,14 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
645 622 while (!failed) {
646 623 if (!seen.add(node)) {
647 624 QTC::TC("qpdf", "NNTree deepen: loop");
648   - warn(
649   - impl.qpdf,
650   - node,
651   - "loop detected while traversing name/number tree");
  625 + warn(impl.qpdf, node, "loop detected while traversing name/number tree");
652 626 failed = true;
653 627 break;
654 628 }
655 629  
656 630 if (!node.isDictionary()) {
657 631 QTC::TC("qpdf", "NNTree node is not a dictionary");
658   - warn(
659   - impl.qpdf,
660   - node,
661   - "non-dictionary node while traversing name/number tree");
  632 + warn(impl.qpdf, node, "non-dictionary node while traversing name/number tree");
662 633 failed = true;
663 634 break;
664 635 }
... ... @@ -703,8 +674,8 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
703 674 warn(
704 675 impl.qpdf,
705 676 node,
706   - ("name/number tree node has neither non-empty " +
707   - impl.details.itemsKey() + " nor /Kids"));
  677 + ("name/number tree node has neither non-empty " + impl.details.itemsKey() +
  678 + " nor /Kids"));
708 679 failed = true;
709 680 break;
710 681 }
... ... @@ -717,10 +688,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
717 688 }
718 689  
719 690 NNTreeImpl::NNTreeImpl(
720   - NNTreeDetails const& details,
721   - QPDF& qpdf,
722   - QPDFObjectHandle& oh,
723   - bool auto_repair) :
  691 + NNTreeDetails const& details, QPDF& qpdf, QPDFObjectHandle& oh, bool auto_repair) :
724 692 details(details),
725 693 qpdf(qpdf),
726 694 split_threshold(32),
... ... @@ -763,8 +731,7 @@ NNTreeImpl::withinLimits(QPDFObjectHandle key, QPDFObjectHandle node)
763 731 int result = 0;
764 732 auto limits = node.getKey("/Limits");
765 733 if (limits.isArray() && (limits.getArrayNItems() >= 2) &&
766   - details.keyValid(limits.getArrayItem(0)) &&
767   - details.keyValid(limits.getArrayItem(1))) {
  734 + details.keyValid(limits.getArrayItem(0)) && details.keyValid(limits.getArrayItem(1))) {
768 735 if (details.compareKeys(key, limits.getArrayItem(0)) < 0) {
769 736 result = -1;
770 737 } else if (details.compareKeys(key, limits.getArrayItem(1)) > 0) {
... ... @@ -783,8 +750,7 @@ NNTreeImpl::binarySearch(
783 750 QPDFObjectHandle items,
784 751 int num_items,
785 752 bool return_prev_if_not_found,
786   - int (NNTreeImpl::*compare)(
787   - QPDFObjectHandle& key, QPDFObjectHandle& arr, int item))
  753 + int (NNTreeImpl::*compare)(QPDFObjectHandle& key, QPDFObjectHandle& arr, int item))
788 754 {
789 755 int max_idx = 1;
790 756 while (max_idx < num_items) {
... ... @@ -838,8 +804,7 @@ NNTreeImpl::binarySearch(
838 804 }
839 805  
840 806 int
841   -NNTreeImpl::compareKeyItem(
842   - QPDFObjectHandle& key, QPDFObjectHandle& items, int idx)
  807 +NNTreeImpl::compareKeyItem(QPDFObjectHandle& key, QPDFObjectHandle& items, int idx)
843 808 {
844 809 if (!((items.isArray() && (items.getArrayNItems() > (2 * idx)) &&
845 810 details.keyValid(items.getArrayItem(2 * idx))))) {
... ... @@ -847,15 +812,13 @@ NNTreeImpl::compareKeyItem(
847 812 error(
848 813 qpdf,
849 814 this->oh,
850   - ("item at index " + std::to_string(2 * idx) +
851   - " is not the right type"));
  815 + ("item at index " + std::to_string(2 * idx) + " is not the right type"));
852 816 }
853 817 return details.compareKeys(key, items.getArrayItem(2 * idx));
854 818 }
855 819  
856 820 int
857   -NNTreeImpl::compareKeyKid(
858   - QPDFObjectHandle& key, QPDFObjectHandle& kids, int idx)
  821 +NNTreeImpl::compareKeyKid(QPDFObjectHandle& key, QPDFObjectHandle& kids, int idx)
859 822 {
860 823 if (!(kids.isArray() && (idx < kids.getArrayNItems()) &&
861 824 kids.getArrayItem(idx).isDictionary())) {
... ... @@ -875,8 +838,7 @@ NNTreeImpl::repair()
875 838 repl.insert(i.first, i.second);
876 839 }
877 840 this->oh.replaceKey("/Kids", new_node.getKey("/Kids"));
878   - this->oh.replaceKey(
879   - details.itemsKey(), new_node.getKey(details.itemsKey()));
  841 + this->oh.replaceKey(details.itemsKey(), new_node.getKey(details.itemsKey()));
880 842 }
881 843  
882 844 NNTreeImpl::iterator
... ... @@ -887,10 +849,7 @@ NNTreeImpl::find(QPDFObjectHandle key, bool return_prev_if_not_found)
887 849 } catch (QPDFExc& e) {
888 850 if (this->auto_repair) {
889 851 QTC::TC("qpdf", "NNTree repair");
890   - warn(
891   - qpdf,
892   - this->oh,
893   - std::string("attempting to repair after error: ") + e.what());
  852 + warn(qpdf, this->oh, std::string("attempting to repair after error: ") + e.what());
894 853 repair();
895 854 return findInternal(key, return_prev_if_not_found);
896 855 } else {
... ... @@ -939,18 +898,13 @@ NNTreeImpl::findInternal(QPDFObjectHandle key, bool return_prev_if_not_found)
939 898 int nitems = items.isArray() ? items.getArrayNItems() : 0;
940 899 if (nitems > 0) {
941 900 int idx = binarySearch(
942   - key,
943   - items,
944   - nitems / 2,
945   - return_prev_if_not_found,
946   - &NNTreeImpl::compareKeyItem);
  901 + key, items, nitems / 2, return_prev_if_not_found, &NNTreeImpl::compareKeyItem);
947 902 if (idx >= 0) {
948 903 result.setItemNumber(node, 2 * idx);
949 904 }
950 905 break;
951 906 } else if (nkids > 0) {
952   - int idx = binarySearch(
953   - key, kids, nkids, true, &NNTreeImpl::compareKeyKid);
  907 + int idx = binarySearch(key, kids, nkids, true, &NNTreeImpl::compareKeyKid);
954 908 if (idx == -1) {
955 909 QTC::TC("qpdf", "NNTree -1 in binary search");
956 910 error(
... ...
libqpdf/OffsetInputSource.cc
... ... @@ -10,11 +10,9 @@ OffsetInputSource::OffsetInputSource(
10 10 global_offset(global_offset)
11 11 {
12 12 if (global_offset < 0) {
13   - throw std::logic_error(
14   - "OffsetInputSource constructed with negative offset");
  13 + throw std::logic_error("OffsetInputSource constructed with negative offset");
15 14 }
16   - this->max_safe_offset =
17   - std::numeric_limits<qpdf_offset_t>::max() - global_offset;
  15 + this->max_safe_offset = std::numeric_limits<qpdf_offset_t>::max() - global_offset;
18 16 }
19 17  
20 18 qpdf_offset_t
... ... @@ -51,8 +49,7 @@ OffsetInputSource::seek(qpdf_offset_t offset, int whence)
51 49 this->proxied->seek(offset, whence);
52 50 }
53 51 if (tell() < 0) {
54   - throw std::runtime_error(
55   - "offset input source: seek before beginning of file");
  52 + throw std::runtime_error("offset input source: seek before beginning of file");
56 53 }
57 54 }
58 55  
... ...
libqpdf/PDFVersion.cc
... ... @@ -7,8 +7,7 @@ PDFVersion::PDFVersion() :
7 7 {
8 8 }
9 9  
10   -PDFVersion::PDFVersion(
11   - int major_version, int minor_version, int extension_level) :
  10 +PDFVersion::PDFVersion(int major_version, int minor_version, int extension_level) :
12 11 major_version(major_version),
13 12 minor_version(minor_version),
14 13 extension_level(extension_level)
... ... @@ -31,8 +30,7 @@ bool
31 30 PDFVersion::operator==(PDFVersion const& rhs) const
32 31 {
33 32 return (
34   - (this->major_version == rhs.major_version) &&
35   - (this->minor_version == rhs.minor_version) &&
  33 + (this->major_version == rhs.major_version) && (this->minor_version == rhs.minor_version) &&
36 34 (this->extension_level == rhs.extension_level));
37 35 }
38 36  
... ... @@ -48,8 +46,7 @@ void
48 46 PDFVersion::getVersion(std::string& version, int& extension_level) const
49 47 {
50 48 extension_level = this->extension_level;
51   - version = std::to_string(this->major_version) + "." +
52   - std::to_string(this->minor_version);
  49 + version = std::to_string(this->major_version) + "." + std::to_string(this->minor_version);
53 50 }
54 51  
55 52 int
... ...
libqpdf/Pipeline.cc
... ... @@ -14,8 +14,7 @@ Pipeline::getNext(bool allow_null)
14 14 {
15 15 if ((this->next == nullptr) && (!allow_null)) {
16 16 throw std::logic_error(
17   - this->identifier +
18   - ": Pipeline::getNext() called on pipeline with no next");
  17 + this->identifier + ": Pipeline::getNext() called on pipeline with no next");
19 18 }
20 19 return this->next;
21 20 }
... ...
libqpdf/Pl_AES_PDF.cc
... ... @@ -117,8 +117,7 @@ Pl_AES_PDF::finish()
117 117 throw std::logic_error("buffer overflow in AES encryption"
118 118 " pipeline");
119 119 }
120   - std::memset(
121   - this->inbuf + this->offset, 0, this->buf_size - this->offset);
  120 + std::memset(this->inbuf + this->offset, 0, this->buf_size - this->offset);
122 121 this->offset = this->buf_size;
123 122 }
124 123 flush(!this->disable_padding);
... ... @@ -149,8 +148,7 @@ void
149 148 Pl_AES_PDF::flush(bool strip_padding)
150 149 {
151 150 if (this->offset != this->buf_size) {
152   - throw std::logic_error(
153   - "AES pipeline: flush called when buffer was not full");
  151 + throw std::logic_error("AES pipeline: flush called when buffer was not full");
154 152 }
155 153  
156 154 if (first) {
... ... @@ -177,11 +175,7 @@ Pl_AES_PDF::flush(bool strip_padding)
177 175 }
178 176 }
179 177 this->crypto->rijndael_init(
180   - encrypt,
181   - this->key.get(),
182   - key_bytes,
183   - this->cbc_mode,
184   - this->cbc_block);
  178 + encrypt, this->key.get(), key_bytes, this->cbc_mode, this->cbc_block);
185 179 if (return_after_init) {
186 180 return;
187 181 }
... ...
libqpdf/Pl_ASCII85Decoder.cc
... ... @@ -26,8 +26,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
26 26 flush();
27 27 eod = 2;
28 28 } else {
29   - throw std::runtime_error(
30   - "broken end-of-data sequence in base 85 data");
  29 + throw std::runtime_error("broken end-of-data sequence in base 85 data");
31 30 }
32 31 } else {
33 32 switch (buf[i]) {
... ... @@ -47,8 +46,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
47 46  
48 47 case 'z':
49 48 if (pos != 0) {
50   - throw std::runtime_error(
51   - "unexpected z during base 85 decode");
  49 + throw std::runtime_error("unexpected z during base 85 decode");
52 50 } else {
53 51 QTC::TC("libtests", "Pl_ASCII85Decoder read z");
54 52 unsigned char zeroes[4];
... ... @@ -59,8 +57,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
59 57  
60 58 default:
61 59 if ((buf[i] < 33) || (buf[i] > 117)) {
62   - throw std::runtime_error(
63   - "character out of range during base 85 decode");
  60 + throw std::runtime_error("character out of range during base 85 decode");
64 61 } else {
65 62 this->inbuf[this->pos++] = buf[i];
66 63 if (pos == 5) {
... ... @@ -93,10 +90,7 @@ Pl_ASCII85Decoder::flush()
93 90 lval >>= 8;
94 91 }
95 92  
96   - QTC::TC(
97   - "libtests",
98   - "Pl_ASCII85Decoder partial flush",
99   - (this->pos == 5) ? 0 : 1);
  93 + QTC::TC("libtests", "Pl_ASCII85Decoder partial flush", (this->pos == 5) ? 0 : 1);
100 94 // Reset before calling getNext()->write in case that throws an
101 95 // exception.
102 96 auto t = this->pos - 1;
... ...
libqpdf/Pl_ASCIIHexDecoder.cc
... ... @@ -78,10 +78,7 @@ Pl_ASCIIHexDecoder::flush()
78 78 }
79 79 auto ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
80 80  
81   - QTC::TC(
82   - "libtests",
83   - "Pl_ASCIIHexDecoder partial flush",
84   - (this->pos == 2) ? 0 : 1);
  81 + QTC::TC("libtests", "Pl_ASCIIHexDecoder partial flush", (this->pos == 2) ? 0 : 1);
85 82 // Reset before calling getNext()->write in case that throws an
86 83 // exception.
87 84 this->pos = 0;
... ...
libqpdf/Pl_Base64.cc
... ... @@ -91,8 +91,7 @@ void
91 91 Pl_Base64::flush_decode()
92 92 {
93 93 if (this->end_of_data) {
94   - throw std::runtime_error(
95   - getIdentifier() + ": base64 decode: data follows pad characters");
  94 + throw std::runtime_error(getIdentifier() + ": base64 decode: data follows pad characters");
96 95 }
97 96 int pad = 0;
98 97 int shift = 18;
... ... @@ -110,14 +109,12 @@ Pl_Base64::flush_decode()
110 109 v = 62;
111 110 } else if ((ch == '/') || (ch == '_')) {
112 111 v = 63;
113   - } else if (
114   - (ch == '=') && ((i == 3) || ((i == 2) && (this->buf[3] == '=')))) {
  112 + } else if ((ch == '=') && ((i == 3) || ((i == 2) && (this->buf[3] == '=')))) {
115 113 ++pad;
116 114 this->end_of_data = true;
117 115 v = 0;
118 116 } else {
119   - throw std::runtime_error(
120   - getIdentifier() + ": base64 decode: invalid input");
  117 + throw std::runtime_error(getIdentifier() + ": base64 decode: invalid input");
121 118 }
122 119 outval |= v << shift;
123 120 shift -= 6;
... ...
libqpdf/Pl_Buffer.cc
... ... @@ -64,8 +64,7 @@ void
64 64 Pl_Buffer::getMallocBuffer(unsigned char** buf, size_t* len)
65 65 {
66 66 if (!m->ready) {
67   - throw std::logic_error(
68   - "Pl_Buffer::getMallocBuffer() called when not ready");
  67 + throw std::logic_error("Pl_Buffer::getMallocBuffer() called when not ready");
69 68 }
70 69 auto size = m->data.length();
71 70 *len = size;
... ...
libqpdf/Pl_DCT.cc
... ... @@ -182,15 +182,12 @@ term_pipeline_destination(j_compress_ptr cinfo)
182 182 }
183 183  
184 184 static void
185   -jpeg_pipeline_dest(
186   - j_compress_ptr cinfo, unsigned char* outbuffer, size_t size, Pipeline* next)
  185 +jpeg_pipeline_dest(j_compress_ptr cinfo, unsigned char* outbuffer, size_t size, Pipeline* next)
187 186 {
188 187 cinfo->dest = static_cast<struct jpeg_destination_mgr*>(
189 188 // line-break
190 189 (*cinfo->mem->alloc_small)(
191   - reinterpret_cast<j_common_ptr>(cinfo),
192   - JPOOL_PERMANENT,
193   - sizeof(dct_pipeline_dest)));
  190 + reinterpret_cast<j_common_ptr>(cinfo), JPOOL_PERMANENT, sizeof(dct_pipeline_dest)));
194 191 auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
195 192 dest->pub.init_destination = init_pipeline_destination;
196 193 dest->pub.empty_output_buffer = empty_pipeline_output_buffer;
... ... @@ -243,9 +240,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, Buffer* buffer)
243 240 cinfo->src = reinterpret_cast<jpeg_source_mgr*>(
244 241 // line-break
245 242 (*cinfo->mem->alloc_small)(
246   - reinterpret_cast<j_common_ptr>(cinfo),
247   - JPOOL_PERMANENT,
248   - sizeof(jpeg_source_mgr)));
  243 + reinterpret_cast<j_common_ptr>(cinfo), JPOOL_PERMANENT, sizeof(jpeg_source_mgr)));
249 244  
250 245 jpeg_source_mgr* src = cinfo->src;
251 246 src->init_source = init_buffer_source;
... ... @@ -262,16 +257,12 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
262 257 {
263 258 auto* cinfo = reinterpret_cast<jpeg_compress_struct*>(cinfo_p);
264 259  
265   -#if ( \
266   - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
267   - defined(__clang__))
  260 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
268 261 # pragma GCC diagnostic push
269 262 # pragma GCC diagnostic ignored "-Wold-style-cast"
270 263 #endif
271 264 jpeg_create_compress(cinfo);
272   -#if ( \
273   - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
274   - defined(__clang__))
  265 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
275 266 # pragma GCC diagnostic pop
276 267 #endif
277 268 static int const BUF_SIZE = 65536;
... ... @@ -290,11 +281,9 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
290 281  
291 282 jpeg_start_compress(cinfo, TRUE);
292 283  
293   - unsigned int width =
294   - cinfo->image_width * QIntC::to_uint(cinfo->input_components);
  284 + unsigned int width = cinfo->image_width * QIntC::to_uint(cinfo->input_components);
295 285 size_t expected_size = QIntC::to_size(cinfo->image_height) *
296   - QIntC::to_size(cinfo->image_width) *
297   - QIntC::to_size(cinfo->input_components);
  286 + QIntC::to_size(cinfo->image_width) * QIntC::to_size(cinfo->input_components);
298 287 if (b->getSize() != expected_size) {
299 288 throw std::runtime_error(
300 289 "Pl_DCT: image buffer size = " + std::to_string(b->getSize()) +
... ... @@ -316,16 +305,12 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b)
316 305 {
317 306 auto* cinfo = reinterpret_cast<jpeg_decompress_struct*>(cinfo_p);
318 307  
319   -#if ( \
320   - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
321   - defined(__clang__))
  308 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
322 309 # pragma GCC diagnostic push
323 310 # pragma GCC diagnostic ignored "-Wold-style-cast"
324 311 #endif
325 312 jpeg_create_decompress(cinfo);
326   -#if ( \
327   - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
328   - defined(__clang__))
  313 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
329 314 # pragma GCC diagnostic pop
330 315 #endif
331 316 jpeg_buffer_src(cinfo, b);
... ... @@ -333,10 +318,9 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b)
333 318 (void)jpeg_read_header(cinfo, TRUE);
334 319 (void)jpeg_calc_output_dimensions(cinfo);
335 320  
336   - unsigned int width =
337   - cinfo->output_width * QIntC::to_uint(cinfo->output_components);
338   - JSAMPARRAY buffer = (*cinfo->mem->alloc_sarray)(
339   - reinterpret_cast<j_common_ptr>(cinfo), JPOOL_IMAGE, width, 1);
  321 + unsigned int width = cinfo->output_width * QIntC::to_uint(cinfo->output_components);
  322 + JSAMPARRAY buffer =
  323 + (*cinfo->mem->alloc_sarray)(reinterpret_cast<j_common_ptr>(cinfo), JPOOL_IMAGE, width, 1);
340 324  
341 325 (void)jpeg_start_decompress(cinfo);
342 326 while (cinfo->output_scanline < cinfo->output_height) {
... ...
libqpdf/Pl_Flate.cc
... ... @@ -54,10 +54,7 @@ Pl_Flate::Members::~Members()
54 54 }
55 55  
56 56 Pl_Flate::Pl_Flate(
57   - char const* identifier,
58   - Pipeline* next,
59   - action_e action,
60   - unsigned int out_bufsize_int) :
  57 + char const* identifier, Pipeline* next, action_e action, unsigned int out_bufsize_int) :
61 58 Pipeline(identifier, next),
62 59 m(new Members(QIntC::to_size(out_bufsize_int), action))
63 60 {
... ... @@ -88,8 +85,7 @@ Pl_Flate::write(unsigned char const* data, size_t len)
88 85 {
89 86 if (m->outbuf == nullptr) {
90 87 throw std::logic_error(
91   - this->identifier +
92   - ": Pl_Flate: write() called after finish() called");
  88 + this->identifier + ": Pl_Flate: write() called after finish() called");
93 89 }
94 90  
95 91 // Write in chunks in case len is too big to fit in an int.
... ... @@ -99,8 +95,7 @@ Pl_Flate::write(unsigned char const* data, size_t len)
99 95 unsigned char const* buf = data;
100 96 while (bytes_left > 0) {
101 97 size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left);
102   - handleData(
103   - buf, bytes, (m->action == a_inflate ? Z_SYNC_FLUSH : Z_NO_FLUSH));
  98 + handleData(buf, bytes, (m->action == a_inflate ? Z_SYNC_FLUSH : Z_NO_FLUSH));
104 99 bytes_left -= bytes;
105 100 buf += bytes;
106 101 }
... ... @@ -124,9 +119,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
124 119  
125 120 // deflateInit and inflateInit are macros that use old-style
126 121 // casts.
127   -#if ( \
128   - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
129   - defined(__clang__))
  122 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
130 123 # pragma GCC diagnostic push
131 124 # pragma GCC diagnostic ignored "-Wold-style-cast"
132 125 #endif
... ... @@ -135,9 +128,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
135 128 } else {
136 129 err = inflateInit(&zstream);
137 130 }
138   -#if ( \
139   - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \
140   - defined(__clang__))
  131 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
141 132 # pragma GCC diagnostic pop
142 133 #endif
143 134  
... ... @@ -171,8 +162,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
171 162 // least one in qpdf's test suite). In some cases, we want
172 163 // to know about this, because it indicates incorrect
173 164 // compression, so call a callback if provided.
174   - this->warn(
175   - "input stream is complete but output may still be valid", err);
  165 + this->warn("input stream is complete but output may still be valid", err);
176 166 done = true;
177 167 break;
178 168  
... ... @@ -188,8 +178,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
188 178 // needed, so we're done for now.
189 179 done = true;
190 180 }
191   - uLong ready =
192   - QIntC::to_ulong(m->out_bufsize - zstream.avail_out);
  181 + uLong ready = QIntC::to_ulong(m->out_bufsize - zstream.avail_out);
193 182 if (ready > 0) {
194 183 this->getNext()->write(m->outbuf.get(), ready);
195 184 zstream.next_out = m->outbuf.get();
... ... @@ -249,10 +238,8 @@ Pl_Flate::checkError(char const* prefix, int error_code)
249 238 {
250 239 z_stream& zstream = *(static_cast<z_stream*>(m->zdata));
251 240 if (error_code != Z_OK) {
252   - char const* action_str =
253   - (m->action == a_deflate ? "deflate" : "inflate");
254   - std::string msg =
255   - this->identifier + ": " + action_str + ": " + prefix + ": ";
  241 + char const* action_str = (m->action == a_deflate ? "deflate" : "inflate");
  242 + std::string msg = this->identifier + ": " + action_str + ": " + prefix + ": ";
256 243  
257 244 if (zstream.msg) {
258 245 msg += zstream.msg;
... ... @@ -283,8 +270,7 @@ Pl_Flate::checkError(char const* prefix, int error_code)
283 270 break;
284 271  
285 272 default:
286   - msg += std::string("zlib unknown error (") +
287   - std::to_string(error_code) + ")";
  273 + msg += std::string("zlib unknown error (") + std::to_string(error_code) + ")";
288 274 break;
289 275 }
290 276 }
... ...
libqpdf/Pl_Function.cc
... ... @@ -13,8 +13,7 @@ Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_t fn) :
13 13 {
14 14 }
15 15  
16   -Pl_Function::Pl_Function(
17   - char const* identifier, Pipeline* next, writer_c_t fn, void* udata) :
  16 +Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_t fn, void* udata) :
18 17 Pipeline(identifier, next),
19 18 m(new Members(nullptr))
20 19 {
... ... @@ -22,14 +21,12 @@ Pl_Function::Pl_Function(
22 21 int code = fn(data, len, udata);
23 22 if (code != 0) {
24 23 throw std::runtime_error(
25   - std::string(identifier) + " function returned code " +
26   - std::to_string(code));
  24 + std::string(identifier) + " function returned code " + std::to_string(code));
27 25 }
28 26 };
29 27 }
30 28  
31   -Pl_Function::Pl_Function(
32   - char const* identifier, Pipeline* next, writer_c_char_t fn, void* udata) :
  29 +Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_char_t fn, void* udata) :
33 30 Pipeline(identifier, next),
34 31 m(new Members(nullptr))
35 32 {
... ... @@ -37,8 +34,7 @@ Pl_Function::Pl_Function(
37 34 int code = fn(reinterpret_cast<char const*>(data), len, udata);
38 35 if (code != 0) {
39 36 throw std::runtime_error(
40   - std::string(identifier) + " function returned code " +
41   - std::to_string(code));
  37 + std::string(identifier) + " function returned code " + std::to_string(code));
42 38 }
43 39 };
44 40 }
... ...
libqpdf/Pl_LZWDecoder.cc
... ... @@ -6,8 +6,7 @@
6 6 #include <cstring>
7 7 #include <stdexcept>
8 8  
9   -Pl_LZWDecoder::Pl_LZWDecoder(
10   - char const* identifier, Pipeline* next, bool early_code_change) :
  9 +Pl_LZWDecoder::Pl_LZWDecoder(char const* identifier, Pipeline* next, bool early_code_change) :
11 10 Pipeline(identifier, next),
12 11 code_size(9),
13 12 next(0),
... ... @@ -90,15 +89,13 @@ Pl_LZWDecoder::getFirstChar(unsigned int code)
90 89 } else if (code > 257) {
91 90 unsigned int idx = code - 258;
92 91 if (idx >= table.size()) {
93   - throw std::runtime_error(
94   - "Pl_LZWDecoder::getFirstChar: table overflow");
  92 + throw std::runtime_error("Pl_LZWDecoder::getFirstChar: table overflow");
95 93 }
96 94 Buffer& b = table.at(idx);
97 95 result = b.getBuffer()[0];
98 96 } else {
99 97 throw std::runtime_error(
100   - "Pl_LZWDecoder::getFirstChar called with invalid code (" +
101   - std::to_string(code) + ")");
  98 + "Pl_LZWDecoder::getFirstChar called with invalid code (" + std::to_string(code) + ")");
102 99 }
103 100 return result;
104 101 }
... ... @@ -117,8 +114,7 @@ Pl_LZWDecoder::addToTable(unsigned char next)
117 114 } else if (this->last_code > 257) {
118 115 unsigned int idx = this->last_code - 258;
119 116 if (idx >= table.size()) {
120   - throw std::runtime_error(
121   - "Pl_LZWDecoder::addToTable: table overflow");
  117 + throw std::runtime_error("Pl_LZWDecoder::addToTable: table overflow");
122 118 }
123 119 Buffer& b = table.at(idx);
124 120 last_data = b.getBuffer();
... ... @@ -182,8 +178,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
182 178 }
183 179 addToTable(next);
184 180 unsigned int change_idx = new_idx + code_change_delta;
185   - if ((change_idx == 511) || (change_idx == 1023) ||
186   - (change_idx == 2047)) {
  181 + if ((change_idx == 511) || (change_idx == 1023) || (change_idx == 2047)) {
187 182 ++this->code_size;
188 183 }
189 184 }
... ... @@ -194,8 +189,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
194 189 } else {
195 190 unsigned int idx = code - 258;
196 191 if (idx >= table.size()) {
197   - throw std::runtime_error(
198   - "Pl_LZWDecoder::handleCode: table overflow");
  192 + throw std::runtime_error("Pl_LZWDecoder::handleCode: table overflow");
199 193 }
200 194 Buffer& b = table.at(idx);
201 195 getNext()->write(b.getBuffer(), b.getSize());
... ...
libqpdf/Pl_MD5.cc
... ... @@ -26,8 +26,7 @@ Pl_MD5::write(unsigned char const* buf, size_t len)
26 26 unsigned char const* data = buf;
27 27 while (bytes_left > 0) {
28 28 size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left);
29   - this->md5.encodeDataIncrementally(
30   - reinterpret_cast<char const*>(data), bytes);
  29 + this->md5.encodeDataIncrementally(reinterpret_cast<char const*>(data), bytes);
31 30 bytes_left -= bytes;
32 31 data += bytes;
33 32 }
... ...
libqpdf/Pl_OStream.cc
... ... @@ -22,8 +22,7 @@ Pl_OStream::~Pl_OStream()
22 22 void
23 23 Pl_OStream::write(unsigned char const* buf, size_t len)
24 24 {
25   - m->os.write(
26   - reinterpret_cast<char const*>(buf), static_cast<std::streamsize>(len));
  25 + m->os.write(reinterpret_cast<char const*>(buf), static_cast<std::streamsize>(len));
27 26 }
28 27  
29 28 void
... ...
libqpdf/Pl_PNGFilter.cc
... ... @@ -29,36 +29,28 @@ Pl_PNGFilter::Pl_PNGFilter(
29 29 pos(0)
30 30 {
31 31 if (samples_per_pixel < 1) {
32   - throw std::runtime_error(
33   - "PNGFilter created with invalid samples_per_pixel");
  32 + throw std::runtime_error("PNGFilter created with invalid samples_per_pixel");
34 33 }
35   - if (!((bits_per_sample == 1) || (bits_per_sample == 2) ||
36   - (bits_per_sample == 4) || (bits_per_sample == 8) ||
37   - (bits_per_sample == 16))) {
38   - throw std::runtime_error(
39   - "PNGFilter created with invalid bits_per_sample not"
40   - " 1, 2, 4, 8, or 16");
  34 + if (!((bits_per_sample == 1) || (bits_per_sample == 2) || (bits_per_sample == 4) ||
  35 + (bits_per_sample == 8) || (bits_per_sample == 16))) {
  36 + throw std::runtime_error("PNGFilter created with invalid bits_per_sample not"
  37 + " 1, 2, 4, 8, or 16");
41 38 }
42 39 this->bytes_per_pixel = ((bits_per_sample * samples_per_pixel) + 7) / 8;
43   - unsigned long long bpr =
44   - ((columns * bits_per_sample * samples_per_pixel) + 7) / 8;
  40 + unsigned long long bpr = ((columns * bits_per_sample * samples_per_pixel) + 7) / 8;
45 41 if ((bpr == 0) || (bpr > (UINT_MAX - 1))) {
46   - throw std::runtime_error(
47   - "PNGFilter created with invalid columns value");
  42 + throw std::runtime_error("PNGFilter created with invalid columns value");
48 43 }
49 44 this->bytes_per_row = bpr & UINT_MAX;
50   - this->buf1 =
51   - QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
52   - this->buf2 =
53   - QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
  45 + this->buf1 = QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
  46 + this->buf2 = QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
54 47 memset(this->buf1.get(), 0, this->bytes_per_row + 1);
55 48 memset(this->buf2.get(), 0, this->bytes_per_row + 1);
56 49 this->cur_row = this->buf1.get();
57 50 this->prev_row = this->buf2.get();
58 51  
59 52 // number of bytes per incoming row
60   - this->incoming =
61   - (action == a_encode ? this->bytes_per_row : this->bytes_per_row + 1);
  53 + this->incoming = (action == a_encode ? this->bytes_per_row : this->bytes_per_row + 1);
62 54 }
63 55  
64 56 void
... ... @@ -197,8 +189,8 @@ Pl_PNGFilter::decodePaeth()
197 189 upper_left = above_buffer[i - bpp];
198 190 }
199 191  
200   - buffer[i] = static_cast<unsigned char>(
201   - buffer[i] + this->PaethPredictor(left, up, upper_left));
  192 + buffer[i] =
  193 + static_cast<unsigned char>(buffer[i] + this->PaethPredictor(left, up, upper_left));
202 194 }
203 195 }
204 196  
... ... @@ -227,8 +219,7 @@ Pl_PNGFilter::encodeRow()
227 219 getNext()->write(&ch, 1);
228 220 if (this->prev_row) {
229 221 for (unsigned int i = 0; i < this->bytes_per_row; ++i) {
230   - ch = static_cast<unsigned char>(
231   - this->cur_row[i] - this->prev_row[i]);
  222 + ch = static_cast<unsigned char>(this->cur_row[i] - this->prev_row[i]);
232 223 getNext()->write(&ch, 1);
233 224 }
234 225 } else {
... ...
libqpdf/Pl_QPDFTokenizer.cc
... ... @@ -11,15 +11,12 @@ Pl_QPDFTokenizer::Members::Members() :
11 11 }
12 12  
13 13 Pl_QPDFTokenizer::Pl_QPDFTokenizer(
14   - char const* identifier,
15   - QPDFObjectHandle::TokenFilter* filter,
16   - Pipeline* next) :
  14 + char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next) :
17 15 Pipeline(identifier, next),
18 16 m(new Members)
19 17 {
20 18 m->filter = filter;
21   - QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(
22   - m->filter, next);
  19 + QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, next);
23 20 m->tokenizer.allowEOF();
24 21 m->tokenizer.includeIgnorable();
25 22 }
... ... @@ -45,8 +42,8 @@ Pl_QPDFTokenizer::finish()
45 42 new BufferInputSource("tokenizer data", m->buf.getBuffer(), true));
46 43  
47 44 while (true) {
48   - QPDFTokenizer::Token token = m->tokenizer.readToken(
49   - input, "offset " + std::to_string(input->tell()), true);
  45 + QPDFTokenizer::Token token =
  46 + m->tokenizer.readToken(input, "offset " + std::to_string(input->tell()), true);
50 47 m->filter->handleToken(token);
51 48 if (token.getType() == QPDFTokenizer::tt_eof) {
52 49 break;
... ... @@ -56,15 +53,13 @@ Pl_QPDFTokenizer::finish()
56 53 input->read(&ch, 1);
57 54 m->filter->handleToken(
58 55 // line-break
59   - QPDFTokenizer::Token(
60   - QPDFTokenizer::tt_space, std::string(1, ch)));
  56 + QPDFTokenizer::Token(QPDFTokenizer::tt_space, std::string(1, ch)));
61 57 QTC::TC("qpdf", "Pl_QPDFTokenizer found ID");
62 58 m->tokenizer.expectInlineImage(input);
63 59 }
64 60 }
65 61 m->filter->handleEOF();
66   - QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(
67   - m->filter, nullptr);
  62 + QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, nullptr);
68 63 Pipeline* next = this->getNext(true);
69 64 if (next) {
70 65 next->finish();
... ...
libqpdf/Pl_RC4.cc
... ... @@ -19,17 +19,14 @@ void
19 19 Pl_RC4::write(unsigned char const* data, size_t len)
20 20 {
21 21 if (this->outbuf == nullptr) {
22   - throw std::logic_error(
23   - this->identifier +
24   - ": Pl_RC4: write() called after finish() called");
  22 + throw std::logic_error(this->identifier + ": Pl_RC4: write() called after finish() called");
25 23 }
26 24  
27 25 size_t bytes_left = len;
28 26 unsigned char const* p = data;
29 27  
30 28 while (bytes_left > 0) {
31   - size_t bytes =
32   - (bytes_left < this->out_bufsize ? bytes_left : out_bufsize);
  29 + size_t bytes = (bytes_left < this->out_bufsize ? bytes_left : out_bufsize);
33 30 bytes_left -= bytes;
34 31 // lgtm[cpp/weak-cryptographic-algorithm]
35 32 rc4.process(p, bytes, outbuf.get());
... ...
libqpdf/Pl_RunLength.cc
... ... @@ -10,8 +10,7 @@ Pl_RunLength::Members::Members(action_e action) :
10 10 {
11 11 }
12 12  
13   -Pl_RunLength::Pl_RunLength(
14   - char const* identifier, Pipeline* next, action_e action) :
  13 +Pl_RunLength::Pl_RunLength(char const* identifier, Pipeline* next, action_e action) :
15 14 Pipeline(identifier, next),
16 15 m(new Members(action))
17 16 {
... ... @@ -38,17 +37,12 @@ Pl_RunLength::encode(unsigned char const* data, size_t len)
38 37 {
39 38 for (size_t i = 0; i < len; ++i) {
40 39 if ((m->state == st_top) != (m->length <= 1)) {
41   - throw std::logic_error(
42   - "Pl_RunLength::encode: state/length inconsistency");
  40 + throw std::logic_error("Pl_RunLength::encode: state/length inconsistency");
43 41 }
44 42 unsigned char ch = data[i];
45   - if ((m->length > 0) &&
46   - ((m->state == st_copying) || (m->length < 128)) &&
  43 + if ((m->length > 0) && ((m->state == st_copying) || (m->length < 128)) &&
47 44 (ch == m->buf[m->length - 1])) {
48   - QTC::TC(
49   - "libtests",
50   - "Pl_RunLength: switch to run",
51   - (m->length == 128) ? 0 : 1);
  45 + QTC::TC("libtests", "Pl_RunLength: switch to run", (m->length == 128) ? 0 : 1);
52 46 if (m->state == st_copying) {
53 47 --m->length;
54 48 flush_encode();
... ... @@ -124,8 +118,7 @@ Pl_RunLength::flush_encode()
124 118 }
125 119 if (m->state == st_run) {
126 120 if ((m->length < 2) || (m->length > 128)) {
127   - throw std::logic_error(
128   - "Pl_RunLength: invalid length in flush_encode for run");
  121 + throw std::logic_error("Pl_RunLength: invalid length in flush_encode for run");
129 122 }
130 123 auto ch = static_cast<unsigned char>(257 - m->length);
131 124 this->getNext()->write(&ch, 1);
... ...
libqpdf/Pl_SHA2.cc
... ... @@ -51,8 +51,7 @@ void
51 51 Pl_SHA2::resetBits(int bits)
52 52 {
53 53 if (this->in_progress) {
54   - throw std::logic_error(
55   - "bit reset requested for in-progress SHA2 Pipeline");
  54 + throw std::logic_error("bit reset requested for in-progress SHA2 Pipeline");
56 55 }
57 56 this->crypto = QPDFCryptoProvider::getImpl();
58 57 this->crypto->SHA2_init(bits);
... ... @@ -62,8 +61,7 @@ std::string
62 61 Pl_SHA2::getRawDigest()
63 62 {
64 63 if (this->in_progress) {
65   - throw std::logic_error(
66   - "digest requested for in-progress SHA2 Pipeline");
  64 + throw std::logic_error("digest requested for in-progress SHA2 Pipeline");
67 65 }
68 66 return this->crypto->SHA2_digest();
69 67 }
... ... @@ -72,8 +70,7 @@ std::string
72 70 Pl_SHA2::getHexDigest()
73 71 {
74 72 if (this->in_progress) {
75   - throw std::logic_error(
76   - "digest requested for in-progress SHA2 Pipeline");
  73 + throw std::logic_error("digest requested for in-progress SHA2 Pipeline");
77 74 }
78 75 return QUtil::hex_encode(getRawDigest());
79 76 }
... ...
libqpdf/Pl_StdioFile.cc
... ... @@ -30,8 +30,7 @@ Pl_StdioFile::write(unsigned char const* buf, size_t len)
30 30 while (len > 0) {
31 31 so_far = fwrite(buf, 1, len, m->file);
32 32 if (so_far == 0) {
33   - QUtil::throw_system_error(
34   - this->identifier + ": Pl_StdioFile::write");
  33 + QUtil::throw_system_error(this->identifier + ": Pl_StdioFile::write");
35 34 } else {
36 35 buf += so_far;
37 36 len -= so_far;
... ... @@ -43,7 +42,6 @@ void
43 42 Pl_StdioFile::finish()
44 43 {
45 44 if ((fflush(m->file) == -1) && (errno == EBADF)) {
46   - throw std::logic_error(
47   - this->identifier + ": Pl_StdioFile::finish: stream already closed");
  45 + throw std::logic_error(this->identifier + ": Pl_StdioFile::finish: stream already closed");
48 46 }
49 47 }
... ...
libqpdf/Pl_TIFFPredictor.cc
... ... @@ -25,23 +25,17 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(
25 25 pos(0)
26 26 {
27 27 if (samples_per_pixel < 1) {
28   - throw std::runtime_error(
29   - "TIFFPredictor created with invalid samples_per_pixel");
  28 + throw std::runtime_error("TIFFPredictor created with invalid samples_per_pixel");
30 29 }
31   - if ((bits_per_sample < 1) ||
32   - (bits_per_sample > (8 * (sizeof(unsigned long long))))) {
33   - throw std::runtime_error(
34   - "TIFFPredictor created with invalid bits_per_sample");
  30 + if ((bits_per_sample < 1) || (bits_per_sample > (8 * (sizeof(unsigned long long))))) {
  31 + throw std::runtime_error("TIFFPredictor created with invalid bits_per_sample");
35 32 }
36   - unsigned long long bpr =
37   - ((columns * bits_per_sample * samples_per_pixel) + 7) / 8;
  33 + unsigned long long bpr = ((columns * bits_per_sample * samples_per_pixel) + 7) / 8;
38 34 if ((bpr == 0) || (bpr > (UINT_MAX - 1))) {
39   - throw std::runtime_error(
40   - "TIFFPredictor created with invalid columns value");
  35 + throw std::runtime_error("TIFFPredictor created with invalid columns value");
41 36 }
42 37 this->bytes_per_row = bpr & UINT_MAX;
43   - this->cur_row =
44   - QUtil::make_shared_array<unsigned char>(this->bytes_per_row);
  38 + this->cur_row = QUtil::make_shared_array<unsigned char>(this->bytes_per_row);
45 39 memset(this->cur_row.get(), 0, this->bytes_per_row);
46 40 }
47 41  
... ... @@ -72,10 +66,7 @@ Pl_TIFFPredictor::write(unsigned char const* data, size_t len)
72 66 void
73 67 Pl_TIFFPredictor::processRow()
74 68 {
75   - QTC::TC(
76   - "libtests",
77   - "Pl_TIFFPredictor processRow",
78   - (action == a_decode ? 0 : 1));
  69 + QTC::TC("libtests", "Pl_TIFFPredictor processRow", (action == a_decode ? 0 : 1));
79 70 BitWriter bw(this->getNext());
80 71 BitStream in(this->cur_row.get(), this->bytes_per_row);
81 72 std::vector<long long> prev;
... ...
libqpdf/QPDF.cc
... ... @@ -105,11 +105,10 @@ namespace
105 105 void
106 106 throwException()
107 107 {
108   - throw std::logic_error(
109   - "QPDF operation attempted on a QPDF object with no input "
110   - "source."
111   - " QPDF operations are invalid before processFile (or another"
112   - " process method) or after closeInputSource");
  108 + throw std::logic_error("QPDF operation attempted on a QPDF object with no input "
  109 + "source."
  110 + " QPDF operations are invalid before processFile (or another"
  111 + " process method) or after closeInputSource");
113 112 }
114 113 };
115 114 } // namespace
... ... @@ -130,8 +129,7 @@ QPDF::ForeignStreamData::ForeignStreamData(
130 129 {
131 130 }
132 131  
133   -QPDF::CopiedStreamDataProvider::CopiedStreamDataProvider(
134   - QPDF& destination_qpdf) :
  132 +QPDF::CopiedStreamDataProvider::CopiedStreamDataProvider(QPDF& destination_qpdf) :
135 133 QPDFObjectHandle::StreamDataProvider(true),
136 134 destination_qpdf(destination_qpdf)
137 135 {
... ... @@ -139,10 +137,7 @@ QPDF::CopiedStreamDataProvider::CopiedStreamDataProvider(
139 137  
140 138 bool
141 139 QPDF::CopiedStreamDataProvider::provideStreamData(
142   - QPDFObjGen const& og,
143   - Pipeline* pipeline,
144   - bool suppress_warnings,
145   - bool will_retry)
  140 + QPDFObjGen const& og, Pipeline* pipeline, bool suppress_warnings, bool will_retry)
146 141 {
147 142 std::shared_ptr<ForeignStreamData> foreign_data = foreign_stream_data[og];
148 143 bool result = false;
... ... @@ -154,8 +149,7 @@ QPDF::CopiedStreamDataProvider::provideStreamData(
154 149 auto foreign_stream = foreign_streams[og];
155 150 result = foreign_stream.pipeStreamData(
156 151 pipeline, nullptr, 0, qpdf_dl_none, suppress_warnings, will_retry);
157   - QTC::TC(
158   - "qpdf", "QPDF copy foreign with foreign_stream", result ? 0 : 1);
  152 + QTC::TC("qpdf", "QPDF copy foreign with foreign_stream", result ? 0 : 1);
159 153 }
160 154 return result;
161 155 }
... ... @@ -169,8 +163,7 @@ QPDF::CopiedStreamDataProvider::registerForeignStream(
169 163  
170 164 void
171 165 QPDF::CopiedStreamDataProvider::registerForeignStream(
172   - QPDFObjGen const& local_og,
173   - std::shared_ptr<ForeignStreamData> foreign_stream)
  166 + QPDFObjGen const& local_og, std::shared_ptr<ForeignStreamData> foreign_stream)
174 167 {
175 168 this->foreign_stream_data[local_og] = foreign_stream;
176 169 }
... ... @@ -269,8 +262,7 @@ QPDF::processFile(char const* filename, char const* password)
269 262 }
270 263  
271 264 void
272   -QPDF::processFile(
273   - char const* description, FILE* filep, bool close_file, char const* password)
  265 +QPDF::processFile(char const* description, FILE* filep, bool close_file, char const* password)
274 266 {
275 267 auto* fi = new FileInputSource(description, filep, close_file);
276 268 processInputSource(std::shared_ptr<InputSource>(fi), password);
... ... @@ -278,24 +270,18 @@ QPDF::processFile(
278 270  
279 271 void
280 272 QPDF::processMemoryFile(
281   - char const* description,
282   - char const* buf,
283   - size_t length,
284   - char const* password)
  273 + char const* description, char const* buf, size_t length, char const* password)
285 274 {
286 275 processInputSource(
287 276 std::shared_ptr<InputSource>(
288 277 // line-break
289 278 new BufferInputSource(
290   - description,
291   - new Buffer(QUtil::unsigned_char_pointer(buf), length),
292   - true)),
  279 + description, new Buffer(QUtil::unsigned_char_pointer(buf), length), true)),
293 280 password);
294 281 }
295 282  
296 283 void
297   -QPDF::processInputSource(
298   - std::shared_ptr<InputSource> source, char const* password)
  284 +QPDF::processInputSource(std::shared_ptr<InputSource> source, char const* password)
299 285 {
300 286 m->file = source;
301 287 parse(password);
... ... @@ -321,8 +307,7 @@ QPDF::emptyPDF()
321 307  
322 308 void
323 309 QPDF::registerStreamFilter(
324   - std::string const& filter_name,
325   - std::function<std::shared_ptr<QPDFStreamFilter>()> factory)
  310 + std::string const& filter_name, std::function<std::shared_ptr<QPDFStreamFilter>()> factory)
326 311 {
327 312 QPDF_Stream::registerStreamFilter(filter_name, factory);
328 313 }
... ... @@ -434,8 +419,7 @@ QPDF::findHeader()
434 419 // offsets in the file are such that 0 points to the
435 420 // beginning of the header.
436 421 QTC::TC("qpdf", "QPDF global offset");
437   - m->file = std::shared_ptr<InputSource>(
438   - new OffsetInputSource(m->file, global_offset));
  422 + m->file = std::shared_ptr<InputSource>(new OffsetInputSource(m->file, global_offset));
439 423 }
440 424 }
441 425 return valid;
... ... @@ -444,8 +428,7 @@ QPDF::findHeader()
444 428 bool
445 429 QPDF::findStartxref()
446 430 {
447   - if (readToken(m->file).isWord("startxref") &&
448   - readToken(m->file).isInteger()) {
  431 + if (readToken(m->file).isWord("startxref") && readToken(m->file).isInteger()) {
449 432 // Position in front of offset token
450 433 m->file->seek(m->file->getLastOffset(), SEEK_SET);
451 434 return true;
... ... @@ -479,8 +462,7 @@ QPDF::parse(char const* password)
479 462 PatternFinder sf(*this, &QPDF::findStartxref);
480 463 qpdf_offset_t xref_offset = 0;
481 464 if (m->file->findLast("startxref", start_offset, 0, sf)) {
482   - xref_offset =
483   - QUtil::string_to_ll(readToken(m->file).getValue().c_str());
  465 + xref_offset = QUtil::string_to_ll(readToken(m->file).getValue().c_str());
484 466 }
485 467  
486 468 try {
... ... @@ -493,8 +475,7 @@ QPDF::parse(char const* password)
493 475 } catch (QPDFExc&) {
494 476 throw;
495 477 } catch (std::exception& e) {
496   - throw damagedPDF(
497   - "", 0, std::string("error reading xref: ") + e.what());
  478 + throw damagedPDF("", 0, std::string("error reading xref: ") + e.what());
498 479 }
499 480 } catch (QPDFExc& e) {
500 481 if (m->attempt_recovery) {
... ... @@ -515,9 +496,8 @@ QPDF::inParse(bool v)
515 496 if (m->in_parse == v) {
516 497 // This happens if QPDFParser::parse tries to
517 498 // resolve an indirect object while it is parsing.
518   - throw std::logic_error(
519   - "QPDF: re-entrant parsing detected. This is a qpdf bug."
520   - " Please report at https://github.com/qpdf/qpdf/issues.");
  499 + throw std::logic_error("QPDF: re-entrant parsing detected. This is a qpdf bug."
  500 + " Please report at https://github.com/qpdf/qpdf/issues.");
521 501 }
522 502 m->in_parse = v;
523 503 }
... ... @@ -590,22 +570,19 @@ QPDF::reconstruct_xref(QPDFExc&amp; e)
590 570 qpdf_offset_t next_line_start = m->file->tell();
591 571 m->file->seek(line_start, SEEK_SET);
592 572 QPDFTokenizer::Token t1 = readToken(m->file, MAX_LEN);
593   - qpdf_offset_t token_start =
594   - m->file->tell() - toO(t1.getValue().length());
  573 + qpdf_offset_t token_start = m->file->tell() - toO(t1.getValue().length());
595 574 if (token_start >= next_line_start) {
596 575 // don't process yet -- wait until we get to the line
597 576 // containing this token
598 577 } else if (t1.isInteger()) {
599 578 QPDFTokenizer::Token t2 = readToken(m->file, MAX_LEN);
600   - if ((t2.isInteger()) &&
601   - (readToken(m->file, MAX_LEN).isWord("obj"))) {
  579 + if ((t2.isInteger()) && (readToken(m->file, MAX_LEN).isWord("obj"))) {
602 580 int obj = QUtil::string_to_int(t1.getValue().c_str());
603 581 int gen = QUtil::string_to_int(t2.getValue().c_str());
604 582 insertXrefEntry(obj, 1, token_start, gen, true);
605 583 }
606 584 } else if (!m->trailer.isInitialized() && t1.isWord("trailer")) {
607   - QPDFObjectHandle t =
608   - readObject(m->file, "trailer", QPDFObjGen(), false);
  585 + QPDFObjectHandle t = readObject(m->file, "trailer", QPDFObjGen(), false);
609 586 if (!t.isDictionary()) {
610 587 // Oh well. It was worth a try.
611 588 } else {
... ... @@ -623,10 +600,7 @@ QPDF::reconstruct_xref(QPDFExc&amp; e)
623 600 // with bad startxref pointers even when they have object
624 601 // streams.
625 602  
626   - throw damagedPDF(
627   - "",
628   - 0,
629   - "unable to find trailer dictionary while recovering damaged file");
  603 + throw damagedPDF("", 0, "unable to find trailer dictionary while recovering damaged file");
630 604 }
631 605  
632 606 // We could iterate through the objects looking for streams and
... ... @@ -666,10 +640,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
666 640 done = true;
667 641 }
668 642 } else {
669   - QTC::TC(
670   - "qpdf",
671   - "QPDF eof skipping spaces before xref",
672   - skipped_space ? 0 : 1);
  643 + QTC::TC("qpdf", "QPDF eof skipping spaces before xref", skipped_space ? 0 : 1);
673 644 done = true;
674 645 }
675 646 }
... ... @@ -681,8 +652,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
681 652 if ((strncmp(buf, "xref", 4) == 0) && QUtil::is_space(buf[4])) {
682 653 if (skipped_space) {
683 654 QTC::TC("qpdf", "QPDF xref skipped space");
684   - warn(damagedPDF(
685   - "", 0, "extraneous whitespace seen before xref"));
  655 + warn(damagedPDF("", 0, "extraneous whitespace seen before xref"));
686 656 }
687 657 QTC::TC(
688 658 "qpdf",
... ... @@ -724,8 +694,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
724 694 "",
725 695 0,
726 696 ("reported number of objects (" + std::to_string(size) +
727   - ") is not one plus the highest object number (" +
728   - std::to_string(max_obj) + ")")));
  697 + ") is not one plus the highest object number (" + std::to_string(max_obj) + ")")));
729 698 }
730 699  
731 700 // We no longer need the deleted_objects table, so go ahead and
... ... @@ -782,8 +751,7 @@ QPDF::parse_xrefFirst(std::string const&amp; line, int&amp; obj, int&amp; num, int&amp; bytes)
782 751 }
783 752  
784 753 bool
785   -QPDF::parse_xrefEntry(
786   - std::string const& line, qpdf_offset_t& f1, int& f2, char& type)
  754 +QPDF::parse_xrefEntry(std::string const& line, qpdf_offset_t& f1, int& f2, char& type)
787 755 {
788 756 // is_space and is_digit both return false on '\0', so this will
789 757 // not overrun the null-terminated buffer.
... ... @@ -891,8 +859,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
891 859 if (!parse_xrefEntry(xref_entry, f1, f2, type)) {
892 860 QTC::TC("qpdf", "QPDF invalid xref entry");
893 861 throw damagedPDF(
894   - "xref table",
895   - "invalid xref entry (obj=" + std::to_string(i) + ")");
  862 + "xref table", "invalid xref entry (obj=" + std::to_string(i) + ")");
896 863 }
897 864 if (type == 'f') {
898 865 // Save deleted items until after we've checked the
... ... @@ -911,8 +878,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
911 878 }
912 879  
913 880 // Set offset to previous xref table if any
914   - QPDFObjectHandle cur_trailer =
915   - readObject(m->file, "trailer", QPDFObjGen(), false);
  881 + QPDFObjectHandle cur_trailer = readObject(m->file, "trailer", QPDFObjGen(), false);
916 882 if (!cur_trailer.isDictionary()) {
917 883 QTC::TC("qpdf", "QPDF missing trailer");
918 884 throw damagedPDF("", "expected trailer dictionary");
... ... @@ -927,8 +893,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
927 893 }
928 894 if (!m->trailer.getKey("/Size").isInteger()) {
929 895 QTC::TC("qpdf", "QPDF trailer size not integer");
930   - throw damagedPDF(
931   - "trailer", "/Size key in trailer dictionary is not an integer");
  896 + throw damagedPDF("trailer", "/Size key in trailer dictionary is not an integer");
932 897 }
933 898 }
934 899  
... ... @@ -940,11 +905,9 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
940 905 // Read the xref stream but disregard any return value
941 906 // -- we'll use our trailer's /Prev key instead of the
942 907 // xref stream's.
943   - (void)read_xrefStream(
944   - cur_trailer.getKey("/XRefStm").getIntValue());
  908 + (void)read_xrefStream(cur_trailer.getKey("/XRefStm").getIntValue());
945 909 } else {
946   - throw damagedPDF(
947   - "xref stream", xref_offset, "invalid /XRefStm");
  910 + throw damagedPDF("xref stream", xref_offset, "invalid /XRefStm");
948 911 }
949 912 }
950 913 }
... ... @@ -957,8 +920,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
957 920 if (cur_trailer.hasKey("/Prev")) {
958 921 if (!cur_trailer.getKey("/Prev").isInteger()) {
959 922 QTC::TC("qpdf", "QPDF trailer prev not integer");
960   - throw damagedPDF(
961   - "trailer", "/Prev key in trailer dictionary is not an integer");
  923 + throw damagedPDF("trailer", "/Prev key in trailer dictionary is not an integer");
962 924 }
963 925 QTC::TC("qpdf", "QPDF prev key in trailer dictionary");
964 926 xref_offset = cur_trailer.getKey("/Prev").getIntValue();
... ... @@ -977,13 +939,8 @@ QPDF::read_xrefStream(qpdf_offset_t xref_offset)
977 939 QPDFObjGen x_og;
978 940 QPDFObjectHandle xref_obj;
979 941 try {
980   - xref_obj = readObjectAtOffset(
981   - false,
982   - xref_offset,
983   - "xref stream",
984   - QPDFObjGen(0, 0),
985   - x_og,
986   - true);
  942 + xref_obj =
  943 + readObjectAtOffset(false, xref_offset, "xref stream", QPDFObjGen(0, 0), x_og, true);
987 944 } catch (QPDFExc&) {
988 945 // ignore -- report error below
989 946 }
... ... @@ -1008,12 +965,9 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1008 965 QPDFObjectHandle dict = xref_obj.getDict();
1009 966 QPDFObjectHandle W_obj = dict.getKey("/W");
1010 967 QPDFObjectHandle Index_obj = dict.getKey("/Index");
1011   - if (!(W_obj.isArray() && (W_obj.getArrayNItems() >= 3) &&
1012   - W_obj.getArrayItem(0).isInteger() &&
1013   - W_obj.getArrayItem(1).isInteger() &&
1014   - W_obj.getArrayItem(2).isInteger() &&
1015   - dict.getKey("/Size").isInteger() &&
1016   - (Index_obj.isArray() || Index_obj.isNull()))) {
  968 + if (!(W_obj.isArray() && (W_obj.getArrayNItems() >= 3) && W_obj.getArrayItem(0).isInteger() &&
  969 + W_obj.getArrayItem(1).isInteger() && W_obj.getArrayItem(2).isInteger() &&
  970 + dict.getKey("/Size").isInteger() && (Index_obj.isArray() || Index_obj.isNull()))) {
1017 971 throw damagedPDF(
1018 972 "xref stream",
1019 973 xref_offset,
... ... @@ -1035,12 +989,9 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1035 989 }
1036 990 if (entry_size == 0) {
1037 991 throw damagedPDF(
1038   - "xref stream",
1039   - xref_offset,
1040   - "Cross-reference stream's /W indicates entry size of 0");
  992 + "xref stream", xref_offset, "Cross-reference stream's /W indicates entry size of 0");
1041 993 }
1042   - unsigned long long max_num_entries =
1043   - static_cast<unsigned long long>(-1) / entry_size;
  994 + unsigned long long max_num_entries = static_cast<unsigned long long>(-1) / entry_size;
1044 995  
1045 996 std::vector<long long> indx;
1046 997 if (Index_obj.isArray()) {
... ... @@ -1059,8 +1010,8 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1059 1010 throw damagedPDF(
1060 1011 "xref stream",
1061 1012 xref_offset,
1062   - ("Cross-reference stream's /Index's item " +
1063   - std::to_string(i) + " is not an integer"));
  1013 + ("Cross-reference stream's /Index's item " + std::to_string(i) +
  1014 + " is not an integer"));
1064 1015 }
1065 1016 }
1066 1017 QTC::TC("qpdf", "QPDF xref /Index is array", n_index == 2 ? 0 : 1);
... ... @@ -1078,8 +1029,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1078 1029 "xref stream",
1079 1030 xref_offset,
1080 1031 ("Cross-reference stream claims to contain too many entries: " +
1081   - std::to_string(indx.at(i)) + " " +
1082   - std::to_string(max_num_entries) + " " +
  1032 + std::to_string(indx.at(i)) + " " + std::to_string(max_num_entries) + " " +
1083 1033 std::to_string(num_entries)));
1084 1034 }
1085 1035 num_entries += toS(indx.at(i));
... ... @@ -1097,8 +1047,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1097 1047 "xref stream",
1098 1048 xref_offset,
1099 1049 ("Cross-reference stream data has the wrong size; expected = " +
1100   - std::to_string(expected_size) +
1101   - "; actual = " + std::to_string(actual_size)));
  1050 + std::to_string(expected_size) + "; actual = " + std::to_string(actual_size)));
1102 1051 if (expected_size > actual_size) {
1103 1052 throw x;
1104 1053 } else {
... ... @@ -1137,8 +1086,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1137 1086 // an uncompressed object record, in which case the generation
1138 1087 // number appears as the third field.
1139 1088 int obj = toI(indx.at(cur_chunk));
1140   - if ((obj < 0) ||
1141   - ((std::numeric_limits<int>::max() - obj) < chunk_count)) {
  1089 + if ((obj < 0) || ((std::numeric_limits<int>::max() - obj) < chunk_count)) {
1142 1090 std::ostringstream msg;
1143 1091 msg.imbue(std::locale::classic());
1144 1092 msg << "adding " << chunk_count << " to " << obj
... ... @@ -1181,8 +1129,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1181 1129 if (dict.hasKey("/Prev")) {
1182 1130 if (!dict.getKey("/Prev").isInteger()) {
1183 1131 throw damagedPDF(
1184   - "xref stream",
1185   - "/Prev key in xref stream dictionary is not an integer");
  1132 + "xref stream", "/Prev key in xref stream dictionary is not an integer");
1186 1133 }
1187 1134 QTC::TC("qpdf", "QPDF prev key in xref stream dictionary");
1188 1135 xref_offset = dict.getKey("/Prev").getIntValue();
... ... @@ -1241,9 +1188,7 @@ QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite)
1241 1188 break;
1242 1189  
1243 1190 default:
1244   - throw damagedPDF(
1245   - "xref stream",
1246   - "unknown xref stream entry type " + std::to_string(f0));
  1191 + throw damagedPDF("xref stream", "unknown xref stream entry type " + std::to_string(f0));
1247 1192 break;
1248 1193 }
1249 1194 }
... ... @@ -1262,9 +1207,8 @@ QPDF::showXRefTable()
1262 1207 break;
1263 1208  
1264 1209 case 2:
1265   - *m->log->getInfo()
1266   - << "compressed; stream = " << entry.getObjStreamNumber()
1267   - << ", index = " << entry.getObjStreamIndex();
  1210 + *m->log->getInfo() << "compressed; stream = " << entry.getObjStreamNumber()
  1211 + << ", index = " << entry.getObjStreamIndex();
1268 1212 break;
1269 1213  
1270 1214 default:
... ... @@ -1337,8 +1281,7 @@ QPDF::getAllObjects()
1337 1281 }
1338 1282  
1339 1283 void
1340   -QPDF::setLastObjectDescription(
1341   - std::string const& description, QPDFObjGen const& og)
  1284 +QPDF::setLastObjectDescription(std::string const& description, QPDFObjGen const& og)
1342 1285 {
1343 1286 m->last_object_description.clear();
1344 1287 if (!description.empty()) {
... ... @@ -1369,16 +1312,13 @@ QPDF::readObject(
1369 1312 decrypter_ph = std::make_shared<StringDecrypter>(this, og);
1370 1313 decrypter = decrypter_ph.get();
1371 1314 }
1372   - auto object =
1373   - QPDFParser(
1374   - input, m->last_object_description, m->tokenizer, decrypter, this)
1375   - .parse(empty, false);
  1315 + auto object = QPDFParser(input, m->last_object_description, m->tokenizer, decrypter, this)
  1316 + .parse(empty, false);
1376 1317 if (empty) {
1377 1318 // Nothing in the PDF spec appears to allow empty objects, but
1378 1319 // they have been encountered in actual PDF files and Adobe
1379 1320 // Reader appears to ignore them.
1380   - warn(damagedPDF(
1381   - input, input->getLastOffset(), "empty object treated as null"));
  1321 + warn(damagedPDF(input, input->getLastOffset(), "empty object treated as null"));
1382 1322 } else if (object.isDictionary() && (!in_object_stream)) {
1383 1323 // check for stream
1384 1324 qpdf_offset_t cur_offset = input->tell();
... ... @@ -1428,9 +1368,7 @@ QPDF::readObject(
1428 1368 }
1429 1369 } else if (QUtil::is_space(ch)) {
1430 1370 warn(damagedPDF(
1431   - input,
1432   - input->tell(),
1433   - "stream keyword followed by extraneous whitespace"));
  1371 + input, input->tell(), "stream keyword followed by extraneous whitespace"));
1434 1372 done = false;
1435 1373 } else {
1436 1374 QTC::TC("qpdf", "QPDF stream without newline");
... ... @@ -1450,13 +1388,11 @@ QPDF::readObject(
1450 1388 size_t length = 0;
1451 1389  
1452 1390 try {
1453   - std::map<std::string, QPDFObjectHandle> dict =
1454   - object.getDictAsMap();
  1391 + std::map<std::string, QPDFObjectHandle> dict = object.getDictAsMap();
1455 1392  
1456 1393 if (dict.count("/Length") == 0) {
1457 1394 QTC::TC("qpdf", "QPDF stream without length");
1458   - throw damagedPDF(
1459   - input, offset, "stream dictionary lacks /Length key");
  1395 + throw damagedPDF(input, offset, "stream dictionary lacks /Length key");
1460 1396 }
1461 1397  
1462 1398 QPDFObjectHandle length_obj = dict["/Length"];
... ... @@ -1475,8 +1411,7 @@ QPDF::readObject(
1475 1411 input->seek(toO(length), SEEK_CUR);
1476 1412 if (!readToken(input).isWord("endstream")) {
1477 1413 QTC::TC("qpdf", "QPDF missing endstream");
1478   - throw damagedPDF(
1479   - input, input->getLastOffset(), "expected endstream");
  1414 + throw damagedPDF(input, input->getLastOffset(), "expected endstream");
1480 1415 }
1481 1416 } catch (QPDFExc& e) {
1482 1417 if (m->attempt_recovery) {
... ... @@ -1486,9 +1421,7 @@ QPDF::readObject(
1486 1421 throw;
1487 1422 }
1488 1423 }
1489   - object = newIndirect(
1490   - og,
1491   - QPDF_Stream::create(this, og, object, stream_offset, length));
  1424 + object = newIndirect(og, QPDF_Stream::create(this, og, object, stream_offset, length));
1492 1425 } else {
1493 1426 input->seek(cur_offset, SEEK_SET);
1494 1427 }
... ... @@ -1514,14 +1447,11 @@ QPDF::findEndstream()
1514 1447  
1515 1448 size_t
1516 1449 QPDF::recoverStreamLength(
1517   - std::shared_ptr<InputSource> input,
1518   - QPDFObjGen const& og,
1519   - qpdf_offset_t stream_offset)
  1450 + std::shared_ptr<InputSource> input, QPDFObjGen const& og, qpdf_offset_t stream_offset)
1520 1451 {
1521 1452 // Try to reconstruct stream length by looking for
1522 1453 // endstream or endobj
1523   - warn(damagedPDF(
1524   - input, stream_offset, "attempting to recover stream length"));
  1454 + warn(damagedPDF(input, stream_offset, "attempting to recover stream length"));
1525 1455  
1526 1456 PatternFinder ef(*this, &QPDF::findEndstream);
1527 1457 size_t length = 0;
... ... @@ -1544,8 +1474,7 @@ QPDF::recoverStreamLength(
1544 1474 if (entry.getType() == 1) {
1545 1475 qpdf_offset_t obj_offset = entry.getOffset();
1546 1476 if ((obj_offset > stream_offset) &&
1547   - ((this_obj_offset == 0) ||
1548   - (this_obj_offset > obj_offset))) {
  1477 + ((this_obj_offset == 0) || (this_obj_offset > obj_offset))) {
1549 1478 this_obj_offset = obj_offset;
1550 1479 this_og = iter.first;
1551 1480 }
... ... @@ -1562,14 +1491,10 @@ QPDF::recoverStreamLength(
1562 1491  
1563 1492 if (length == 0) {
1564 1493 warn(damagedPDF(
1565   - input,
1566   - stream_offset,
1567   - "unable to recover stream data; treating stream as empty"));
  1494 + input, stream_offset, "unable to recover stream data; treating stream as empty"));
1568 1495 } else {
1569   - warn(damagedPDF(
1570   - input,
1571   - stream_offset,
1572   - "recovered stream length: " + std::to_string(length)));
  1496 + warn(
  1497 + damagedPDF(input, stream_offset, "recovered stream length: " + std::to_string(length)));
1573 1498 }
1574 1499  
1575 1500 QTC::TC("qpdf", "QPDF recovered stream length");
... ... @@ -1579,8 +1504,7 @@ QPDF::recoverStreamLength(
1579 1504 QPDFTokenizer::Token
1580 1505 QPDF::readToken(std::shared_ptr<InputSource> input, size_t max_len)
1581 1506 {
1582   - return m->tokenizer.readToken(
1583   - input, m->last_object_description, true, max_len);
  1507 + return m->tokenizer.readToken(input, m->last_object_description, true, max_len);
1584 1508 }
1585 1509  
1586 1510 QPDFObjectHandle
... ... @@ -1650,8 +1574,7 @@ QPDF::readObjectAtOffset(
1650 1574 }
1651 1575 if (check_og && (exp_og != og)) {
1652 1576 QTC::TC("qpdf", "QPDF err wrong objid/generation");
1653   - QPDFExc e =
1654   - damagedPDF(offset, "expected " + exp_og.unparse(' ') + " obj");
  1577 + QPDFExc e = damagedPDF(offset, "expected " + exp_og.unparse(' ') + " obj");
1655 1578 if (try_recovery) {
1656 1579 // Will be retried below
1657 1580 throw e;
... ... @@ -1665,11 +1588,10 @@ QPDF::readObjectAtOffset(
1665 1588 if (try_recovery) {
1666 1589 // Try again after reconstructing xref table
1667 1590 reconstruct_xref(e);
1668   - if (m->xref_table.count(exp_og) &&
1669   - (m->xref_table[exp_og].getType() == 1)) {
  1591 + if (m->xref_table.count(exp_og) && (m->xref_table[exp_og].getType() == 1)) {
1670 1592 qpdf_offset_t new_offset = m->xref_table[exp_og].getOffset();
1671   - QPDFObjectHandle result = readObjectAtOffset(
1672   - false, new_offset, description, exp_og, og, false);
  1593 + QPDFObjectHandle result =
  1594 + readObjectAtOffset(false, new_offset, description, exp_og, og, false);
1673 1595 QTC::TC("qpdf", "QPDF recovered in readObjectAtOffset");
1674 1596 return result;
1675 1597 } else {
... ... @@ -1777,8 +1699,7 @@ QPDF::resolve(QPDFObjGen og)
1777 1699 // indirectly in some key that has to be resolved during
1778 1700 // object parsing, such as stream length.
1779 1701 QTC::TC("qpdf", "QPDF recursion loop in resolve");
1780   - warn(damagedPDF(
1781   - "", "loop detected resolving object " + og.unparse(' ')));
  1702 + warn(damagedPDF("", "loop detected resolving object " + og.unparse(' ')));
1782 1703 updateCache(og, QPDF_Null::create(), -1, -1);
1783 1704 return;
1784 1705 }
... ... @@ -1793,8 +1714,7 @@ QPDF::resolve(QPDFObjGen og)
1793 1714 qpdf_offset_t offset = entry.getOffset();
1794 1715 // Object stored in cache by readObjectAtOffset
1795 1716 QPDFObjGen a_og;
1796   - QPDFObjectHandle oh =
1797   - readObjectAtOffset(true, offset, "", og, a_og, false);
  1717 + QPDFObjectHandle oh = readObjectAtOffset(true, offset, "", og, a_og, false);
1798 1718 }
1799 1719 break;
1800 1720  
... ... @@ -1804,19 +1724,13 @@ QPDF::resolve(QPDFObjGen og)
1804 1724  
1805 1725 default:
1806 1726 throw damagedPDF(
1807   - "",
1808   - 0,
1809   - ("object " + og.unparse('/') +
1810   - " has unexpected xref entry type"));
  1727 + "", 0, ("object " + og.unparse('/') + " has unexpected xref entry type"));
1811 1728 }
1812 1729 } catch (QPDFExc& e) {
1813 1730 warn(e);
1814 1731 } catch (std::exception& e) {
1815 1732 warn(damagedPDF(
1816   - "",
1817   - 0,
1818   - ("object " + og.unparse('/') +
1819   - ": error reading object: " + e.what())));
  1733 + "", 0, ("object " + og.unparse('/') + ": error reading object: " + e.what())));
1820 1734 }
1821 1735 }
1822 1736  
... ... @@ -1841,8 +1755,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1841 1755 QPDFObjectHandle obj_stream = getObjectByID(obj_stream_number, 0);
1842 1756 if (!obj_stream.isStream()) {
1843 1757 throw damagedPDF(
1844   - "supposed object stream " + std::to_string(obj_stream_number) +
1845   - " is not a stream");
  1758 + "supposed object stream " + std::to_string(obj_stream_number) + " is not a stream");
1846 1759 }
1847 1760  
1848 1761 // For linearization data in the object, use the data from the
... ... @@ -1855,14 +1768,12 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1855 1768 if (!dict.isDictionaryOfType("/ObjStm")) {
1856 1769 QTC::TC("qpdf", "QPDF ERR object stream with wrong type");
1857 1770 warn(damagedPDF(
1858   - "supposed object stream " + std::to_string(obj_stream_number) +
1859   - " has wrong type"));
  1771 + "supposed object stream " + std::to_string(obj_stream_number) + " has wrong type"));
1860 1772 }
1861 1773  
1862 1774 if (!(dict.getKey("/N").isInteger() && dict.getKey("/First").isInteger())) {
1863 1775 throw damagedPDF(
1864   - ("object stream " + std::to_string(obj_stream_number) +
1865   - " has incorrect keys"));
  1776 + ("object stream " + std::to_string(obj_stream_number) + " has incorrect keys"));
1866 1777 }
1867 1778  
1868 1779 int n = dict.getKey("/N").getIntValueAsInt();
... ... @@ -1874,8 +1785,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1874 1785 auto input = std::shared_ptr<InputSource>(
1875 1786 // line-break
1876 1787 new BufferInputSource(
1877   - (m->file->getName() + " object stream " +
1878   - std::to_string(obj_stream_number)),
  1788 + (m->file->getName() + " object stream " + std::to_string(obj_stream_number)),
1879 1789 bp.get()));
1880 1790  
1881 1791 for (int i = 0; i < n; ++i) {
... ... @@ -1902,8 +1812,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1902 1812 for (auto const& iter: offsets) {
1903 1813 QPDFObjGen og(iter.first, 0);
1904 1814 QPDFXRefEntry const& entry = m->xref_table[og];
1905   - if ((entry.getType() == 2) &&
1906   - (entry.getObjStreamNumber() == obj_stream_number)) {
  1815 + if ((entry.getType() == 2) && (entry.getObjStreamNumber() == obj_stream_number)) {
1907 1816 int offset = iter.second;
1908 1817 input->seek(offset, SEEK_SET);
1909 1818 QPDFObjectHandle oh = readObject(input, "", og, true);
... ... @@ -1956,8 +1865,7 @@ QPDF::nextObjGen()
1956 1865 {
1957 1866 int max_objid = toI(getObjectCount());
1958 1867 if (max_objid == std::numeric_limits<int>::max()) {
1959   - throw std::range_error(
1960   - "max object id is too high to create new objects");
  1868 + throw std::range_error("max object id is too high to create new objects");
1961 1869 }
1962 1870 return QPDFObjGen(max_objid + 1, 0);
1963 1871 }
... ... @@ -1974,8 +1882,7 @@ QPDFObjectHandle
1974 1882 QPDF::makeIndirectObject(QPDFObjectHandle oh)
1975 1883 {
1976 1884 if (!oh.isInitialized()) {
1977   - throw std::logic_error(
1978   - "attempted to make an uninitialized QPDFObjectHandle indirect");
  1885 + throw std::logic_error("attempted to make an uninitialized QPDFObjectHandle indirect");
1979 1886 }
1980 1887 return makeIndirectFromQPDFObject(oh.getObj());
1981 1888 }
... ... @@ -1989,16 +1896,15 @@ QPDF::newReserved()
1989 1896 QPDFObjectHandle
1990 1897 QPDF::newStream()
1991 1898 {
1992   - return makeIndirectFromQPDFObject(QPDF_Stream::create(
1993   - this, nextObjGen(), QPDFObjectHandle::newDictionary(), 0, 0));
  1899 + return makeIndirectFromQPDFObject(
  1900 + QPDF_Stream::create(this, nextObjGen(), QPDFObjectHandle::newDictionary(), 0, 0));
1994 1901 }
1995 1902  
1996 1903 QPDFObjectHandle
1997 1904 QPDF::newStream(std::shared_ptr<Buffer> data)
1998 1905 {
1999 1906 auto result = newStream();
2000   - result.replaceStreamData(
2001   - data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
  1907 + result.replaceStreamData(data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
2002 1908 return result;
2003 1909 }
2004 1910  
... ... @@ -2006,8 +1912,7 @@ QPDFObjectHandle
2006 1912 QPDF::newStream(std::string const& data)
2007 1913 {
2008 1914 auto result = newStream();
2009   - result.replaceStreamData(
2010   - data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
  1915 + result.replaceStreamData(data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
2011 1916 return result;
2012 1917 }
2013 1918  
... ... @@ -2025,8 +1930,7 @@ QPDF::reserveObjectIfNotExists(QPDFObjGen const&amp; og)
2025 1930 QPDFObjectHandle
2026 1931 QPDF::reserveStream(QPDFObjGen const& og)
2027 1932 {
2028   - return {
2029   - QPDF_Stream::create(this, og, QPDFObjectHandle::newDictionary(), 0, 0)};
  1933 + return {QPDF_Stream::create(this, og, QPDFObjectHandle::newDictionary(), 0, 0)};
2030 1934 }
2031 1935  
2032 1936 QPDFObjectHandle
... ... @@ -2069,8 +1973,7 @@ QPDF::replaceObject(QPDFObjGen const&amp; og, QPDFObjectHandle oh)
2069 1973 {
2070 1974 if (oh.isIndirect() || !oh.isInitialized()) {
2071 1975 QTC::TC("qpdf", "QPDF replaceObject called with indirect object");
2072   - throw std::logic_error(
2073   - "QPDF::replaceObject called with indirect object handle");
  1976 + throw std::logic_error("QPDF::replaceObject called with indirect object handle");
2074 1977 }
2075 1978 updateCache(og, oh.getObj(), -1, -1);
2076 1979 }
... ... @@ -2132,14 +2035,12 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign)
2132 2035 // the intention is to not update the pages tree.
2133 2036 if (!foreign.isIndirect()) {
2134 2037 QTC::TC("qpdf", "QPDF copyForeign direct");
2135   - throw std::logic_error(
2136   - "QPDF::copyForeign called with direct object handle");
  2038 + throw std::logic_error("QPDF::copyForeign called with direct object handle");
2137 2039 }
2138 2040 QPDF& other = foreign.getQPDF();
2139 2041 if (&other == this) {
2140 2042 QTC::TC("qpdf", "QPDF copyForeign not foreign");
2141   - throw std::logic_error(
2142   - "QPDF::copyForeign called with object from this QPDF");
  2043 + throw std::logic_error("QPDF::copyForeign called with object from this QPDF");
2143 2044 }
2144 2045  
2145 2046 ObjCopier& obj_copier = m->object_copiers[other.m->unique_id];
... ... @@ -2163,8 +2064,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign)
2163 2064  
2164 2065 // Copy any new objects and replace the reservations.
2165 2066 for (auto& to_copy: obj_copier.to_copy) {
2166   - QPDFObjectHandle copy =
2167   - replaceForeignIndirectObjects(to_copy, obj_copier, true);
  2067 + QPDFObjectHandle copy = replaceForeignIndirectObjects(to_copy, obj_copier, true);
2168 2068 if (!to_copy.isStream()) {
2169 2069 QPDFObjGen og(to_copy.getObjGen());
2170 2070 replaceReserved(obj_copier.object_map[og], copy);
... ... @@ -2180,8 +2080,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top)
2180 2080 {
2181 2081 auto foreign_tc = foreign.getTypeCode();
2182 2082 if (foreign_tc == ::ot_reserved) {
2183   - throw std::logic_error(
2184   - "QPDF: attempting to copy a foreign reserved object");
  2083 + throw std::logic_error("QPDF: attempting to copy a foreign reserved object");
2185 2084 }
2186 2085  
2187 2086 if (foreign.isPagesObject()) {
... ... @@ -2209,8 +2108,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top)
2209 2108 QTC::TC("qpdf", "QPDF copy indirect");
2210 2109 if (obj_copier.object_map.count(foreign_og) == 0) {
2211 2110 obj_copier.to_copy.push_back(foreign);
2212   - obj_copier.object_map[foreign_og] =
2213   - foreign.isStream() ? newStream() : newReserved();
  2111 + obj_copier.object_map[foreign_og] = foreign.isStream() ? newStream() : newReserved();
2214 2112 }
2215 2113 }
2216 2114  
... ... @@ -2234,8 +2132,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top)
2234 2132 }
2235 2133  
2236 2134 QPDFObjectHandle
2237   -QPDF::replaceForeignIndirectObjects(
2238   - QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top)
  2135 +QPDF::replaceForeignIndirectObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top)
2239 2136 {
2240 2137 auto foreign_tc = foreign.getTypeCode();
2241 2138 QPDFObjectHandle result;
... ... @@ -2257,8 +2154,7 @@ QPDF::replaceForeignIndirectObjects(
2257 2154 for (int i = 0; i < n; ++i) {
2258 2155 result.appendItem(
2259 2156 // line-break
2260   - replaceForeignIndirectObjects(
2261   - foreign.getArrayItem(i), obj_copier, false));
  2157 + replaceForeignIndirectObjects(foreign.getArrayItem(i), obj_copier, false));
2262 2158 }
2263 2159 } else if (foreign_tc == ::ot_dictionary) {
2264 2160 QTC::TC("qpdf", "QPDF replace dictionary");
... ... @@ -2266,9 +2162,7 @@ QPDF::replaceForeignIndirectObjects(
2266 2162 std::set<std::string> keys = foreign.getKeys();
2267 2163 for (auto const& iter: keys) {
2268 2164 result.replaceKey(
2269   - iter,
2270   - replaceForeignIndirectObjects(
2271   - foreign.getKey(iter), obj_copier, false));
  2165 + iter, replaceForeignIndirectObjects(foreign.getKey(iter), obj_copier, false));
2272 2166 }
2273 2167 } else if (foreign_tc == ::ot_stream) {
2274 2168 QTC::TC("qpdf", "QPDF replace stream");
... ... @@ -2279,9 +2173,7 @@ QPDF::replaceForeignIndirectObjects(
2279 2173 std::set<std::string> keys = old_dict.getKeys();
2280 2174 for (auto const& iter: keys) {
2281 2175 dict.replaceKey(
2282   - iter,
2283   - replaceForeignIndirectObjects(
2284   - old_dict.getKey(iter), obj_copier, false));
  2176 + iter, replaceForeignIndirectObjects(old_dict.getKey(iter), obj_copier, false));
2285 2177 }
2286 2178 copyStreamData(result, foreign);
2287 2179 } else {
... ... @@ -2309,8 +2201,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2309 2201 if (m->copied_stream_data_provider == nullptr) {
2310 2202 m->copied_stream_data_provider = new CopiedStreamDataProvider(*this);
2311 2203 m->copied_streams =
2312   - std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(
2313   - m->copied_stream_data_provider);
  2204 + std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(m->copied_stream_data_provider);
2314 2205 }
2315 2206 QPDFObjGen local_og(result.getObjGen());
2316 2207 // Copy information from the foreign stream so we can pipe its
... ... @@ -2325,8 +2216,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2325 2216 " stream object from foreign stream");
2326 2217 }
2327 2218 std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer();
2328   - if ((foreign_stream_qpdf.m->immediate_copy_from) &&
2329   - (stream_buffer == nullptr)) {
  2219 + if ((foreign_stream_qpdf.m->immediate_copy_from) && (stream_buffer == nullptr)) {
2330 2220 // Pull the stream data into a buffer before attempting
2331 2221 // the copy operation. Do it on the source stream so that
2332 2222 // if the source stream is copied multiple times, we don't
... ... @@ -2347,12 +2237,9 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2347 2237 } else if (stream_provider.get()) {
2348 2238 // In this case, the remote stream's QPDF must stay in scope.
2349 2239 QTC::TC("qpdf", "QPDF copy foreign stream with provider");
2350   - m->copied_stream_data_provider->registerForeignStream(
2351   - local_og, foreign);
  2240 + m->copied_stream_data_provider->registerForeignStream(local_og, foreign);
2352 2241 result.replaceStreamData(
2353   - m->copied_streams,
2354   - dict.getKey("/Filter"),
2355   - dict.getKey("/DecodeParms"));
  2242 + m->copied_streams, dict.getKey("/Filter"), dict.getKey("/DecodeParms"));
2356 2243 } else {
2357 2244 auto foreign_stream_data = std::make_shared<ForeignStreamData>(
2358 2245 foreign_stream_qpdf.m->encp,
... ... @@ -2361,20 +2248,16 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2361 2248 stream->getParsedOffset(),
2362 2249 stream->getLength(),
2363 2250 dict);
2364   - m->copied_stream_data_provider->registerForeignStream(
2365   - local_og, foreign_stream_data);
  2251 + m->copied_stream_data_provider->registerForeignStream(local_og, foreign_stream_data);
2366 2252 result.replaceStreamData(
2367   - m->copied_streams,
2368   - dict.getKey("/Filter"),
2369   - dict.getKey("/DecodeParms"));
  2253 + m->copied_streams, dict.getKey("/Filter"), dict.getKey("/DecodeParms"));
2370 2254 }
2371 2255 }
2372 2256  
2373 2257 void
2374 2258 QPDF::swapObjects(int objid1, int generation1, int objid2, int generation2)
2375 2259 {
2376   - swapObjects(
2377   - QPDFObjGen(objid1, generation1), QPDFObjGen(objid2, generation2));
  2260 + swapObjects(QPDFObjGen(objid1, generation1), QPDFObjGen(objid2, generation2));
2378 2261 }
2379 2262  
2380 2263 void
... ... @@ -2519,8 +2402,7 @@ QPDF::getCompressibleObjGens()
2519 2402 if (og == encryption_dict_og) {
2520 2403 QTC::TC("qpdf", "QPDF exclude encryption dictionary");
2521 2404 } else if (!(obj.isStream() ||
2522   - (obj.isDictionaryOfType("/Sig") &&
2523   - obj.hasKey("/ByteRange") &&
  2405 + (obj.isDictionaryOfType("/Sig") && obj.hasKey("/ByteRange") &&
2524 2406 obj.hasKey("/Contents")))) {
2525 2407 result.push_back(og);
2526 2408 }
... ... @@ -2571,8 +2453,7 @@ QPDF::pipeStreamData(
2571 2453 {
2572 2454 std::vector<std::shared_ptr<Pipeline>> to_delete;
2573 2455 if (encp->encrypted) {
2574   - decryptStream(
2575   - encp, file, qpdf_for_warning, pipeline, og, stream_dict, to_delete);
  2456 + decryptStream(encp, file, qpdf_for_warning, pipeline, og, stream_dict, to_delete);
2576 2457 }
2577 2458  
2578 2459 bool success = false;
... ... @@ -2584,10 +2465,7 @@ QPDF::pipeStreamData(
2584 2465 size_t len = file->read(buf, to_read);
2585 2466 if (len == 0) {
2586 2467 throw damagedPDF(
2587   - file,
2588   - "",
2589   - file->getLastOffset(),
2590   - "unexpected EOF reading stream data");
  2468 + file, "", file->getLastOffset(), "unexpected EOF reading stream data");
2591 2469 }
2592 2470 length -= len;
2593 2471 pipeline->write(buf, len);
... ... @@ -2607,8 +2485,8 @@ QPDF::pipeStreamData(
2607 2485 file,
2608 2486 "",
2609 2487 file->getLastOffset(),
2610   - ("error decoding stream data for object " +
2611   - og.unparse(' ') + ": " + e.what())));
  2488 + ("error decoding stream data for object " + og.unparse(' ') + ": " +
  2489 + e.what())));
2612 2490 if (will_retry) {
2613 2491 qpdf_for_warning.warn(
2614 2492 // line-break
... ... @@ -2694,17 +2572,14 @@ QPDF::damagedPDF(
2694 2572 qpdf_offset_t offset,
2695 2573 std::string const& message)
2696 2574 {
2697   - return QPDFExc(
2698   - qpdf_e_damaged_pdf, input->getName(), object, offset, message);
  2575 + return QPDFExc(qpdf_e_damaged_pdf, input->getName(), object, offset, message);
2699 2576 }
2700 2577  
2701 2578 // Return an exception of type qpdf_e_damaged_pdf. The object is taken from
2702 2579 // m->last_object_description.
2703 2580 QPDFExc
2704 2581 QPDF::damagedPDF(
2705   - std::shared_ptr<InputSource> const& input,
2706   - qpdf_offset_t offset,
2707   - std::string const& message)
  2582 + std::shared_ptr<InputSource> const& input, qpdf_offset_t offset, std::string const& message)
2708 2583 {
2709 2584 return damagedPDF(input, m->last_object_description, offset, message);
2710 2585 }
... ... @@ -2712,11 +2587,9 @@ QPDF::damagedPDF(
2712 2587 // Return an exception of type qpdf_e_damaged_pdf. The filename is taken from
2713 2588 // m->file.
2714 2589 QPDFExc
2715   -QPDF::damagedPDF(
2716   - std::string const& object, qpdf_offset_t offset, std::string const& message)
  2590 +QPDF::damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message)
2717 2591 {
2718   - return QPDFExc(
2719   - qpdf_e_damaged_pdf, m->file->getName(), object, offset, message);
  2592 + return QPDFExc(qpdf_e_damaged_pdf, m->file->getName(), object, offset, message);
2720 2593 }
2721 2594  
2722 2595 // Return an exception of type qpdf_e_damaged_pdf. The filename is taken from
... ... @@ -2741,8 +2614,7 @@ QPDF::damagedPDF(qpdf_offset_t offset, std::string const&amp; message)
2741 2614 QPDFExc
2742 2615 QPDF::damagedPDF(std::string const& message)
2743 2616 {
2744   - return damagedPDF(
2745   - m->last_object_description, m->file->getLastOffset(), message);
  2617 + return damagedPDF(m->last_object_description, m->file->getLastOffset(), message);
2746 2618 }
2747 2619  
2748 2620 bool
... ...
libqpdf/QPDFAcroFormDocumentHelper.cc
... ... @@ -41,8 +41,7 @@ QPDFAcroFormDocumentHelper::getOrCreateAcroForm()
41 41 auto acroform = this->qpdf.getRoot().getKey("/AcroForm");
42 42 if (!acroform.isDictionary()) {
43 43 acroform = this->qpdf.getRoot().replaceKeyAndGetNew(
44   - "/AcroForm",
45   - this->qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary()));
  44 + "/AcroForm", this->qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary()));
46 45 }
47 46 return acroform;
48 47 }
... ... @@ -53,24 +52,20 @@ QPDFAcroFormDocumentHelper::addFormField(QPDFFormFieldObjectHelper ff)
53 52 auto acroform = getOrCreateAcroForm();
54 53 auto fields = acroform.getKey("/Fields");
55 54 if (!fields.isArray()) {
56   - fields = acroform.replaceKeyAndGetNew(
57   - "/Fields", QPDFObjectHandle::newArray());
  55 + fields = acroform.replaceKeyAndGetNew("/Fields", QPDFObjectHandle::newArray());
58 56 }
59 57 fields.appendItem(ff.getObjectHandle());
60 58 QPDFObjGen::set visited;
61   - traverseField(
62   - ff.getObjectHandle(), QPDFObjectHandle::newNull(), 0, visited);
  59 + traverseField(ff.getObjectHandle(), QPDFObjectHandle::newNull(), 0, visited);
63 60 }
64 61  
65 62 void
66   -QPDFAcroFormDocumentHelper::addAndRenameFormFields(
67   - std::vector<QPDFObjectHandle> fields)
  63 +QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle> fields)
68 64 {
69 65 analyze();
70 66 std::map<std::string, std::string> renames;
71 67 QPDFObjGen::set seen;
72   - for (std::list<QPDFObjectHandle> queue{fields.begin(), fields.end()};
73   - !queue.empty();
  68 + for (std::list<QPDFObjectHandle> queue{fields.begin(), fields.end()}; !queue.empty();
74 69 queue.pop_front()) {
75 70 auto& obj = queue.front();
76 71 if (seen.add(obj)) {
... ... @@ -90,8 +85,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(
90 85 // at the end of the fully qualified name, appending to /T
91 86 // has the effect of appending the same thing to the fully
92 87 // qualified name.
93   - std::string old_name =
94   - QPDFFormFieldObjectHelper(obj).getFullyQualifiedName();
  88 + std::string old_name = QPDFFormFieldObjectHelper(obj).getFullyQualifiedName();
95 89 if (renames.count(old_name) == 0) {
96 90 std::string new_name = old_name;
97 91 int suffix = 0;
... ... @@ -120,8 +114,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(
120 114 }
121 115  
122 116 void
123   -QPDFAcroFormDocumentHelper::removeFormFields(
124   - std::set<QPDFObjGen> const& to_remove)
  117 +QPDFAcroFormDocumentHelper::removeFormFields(std::set<QPDFObjGen> const& to_remove)
125 118 {
126 119 auto acroform = this->qpdf.getRoot().getKey("/AcroForm");
127 120 if (!acroform.isDictionary()) {
... ... @@ -162,8 +155,7 @@ QPDFAcroFormDocumentHelper::removeFormFields(
162 155 }
163 156  
164 157 void
165   -QPDFAcroFormDocumentHelper::setFormFieldName(
166   - QPDFFormFieldObjectHelper ff, std::string const& name)
  158 +QPDFAcroFormDocumentHelper::setFormFieldName(QPDFFormFieldObjectHelper ff, std::string const& name)
167 159 {
168 160 ff.setFieldAttribute("/T", name);
169 161 QPDFObjGen::set visited;
... ... @@ -257,8 +249,7 @@ QPDFAcroFormDocumentHelper::analyze()
257 249 QPDFObjectHandle fields = acroform.getKey("/Fields");
258 250 if (!fields.isArray()) {
259 251 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper fields not array");
260   - acroform.warnIfPossible(
261   - "/Fields key of /AcroForm dictionary is not an array; ignoring");
  252 + acroform.warnIfPossible("/Fields key of /AcroForm dictionary is not an array; ignoring");
262 253 fields = QPDFObjectHandle::newArray();
263 254 }
264 255  
... ... @@ -294,12 +285,10 @@ QPDFAcroFormDocumentHelper::analyze()
294 285 // adding a self-contained annotation (merged with the
295 286 // field dictionary) to the page's /Annots array and
296 287 // forgetting to also put it in /AcroForm.
297   - annot.warnIfPossible(
298   - "this widget annotation is not"
299   - " reachable from /AcroForm in the document catalog");
  288 + annot.warnIfPossible("this widget annotation is not"
  289 + " reachable from /AcroForm in the document catalog");
300 290 m->annotation_to_field[og] = QPDFFormFieldObjectHelper(annot);
301   - m->field_to_annotations[og].push_back(
302   - QPDFAnnotationObjectHelper(annot));
  291 + m->field_to_annotations[og].push_back(QPDFAnnotationObjectHelper(annot));
303 292 }
304 293 }
305 294 }
... ... @@ -307,10 +296,7 @@ QPDFAcroFormDocumentHelper::analyze()
307 296  
308 297 void
309 298 QPDFAcroFormDocumentHelper::traverseField(
310   - QPDFObjectHandle field,
311   - QPDFObjectHandle parent,
312   - int depth,
313   - QPDFObjGen::set& visited)
  299 + QPDFObjectHandle field, QPDFObjectHandle parent, int depth, QPDFObjGen::set& visited)
314 300 {
315 301 if (depth > 100) {
316 302 // Arbitrarily cut off recursion at a fixed depth to avoid
... ... @@ -319,16 +305,14 @@ QPDFAcroFormDocumentHelper::traverseField(
319 305 }
320 306 if (!field.isIndirect()) {
321 307 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper direct field");
322   - field.warnIfPossible(
323   - "encountered a direct object as a field or annotation while"
324   - " traversing /AcroForm; ignoring field or annotation");
  308 + field.warnIfPossible("encountered a direct object as a field or annotation while"
  309 + " traversing /AcroForm; ignoring field or annotation");
325 310 return;
326 311 }
327 312 if (!field.isDictionary()) {
328 313 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper non-dictionary field");
329   - field.warnIfPossible(
330   - "encountered a non-dictionary as a field or annotation while"
331   - " traversing /AcroForm; ignoring field or annotation");
  314 + field.warnIfPossible("encountered a non-dictionary as a field or annotation while"
  315 + " traversing /AcroForm; ignoring field or annotation");
332 316 return;
333 317 }
334 318 QPDFObjGen og(field.getObjGen());
... ... @@ -359,23 +343,17 @@ QPDFAcroFormDocumentHelper::traverseField(
359 343 if (field.hasKey("/Parent")) {
360 344 is_field = true;
361 345 }
362   - if (field.hasKey("/Subtype") || field.hasKey("/Rect") ||
363   - field.hasKey("/AP")) {
  346 + if (field.hasKey("/Subtype") || field.hasKey("/Rect") || field.hasKey("/AP")) {
364 347 is_annotation = true;
365 348 }
366 349 }
367 350  
368   - QTC::TC(
369   - "qpdf", "QPDFAcroFormDocumentHelper field found", (depth == 0) ? 0 : 1);
370   - QTC::TC(
371   - "qpdf",
372   - "QPDFAcroFormDocumentHelper annotation found",
373   - (is_field ? 0 : 1));
  351 + QTC::TC("qpdf", "QPDFAcroFormDocumentHelper field found", (depth == 0) ? 0 : 1);
  352 + QTC::TC("qpdf", "QPDFAcroFormDocumentHelper annotation found", (is_field ? 0 : 1));
374 353  
375 354 if (is_annotation) {
376 355 QPDFObjectHandle our_field = (is_field ? field : parent);
377   - m->field_to_annotations[our_field.getObjGen()].push_back(
378   - QPDFAnnotationObjectHelper(field));
  356 + m->field_to_annotations[our_field.getObjGen()].push_back(QPDFAnnotationObjectHelper(field));
379 357 m->annotation_to_field[og] = QPDFFormFieldObjectHelper(our_field);
380 358 }
381 359  
... ... @@ -400,8 +378,7 @@ QPDFAcroFormDocumentHelper::getNeedAppearances()
400 378 {
401 379 bool result = false;
402 380 QPDFObjectHandle acroform = this->qpdf.getRoot().getKey("/AcroForm");
403   - if (acroform.isDictionary() &&
404   - acroform.getKey("/NeedAppearances").isBool()) {
  381 + if (acroform.isDictionary() && acroform.getKey("/NeedAppearances").isBool()) {
405 382 result = acroform.getKey("/NeedAppearances").getBoolValue();
406 383 }
407 384 return result;
... ... @@ -418,8 +395,7 @@ QPDFAcroFormDocumentHelper::setNeedAppearances(bool val)
418 395 return;
419 396 }
420 397 if (val) {
421   - acroform.replaceKey(
422   - "/NeedAppearances", QPDFObjectHandle::newBool(true));
  398 + acroform.replaceKey("/NeedAppearances", QPDFObjectHandle::newBool(true));
423 399 } else {
424 400 acroform.removeKey("/NeedAppearances");
425 401 }
... ... @@ -472,8 +448,7 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields(
472 448 // we may be put a value on the field that is unused. This is
473 449 // harmless, so it's not worth trying to work around.
474 450  
475   - auto has_explicit = [](QPDFFormFieldObjectHelper& field,
476   - std::string const& key) {
  451 + auto has_explicit = [](QPDFFormFieldObjectHelper& field, std::string const& key) {
477 452 if (field.getObjectHandle().hasKey(key)) {
478 453 return true;
479 454 }
... ... @@ -490,16 +465,14 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields(
490 465 std::string da = cur_field.getDefaultAppearance();
491 466 if (da != from_default_da) {
492 467 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override da");
493   - obj.replaceKey(
494   - "/DA", QPDFObjectHandle::newUnicodeString(from_default_da));
  468 + obj.replaceKey("/DA", QPDFObjectHandle::newUnicodeString(from_default_da));
495 469 }
496 470 }
497 471 if (override_q && (!has_explicit(cur_field, "/Q"))) {
498 472 int q = cur_field.getQuadding();
499 473 if (q != from_default_q) {
500 474 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override q");
501   - obj.replaceKey(
502   - "/Q", QPDFObjectHandle::newInteger(from_default_q));
  475 + obj.replaceKey("/Q", QPDFObjectHandle::newInteger(from_default_q));
503 476 }
504 477 }
505 478 }
... ... @@ -511,11 +484,8 @@ namespace
511 484 {
512 485 public:
513 486 ResourceReplacer(
514   - std::map<std::string, std::map<std::string, std::string>> const&
515   - dr_map,
516   - std::map<
517   - std::string,
518   - std::map<std::string, std::set<size_t>>> const& rnames);
  487 + std::map<std::string, std::map<std::string, std::string>> const& dr_map,
  488 + std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames);
519 489 virtual ~ResourceReplacer() = default;
520 490 virtual void handleToken(QPDFTokenizer::Token const&) override;
521 491  
... ... @@ -527,8 +497,7 @@ namespace
527 497  
528 498 ResourceReplacer::ResourceReplacer(
529 499 std::map<std::string, std::map<std::string, std::string>> const& dr_map,
530   - std::map<std::string, std::map<std::string, std::set<size_t>>> const&
531   - rnames) :
  500 + std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames) :
532 501 offset(0)
533 502 {
534 503 // We have:
... ... @@ -564,8 +533,7 @@ ResourceReplacer::handleToken(QPDFTokenizer::Token const&amp; token)
564 533 {
565 534 bool wrote = false;
566 535 if (token.getType() == QPDFTokenizer::tt_name) {
567   - std::string name =
568   - QPDFObjectHandle::newName(token.getValue()).getName();
  536 + std::string name = QPDFObjectHandle::newName(token.getValue()).getName();
569 537 if (to_replace.count(name) && to_replace[name].count(offset)) {
570 538 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper replaced DA token");
571 539 write(to_replace[name][offset]);
... ... @@ -580,8 +548,7 @@ ResourceReplacer::handleToken(QPDFTokenizer::Token const&amp; token)
580 548  
581 549 void
582 550 QPDFAcroFormDocumentHelper::adjustDefaultAppearances(
583   - QPDFObjectHandle obj,
584   - std::map<std::string, std::map<std::string, std::string>> const& dr_map)
  551 + QPDFObjectHandle obj, std::map<std::string, std::map<std::string, std::string>> const& dr_map)
585 552 {
586 553 // This method is called on a field that has been copied from
587 554 // another file but whose /DA still refers to resources in the
... ... @@ -624,8 +591,7 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances(
624 591 // then filter it. We don't attach the stream to anything, so it
625 592 // will get discarded.
626 593 ResourceFinder rf;
627   - auto da_stream =
628   - QPDFObjectHandle::newStream(&this->qpdf, DA.getUTF8Value());
  594 + auto da_stream = QPDFObjectHandle::newStream(&this->qpdf, DA.getUTF8Value());
629 595 try {
630 596 auto nwarnings = this->qpdf.numWarnings();
631 597 da_stream.parseAsContents(&rf);
... ... @@ -646,15 +612,13 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances(
646 612 Pl_Buffer buf_pl("filtered DA");
647 613 da_stream.filterAsContents(&rr, &buf_pl);
648 614 auto buf = buf_pl.getBufferSharedPointer();
649   - std::string new_da(
650   - reinterpret_cast<char*>(buf->getBuffer()), buf->getSize());
  615 + std::string new_da(reinterpret_cast<char*>(buf->getBuffer()), buf->getSize());
651 616 obj.replaceKey("/DA", QPDFObjectHandle::newString(new_da));
652 617 }
653 618  
654 619 void
655 620 QPDFAcroFormDocumentHelper::adjustAppearanceStream(
656   - QPDFObjectHandle stream,
657   - std::map<std::string, std::map<std::string, std::string>> dr_map)
  621 + QPDFObjectHandle stream, std::map<std::string, std::map<std::string, std::string>> dr_map)
658 622 {
659 623 // We don't have to modify appearance streams or their resource
660 624 // dictionaries for them to display properly, but we need to do so
... ... @@ -740,8 +704,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
740 704 } catch (std::exception& e) {
741 705 // No way to reproduce in test suite right now since error
742 706 // conditions are converted to warnings.
743   - stream.warnIfPossible(
744   - std::string("Unable to parse appearance stream: ") + e.what());
  707 + stream.warnIfPossible(std::string("Unable to parse appearance stream: ") + e.what());
745 708 }
746 709 }
747 710  
... ... @@ -839,8 +802,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
839 802 }
840 803 dr.makeResourcesIndirect(this->qpdf);
841 804 if (!dr.isIndirect()) {
842   - dr = acroform.replaceKeyAndGetNew(
843   - "/DR", this->qpdf.makeIndirectObject(dr));
  805 + dr = acroform.replaceKeyAndGetNew("/DR", this->qpdf.makeIndirectObject(dr));
844 806 }
845 807 // Merge the other document's /DR, creating a conflict
846 808 // map. mergeResources checks to make sure both objects
... ... @@ -969,8 +931,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
969 931 obj.replaceKey("/Parent", orig_to_copy[parent_og]);
970 932 } else {
971 933 parent.warnIfPossible(
972   - "while traversing field " +
973   - obj.getObjGen().unparse(',') +
  934 + "while traversing field " + obj.getObjGen().unparse(',') +
974 935 ", found parent (" + parent_og.unparse(',') +
975 936 ") that had not been seen, indicating likely"
976 937 " invalid field structure");
... ... @@ -989,11 +950,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
989 950  
990 951 if (override_da || override_q) {
991 952 adjustInheritedFields(
992   - obj,
993   - override_da,
994   - from_default_da,
995   - override_q,
996   - from_default_q);
  953 + obj, override_da, from_default_da, override_q, from_default_q);
997 954 }
998 955 if (foreign) {
999 956 // Lazily initialize our /DR and the conflict map.
... ... @@ -1013,8 +970,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
1013 970 obj.replaceKey("/DR", dr);
1014 971 }
1015 972 }
1016   - if (foreign && obj.getKey("/DA").isString() &&
1017   - (!dr_map.empty())) {
  973 + if (foreign && obj.getKey("/DA").isString() && (!dr_map.empty())) {
1018 974 adjustDefaultAppearances(obj, dr_map);
1019 975 }
1020 976 }
... ... @@ -1060,15 +1016,13 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
1060 1016 if (apdict.isDictionary()) {
1061 1017 for (auto& ap: apdict.ditems()) {
1062 1018 if (ap.second.isStream()) {
1063   - streams.push_back(
1064   - replace_stream(apdict, ap.first, ap.second));
  1019 + streams.push_back(replace_stream(apdict, ap.first, ap.second));
1065 1020 } else if (ap.second.isDictionary()) {
1066 1021 for (auto& ap2: ap.second.ditems()) {
1067 1022 if (ap2.second.isStream()) {
1068 1023 streams.push_back(
1069 1024 // line-break
1070   - replace_stream(
1071   - ap.second, ap2.first, ap2.second));
  1025 + replace_stream(ap.second, ap2.first, ap2.second));
1072 1026 }
1073 1027 }
1074 1028 }
... ... @@ -1096,8 +1050,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
1096 1050 adjustAppearanceStream(stream, dr_map);
1097 1051 }
1098 1052 }
1099   - auto rect =
1100   - cm.transformRectangle(annot.getKey("/Rect").getArrayAsRectangle());
  1053 + auto rect = cm.transformRectangle(annot.getKey("/Rect").getArrayAsRectangle());
1101 1054 annot.replaceKey("/Rect", QPDFObjectHandle::newFromRectangle(rect));
1102 1055 }
1103 1056 }
... ...
libqpdf/QPDFAnnotationObjectHelper.cc
... ... @@ -47,8 +47,7 @@ QPDFAnnotationObjectHelper::getFlags()
47 47 }
48 48  
49 49 QPDFObjectHandle
50   -QPDFAnnotationObjectHelper::getAppearanceStream(
51   - std::string const& which, std::string const& state)
  50 +QPDFAnnotationObjectHelper::getAppearanceStream(std::string const& which, std::string const& state)
52 51 {
53 52 QPDFObjectHandle ap = getAppearanceDictionary();
54 53 std::string desired_state = state.empty() ? getAppearanceState() : state;
... ... @@ -80,10 +79,7 @@ QPDFAnnotationObjectHelper::getAppearanceStream(
80 79  
81 80 std::string
82 81 QPDFAnnotationObjectHelper::getPageContentForAppearance(
83   - std::string const& name,
84   - int rotate,
85   - int required_flags,
86   - int forbidden_flags)
  82 + std::string const& name, int rotate, int required_flags, int forbidden_flags)
87 83 {
88 84 if (!getAppearanceStream("/N").isStream()) {
89 85 return "";
... ... @@ -242,9 +238,7 @@ QPDFAnnotationObjectHelper::getPageContentForAppearance(
242 238 // Compute a matrix to transform the appearance box to the rectangle
243 239 QPDFMatrix AA;
244 240 AA.translate(rect.llx, rect.lly);
245   - AA.scale(
246   - (rect.urx - rect.llx) / (T.urx - T.llx),
247   - (rect.ury - rect.lly) / (T.ury - T.lly));
  241 + AA.scale((rect.urx - rect.llx) / (T.urx - T.llx), (rect.ury - rect.lly) / (T.ury - T.lly));
248 242 AA.translate(-T.llx, -T.lly);
249 243 if (do_rotate) {
250 244 AA.rotatex90(rotate);
... ...
libqpdf/QPDFArgParser.cc
... ... @@ -9,8 +9,7 @@
9 9 #include <cstring>
10 10 #include <iostream>
11 11  
12   -QPDFArgParser::Members::Members(
13   - int argc, char const* const argv[], char const* progname_env) :
  12 +QPDFArgParser::Members::Members(int argc, char const* const argv[], char const* progname_env) :
14 13  
15 14 argc(argc),
16 15 argv(argv),
... ... @@ -25,19 +24,15 @@ QPDFArgParser::Members::Members(
25 24 whoami = QUtil::getWhoami(tmp.get());
26 25 }
27 26  
28   -QPDFArgParser::QPDFArgParser(
29   - int argc, char const* const argv[], char const* progname_env) :
  27 +QPDFArgParser::QPDFArgParser(int argc, char const* const argv[], char const* progname_env) :
30 28 m(new Members(argc, argv, progname_env))
31 29 {
32 30 selectHelpOptionTable();
33 31 char const* help_choices[] = {"all", nullptr};
34 32 // More help choices are added dynamically.
35   - addChoices(
36   - "help", bindParam(&QPDFArgParser::argHelp, this), false, help_choices);
37   - addInvalidChoiceHandler(
38   - "help", bindParam(&QPDFArgParser::invalidHelpArg, this));
39   - addBare(
40   - "completion-bash", bindBare(&QPDFArgParser::argCompletionBash, this));
  33 + addChoices("help", bindParam(&QPDFArgParser::argHelp, this), false, help_choices);
  34 + addInvalidChoiceHandler("help", bindParam(&QPDFArgParser::invalidHelpArg, this));
  35 + addBare("completion-bash", bindBare(&QPDFArgParser::argCompletionBash, this));
41 36 addBare("completion-zsh", bindBare(&QPDFArgParser::argCompletionZsh, this));
42 37 selectMainOptionTable();
43 38 }
... ... @@ -62,22 +57,19 @@ QPDFArgParser::selectOptionTable(std::string const&amp; name)
62 57 auto t = m->option_tables.find(name);
63 58 if (t == m->option_tables.end()) {
64 59 QTC::TC("libtests", "QPDFArgParser select unregistered table");
65   - throw std::logic_error(
66   - "QPDFArgParser: selecting unregistered option table " + name);
  60 + throw std::logic_error("QPDFArgParser: selecting unregistered option table " + name);
67 61 }
68 62 m->option_table = &(t->second);
69 63 m->option_table_name = name;
70 64 }
71 65  
72 66 void
73   -QPDFArgParser::registerOptionTable(
74   - std::string const& name, bare_arg_handler_t end_handler)
  67 +QPDFArgParser::registerOptionTable(std::string const& name, bare_arg_handler_t end_handler)
75 68 {
76 69 if (0 != m->option_tables.count(name)) {
77 70 QTC::TC("libtests", "QPDFArgParser register registered table");
78 71 throw std::logic_error(
79   - "QPDFArgParser: registering already registered option table " +
80   - name);
  72 + "QPDFArgParser: registering already registered option table " + name);
81 73 }
82 74 m->option_tables[name];
83 75 selectOptionTable(name);
... ... @@ -90,8 +82,8 @@ QPDFArgParser::registerArg(std::string const&amp; arg)
90 82 if (0 != m->option_table->count(arg)) {
91 83 QTC::TC("libtests", "QPDFArgParser duplicate handler");
92 84 throw std::logic_error(
93   - "QPDFArgParser: adding a duplicate handler for option " + arg +
94   - " in " + m->option_table_name + " option table");
  85 + "QPDFArgParser: adding a duplicate handler for option " + arg + " in " +
  86 + m->option_table_name + " option table");
95 87 }
96 88 return ((*m->option_table)[arg]);
97 89 }
... ... @@ -113,9 +105,7 @@ QPDFArgParser::addBare(std::string const&amp; arg, bare_arg_handler_t handler)
113 105  
114 106 void
115 107 QPDFArgParser::addRequiredParameter(
116   - std::string const& arg,
117   - param_arg_handler_t handler,
118   - char const* parameter_name)
  108 + std::string const& arg, param_arg_handler_t handler, char const* parameter_name)
119 109 {
120 110 OptionEntry& oe = registerArg(arg);
121 111 oe.parameter_needed = true;
... ... @@ -124,8 +114,7 @@ QPDFArgParser::addRequiredParameter(
124 114 }
125 115  
126 116 void
127   -QPDFArgParser::addOptionalParameter(
128   - std::string const& arg, param_arg_handler_t handler)
  117 +QPDFArgParser::addOptionalParameter(std::string const& arg, param_arg_handler_t handler)
129 118 {
130 119 OptionEntry& oe = registerArg(arg);
131 120 oe.parameter_needed = false;
... ... @@ -134,10 +123,7 @@ QPDFArgParser::addOptionalParameter(
134 123  
135 124 void
136 125 QPDFArgParser::addChoices(
137   - std::string const& arg,
138   - param_arg_handler_t handler,
139   - bool required,
140   - char const** choices)
  126 + std::string const& arg, param_arg_handler_t handler, bool required, char const** choices)
141 127 {
142 128 OptionEntry& oe = registerArg(arg);
143 129 oe.parameter_needed = required;
... ... @@ -148,15 +134,13 @@ QPDFArgParser::addChoices(
148 134 }
149 135  
150 136 void
151   -QPDFArgParser::addInvalidChoiceHandler(
152   - std::string const& arg, param_arg_handler_t handler)
  137 +QPDFArgParser::addInvalidChoiceHandler(std::string const& arg, param_arg_handler_t handler)
153 138 {
154 139 auto i = m->option_table->find(arg);
155 140 if (i == m->option_table->end()) {
156 141 QTC::TC("libtests", "QPDFArgParser invalid choice handler to unknown");
157   - throw std::logic_error(
158   - "QPDFArgParser: attempt to add invalid choice handler"
159   - " to unknown argument");
  142 + throw std::logic_error("QPDFArgParser: attempt to add invalid choice handler"
  143 + " to unknown argument");
160 144 }
161 145 auto& oe = i->second;
162 146 oe.invalid_choice_handler = handler;
... ... @@ -195,9 +179,7 @@ QPDFArgParser::completionCommon(bool zsh)
195 179 std::string appimage;
196 180 if (QUtil::get_env(m->progname_env.c_str(), &executable)) {
197 181 progname = executable;
198   - } else if (
199   - QUtil::get_env("APPDIR", &appdir) &&
200   - QUtil::get_env("APPIMAGE", &appimage)) {
  182 + } else if (QUtil::get_env("APPDIR", &appdir) && QUtil::get_env("APPIMAGE", &appimage)) {
201 183 // Detect if we're in an AppImage and adjust
202 184 if ((appdir.length() < strlen(m->argv[0])) &&
203 185 (strncmp(appdir.c_str(), m->argv[0], appdir.length()) == 0)) {
... ... @@ -345,8 +327,7 @@ QPDFArgParser::handleBashArguments()
345 327 }
346 328 // Explicitly discard any non-space-terminated word. The "current
347 329 // word" is handled specially.
348   - m->bash_argv_ph =
349   - QUtil::make_shared_array<char const*>(1 + m->bash_argv.size());
  330 + m->bash_argv_ph = QUtil::make_shared_array<char const*>(1 + m->bash_argv.size());
350 331 for (size_t i = 0; i < m->bash_argv.size(); ++i) {
351 332 m->bash_argv_ph.get()[i] = m->bash_argv.at(i).get();
352 333 }
... ... @@ -479,8 +460,7 @@ QPDFArgParser::parseArgs()
479 460 end_option = true;
480 461 if (oep == m->option_table->end()) {
481 462 // This is registered automatically, so this can't happen.
482   - throw std::logic_error(
483   - "QPDFArgParser: -- handler not registered");
  463 + throw std::logic_error("QPDFArgParser: -- handler not registered");
484 464 }
485 465 } else if ((arg[0] == '-') && (strcmp(arg, "-") != 0)) {
486 466 ++arg;
... ... @@ -531,18 +511,15 @@ QPDFArgParser::parseArgs()
531 511 QTC::TC("libtests", "QPDFArgParser unrecognized");
532 512 std::string message = "unrecognized argument " + o_arg;
533 513 if (m->option_table != &m->main_option_table) {
534   - message += " (" + m->option_table_name +
535   - " options must be terminated with --)";
  514 + message += " (" + m->option_table_name + " options must be terminated with --)";
536 515 }
537 516 usage(message);
538 517 }
539 518  
540 519 OptionEntry& oe = oep->second;
541 520 if ((oe.parameter_needed && (!have_parameter)) ||
542   - ((!oe.choices.empty() && have_parameter &&
543   - (0 == oe.choices.count(parameter))))) {
544   - std::string message =
545   - "--" + arg_s + " must be given as --" + arg_s + "=";
  521 + ((!oe.choices.empty() && have_parameter && (0 == oe.choices.count(parameter))))) {
  522 + std::string message = "--" + arg_s + " must be given as --" + arg_s + "=";
546 523 if (oe.invalid_choice_handler) {
547 524 oe.invalid_choice_handler(parameter);
548 525 // Method should call usage() or exit. Just in case it
... ... @@ -609,9 +586,7 @@ QPDFArgParser::doFinalChecks()
609 586  
610 587 void
611 588 QPDFArgParser::addChoicesToCompletions(
612   - option_table_t& option_table,
613   - std::string const& option,
614   - std::string const& extra_prefix)
  589 + option_table_t& option_table, std::string const& option, std::string const& extra_prefix)
615 590 {
616 591 if (option_table.count(option) != 0) {
617 592 OptionEntry& oe = option_table[option];
... ... @@ -648,9 +623,7 @@ QPDFArgParser::addOptionsToCompletions(option_table_t&amp; option_table)
648 623  
649 624 void
650 625 QPDFArgParser::insertCompletions(
651   - option_table_t& option_table,
652   - std::string const& choice_option,
653   - std::string const& extra_prefix)
  626 + option_table_t& option_table, std::string const& choice_option, std::string const& extra_prefix)
654 627 {
655 628 if (!choice_option.empty()) {
656 629 addChoicesToCompletions(option_table, choice_option, extra_prefix);
... ... @@ -666,21 +639,17 @@ QPDFArgParser::handleCompletion()
666 639 if (m->completions.empty()) {
667 640 // Detect --option=... Bash treats the = as a word separator.
668 641 std::string choice_option;
669   - if (m->bash_cur.empty() && (m->bash_prev.length() > 2) &&
670   - (m->bash_prev.at(0) == '-') && (m->bash_prev.at(1) == '-') &&
671   - (m->bash_line.at(m->bash_line.length() - 1) == '=')) {
  642 + if (m->bash_cur.empty() && (m->bash_prev.length() > 2) && (m->bash_prev.at(0) == '-') &&
  643 + (m->bash_prev.at(1) == '-') && (m->bash_line.at(m->bash_line.length() - 1) == '=')) {
672 644 choice_option = m->bash_prev.substr(2, std::string::npos);
673   - } else if (
674   - (m->bash_prev == "=") &&
675   - (m->bash_line.length() > (m->bash_cur.length() + 1))) {
  645 + } else if ((m->bash_prev == "=") && (m->bash_line.length() > (m->bash_cur.length() + 1))) {
676 646 // We're sitting at --option=x. Find previous option.
677 647 size_t end_mark = m->bash_line.length() - m->bash_cur.length() - 1;
678 648 char before_cur = m->bash_line.at(end_mark);
679 649 if (before_cur == '=') {
680 650 size_t space = m->bash_line.find_last_of(' ', end_mark);
681 651 if (space != std::string::npos) {
682   - std::string candidate =
683   - m->bash_line.substr(space + 1, end_mark - space - 1);
  652 + std::string candidate = m->bash_line.substr(space + 1, end_mark - space - 1);
684 653 if ((candidate.length() > 2) && (candidate.at(0) == '-') &&
685 654 (candidate.at(1) == '-')) {
686 655 choice_option = candidate.substr(2, std::string::npos);
... ... @@ -695,8 +664,7 @@ QPDFArgParser::handleCompletion()
695 664 insertCompletions(*m->option_table, choice_option, extra_prefix);
696 665 if (m->argc == 1) {
697 666 // Help options are valid only by themselves.
698   - insertCompletions(
699   - m->help_option_table, choice_option, extra_prefix);
  667 + insertCompletions(m->help_option_table, choice_option, extra_prefix);
700 668 }
701 669 }
702 670 std::string prefix = extra_prefix + m->bash_cur;
... ... @@ -716,24 +684,19 @@ QPDFArgParser::addHelpFooter(std::string const&amp; text)
716 684  
717 685 void
718 686 QPDFArgParser::addHelpTopic(
719   - std::string const& topic,
720   - std::string const& short_text,
721   - std::string const& long_text)
  687 + std::string const& topic, std::string const& short_text, std::string const& long_text)
722 688 {
723 689 if (topic == "all") {
724 690 QTC::TC("libtests", "QPDFArgParser add reserved help topic");
725   - throw std::logic_error(
726   - "QPDFArgParser: can't register reserved help topic " + topic);
  691 + throw std::logic_error("QPDFArgParser: can't register reserved help topic " + topic);
727 692 }
728 693 if (!((topic.length() > 0) && (topic.at(0) != '-'))) {
729 694 QTC::TC("libtests", "QPDFArgParser bad topic for help");
730   - throw std::logic_error(
731   - "QPDFArgParser: help topics must not start with -");
  695 + throw std::logic_error("QPDFArgParser: help topics must not start with -");
732 696 }
733 697 if (m->help_topics.count(topic)) {
734 698 QTC::TC("libtests", "QPDFArgParser add existing topic");
735   - throw std::logic_error(
736   - "QPDFArgParser: topic " + topic + " has already been added");
  699 + throw std::logic_error("QPDFArgParser: topic " + topic + " has already been added");
737 700 }
738 701  
739 702 m->help_topics[topic] = HelpTopic(short_text, long_text);
... ... @@ -747,23 +710,20 @@ QPDFArgParser::addOptionHelp(
747 710 std::string const& short_text,
748 711 std::string const& long_text)
749 712 {
750   - if (!((option_name.length() > 2) && (option_name.at(0) == '-') &&
751   - (option_name.at(1) == '-'))) {
  713 + if (!((option_name.length() > 2) && (option_name.at(0) == '-') && (option_name.at(1) == '-'))) {
752 714 QTC::TC("libtests", "QPDFArgParser bad option for help");
753   - throw std::logic_error(
754   - "QPDFArgParser: options for help must start with --");
  715 + throw std::logic_error("QPDFArgParser: options for help must start with --");
755 716 }
756 717 if (m->option_help.count(option_name)) {
757 718 QTC::TC("libtests", "QPDFArgParser duplicate option help");
758   - throw std::logic_error(
759   - "QPDFArgParser: option " + option_name + " already has help");
  719 + throw std::logic_error("QPDFArgParser: option " + option_name + " already has help");
760 720 }
761 721 auto ht = m->help_topics.find(topic);
762 722 if (ht == m->help_topics.end()) {
763 723 QTC::TC("libtests", "QPDFArgParser add to unknown topic");
764 724 throw std::logic_error(
765   - "QPDFArgParser: unable to add option " + option_name +
766   - " to unknown help topic " + topic);
  725 + "QPDFArgParser: unable to add option " + option_name + " to unknown help topic " +
  726 + topic);
767 727 }
768 728 m->option_help[option_name] = HelpTopic(short_text, long_text);
769 729 ht->second.options.insert(option_name);
... ... @@ -773,12 +733,9 @@ QPDFArgParser::addOptionHelp(
773 733 void
774 734 QPDFArgParser::getTopHelp(std::ostringstream& msg)
775 735 {
776   - msg << "Run \"" << m->whoami << " --help=topic\" for help on a topic."
777   - << std::endl
778   - << "Run \"" << m->whoami << " --help=--option\" for help on an option."
779   - << std::endl
780   - << "Run \"" << m->whoami << " --help=all\" to see all available help."
781   - << std::endl
  736 + msg << "Run \"" << m->whoami << " --help=topic\" for help on a topic." << std::endl
  737 + << "Run \"" << m->whoami << " --help=--option\" for help on an option." << std::endl
  738 + << "Run \"" << m->whoami << " --help=all\" to see all available help." << std::endl
782 739 << std::endl
783 740 << "Topics:" << std::endl;
784 741 for (auto const& i: m->help_topics) {
... ... @@ -794,8 +751,7 @@ QPDFArgParser::getAllHelp(std::ostringstream&amp; msg)
794 751 for (auto const& i: topics) {
795 752 auto const& topic = i.first;
796 753 msg << std::endl
797   - << "== " << topic << " (" << i.second.short_text
798   - << ") ==" << std::endl
  754 + << "== " << topic << " (" << i.second.short_text << ") ==" << std::endl
799 755 << std::endl;
800 756 getTopicHelp(topic, i.second, msg);
801 757 }
... ... @@ -806,8 +762,7 @@ QPDFArgParser::getAllHelp(std::ostringstream&amp; msg)
806 762 }
807 763  
808 764 void
809   -QPDFArgParser::getTopicHelp(
810   - std::string const& name, HelpTopic const& ht, std::ostringstream& msg)
  765 +QPDFArgParser::getTopicHelp(std::string const& name, HelpTopic const& ht, std::ostringstream& msg)
811 766 {
812 767 if (ht.long_text.empty()) {
813 768 msg << ht.short_text << std::endl;
... ... @@ -817,8 +772,7 @@ QPDFArgParser::getTopicHelp(
817 772 if (!ht.options.empty()) {
818 773 msg << std::endl << "Related options:" << std::endl;
819 774 for (auto const& i: ht.options) {
820   - msg << " " << i << ": " << m->option_help[i].short_text
821   - << std::endl;
  775 + msg << " " << i << ": " << m->option_help[i].short_text << std::endl;
822 776 }
823 777 }
824 778 }
... ...
libqpdf/QPDFCryptoProvider.cc
... ... @@ -19,8 +19,7 @@ QPDFCryptoProvider::getImpl()
19 19 {
20 20 QPDFCryptoProvider& p = getInstance();
21 21 if (p.m->default_provider.empty()) {
22   - throw std::logic_error(
23   - "QPDFCryptoProvider::getImpl called with no default provider.");
  22 + throw std::logic_error("QPDFCryptoProvider::getImpl called with no default provider.");
24 23 }
25 24 return p.getImpl_internal(p.m->default_provider);
26 25 }
... ... @@ -76,8 +75,7 @@ QPDFCryptoProvider::getImpl_internal(std::string const&amp; name) const
76 75 auto iter = m->providers.find(name);
77 76 if (iter == m->providers.end()) {
78 77 throw std::logic_error(
79   - "QPDFCryptoProvider requested unknown implementation \"" + name +
80   - "\"");
  78 + "QPDFCryptoProvider requested unknown implementation \"" + name + "\"");
81 79 }
82 80 return m->providers[name]();
83 81 }
... ...
libqpdf/QPDFCrypto_gnutls.cc
... ... @@ -47,8 +47,7 @@ QPDFCrypto_gnutls::MD5_init()
47 47 if (code < 0) {
48 48 this->hash_ctx = nullptr;
49 49 throw std::runtime_error(
50   - std::string("gnutls: MD5 error: ") +
51   - std::string(gnutls_strerror(code)));
  50 + std::string("gnutls: MD5 error: ") + std::string(gnutls_strerror(code)));
52 51 }
53 52 }
54 53  
... ... @@ -78,26 +77,22 @@ QPDFCrypto_gnutls::RC4_init(unsigned char const* key_data, int key_len)
78 77 {
79 78 RC4_finalize();
80 79 if (key_len == -1) {
81   - key_len =
82   - QIntC::to_int(strlen(reinterpret_cast<char const*>(key_data)));
  80 + key_len = QIntC::to_int(strlen(reinterpret_cast<char const*>(key_data)));
83 81 }
84 82 gnutls_datum_t key;
85 83 key.data = const_cast<unsigned char*>(key_data);
86 84 key.size = QIntC::to_uint(key_len);
87 85  
88   - int code = gnutls_cipher_init(
89   - &this->cipher_ctx, GNUTLS_CIPHER_ARCFOUR_128, &key, nullptr);
  86 + int code = gnutls_cipher_init(&this->cipher_ctx, GNUTLS_CIPHER_ARCFOUR_128, &key, nullptr);
90 87 if (code < 0) {
91 88 this->cipher_ctx = nullptr;
92 89 throw std::runtime_error(
93   - std::string("gnutls: RC4 error: ") +
94   - std::string(gnutls_strerror(code)));
  90 + std::string("gnutls: RC4 error: ") + std::string(gnutls_strerror(code)));
95 91 }
96 92 }
97 93  
98 94 void
99   -QPDFCrypto_gnutls::RC4_process(
100   - unsigned char const* in_data, size_t len, unsigned char* out_data)
  95 +QPDFCrypto_gnutls::RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data)
101 96 {
102 97 gnutls_cipher_encrypt2(this->cipher_ctx, in_data, len, out_data, len);
103 98 }
... ... @@ -223,29 +218,19 @@ QPDFCrypto_gnutls::rijndael_init(
223 218 if (code < 0) {
224 219 this->cipher_ctx = nullptr;
225 220 throw std::runtime_error(
226   - std::string("gnutls: AES error: ") +
227   - std::string(gnutls_strerror(code)));
  221 + std::string("gnutls: AES error: ") + std::string(gnutls_strerror(code)));
228 222 }
229 223 }
230 224  
231 225 void
232   -QPDFCrypto_gnutls::rijndael_process(
233   - unsigned char* in_data, unsigned char* out_data)
  226 +QPDFCrypto_gnutls::rijndael_process(unsigned char* in_data, unsigned char* out_data)
234 227 {
235 228 if (this->encrypt) {
236 229 gnutls_cipher_encrypt2(
237   - this->cipher_ctx,
238   - in_data,
239   - rijndael_buf_size,
240   - out_data,
241   - rijndael_buf_size);
  230 + this->cipher_ctx, in_data, rijndael_buf_size, out_data, rijndael_buf_size);
242 231 } else {
243 232 gnutls_cipher_decrypt2(
244   - this->cipher_ctx,
245   - in_data,
246   - rijndael_buf_size,
247   - out_data,
248   - rijndael_buf_size);
  233 + this->cipher_ctx, in_data, rijndael_buf_size, out_data, rijndael_buf_size);
249 234 }
250 235  
251 236 // Gnutls doesn't support AES in ECB (non-CBC) mode, but the
... ... @@ -253,14 +238,8 @@ QPDFCrypto_gnutls::rijndael_process(
253 238 // zeroes each time. We jump through a few hoops here to make this
254 239 // work.
255 240 if (!this->cbc_mode) {
256   - static unsigned char zeroes[16] = {
257   - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
258   - rijndael_init(
259   - this->encrypt,
260   - this->aes_key_data,
261   - this->aes_key_len,
262   - false,
263   - zeroes);
  241 + static unsigned char zeroes[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  242 + rijndael_init(this->encrypt, this->aes_key_data, this->aes_key_len, false, zeroes);
264 243 }
265 244 }
266 245  
... ...
libqpdf/QPDFCrypto_native.cc
... ... @@ -68,8 +68,7 @@ QPDFCrypto_native::RC4_init(unsigned char const* key_data, int key_len)
68 68 }
69 69  
70 70 void
71   -QPDFCrypto_native::RC4_process(
72   - unsigned char const* in_data, size_t len, unsigned char* out_data)
  71 +QPDFCrypto_native::RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data)
73 72 {
74 73 this->rc4->process(in_data, len, out_data);
75 74 }
... ... @@ -112,13 +111,12 @@ QPDFCrypto_native::rijndael_init(
112 111 unsigned char* cbc_block)
113 112  
114 113 {
115   - this->aes_pdf = std::make_shared<AES_PDF_native>(
116   - encrypt, key_data, key_len, cbc_mode, cbc_block);
  114 + this->aes_pdf =
  115 + std::make_shared<AES_PDF_native>(encrypt, key_data, key_len, cbc_mode, cbc_block);
117 116 }
118 117  
119 118 void
120   -QPDFCrypto_native::rijndael_process(
121   - unsigned char* in_data, unsigned char* out_data)
  119 +QPDFCrypto_native::rijndael_process(unsigned char* in_data, unsigned char* out_data)
122 120 {
123 121 this->aes_pdf->update(in_data, out_data);
124 122 }
... ...
libqpdf/QPDFCrypto_openssl.cc
... ... @@ -76,8 +76,7 @@ RC4Loader::~RC4Loader()
76 76 static void
77 77 bad_bits(int bits)
78 78 {
79   - throw std::logic_error(
80   - std::string("unsupported key length: ") + std::to_string(bits));
  79 + throw std::logic_error(std::string("unsupported key length: ") + std::to_string(bits));
81 80 }
82 81  
83 82 static void
... ... @@ -208,14 +207,11 @@ QPDFCrypto_openssl::RC4_init(unsigned char const* key_data, int key_len)
208 207 #endif
209 208 check_openssl(EVP_CIPHER_CTX_reset(cipher_ctx));
210 209 if (key_len == -1) {
211   - key_len =
212   - QIntC::to_int(strlen(reinterpret_cast<const char*>(key_data)));
  210 + key_len = QIntC::to_int(strlen(reinterpret_cast<const char*>(key_data)));
213 211 }
214   - check_openssl(
215   - EVP_EncryptInit_ex(cipher_ctx, rc4, nullptr, nullptr, nullptr));
  212 + check_openssl(EVP_EncryptInit_ex(cipher_ctx, rc4, nullptr, nullptr, nullptr));
216 213 check_openssl(EVP_CIPHER_CTX_set_key_length(cipher_ctx, key_len));
217   - check_openssl(
218   - EVP_EncryptInit_ex(cipher_ctx, nullptr, nullptr, key_data, nullptr));
  214 + check_openssl(EVP_EncryptInit_ex(cipher_ctx, nullptr, nullptr, key_data, nullptr));
219 215 }
220 216  
221 217 void
... ... @@ -242,23 +238,19 @@ QPDFCrypto_openssl::rijndael_init(
242 238 check_openssl(EVP_CIPHER_CTX_reset(cipher_ctx));
243 239 check_openssl(
244 240 // line-break
245   - EVP_CipherInit_ex(
246   - cipher_ctx, cipher, nullptr, key_data, cbc_block, encrypt));
  241 + EVP_CipherInit_ex(cipher_ctx, cipher, nullptr, key_data, cbc_block, encrypt));
247 242 check_openssl(EVP_CIPHER_CTX_set_padding(cipher_ctx, 0));
248 243 }
249 244  
250 245 void
251   -QPDFCrypto_openssl::RC4_process(
252   - unsigned char const* in_data, size_t len, unsigned char* out_data)
  246 +QPDFCrypto_openssl::RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data)
253 247 {
254 248 int out_len = static_cast<int>(len);
255   - check_openssl(
256   - EVP_EncryptUpdate(cipher_ctx, out_data, &out_len, in_data, out_len));
  249 + check_openssl(EVP_EncryptUpdate(cipher_ctx, out_data, &out_len, in_data, out_len));
257 250 }
258 251  
259 252 void
260   -QPDFCrypto_openssl::rijndael_process(
261   - unsigned char* in_data, unsigned char* out_data)
  253 +QPDFCrypto_openssl::rijndael_process(unsigned char* in_data, unsigned char* out_data)
262 254 {
263 255 int len = QPDFCryptoImpl::rijndael_buf_size;
264 256 check_openssl(EVP_CipherUpdate(cipher_ctx, out_data, &len, in_data, len));
... ...
libqpdf/QPDFEFStreamObjectHelper.cc
... ... @@ -24,13 +24,12 @@ QPDFEFStreamObjectHelper::getParam(std::string const&amp; pkey)
24 24 }
25 25  
26 26 void
27   -QPDFEFStreamObjectHelper::setParam(
28   - std::string const& pkey, QPDFObjectHandle const& pval)
  27 +QPDFEFStreamObjectHelper::setParam(std::string const& pkey, QPDFObjectHandle const& pval)
29 28 {
30 29 auto params = this->oh.getDict().getKey("/Params");
31 30 if (!params.isDictionary()) {
32   - params = this->oh.getDict().replaceKeyAndGetNew(
33   - "/Params", QPDFObjectHandle::newDictionary());
  31 + params =
  32 + this->oh.getDict().replaceKeyAndGetNew("/Params", QPDFObjectHandle::newDictionary());
34 33 }
35 34 params.replaceKey(pkey, pval);
36 35 }
... ... @@ -89,8 +88,7 @@ QPDFEFStreamObjectHelper::getChecksum()
89 88 }
90 89  
91 90 QPDFEFStreamObjectHelper
92   -QPDFEFStreamObjectHelper::createEFStream(
93   - QPDF& qpdf, std::shared_ptr<Buffer> data)
  91 +QPDFEFStreamObjectHelper::createEFStream(QPDF& qpdf, std::shared_ptr<Buffer> data)
94 92 {
95 93 return newFromStream(qpdf.newStream(data));
96 94 }
... ... @@ -102,12 +100,10 @@ QPDFEFStreamObjectHelper::createEFStream(QPDF&amp; qpdf, std::string const&amp; data)
102 100 }
103 101  
104 102 QPDFEFStreamObjectHelper
105   -QPDFEFStreamObjectHelper::createEFStream(
106   - QPDF& qpdf, std::function<void(Pipeline*)> provider)
  103 +QPDFEFStreamObjectHelper::createEFStream(QPDF& qpdf, std::function<void(Pipeline*)> provider)
107 104 {
108 105 auto stream = qpdf.newStream();
109   - stream.replaceStreamData(
110   - provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
  106 + stream.replaceStreamData(provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
111 107 return newFromStream(stream);
112 108 }
113 109  
... ... @@ -128,8 +124,7 @@ QPDFEFStreamObjectHelper::setModDate(std::string const&amp; date)
128 124 QPDFEFStreamObjectHelper&
129 125 QPDFEFStreamObjectHelper::setSubtype(std::string const& subtype)
130 126 {
131   - this->oh.getDict().replaceKey(
132   - "/Subtype", QPDFObjectHandle::newName("/" + subtype));
  127 + this->oh.getDict().replaceKey("/Subtype", QPDFObjectHandle::newName("/" + subtype));
133 128 return *this;
134 129 }
135 130  
... ... @@ -137,22 +132,18 @@ QPDFEFStreamObjectHelper
137 132 QPDFEFStreamObjectHelper::newFromStream(QPDFObjectHandle stream)
138 133 {
139 134 QPDFEFStreamObjectHelper result(stream);
140   - stream.getDict().replaceKey(
141   - "/Type", QPDFObjectHandle::newName("/EmbeddedFile"));
  135 + stream.getDict().replaceKey("/Type", QPDFObjectHandle::newName("/EmbeddedFile"));
142 136 Pl_Discard discard;
143 137 // The PDF spec specifies use of MD5 here and notes that it is not
144 138 // to be used for security. MD5 is known to be insecure.
145 139 Pl_MD5 md5("EF md5", &discard);
146 140 Pl_Count count("EF size", &md5);
147 141 if (!stream.pipeStreamData(&count, nullptr, 0, qpdf_dl_all)) {
148   - stream.warnIfPossible(
149   - "unable to get stream data for new embedded file stream");
  142 + stream.warnIfPossible("unable to get stream data for new embedded file stream");
150 143 } else {
  144 + result.setParam("/Size", QPDFObjectHandle::newInteger(count.getCount()));
151 145 result.setParam(
152   - "/Size", QPDFObjectHandle::newInteger(count.getCount()));
153   - result.setParam(
154   - "/CheckSum",
155   - QPDFObjectHandle::newString(QUtil::hex_decode(md5.getHexDigest())));
  146 + "/CheckSum", QPDFObjectHandle::newString(QUtil::hex_decode(md5.getHexDigest())));
156 147 }
157 148 return result;
158 149 }
... ...
libqpdf/QPDFEmbeddedFileDocumentHelper.cc
... ... @@ -40,8 +40,7 @@ QPDFEmbeddedFileDocumentHelper::QPDFEmbeddedFileDocumentHelper(QPDF&amp; qpdf) :
40 40 if (names.isDictionary()) {
41 41 auto embedded_files = names.getKey("/EmbeddedFiles");
42 42 if (embedded_files.isDictionary()) {
43   - m->embedded_files = std::make_shared<QPDFNameTreeObjectHelper>(
44   - embedded_files, qpdf);
  43 + m->embedded_files = std::make_shared<QPDFNameTreeObjectHelper>(embedded_files, qpdf);
45 44 }
46 45 }
47 46 }
... ... @@ -61,8 +60,7 @@ QPDFEmbeddedFileDocumentHelper::initEmbeddedFiles()
61 60 auto root = qpdf.getRoot();
62 61 auto names = root.getKey("/Names");
63 62 if (!names.isDictionary()) {
64   - names = root.replaceKeyAndGetNew(
65   - "/Names", QPDFObjectHandle::newDictionary());
  63 + names = root.replaceKeyAndGetNew("/Names", QPDFObjectHandle::newDictionary());
66 64 }
67 65 auto embedded_files = names.getKey("/EmbeddedFiles");
68 66 if (!embedded_files.isDictionary()) {
... ... @@ -91,8 +89,7 @@ QPDFEmbeddedFileDocumentHelper::getEmbeddedFiles()
91 89 std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>> result;
92 90 if (m->embedded_files) {
93 91 for (auto const& i: *(m->embedded_files)) {
94   - result[i.first] =
95   - std::make_shared<QPDFFileSpecObjectHelper>(i.second);
  92 + result[i.first] = std::make_shared<QPDFFileSpecObjectHelper>(i.second);
96 93 }
97 94 }
98 95 return result;
... ...
libqpdf/QPDFFileSpecObjectHelper.cc
... ... @@ -19,8 +19,7 @@ QPDFFileSpecObjectHelper::QPDFFileSpecObjectHelper(QPDFObjectHandle oh) :
19 19 }
20 20 }
21 21  
22   -static std::vector<std::string> name_keys = {
23   - "/UF", "/F", "/Unix", "/DOS", "/Mac"};
  22 +static std::vector<std::string> name_keys = {"/UF", "/F", "/Unix", "/DOS", "/Mac"};
24 23  
25 24 std::string
26 25 QPDFFileSpecObjectHelper::getDescription()
... ... @@ -90,8 +89,7 @@ QPDFFileSpecObjectHelper::createFileSpec(
90 89 return createFileSpec(
91 90 qpdf,
92 91 filename,
93   - QPDFEFStreamObjectHelper::createEFStream(
94   - qpdf, QUtil::file_provider(fullpath)));
  92 + QPDFEFStreamObjectHelper::createEFStream(qpdf, QUtil::file_provider(fullpath)));
95 93 }
96 94  
97 95 QPDFFileSpecObjectHelper
... ...
libqpdf/QPDFFormFieldObjectHelper.cc
... ... @@ -76,9 +76,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValue(std::string const&amp; name)
76 76 node = node.getKey("/Parent");
77 77 result = node.getKey(name);
78 78 if (!result.isNull()) {
79   - QTC::TC(
80   - "qpdf",
81   - "QPDFFormFieldObjectHelper non-trivial inheritance");
  79 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper non-trivial inheritance");
82 80 return result;
83 81 }
84 82 }
... ... @@ -87,8 +85,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValue(std::string const&amp; name)
87 85 }
88 86  
89 87 std::string
90   -QPDFFormFieldObjectHelper::getInheritableFieldValueAsString(
91   - std::string const& name)
  88 +QPDFFormFieldObjectHelper::getInheritableFieldValueAsString(std::string const& name)
92 89 {
93 90 QPDFObjectHandle fv = getInheritableFieldValue(name);
94 91 std::string result;
... ... @@ -99,8 +96,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValueAsString(
99 96 }
100 97  
101 98 std::string
102   -QPDFFormFieldObjectHelper::getInheritableFieldValueAsName(
103   - std::string const& name)
  99 +QPDFFormFieldObjectHelper::getInheritableFieldValueAsName(std::string const& name)
104 100 {
105 101 QPDFObjectHandle fv = getInheritableFieldValue(name);
106 102 std::string result;
... ... @@ -125,9 +121,7 @@ QPDFFormFieldObjectHelper::getFullyQualifiedName()
125 121 while (!node.isNull() && seen.add(node)) {
126 122 if (node.getKey("/T").isString()) {
127 123 if (!result.empty()) {
128   - QTC::TC(
129   - "qpdf",
130   - "QPDFFormFieldObjectHelper non-trivial qualified name");
  124 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper non-trivial qualified name");
131 125 result = "." + result;
132 126 }
133 127 result = node.getKey("/T").getUTF8Value() + result;
... ... @@ -210,10 +204,7 @@ QPDFFormFieldObjectHelper::getDefaultAppearance()
210 204 }
211 205 std::string result;
212 206 if (value.isString()) {
213   - QTC::TC(
214   - "qpdf",
215   - "QPDFFormFieldObjectHelper DA present",
216   - looked_in_acroform ? 0 : 1);
  207 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper DA present", looked_in_acroform ? 0 : 1);
217 208 result = value.getUTF8Value();
218 209 }
219 210 return result;
... ... @@ -230,10 +221,7 @@ QPDFFormFieldObjectHelper::getQuadding()
230 221 }
231 222 int result = 0;
232 223 if (fv.isInteger()) {
233   - QTC::TC(
234   - "qpdf",
235   - "QPDFFormFieldObjectHelper Q present",
236   - looked_in_acroform ? 0 : 1);
  224 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper Q present", looked_in_acroform ? 0 : 1);
237 225 result = QIntC::to_int(fv.getIntValue());
238 226 }
239 227 return result;
... ... @@ -255,25 +243,19 @@ QPDFFormFieldObjectHelper::isText()
255 243 bool
256 244 QPDFFormFieldObjectHelper::isCheckbox()
257 245 {
258   - return (
259   - (getFieldType() == "/Btn") &&
260   - ((getFlags() & (ff_btn_radio | ff_btn_pushbutton)) == 0));
  246 + return ((getFieldType() == "/Btn") && ((getFlags() & (ff_btn_radio | ff_btn_pushbutton)) == 0));
261 247 }
262 248  
263 249 bool
264 250 QPDFFormFieldObjectHelper::isRadioButton()
265 251 {
266   - return (
267   - (getFieldType() == "/Btn") &&
268   - ((getFlags() & ff_btn_radio) == ff_btn_radio));
  252 + return ((getFieldType() == "/Btn") && ((getFlags() & ff_btn_radio) == ff_btn_radio));
269 253 }
270 254  
271 255 bool
272 256 QPDFFormFieldObjectHelper::isPushbutton()
273 257 {
274   - return (
275   - (getFieldType() == "/Btn") &&
276   - ((getFlags() & ff_btn_pushbutton) == ff_btn_pushbutton));
  258 + return ((getFieldType() == "/Btn") && ((getFlags() & ff_btn_pushbutton) == ff_btn_pushbutton));
277 259 }
278 260  
279 261 bool
... ... @@ -303,15 +285,13 @@ QPDFFormFieldObjectHelper::getChoices()
303 285 }
304 286  
305 287 void
306   -QPDFFormFieldObjectHelper::setFieldAttribute(
307   - std::string const& key, QPDFObjectHandle value)
  288 +QPDFFormFieldObjectHelper::setFieldAttribute(std::string const& key, QPDFObjectHandle value)
308 289 {
309 290 this->oh.replaceKey(key, value);
310 291 }
311 292  
312 293 void
313   -QPDFFormFieldObjectHelper::setFieldAttribute(
314   - std::string const& key, std::string const& utf8_value)
  294 +QPDFFormFieldObjectHelper::setFieldAttribute(std::string const& key, std::string const& utf8_value)
315 295 {
316 296 this->oh.replaceKey(key, QPDFObjectHandle::newUnicodeString(utf8_value));
317 297 }
... ... @@ -330,41 +310,36 @@ QPDFFormFieldObjectHelper::setV(QPDFObjectHandle value, bool need_appearances)
330 310 }
331 311 }
332 312 if (!okay) {
333   - this->oh.warnIfPossible(
334   - "ignoring attempt to set a checkbox field to a"
335   - " value of other than /Yes or /Off");
  313 + this->oh.warnIfPossible("ignoring attempt to set a checkbox field to a"
  314 + " value of other than /Yes or /Off");
336 315 }
337 316 } else if (isRadioButton()) {
338 317 if (value.isName()) {
339 318 setRadioButtonValue(value);
340 319 } else {
341   - this->oh.warnIfPossible(
342   - "ignoring attempt to set a radio button field to"
343   - " an object that is not a name");
  320 + this->oh.warnIfPossible("ignoring attempt to set a radio button field to"
  321 + " an object that is not a name");
344 322 }
345 323 } else if (isPushbutton()) {
346   - this->oh.warnIfPossible(
347   - "ignoring attempt set the value of a pushbutton field");
  324 + this->oh.warnIfPossible("ignoring attempt set the value of a pushbutton field");
348 325 }
349 326 return;
350 327 }
351 328 if (value.isString()) {
352   - setFieldAttribute(
353   - "/V", QPDFObjectHandle::newUnicodeString(value.getUTF8Value()));
  329 + setFieldAttribute("/V", QPDFObjectHandle::newUnicodeString(value.getUTF8Value()));
354 330 } else {
355 331 setFieldAttribute("/V", value);
356 332 }
357 333 if (need_appearances) {
358   - QPDF& qpdf = this->oh.getQPDF(
359   - "QPDFFormFieldObjectHelper::setV called with need_appearances = "
360   - "true on an object that is not associated with an owning QPDF");
  334 + QPDF& qpdf =
  335 + this->oh.getQPDF("QPDFFormFieldObjectHelper::setV called with need_appearances = "
  336 + "true on an object that is not associated with an owning QPDF");
361 337 QPDFAcroFormDocumentHelper(qpdf).setNeedAppearances(true);
362 338 }
363 339 }
364 340  
365 341 void
366   -QPDFFormFieldObjectHelper::setV(
367   - std::string const& utf8_value, bool need_appearances)
  342 +QPDFFormFieldObjectHelper::setV(std::string const& utf8_value, bool need_appearances)
368 343 {
369 344 setV(QPDFObjectHandle::newUnicodeString(utf8_value), need_appearances);
370 345 }
... ... @@ -390,8 +365,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
390 365 if (ph.isRadioButton()) {
391 366 // This is most likely one of the individual buttons. Try
392 367 // calling on the parent.
393   - QTC::TC(
394   - "qpdf", "QPDFFormFieldObjectHelper set parent radio button");
  368 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper set parent radio button");
395 369 ph.setRadioButtonValue(name);
396 370 return;
397 371 }
... ... @@ -419,9 +393,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
419 393 QPDFObjectHandle grandkid = grandkids.getArrayItem(j);
420 394 AP = grandkid.getKey("/AP");
421 395 if (!AP.isNull()) {
422   - QTC::TC(
423   - "qpdf",
424   - "QPDFFormFieldObjectHelper radio button grandkid");
  396 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper radio button grandkid");
425 397 annot = grandkid;
426 398 break;
427 399 }
... ... @@ -432,8 +404,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
432 404 }
433 405 if (!annot.isInitialized()) {
434 406 QTC::TC("qpdf", "QPDFObjectHandle broken radio button");
435   - this->oh.warnIfPossible(
436   - "unable to set the value of this radio button");
  407 + this->oh.warnIfPossible("unable to set the value of this radio button");
437 408 continue;
438 409 }
439 410 if (AP.isDictionary() && AP.getKey("/N").isDictionary() &&
... ... @@ -465,9 +436,7 @@ QPDFFormFieldObjectHelper::setCheckBoxValue(bool value)
465 436 QPDFObjectHandle kid = kids.getArrayItem(i);
466 437 AP = kid.getKey("/AP");
467 438 if (!AP.isNull()) {
468   - QTC::TC(
469   - "qpdf",
470   - "QPDFFormFieldObjectHelper checkbox kid widget");
  439 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper checkbox kid widget");
471 440 annot = kid;
472 441 break;
473 442 }
... ... @@ -555,8 +524,7 @@ ValueSetter::handleToken(QPDFTokenizer::Token const&amp; token)
555 524 break;
556 525  
557 526 case st_bmc:
558   - if ((ttype == QPDFTokenizer::tt_space) ||
559   - (ttype == QPDFTokenizer::tt_comment)) {
  527 + if ((ttype == QPDFTokenizer::tt_space) || (ttype == QPDFTokenizer::tt_comment)) {
560 528 writeToken(token);
561 529 } else {
562 530 state = st_emc;
... ... @@ -642,9 +610,7 @@ ValueSetter::writeAppearance()
642 610 }
643 611 highlight = true;
644 612 highlight_idx = found_idx - QIntC::to_size(wanted_first);
645   - for (size_t i = QIntC::to_size(wanted_first);
646   - i <= QIntC::to_size(wanted_last);
647   - ++i) {
  613 + for (size_t i = QIntC::to_size(wanted_first); i <= QIntC::to_size(wanted_last); ++i) {
648 614 lines.push_back(opt.at(i));
649 615 }
650 616 } else {
... ... @@ -661,14 +627,12 @@ ValueSetter::writeAppearance()
661 627  
662 628 // Write the lines centered vertically, highlighting if needed
663 629 size_t nlines = lines.size();
664   - double dy = bbox.ury -
665   - ((bbox.ury - bbox.lly - (static_cast<double>(nlines) * tfh)) / 2.0);
  630 + double dy = bbox.ury - ((bbox.ury - bbox.lly - (static_cast<double>(nlines) * tfh)) / 2.0);
666 631 if (highlight) {
667 632 write(
668 633 "q\n0.85 0.85 0.85 rg\n" + QUtil::double_to_string(bbox.llx) + " " +
669 634 QUtil::double_to_string(
670   - bbox.lly + dy -
671   - (tfh * (static_cast<double>(highlight_idx + 1)))) +
  635 + bbox.lly + dy - (tfh * (static_cast<double>(highlight_idx + 1)))) +
672 636 " " + QUtil::double_to_string(bbox.urx - bbox.llx) + " " +
673 637 QUtil::double_to_string(tfh) + " re f\nQ\n");
674 638 }
... ... @@ -681,10 +645,8 @@ ValueSetter::writeAppearance()
681 645 // which doesn't seem really worth the effort.
682 646 if (i == 0) {
683 647 write(
684   - QUtil::double_to_string(bbox.llx + static_cast<double>(dx)) +
685   - " " +
686   - QUtil::double_to_string(bbox.lly + static_cast<double>(dy)) +
687   - " Td\n");
  648 + QUtil::double_to_string(bbox.llx + static_cast<double>(dx)) + " " +
  649 + QUtil::double_to_string(bbox.lly + static_cast<double>(dy)) + " Td\n");
688 650 } else {
689 651 write("0 " + QUtil::double_to_string(-tfh) + " Td\n");
690 652 }
... ... @@ -794,8 +756,7 @@ TfFinder::getFontName()
794 756 }
795 757  
796 758 QPDFObjectHandle
797   -QPDFFormFieldObjectHelper::getFontFromResource(
798   - QPDFObjectHandle resources, std::string const& name)
  759 +QPDFFormFieldObjectHelper::getFontFromResource(QPDFObjectHandle resources, std::string const& name)
799 760 {
800 761 QPDFObjectHandle result;
801 762 if (resources.isDictionary() && resources.getKey("/Font").isDictionary() &&
... ... @@ -806,40 +767,34 @@ QPDFFormFieldObjectHelper::getFontFromResource(
806 767 }
807 768  
808 769 void
809   -QPDFFormFieldObjectHelper::generateTextAppearance(
810   - QPDFAnnotationObjectHelper& aoh)
  770 +QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
811 771 {
812 772 QPDFObjectHandle AS = aoh.getAppearanceStream("/N");
813 773 if (AS.isNull()) {
814 774 QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AS from scratch");
815 775 QPDFObjectHandle::Rectangle rect = aoh.getRect();
816   - QPDFObjectHandle::Rectangle bbox(
817   - 0, 0, rect.urx - rect.llx, rect.ury - rect.lly);
818   - QPDFObjectHandle dict = QPDFObjectHandle::parse(
819   - "<< /Resources << /ProcSet [ /PDF /Text ] >>"
820   - " /Type /XObject /Subtype /Form >>");
  776 + QPDFObjectHandle::Rectangle bbox(0, 0, rect.urx - rect.llx, rect.ury - rect.lly);
  777 + QPDFObjectHandle dict =
  778 + QPDFObjectHandle::parse("<< /Resources << /ProcSet [ /PDF /Text ] >>"
  779 + " /Type /XObject /Subtype /Form >>");
821 780 dict.replaceKey("/BBox", QPDFObjectHandle::newFromRectangle(bbox));
822   - AS = QPDFObjectHandle::newStream(
823   - this->oh.getOwningQPDF(), "/Tx BMC\nEMC\n");
  781 + AS = QPDFObjectHandle::newStream(this->oh.getOwningQPDF(), "/Tx BMC\nEMC\n");
824 782 AS.replaceDict(dict);
825 783 QPDFObjectHandle AP = aoh.getAppearanceDictionary();
826 784 if (AP.isNull()) {
827 785 QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AP from scratch");
828   - aoh.getObjectHandle().replaceKey(
829   - "/AP", QPDFObjectHandle::newDictionary());
  786 + aoh.getObjectHandle().replaceKey("/AP", QPDFObjectHandle::newDictionary());
830 787 AP = aoh.getAppearanceDictionary();
831 788 }
832 789 AP.replaceKey("/N", AS);
833 790 }
834 791 if (!AS.isStream()) {
835   - aoh.getObjectHandle().warnIfPossible(
836   - "unable to get normal appearance stream for update");
  792 + aoh.getObjectHandle().warnIfPossible("unable to get normal appearance stream for update");
837 793 return;
838 794 }
839 795 QPDFObjectHandle bbox_obj = AS.getDict().getKey("/BBox");
840 796 if (!bbox_obj.isRectangle()) {
841   - aoh.getObjectHandle().warnIfPossible(
842   - "unable to get appearance stream bounding box");
  797 + aoh.getObjectHandle().warnIfPossible("unable to get appearance stream bounding box");
843 798 return;
844 799 }
845 800 QPDFObjectHandle::Rectangle bbox = bbox_obj.getArrayAsRectangle();
... ... @@ -872,8 +827,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(
872 827 if (found_font_in_dr && resources.isDictionary()) {
873 828 QTC::TC("qpdf", "QPDFFormFieldObjectHelper get font from /DR");
874 829 if (resources.isIndirect()) {
875   - resources = resources.getQPDF().makeIndirectObject(
876   - resources.shallowCopy());
  830 + resources = resources.getQPDF().makeIndirectObject(resources.shallowCopy());
877 831 AS.getDict().replaceKey("/Resources", resources);
878 832 }
879 833 // Use mergeResources to force /Font to be local
... ... @@ -899,6 +853,5 @@ QPDFFormFieldObjectHelper::generateTextAppearance(
899 853  
900 854 AS.addTokenFilter(
901 855 // line-break
902   - std::shared_ptr<QPDFObjectHandle::TokenFilter>(
903   - new ValueSetter(DA, V, opt, tf, bbox)));
  856 + std::shared_ptr<QPDFObjectHandle::TokenFilter>(new ValueSetter(DA, V, opt, tf, bbox)));
904 857 }
... ...
libqpdf/QPDFJob.cc
... ... @@ -50,8 +50,7 @@ namespace
50 50 QPDFObjectHandle& image);
51 51 ~ImageOptimizer() override = default;
52 52 void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
53   - std::shared_ptr<Pipeline>
54   - makePipeline(std::string const& description, Pipeline* next);
  53 + std::shared_ptr<Pipeline> makePipeline(std::string const& description, Pipeline* next);
55 54 bool evaluate(std::string const& description);
56 55  
57 56 private:
... ... @@ -78,8 +77,7 @@ namespace
78 77  
79 78 struct QPDFPageData
80 79 {
81   - QPDFPageData(
82   - std::string const& filename, QPDF* qpdf, std::string const& range);
  80 + QPDFPageData(std::string const& filename, QPDF* qpdf, std::string const& range);
83 81 QPDFPageData(QPDFPageData const& other, int page);
84 82  
85 83 std::string filename;
... ... @@ -91,8 +89,7 @@ namespace
91 89 class ProgressReporter: public QPDFWriter::ProgressReporter
92 90 {
93 91 public:
94   - ProgressReporter(
95   - Pipeline& p, std::string const& prefix, char const* filename) :
  92 + ProgressReporter(Pipeline& p, std::string const& prefix, char const* filename) :
96 93 p(p),
97 94 prefix(prefix),
98 95 filename(filename)
... ... @@ -133,8 +130,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
133 130 if (!(w_obj.isNumber() && h_obj.isNumber())) {
134 131 if (!description.empty()) {
135 132 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
136   - v << prefix << ": " << description
137   - << ": not optimizing because image dictionary"
  133 + v << prefix << ": " << description << ": not optimizing because image dictionary"
138 134 << " is missing required keys\n";
139 135 });
140 136 }
... ... @@ -166,8 +162,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
166 162 } else {
167 163 h = static_cast<JDIMENSION>(h_obj.getNumericValue());
168 164 }
169   - std::string colorspace =
170   - (colorspace_obj.isName() ? colorspace_obj.getName() : std::string());
  165 + std::string colorspace = (colorspace_obj.isName() ? colorspace_obj.getName() : std::string());
171 166 int components = 0;
172 167 J_COLOR_SPACE cs = JCS_UNKNOWN;
173 168 if (colorspace == "/DeviceRGB") {
... ... @@ -183,8 +178,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
183 178 QTC::TC("qpdf", "QPDFJob image optimize colorspace");
184 179 if (!description.empty()) {
185 180 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
186   - v << prefix << ": " << description
187   - << ": not optimizing because qpdf can't optimize"
  181 + v << prefix << ": " << description << ": not optimizing because qpdf can't optimize"
188 182 << " images with this colorspace\n";
189 183 });
190 184 }
... ... @@ -196,8 +190,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
196 190 QTC::TC("qpdf", "QPDFJob image optimize too small");
197 191 if (!description.empty()) {
198 192 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
199   - v << prefix << ": " << description
200   - << ": not optimizing because image"
  193 + v << prefix << ": " << description << ": not optimizing because image"
201 194 << " is smaller than requested minimum dimensions\n";
202 195 });
203 196 }
... ... @@ -214,8 +207,7 @@ ImageOptimizer::evaluate(std::string const&amp; description)
214 207 if (!image.pipeStreamData(nullptr, 0, qpdf_dl_specialized, true)) {
215 208 QTC::TC("qpdf", "QPDFJob image optimize no pipeline");
216 209 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
217   - v << prefix << ": " << description
218   - << ": not optimizing because unable to decode data"
  210 + v << prefix << ": " << description << ": not optimizing because unable to decode data"
219 211 << " or data already uses DCT\n";
220 212 });
221 213 return false;
... ... @@ -241,9 +233,8 @@ ImageOptimizer::evaluate(std::string const&amp; description)
241 233 return false;
242 234 }
243 235 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
244   - v << prefix << ": " << description
245   - << ": optimizing image reduces size from " << orig_length << " to "
246   - << c.getCount() << "\n";
  236 + v << prefix << ": " << description << ": optimizing image reduces size from " << orig_length
  237 + << " to " << c.getCount() << "\n";
247 238 });
248 239 return true;
249 240 }
... ... @@ -263,9 +254,7 @@ ImageOptimizer::provideStreamData(QPDFObjGen const&amp;, Pipeline* pipeline)
263 254 }
264 255  
265 256 QPDFJob::PageSpec::PageSpec(
266   - std::string const& filename,
267   - char const* password,
268   - std::string const& range) :
  257 + std::string const& filename, char const* password, std::string const& range) :
269 258 filename(filename),
270 259 range(range)
271 260 {
... ... @@ -274,18 +263,16 @@ QPDFJob::PageSpec::PageSpec(
274 263 }
275 264 }
276 265  
277   -QPDFPageData::QPDFPageData(
278   - std::string const& filename, QPDF* qpdf, std::string const& range) :
  266 +QPDFPageData::QPDFPageData(std::string const& filename, QPDF* qpdf, std::string const& range) :
279 267 filename(filename),
280 268 qpdf(qpdf),
281 269 orig_pages(qpdf->getAllPages())
282 270 {
283 271 try {
284   - this->selected_pages = QUtil::parse_numrange(
285   - range.c_str(), QIntC::to_int(this->orig_pages.size()));
  272 + this->selected_pages =
  273 + QUtil::parse_numrange(range.c_str(), QIntC::to_int(this->orig_pages.size()));
286 274 } catch (std::runtime_error& e) {
287   - throw std::runtime_error(
288   - "parsing numeric range for " + filename + ": " + e.what());
  275 + throw std::runtime_error("parsing numeric range for " + filename + ": " + e.what());
289 276 }
290 277 }
291 278  
... ... @@ -300,8 +287,7 @@ QPDFPageData::QPDFPageData(QPDFPageData const&amp; other, int page) :
300 287 void
301 288 ProgressReporter::reportProgress(int percentage)
302 289 {
303   - this->p << prefix << ": " << filename << ": write progress: " << percentage
304   - << "%\n";
  290 + this->p << prefix << ": " << filename << ": write progress: " << percentage << "%\n";
305 291 }
306 292  
307 293 QPDFJob::Members::Members() :
... ... @@ -358,8 +344,7 @@ QPDFJob::registerProgressReporter(std::function&lt;void(int)&gt; handler)
358 344 }
359 345  
360 346 void
361   -QPDFJob::doIfVerbose(
362   - std::function<void(Pipeline&, std::string const& prefix)> fn)
  347 +QPDFJob::doIfVerbose(std::function<void(Pipeline&, std::string const& prefix)> fn)
363 348 {
364 349 if (m->verbose) {
365 350 fn(*m->log->getInfo(), m->message_prefix);
... ... @@ -459,8 +444,7 @@ QPDFJob::createQPDF()
459 444 // Allow certain operations to work when an incorrect
460 445 // password is supplied.
461 446 if (m->check_is_encrypted || m->check_requires_password) {
462   - m->encryption_status =
463   - qpdf_es_encrypted | qpdf_es_password_incorrect;
  447 + m->encryption_status = qpdf_es_encrypted | qpdf_es_password_incorrect;
464 448 return nullptr;
465 449 }
466 450 if (m->show_encryption && pdf_sp) {
... ... @@ -513,12 +497,10 @@ QPDFJob::writeQPDF(QPDF&amp; pdf)
513 497 }
514 498 if (m->warnings && (!m->suppress_warnings)) {
515 499 if (createsOutput()) {
516   - *m->log->getWarn()
517   - << m->message_prefix << ": operation succeeded with warnings;"
518   - << " resulting file may have some problems\n";
  500 + *m->log->getWarn() << m->message_prefix << ": operation succeeded with warnings;"
  501 + << " resulting file may have some problems\n";
519 502 } else {
520   - *m->log->getWarn()
521   - << m->message_prefix << ": operation succeeded with warnings\n";
  503 + *m->log->getWarn() << m->message_prefix << ": operation succeeded with warnings\n";
522 504 }
523 505 }
524 506 if (m->report_mem_usage) {
... ... @@ -611,13 +593,9 @@ QPDFJob::checkConfiguration()
611 593 usage("an input file name is required");
612 594 } else if (m->replace_input && (strlen(m->infilename.get()) == 0)) {
613 595 usage("--replace-input may not be used with --empty");
614   - } else if (
615   - m->require_outfile && (m->outfilename == nullptr) &&
616   - (!m->replace_input)) {
  596 + } else if (m->require_outfile && (m->outfilename == nullptr) && (!m->replace_input)) {
617 597 usage("an output file name is required; use - for standard output");
618   - } else if (
619   - (!m->require_outfile) &&
620   - ((m->outfilename != nullptr) || m->replace_input)) {
  598 + } else if ((!m->require_outfile) && ((m->outfilename != nullptr) || m->replace_input)) {
621 599 usage("no output file may be given for this option");
622 600 }
623 601 if (m->check_requires_password && m->check_is_encrypted) {
... ... @@ -626,8 +604,7 @@ QPDFJob::checkConfiguration()
626 604 }
627 605  
628 606 if (m->encrypt && (!m->allow_insecure) &&
629   - (m->owner_password.empty() && (!m->user_password.empty()) &&
630   - (m->keylen == 256))) {
  607 + (m->owner_password.empty() && (!m->user_password.empty()) && (m->keylen == 256))) {
631 608 // Note that empty owner passwords for R < 5 are copied from
632 609 // the user password, so this lack of security is not an issue
633 610 // for those files. Also we are consider only the ability to
... ... @@ -642,8 +619,7 @@ QPDFJob::checkConfiguration()
642 619 }
643 620  
644 621 bool save_to_stdout = false;
645   - if (m->require_outfile && m->outfilename &&
646   - (strcmp(m->outfilename.get(), "-") == 0)) {
  622 + if (m->require_outfile && m->outfilename && (strcmp(m->outfilename.get(), "-") == 0)) {
647 623 if (m->split_pages) {
648 624 usage("--split-pages may not be used when"
649 625 " writing to standard output");
... ... @@ -656,8 +632,7 @@ QPDFJob::checkConfiguration()
656 632 if (save_to_stdout) {
657 633 m->log->saveToStandardOutput(true);
658 634 }
659   - if ((!m->split_pages) &&
660   - QUtil::same_file(m->infilename.get(), m->outfilename.get())) {
  635 + if ((!m->split_pages) && QUtil::same_file(m->infilename.get(), m->outfilename.get())) {
661 636 QTC::TC("qpdf", "QPDFJob same file error");
662 637 usage("input file and output file are the same;"
663 638 " use --replace-input to intentionally"
... ... @@ -751,8 +726,7 @@ QPDFJob::showEncryption(QPDF&amp; pdf)
751 726 std::string encryption_key = pdf.getEncryptionKey();
752 727 cout << "User password = " << user_password << "\n";
753 728 if (m->show_encryption_key) {
754   - cout << "Encryption key = " << QUtil::hex_encode(encryption_key)
755   - << "\n";
  729 + cout << "Encryption key = " << QUtil::hex_encode(encryption_key) << "\n";
756 730 }
757 731 if (pdf.ownerPasswordMatched()) {
758 732 cout << "Supplied password is owner password\n";
... ... @@ -760,28 +734,19 @@ QPDFJob::showEncryption(QPDF&amp; pdf)
760 734 if (pdf.userPasswordMatched()) {
761 735 cout << "Supplied password is user password\n";
762 736 }
763   - cout << "extract for accessibility: "
764   - << show_bool(pdf.allowAccessibility()) << "\n"
765   - << "extract for any purpose: " << show_bool(pdf.allowExtractAll())
766   - << "\n"
767   - << "print low resolution: " << show_bool(pdf.allowPrintLowRes())
768   - << "\n"
769   - << "print high resolution: " << show_bool(pdf.allowPrintHighRes())
770   - << "\n"
771   - << "modify document assembly: "
772   - << show_bool(pdf.allowModifyAssembly()) << "\n"
  737 + cout << "extract for accessibility: " << show_bool(pdf.allowAccessibility()) << "\n"
  738 + << "extract for any purpose: " << show_bool(pdf.allowExtractAll()) << "\n"
  739 + << "print low resolution: " << show_bool(pdf.allowPrintLowRes()) << "\n"
  740 + << "print high resolution: " << show_bool(pdf.allowPrintHighRes()) << "\n"
  741 + << "modify document assembly: " << show_bool(pdf.allowModifyAssembly()) << "\n"
773 742 << "modify forms: " << show_bool(pdf.allowModifyForm()) << "\n"
774   - << "modify annotations: " << show_bool(pdf.allowModifyAnnotation())
775   - << "\n"
  743 + << "modify annotations: " << show_bool(pdf.allowModifyAnnotation()) << "\n"
776 744 << "modify other: " << show_bool(pdf.allowModifyOther()) << "\n"
777 745 << "modify anything: " << show_bool(pdf.allowModifyAll()) << "\n";
778 746 if (V >= 4) {
779   - cout << "stream encryption method: "
780   - << show_encryption_method(stream_method) << "\n"
781   - << "string encryption method: "
782   - << show_encryption_method(string_method) << "\n"
783   - << "file encryption method: "
784   - << show_encryption_method(file_method) << "\n";
  747 + cout << "stream encryption method: " << show_encryption_method(stream_method) << "\n"
  748 + << "string encryption method: " << show_encryption_method(string_method) << "\n"
  749 + << "file encryption method: " << show_encryption_method(file_method) << "\n";
785 750 }
786 751 }
787 752 }
... ... @@ -830,8 +795,7 @@ QPDFJob::doCheck(QPDF&amp; pdf)
830 795 page.parseContents(&discard_contents);
831 796 } catch (QPDFExc& e) {
832 797 okay = false;
833   - *m->log->getError()
834   - << "ERROR: page " << pageno << ": " << e.what() << "\n";
  798 + *m->log->getError() << "ERROR: page " << pageno << ": " << e.what() << "\n";
835 799 }
836 800 }
837 801 } catch (std::exception& e) {
... ... @@ -885,8 +849,7 @@ QPDFJob::doShowObj(QPDF&amp; pdf)
885 849 *m->log->getInfo() << obj.unparseResolved() << "\n";
886 850 }
887 851 if (error) {
888   - throw std::runtime_error(
889   - "unable to get object " + obj.getObjGen().unparse(','));
  852 + throw std::runtime_error("unable to get object " + obj.getObjGen().unparse(','));
890 853 }
891 854 }
892 855  
... ... @@ -899,8 +862,8 @@ QPDFJob::doShowPages(QPDF&amp; pdf)
899 862 QPDFObjectHandle page = ph.getObjectHandle();
900 863 ++pageno;
901 864  
902   - cout << "page " << pageno << ": " << page.getObjectID() << " "
903   - << page.getGeneration() << " R\n";
  865 + cout << "page " << pageno << ": " << page.getObjectID() << " " << page.getGeneration()
  866 + << " R\n";
904 867 if (m->show_page_images) {
905 868 std::map<std::string, QPDFObjectHandle> images = ph.getImages();
906 869 if (!images.empty()) {
... ... @@ -911,8 +874,8 @@ QPDFJob::doShowPages(QPDF&amp; pdf)
911 874 QPDFObjectHandle dict = image.getDict();
912 875 int width = dict.getKey("/Width").getIntValueAsInt();
913 876 int height = dict.getKey("/Height").getIntValueAsInt();
914   - cout << " " << name << ": " << image.unparse() << ", "
915   - << width << " x " << height << "\n";
  877 + cout << " " << name << ": " << image.unparse() << ", " << width << " x "
  878 + << height << "\n";
916 879 }
917 880 }
918 881 }
... ... @@ -932,10 +895,8 @@ QPDFJob::doListAttachments(QPDF&amp; pdf)
932 895 for (auto const& i: efdh.getEmbeddedFiles()) {
933 896 std::string const& key = i.first;
934 897 auto efoh = i.second;
935   - *m->log->getInfo()
936   - << key << " -> "
937   - << efoh->getEmbeddedFileStream().getObjGen().unparse(',')
938   - << "\n";
  898 + *m->log->getInfo() << key << " -> "
  899 + << efoh->getEmbeddedFileStream().getObjGen().unparse(',') << "\n";
939 900 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
940 901 auto desc = efoh->getDescription();
941 902 if (!desc.empty()) {
... ... @@ -951,12 +912,10 @@ QPDFJob::doListAttachments(QPDF&amp; pdf)
951 912 auto efs = QPDFEFStreamObjectHelper(i2.second);
952 913 v << " " << i2.first << " -> "
953 914 << efs.getObjectHandle().getObjGen().unparse(',') << "\n";
954   - v << " creation date: " << efs.getCreationDate()
955   - << "\n"
  915 + v << " creation date: " << efs.getCreationDate() << "\n"
956 916 << " modification date: " << efs.getModDate() << "\n"
957 917 << " mime type: " << efs.getSubtype() << "\n"
958   - << " checksum: "
959   - << QUtil::hex_encode(efs.getChecksum()) << "\n";
  918 + << " checksum: " << QUtil::hex_encode(efs.getChecksum()) << "\n";
960 919 }
961 920 });
962 921 }
... ... @@ -971,8 +930,7 @@ QPDFJob::doShowAttachment(QPDF&amp; pdf)
971 930 QPDFEmbeddedFileDocumentHelper efdh(pdf);
972 931 auto fs = efdh.getEmbeddedFile(m->attachment_to_show);
973 932 if (!fs) {
974   - throw std::runtime_error(
975   - "attachment " + m->attachment_to_show + " not found");
  933 + throw std::runtime_error("attachment " + m->attachment_to_show + " not found");
976 934 }
977 935 auto efs = fs->getEmbeddedFileStream();
978 936 // saveToStandardOutput has already been called, but it's harmless
... ... @@ -982,8 +940,7 @@ QPDFJob::doShowAttachment(QPDF&amp; pdf)
982 940 }
983 941  
984 942 void
985   -QPDFJob::parse_object_id(
986   - std::string const& objspec, bool& trailer, int& obj, int& gen)
  943 +QPDFJob::parse_object_id(std::string const& objspec, bool& trailer, int& obj, int& gen)
987 944 {
988 945 if (objspec == "trailer") {
989 946 trailer = true;
... ... @@ -992,8 +949,7 @@ QPDFJob::parse_object_id(
992 949 obj = QUtil::string_to_int(objspec.c_str());
993 950 size_t comma = objspec.find(',');
994 951 if ((comma != std::string::npos) && (comma + 1 < objspec.length())) {
995   - gen = QUtil::string_to_int(
996   - objspec.substr(1 + comma, std::string::npos).c_str());
  952 + gen = QUtil::string_to_int(objspec.substr(1 + comma, std::string::npos).c_str());
997 953 }
998 954 }
999 955 }
... ... @@ -1013,8 +969,7 @@ QPDFJob::getWantedJSONObjects()
1013 969 }
1014 970  
1015 971 void
1016   -QPDFJob::doJSONObject(
1017   - Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle& obj)
  972 +QPDFJob::doJSONObject(Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle& obj)
1018 973 {
1019 974 if (m->json_version == 1) {
1020 975 JSON::writeDictionaryItem(p, first, key, obj.getJSON(1, true), 2);
... ... @@ -1022,8 +977,7 @@ QPDFJob::doJSONObject(
1022 977 auto j = JSON::makeDictionary();
1023 978 if (obj.isStream()) {
1024 979 j.addDictionaryMember("stream", JSON::makeDictionary())
1025   - .addDictionaryMember(
1026   - "dict", obj.getDict().getJSON(m->json_version, true));
  980 + .addDictionaryMember("dict", obj.getDict().getJSON(m->json_version, true));
1027 981 } else {
1028 982 j.addDictionaryMember("value", obj.getJSON(m->json_version, true));
1029 983 }
... ... @@ -1085,22 +1039,18 @@ QPDFJob::doJSONObjectinfo(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1085 1039 for (auto& obj: pdf.getAllObjects()) {
1086 1040 if (all_objects || wanted_og.count(obj.getObjGen())) {
1087 1041 auto j_details = JSON::makeDictionary();
1088   - auto j_stream =
1089   - j_details.addDictionaryMember("stream", JSON::makeDictionary());
  1042 + auto j_stream = j_details.addDictionaryMember("stream", JSON::makeDictionary());
1090 1043 bool is_stream = obj.isStream();
1091 1044 j_stream.addDictionaryMember("is", JSON::makeBool(is_stream));
1092 1045 j_stream.addDictionaryMember(
1093 1046 "length",
1094   - (is_stream ? obj.getDict().getKey("/Length").getJSON(
1095   - m->json_version, true)
  1047 + (is_stream ? obj.getDict().getKey("/Length").getJSON(m->json_version, true)
1096 1048 : JSON::makeNull()));
1097 1049 j_stream.addDictionaryMember(
1098 1050 "filter",
1099   - (is_stream ? obj.getDict().getKey("/Filter").getJSON(
1100   - m->json_version, true)
  1051 + (is_stream ? obj.getDict().getKey("/Filter").getJSON(m->json_version, true)
1101 1052 : JSON::makeNull()));
1102   - JSON::writeDictionaryItem(
1103   - p, first_object, obj.unparse(), j_details, 2);
  1053 + JSON::writeDictionaryItem(p, first_object, obj.unparse(), j_details, 2);
1104 1054 }
1105 1055 }
1106 1056 JSON::writeDictionaryClose(p, first_object, 1);
... ... @@ -1126,21 +1076,15 @@ QPDFJob::doJSONPages(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1126 1076 j_image.addDictionaryMember("name", JSON::makeString(iter2.first));
1127 1077 QPDFObjectHandle image = iter2.second;
1128 1078 QPDFObjectHandle dict = image.getDict();
  1079 + j_image.addDictionaryMember("object", image.getJSON(m->json_version));
  1080 + j_image.addDictionaryMember("width", dict.getKey("/Width").getJSON(m->json_version));
  1081 + j_image.addDictionaryMember("height", dict.getKey("/Height").getJSON(m->json_version));
1129 1082 j_image.addDictionaryMember(
1130   - "object", image.getJSON(m->json_version));
1131   - j_image.addDictionaryMember(
1132   - "width", dict.getKey("/Width").getJSON(m->json_version));
1133   - j_image.addDictionaryMember(
1134   - "height", dict.getKey("/Height").getJSON(m->json_version));
1135   - j_image.addDictionaryMember(
1136   - "colorspace",
1137   - dict.getKey("/ColorSpace").getJSON(m->json_version));
  1083 + "colorspace", dict.getKey("/ColorSpace").getJSON(m->json_version));
1138 1084 j_image.addDictionaryMember(
1139   - "bitspercomponent",
1140   - dict.getKey("/BitsPerComponent").getJSON(m->json_version));
  1085 + "bitspercomponent", dict.getKey("/BitsPerComponent").getJSON(m->json_version));
1141 1086 QPDFObjectHandle filters = dict.getKey("/Filter").wrapInArray();
1142   - j_image.addDictionaryMember(
1143   - "filter", filters.getJSON(m->json_version));
  1087 + j_image.addDictionaryMember("filter", filters.getJSON(m->json_version));
1144 1088 QPDFObjectHandle decode_parms = dict.getKey("/DecodeParms");
1145 1089 QPDFObjectHandle dp_array;
1146 1090 if (decode_parms.isArray()) {
... ... @@ -1151,33 +1095,25 @@ QPDFJob::doJSONPages(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1151 1095 dp_array.appendItem(decode_parms);
1152 1096 }
1153 1097 }
1154   - j_image.addDictionaryMember(
1155   - "decodeparms", dp_array.getJSON(m->json_version));
  1098 + j_image.addDictionaryMember("decodeparms", dp_array.getJSON(m->json_version));
1156 1099 j_image.addDictionaryMember(
1157 1100 "filterable",
1158   - JSON::makeBool(
1159   - image.pipeStreamData(nullptr, 0, m->decode_level, true)));
  1101 + JSON::makeBool(image.pipeStreamData(nullptr, 0, m->decode_level, true)));
1160 1102 }
1161 1103 j_page.addDictionaryMember("images", j_images);
1162   - JSON j_contents =
1163   - j_page.addDictionaryMember("contents", JSON::makeArray());
  1104 + JSON j_contents = j_page.addDictionaryMember("contents", JSON::makeArray());
1164 1105 for (auto& iter2: ph.getPageContents()) {
1165 1106 j_contents.addArrayElement(iter2.getJSON(m->json_version));
1166 1107 }
1167   - j_page.addDictionaryMember(
1168   - "label", pldh.getLabelForPage(pageno).getJSON(m->json_version));
1169   - JSON j_outlines =
1170   - j_page.addDictionaryMember("outlines", JSON::makeArray());
1171   - std::vector<QPDFOutlineObjectHelper> outlines =
1172   - odh.getOutlinesForPage(page.getObjGen());
  1108 + j_page.addDictionaryMember("label", pldh.getLabelForPage(pageno).getJSON(m->json_version));
  1109 + JSON j_outlines = j_page.addDictionaryMember("outlines", JSON::makeArray());
  1110 + std::vector<QPDFOutlineObjectHelper> outlines = odh.getOutlinesForPage(page.getObjGen());
1173 1111 for (auto& oiter: outlines) {
1174 1112 JSON j_outline = j_outlines.addArrayElement(JSON::makeDictionary());
1175 1113 j_outline.addDictionaryMember(
1176 1114 "object", oiter.getObjectHandle().getJSON(m->json_version));
1177   - j_outline.addDictionaryMember(
1178   - "title", JSON::makeString(oiter.getTitle()));
1179   - j_outline.addDictionaryMember(
1180   - "dest", oiter.getDest().getJSON(m->json_version, true));
  1115 + j_outline.addDictionaryMember("title", JSON::makeString(oiter.getTitle()));
  1116 + j_outline.addDictionaryMember("dest", oiter.getDest().getJSON(m->json_version, true));
1181 1117 }
1182 1118 j_page.addDictionaryMember("pageposfrom1", JSON::makeInt(1 + pageno));
1183 1119 JSON::writeArrayItem(p, first_page, j_page, 2);
... ... @@ -1190,8 +1126,7 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1190 1126 {
1191 1127 JSON j_labels = JSON::makeArray();
1192 1128 QPDFPageLabelDocumentHelper pldh(pdf);
1193   - long long npages =
1194   - QIntC::to_longlong(QPDFPageDocumentHelper(pdf).getAllPages().size());
  1129 + long long npages = QIntC::to_longlong(QPDFPageDocumentHelper(pdf).getAllPages().size());
1195 1130 if (pldh.hasPageLabels()) {
1196 1131 std::vector<QPDFObjectHandle> labels;
1197 1132 pldh.getLabelsForPageRange(0, npages - 1, 0, labels);
... ... @@ -1203,11 +1138,9 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1203 1138 break;
1204 1139 }
1205 1140 JSON j_label = j_labels.addArrayElement(JSON::makeDictionary());
1206   - j_label.addDictionaryMember(
1207   - "index", (*iter).getJSON(m->json_version));
  1141 + j_label.addDictionaryMember("index", (*iter).getJSON(m->json_version));
1208 1142 ++iter;
1209   - j_label.addDictionaryMember(
1210   - "label", (*iter).getJSON(m->json_version));
  1143 + j_label.addDictionaryMember("label", (*iter).getJSON(m->json_version));
1211 1144 }
1212 1145 }
1213 1146 JSON::writeDictionaryItem(p, first, "pagelabels", j_labels, 1);
... ... @@ -1215,17 +1148,13 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1215 1148  
1216 1149 void
1217 1150 QPDFJob::addOutlinesToJson(
1218   - std::vector<QPDFOutlineObjectHelper> outlines,
1219   - JSON& j,
1220   - std::map<QPDFObjGen, int>& page_numbers)
  1151 + std::vector<QPDFOutlineObjectHelper> outlines, JSON& j, std::map<QPDFObjGen, int>& page_numbers)
1221 1152 {
1222 1153 for (auto& ol: outlines) {
1223 1154 JSON jo = j.addArrayElement(JSON::makeDictionary());
1224   - jo.addDictionaryMember(
1225   - "object", ol.getObjectHandle().getJSON(m->json_version));
  1155 + jo.addDictionaryMember("object", ol.getObjectHandle().getJSON(m->json_version));
1226 1156 jo.addDictionaryMember("title", JSON::makeString(ol.getTitle()));
1227   - jo.addDictionaryMember(
1228   - "dest", ol.getDest().getJSON(m->json_version, true));
  1157 + jo.addDictionaryMember("dest", ol.getDest().getJSON(m->json_version, true));
1229 1158 jo.addDictionaryMember("open", JSON::makeBool(ol.getCount() >= 0));
1230 1159 QPDFObjectHandle page = ol.getDestPage();
1231 1160 JSON j_destpage = JSON::makeNull();
... ... @@ -1262,10 +1191,8 @@ QPDFJob::doJSONAcroform(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1262 1191 {
1263 1192 JSON j_acroform = JSON::makeDictionary();
1264 1193 QPDFAcroFormDocumentHelper afdh(pdf);
1265   - j_acroform.addDictionaryMember(
1266   - "hasacroform", JSON::makeBool(afdh.hasAcroForm()));
1267   - j_acroform.addDictionaryMember(
1268   - "needappearances", JSON::makeBool(afdh.getNeedAppearances()));
  1194 + j_acroform.addDictionaryMember("hasacroform", JSON::makeBool(afdh.hasAcroForm()));
  1195 + j_acroform.addDictionaryMember("needappearances", JSON::makeBool(afdh.getNeedAppearances()));
1269 1196 JSON j_fields = j_acroform.addDictionaryMember("fields", JSON::makeArray());
1270 1197 int pagepos1 = 0;
1271 1198 for (auto const& page: QPDFPageDocumentHelper(pdf).getAllPages()) {
... ... @@ -1273,52 +1200,34 @@ QPDFJob::doJSONAcroform(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1273 1200 for (auto& aoh: afdh.getWidgetAnnotationsForPage(page)) {
1274 1201 QPDFFormFieldObjectHelper ffh = afdh.getFieldForAnnotation(aoh);
1275 1202 JSON j_field = j_fields.addArrayElement(JSON::makeDictionary());
  1203 + j_field.addDictionaryMember("object", ffh.getObjectHandle().getJSON(m->json_version));
1276 1204 j_field.addDictionaryMember(
1277   - "object", ffh.getObjectHandle().getJSON(m->json_version));
1278   - j_field.addDictionaryMember(
1279   - "parent",
1280   - ffh.getObjectHandle().getKey("/Parent").getJSON(
1281   - m->json_version));
1282   - j_field.addDictionaryMember(
1283   - "pageposfrom1", JSON::makeInt(pagepos1));
1284   - j_field.addDictionaryMember(
1285   - "fieldtype", JSON::makeString(ffh.getFieldType()));
1286   - j_field.addDictionaryMember(
1287   - "fieldflags", JSON::makeInt(ffh.getFlags()));
1288   - j_field.addDictionaryMember(
1289   - "fullname", JSON::makeString(ffh.getFullyQualifiedName()));
1290   - j_field.addDictionaryMember(
1291   - "partialname", JSON::makeString(ffh.getPartialName()));
  1205 + "parent", ffh.getObjectHandle().getKey("/Parent").getJSON(m->json_version));
  1206 + j_field.addDictionaryMember("pageposfrom1", JSON::makeInt(pagepos1));
  1207 + j_field.addDictionaryMember("fieldtype", JSON::makeString(ffh.getFieldType()));
  1208 + j_field.addDictionaryMember("fieldflags", JSON::makeInt(ffh.getFlags()));
  1209 + j_field.addDictionaryMember("fullname", JSON::makeString(ffh.getFullyQualifiedName()));
  1210 + j_field.addDictionaryMember("partialname", JSON::makeString(ffh.getPartialName()));
1292 1211 j_field.addDictionaryMember(
1293 1212 "alternativename", JSON::makeString(ffh.getAlternativeName()));
1294   - j_field.addDictionaryMember(
1295   - "mappingname", JSON::makeString(ffh.getMappingName()));
1296   - j_field.addDictionaryMember(
1297   - "value", ffh.getValue().getJSON(m->json_version));
  1213 + j_field.addDictionaryMember("mappingname", JSON::makeString(ffh.getMappingName()));
  1214 + j_field.addDictionaryMember("value", ffh.getValue().getJSON(m->json_version));
1298 1215 j_field.addDictionaryMember(
1299 1216 "defaultvalue", ffh.getDefaultValue().getJSON(m->json_version));
1300   - j_field.addDictionaryMember(
1301   - "quadding", JSON::makeInt(ffh.getQuadding()));
1302   - j_field.addDictionaryMember(
1303   - "ischeckbox", JSON::makeBool(ffh.isCheckbox()));
1304   - j_field.addDictionaryMember(
1305   - "isradiobutton", JSON::makeBool(ffh.isRadioButton()));
1306   - j_field.addDictionaryMember(
1307   - "ischoice", JSON::makeBool(ffh.isChoice()));
  1217 + j_field.addDictionaryMember("quadding", JSON::makeInt(ffh.getQuadding()));
  1218 + j_field.addDictionaryMember("ischeckbox", JSON::makeBool(ffh.isCheckbox()));
  1219 + j_field.addDictionaryMember("isradiobutton", JSON::makeBool(ffh.isRadioButton()));
  1220 + j_field.addDictionaryMember("ischoice", JSON::makeBool(ffh.isChoice()));
1308 1221 j_field.addDictionaryMember("istext", JSON::makeBool(ffh.isText()));
1309   - JSON j_choices =
1310   - j_field.addDictionaryMember("choices", JSON::makeArray());
  1222 + JSON j_choices = j_field.addDictionaryMember("choices", JSON::makeArray());
1311 1223 for (auto const& choice: ffh.getChoices()) {
1312 1224 j_choices.addArrayElement(JSON::makeString(choice));
1313 1225 }
1314   - JSON j_annot = j_field.addDictionaryMember(
1315   - "annotation", JSON::makeDictionary());
1316   - j_annot.addDictionaryMember(
1317   - "object", aoh.getObjectHandle().getJSON(m->json_version));
  1226 + JSON j_annot = j_field.addDictionaryMember("annotation", JSON::makeDictionary());
  1227 + j_annot.addDictionaryMember("object", aoh.getObjectHandle().getJSON(m->json_version));
1318 1228 j_annot.addDictionaryMember(
1319 1229 "appearancestate", JSON::makeString(aoh.getAppearanceState()));
1320   - j_annot.addDictionaryMember(
1321   - "annotationflags", JSON::makeInt(aoh.getFlags()));
  1230 + j_annot.addDictionaryMember("annotationflags", JSON::makeInt(aoh.getFlags()));
1322 1231 }
1323 1232 }
1324 1233 JSON::writeDictionaryItem(p, first, "acroform", j_acroform, 1);
... ... @@ -1333,50 +1242,34 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1333 1242 QPDF::encryption_method_e stream_method = QPDF::e_none;
1334 1243 QPDF::encryption_method_e string_method = QPDF::e_none;
1335 1244 QPDF::encryption_method_e file_method = QPDF::e_none;
1336   - bool is_encrypted =
1337   - pdf.isEncrypted(R, P, V, stream_method, string_method, file_method);
  1245 + bool is_encrypted = pdf.isEncrypted(R, P, V, stream_method, string_method, file_method);
1338 1246 JSON j_encrypt = JSON::makeDictionary();
1339 1247 j_encrypt.addDictionaryMember("encrypted", JSON::makeBool(is_encrypted));
1340 1248 j_encrypt.addDictionaryMember(
1341   - "userpasswordmatched",
1342   - JSON::makeBool(is_encrypted && pdf.userPasswordMatched()));
  1249 + "userpasswordmatched", JSON::makeBool(is_encrypted && pdf.userPasswordMatched()));
1343 1250 j_encrypt.addDictionaryMember(
1344   - "ownerpasswordmatched",
1345   - JSON::makeBool(is_encrypted && pdf.ownerPasswordMatched()));
1346   - if (is_encrypted && (V < 5) && pdf.ownerPasswordMatched() &&
1347   - (!pdf.userPasswordMatched())) {
  1251 + "ownerpasswordmatched", JSON::makeBool(is_encrypted && pdf.ownerPasswordMatched()));
  1252 + if (is_encrypted && (V < 5) && pdf.ownerPasswordMatched() && (!pdf.userPasswordMatched())) {
1348 1253 std::string user_password = pdf.getTrimmedUserPassword();
1349   - j_encrypt.addDictionaryMember(
1350   - "recovereduserpassword", JSON::makeString(user_password));
  1254 + j_encrypt.addDictionaryMember("recovereduserpassword", JSON::makeString(user_password));
1351 1255 } else {
1352   - j_encrypt.addDictionaryMember(
1353   - "recovereduserpassword", JSON::makeNull());
1354   - }
1355   - JSON j_capabilities =
1356   - j_encrypt.addDictionaryMember("capabilities", JSON::makeDictionary());
1357   - j_capabilities.addDictionaryMember(
1358   - "accessibility", JSON::makeBool(pdf.allowAccessibility()));
1359   - j_capabilities.addDictionaryMember(
1360   - "extract", JSON::makeBool(pdf.allowExtractAll()));
1361   - j_capabilities.addDictionaryMember(
1362   - "printlow", JSON::makeBool(pdf.allowPrintLowRes()));
1363   - j_capabilities.addDictionaryMember(
1364   - "printhigh", JSON::makeBool(pdf.allowPrintHighRes()));
1365   - j_capabilities.addDictionaryMember(
1366   - "modifyassembly", JSON::makeBool(pdf.allowModifyAssembly()));
1367   - j_capabilities.addDictionaryMember(
1368   - "modifyforms", JSON::makeBool(pdf.allowModifyForm()));
  1256 + j_encrypt.addDictionaryMember("recovereduserpassword", JSON::makeNull());
  1257 + }
  1258 + JSON j_capabilities = j_encrypt.addDictionaryMember("capabilities", JSON::makeDictionary());
  1259 + j_capabilities.addDictionaryMember("accessibility", JSON::makeBool(pdf.allowAccessibility()));
  1260 + j_capabilities.addDictionaryMember("extract", JSON::makeBool(pdf.allowExtractAll()));
  1261 + j_capabilities.addDictionaryMember("printlow", JSON::makeBool(pdf.allowPrintLowRes()));
  1262 + j_capabilities.addDictionaryMember("printhigh", JSON::makeBool(pdf.allowPrintHighRes()));
  1263 + j_capabilities.addDictionaryMember("modifyassembly", JSON::makeBool(pdf.allowModifyAssembly()));
  1264 + j_capabilities.addDictionaryMember("modifyforms", JSON::makeBool(pdf.allowModifyForm()));
1369 1265 /* cSpell:ignore moddifyannotations */
1370 1266 std::string MODIFY_ANNOTATIONS =
1371 1267 (m->json_version == 1 ? "moddifyannotations" : "modifyannotations");
1372 1268 j_capabilities.addDictionaryMember(
1373 1269 MODIFY_ANNOTATIONS, JSON::makeBool(pdf.allowModifyAnnotation()));
1374   - j_capabilities.addDictionaryMember(
1375   - "modifyother", JSON::makeBool(pdf.allowModifyOther()));
1376   - j_capabilities.addDictionaryMember(
1377   - "modify", JSON::makeBool(pdf.allowModifyAll()));
1378   - JSON j_parameters =
1379   - j_encrypt.addDictionaryMember("parameters", JSON::makeDictionary());
  1270 + j_capabilities.addDictionaryMember("modifyother", JSON::makeBool(pdf.allowModifyOther()));
  1271 + j_capabilities.addDictionaryMember("modify", JSON::makeBool(pdf.allowModifyAll()));
  1272 + JSON j_parameters = j_encrypt.addDictionaryMember("parameters", JSON::makeDictionary());
1380 1273 j_parameters.addDictionaryMember("R", JSON::makeInt(R));
1381 1274 j_parameters.addDictionaryMember("V", JSON::makeInt(V));
1382 1275 j_parameters.addDictionaryMember("P", JSON::makeInt(P));
... ... @@ -1408,14 +1301,10 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1408 1301 } else {
1409 1302 s_overall_method = "mixed";
1410 1303 }
1411   - j_parameters.addDictionaryMember(
1412   - "method", JSON::makeString(s_overall_method));
1413   - j_parameters.addDictionaryMember(
1414   - "streammethod", JSON::makeString(s_stream_method));
1415   - j_parameters.addDictionaryMember(
1416   - "stringmethod", JSON::makeString(s_string_method));
1417   - j_parameters.addDictionaryMember(
1418   - "filemethod", JSON::makeString(s_file_method));
  1304 + j_parameters.addDictionaryMember("method", JSON::makeString(s_overall_method));
  1305 + j_parameters.addDictionaryMember("streammethod", JSON::makeString(s_stream_method));
  1306 + j_parameters.addDictionaryMember("stringmethod", JSON::makeString(s_string_method));
  1307 + j_parameters.addDictionaryMember("filemethod", JSON::makeString(s_file_method));
1419 1308 JSON::writeDictionaryItem(p, first, "encrypt", j_encrypt, 1);
1420 1309 }
1421 1310  
... ... @@ -1443,39 +1332,28 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1443 1332 for (auto const& iter: efdh.getEmbeddedFiles()) {
1444 1333 std::string const& key = iter.first;
1445 1334 auto fsoh = iter.second;
1446   - auto j_details =
1447   - j_attachments.addDictionaryMember(key, JSON::makeDictionary());
  1335 + auto j_details = j_attachments.addDictionaryMember(key, JSON::makeDictionary());
1448 1336 j_details.addDictionaryMember(
1449 1337 "filespec", JSON::makeString(fsoh->getObjectHandle().unparse()));
  1338 + j_details.addDictionaryMember("preferredname", JSON::makeString(fsoh->getFilename()));
1450 1339 j_details.addDictionaryMember(
1451   - "preferredname", JSON::makeString(fsoh->getFilename()));
1452   - j_details.addDictionaryMember(
1453   - "preferredcontents",
1454   - JSON::makeString(fsoh->getEmbeddedFileStream().unparse()));
1455   - j_details.addDictionaryMember(
1456   - "description", null_or_string(fsoh->getDescription()));
1457   - auto j_names =
1458   - j_details.addDictionaryMember("names", JSON::makeDictionary());
  1340 + "preferredcontents", JSON::makeString(fsoh->getEmbeddedFileStream().unparse()));
  1341 + j_details.addDictionaryMember("description", null_or_string(fsoh->getDescription()));
  1342 + auto j_names = j_details.addDictionaryMember("names", JSON::makeDictionary());
1459 1343 for (auto const& i2: fsoh->getFilenames()) {
1460 1344 j_names.addDictionaryMember(i2.first, JSON::makeString(i2.second));
1461 1345 }
1462   - auto j_streams =
1463   - j_details.addDictionaryMember("streams", JSON::makeDictionary());
  1346 + auto j_streams = j_details.addDictionaryMember("streams", JSON::makeDictionary());
1464 1347 for (auto i2: fsoh->getEmbeddedFileStreams().ditems()) {
1465 1348 auto efs = QPDFEFStreamObjectHelper(i2.second);
1466   - auto j_stream =
1467   - j_streams.addDictionaryMember(i2.first, JSON::makeDictionary());
1468   - j_stream.addDictionaryMember(
1469   - "creationdate",
1470   - null_or_string(to_iso8601(efs.getCreationDate())));
  1349 + auto j_stream = j_streams.addDictionaryMember(i2.first, JSON::makeDictionary());
1471 1350 j_stream.addDictionaryMember(
1472   - "modificationdate",
1473   - null_or_string(to_iso8601(efs.getCreationDate())));
  1351 + "creationdate", null_or_string(to_iso8601(efs.getCreationDate())));
1474 1352 j_stream.addDictionaryMember(
1475   - "mimetype", null_or_string(efs.getSubtype()));
  1353 + "modificationdate", null_or_string(to_iso8601(efs.getCreationDate())));
  1354 + j_stream.addDictionaryMember("mimetype", null_or_string(efs.getSubtype()));
1476 1355 j_stream.addDictionaryMember(
1477   - "checksum",
1478   - null_or_string(QUtil::hex_encode(efs.getChecksum())));
  1356 + "checksum", null_or_string(QUtil::hex_encode(efs.getChecksum())));
1479 1357 }
1480 1358 }
1481 1359 JSON::writeDictionaryItem(p, first, "attachments", j_attachments, 1);
... ... @@ -1503,8 +1381,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys)
1503 1381 JSON schema = JSON::makeDictionary();
1504 1382 schema.addDictionaryMember(
1505 1383 "version",
1506   - JSON::makeString(
1507   - "JSON format serial number; increased for non-compatible changes"));
  1384 + JSON::makeString("JSON format serial number; increased for non-compatible changes"));
1508 1385 JSON j_params = schema.addDictionaryMember("parameters", JSON::parse(R"({
1509 1386 "decodelevel": "decode level used to determine stream filterability"
1510 1387 })"));
... ... @@ -1521,8 +1398,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys)
1521 1398 })"));
1522 1399 }
1523 1400 if (all_keys || keys->count("objectinfo")) {
1524   - JSON objectinfo =
1525   - schema.addDictionaryMember("objectinfo", JSON::parse(R"({
  1401 + JSON objectinfo = schema.addDictionaryMember("objectinfo", JSON::parse(R"({
1526 1402 "<object-id>": {
1527 1403 "stream": {
1528 1404 "filter": "if stream, its filters, otherwise null",
... ... @@ -1667,8 +1543,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys)
1667 1543 })"));
1668 1544 }
1669 1545 if (all_keys || keys->count("attachments")) {
1670   - JSON attachments =
1671   - schema.addDictionaryMember("attachments", JSON::parse(R"({
  1546 + JSON attachments = schema.addDictionaryMember("attachments", JSON::parse(R"({
1672 1547 "<attachment-key>": {
1673 1548 "filespec": "object containing the file spec",
1674 1549 "preferredcontents": "most preferred embedded file stream",
... ... @@ -1728,8 +1603,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p)
1728 1603 // change is made to the JSON format. Clients of the JSON are to
1729 1604 // ignore unrecognized keys, so we only update the version of a
1730 1605 // key disappears or if its value changes meaning.
1731   - JSON::writeDictionaryItem(
1732   - p, first, "version", JSON::makeInt(m->json_version), 1);
  1606 + JSON::writeDictionaryItem(p, first, "version", JSON::makeInt(m->json_version), 1);
1733 1607 JSON j_params = JSON::makeDictionary();
1734 1608 std::string decode_level_str;
1735 1609 switch (m->decode_level) {
... ... @@ -1746,8 +1620,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p)
1746 1620 decode_level_str = "all";
1747 1621 break;
1748 1622 }
1749   - j_params.addDictionaryMember(
1750   - "decodelevel", JSON::makeString(decode_level_str));
  1623 + j_params.addDictionaryMember("decodelevel", JSON::makeString(decode_level_str));
1751 1624 JSON::writeDictionaryItem(p, first, "parameters", j_params, 1);
1752 1625 }
1753 1626 bool all_keys = m->json_keys.empty();
... ... @@ -1784,8 +1657,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p)
1784 1657 // repairing the page tree. To see the original file with any page
1785 1658 // tree problems and the page tree not flattened, select
1786 1659 // qpdf/objects/objectinfo without other keys.
1787   - if (all_keys || m->json_keys.count("objects") ||
1788   - m->json_keys.count("qpdf")) {
  1660 + if (all_keys || m->json_keys.count("objects") || m->json_keys.count("qpdf")) {
1789 1661 doJSONObjects(p, first, pdf);
1790 1662 }
1791 1663 if (m->json_version == 1) {
... ... @@ -1823,8 +1695,7 @@ QPDFJob::doInspection(QPDF&amp; pdf)
1823 1695 }
1824 1696 if (m->show_npages) {
1825 1697 QTC::TC("qpdf", "QPDFJob npages");
1826   - cout << pdf.getRoot().getKey("/Pages").getKey("/Count").getIntValue()
1827   - << "\n";
  1698 + cout << pdf.getRoot().getKey("/Pages").getKey("/Count").getIntValue() << "\n";
1828 1699 }
1829 1700 if (m->show_encryption) {
1830 1701 showEncryption(pdf);
... ... @@ -1917,8 +1788,7 @@ QPDFJob::doProcess(
1917 1788 password = ptemp.c_str();
1918 1789 }
1919 1790 }
1920   - if ((password == nullptr) || empty || m->password_is_hex_key ||
1921   - m->suppress_password_recovery) {
  1791 + if ((password == nullptr) || empty || m->password_is_hex_key || m->suppress_password_recovery) {
1922 1792 // There is no password, or we're not doing recovery, so just
1923 1793 // do the normal processing with the supplied password.
1924 1794 doProcessOnce(pdf, fn, password, empty, used_for_input, main_input);
... ... @@ -1927,8 +1797,7 @@ QPDFJob::doProcess(
1927 1797  
1928 1798 // Get a list of otherwise encoded strings. Keep in scope for this
1929 1799 // method.
1930   - std::vector<std::string> passwords_str =
1931   - QUtil::possible_repaired_encodings(password);
  1800 + std::vector<std::string> passwords_str = QUtil::possible_repaired_encodings(password);
1932 1801 // Represent to char const*, as required by the QPDF class.
1933 1802 std::vector<char const*> passwords;
1934 1803 for (auto const& iter: passwords_str) {
... ... @@ -1981,15 +1850,8 @@ QPDFJob::processFile(
1981 1850 bool main_input)
1982 1851 {
1983 1852 auto f1 = std::mem_fn<void(char const*, char const*)>(&QPDF::processFile);
1984   - auto fn =
1985   - std::bind(f1, std::placeholders::_1, filename, std::placeholders::_2);
1986   - doProcess(
1987   - pdf,
1988   - fn,
1989   - password,
1990   - strcmp(filename, "") == 0,
1991   - used_for_input,
1992   - main_input);
  1853 + auto fn = std::bind(f1, std::placeholders::_1, filename, std::placeholders::_2);
  1854 + doProcess(pdf, fn, password, strcmp(filename, "") == 0, used_for_input, main_input);
1993 1855 }
1994 1856  
1995 1857 void
... ... @@ -2019,32 +1881,26 @@ QPDFJob::validateUnderOverlay(QPDF&amp; pdf, UnderOverlay* uo)
2019 1881 uo->to_pagenos = QUtil::parse_numrange(uo->to_nr.c_str(), main_npages);
2020 1882 } catch (std::runtime_error& e) {
2021 1883 throw std::runtime_error(
2022   - "parsing numeric range for " + uo->which +
2023   - " \"to\" pages: " + e.what());
  1884 + "parsing numeric range for " + uo->which + " \"to\" pages: " + e.what());
2024 1885 }
2025 1886 try {
2026 1887 if (uo->from_nr.empty()) {
2027 1888 QTC::TC("qpdf", "QPDFJob from_nr from repeat_nr");
2028 1889 uo->from_nr = uo->repeat_nr;
2029 1890 }
2030   - uo->from_pagenos =
2031   - QUtil::parse_numrange(uo->from_nr.c_str(), uo_npages);
  1891 + uo->from_pagenos = QUtil::parse_numrange(uo->from_nr.c_str(), uo_npages);
2032 1892 if (!uo->repeat_nr.empty()) {
2033   - uo->repeat_pagenos =
2034   - QUtil::parse_numrange(uo->repeat_nr.c_str(), uo_npages);
  1893 + uo->repeat_pagenos = QUtil::parse_numrange(uo->repeat_nr.c_str(), uo_npages);
2035 1894 }
2036 1895 } catch (std::runtime_error& e) {
2037 1896 throw std::runtime_error(
2038   - "parsing numeric range for " + uo->which + " file " + uo->filename +
2039   - ": " + e.what());
  1897 + "parsing numeric range for " + uo->which + " file " + uo->filename + ": " + e.what());
2040 1898 }
2041 1899 }
2042 1900  
2043 1901 static QPDFAcroFormDocumentHelper*
2044 1902 get_afdh_for_qpdf(
2045   - std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>&
2046   - afdh_map,
2047   - QPDF* q)
  1903 + std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>& afdh_map, QPDF* q)
2048 1904 {
2049 1905 auto uid = q->getUniqueId();
2050 1906 if (!afdh_map.count(uid)) {
... ... @@ -2068,8 +1924,7 @@ QPDFJob::doUnderOverlayForPage(
2068 1924 return "";
2069 1925 }
2070 1926  
2071   - std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>
2072   - afdh;
  1927 + std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>> afdh;
2073 1928 auto make_afdh = [&](QPDFPageObjectHelper& ph) {
2074 1929 QPDF& q = ph.getObjectHandle().getQPDF();
2075 1930 return get_afdh_for_qpdf(afdh, &q);
... ... @@ -2085,8 +1940,7 @@ QPDFJob::doUnderOverlayForPage(
2085 1940 });
2086 1941 auto from_page = pages.at(QIntC::to_size(from_pageno - 1));
2087 1942 if (0 == fo.count(from_pageno)) {
2088   - fo[from_pageno] =
2089   - pdf.copyForeignObject(from_page.getFormXObjectForPage());
  1943 + fo[from_pageno] = pdf.copyForeignObject(from_page.getFormXObjectForPage());
2090 1944 }
2091 1945  
2092 1946 // If the same page is overlaid or underlaid multiple times,
... ... @@ -2096,12 +1950,8 @@ QPDFJob::doUnderOverlayForPage(
2096 1950 std::string name = resources.getUniqueResourceName("/Fx", min_suffix);
2097 1951 QPDFMatrix cm;
2098 1952 std::string new_content = dest_page.placeFormXObject(
2099   - fo[from_pageno],
2100   - name,
2101   - dest_page.getTrimBox().getArrayAsRectangle(),
2102   - cm);
2103   - dest_page.copyAnnotations(
2104   - from_page, cm, dest_afdh, make_afdh(from_page));
  1953 + fo[from_pageno], name, dest_page.getTrimBox().getArrayAsRectangle(), cm);
  1954 + dest_page.copyAnnotations(from_page, cm, dest_afdh, make_afdh(from_page));
2105 1955 if (!new_content.empty()) {
2106 1956 resources.mergeResources("<< /XObject << >> >>"_qpdf);
2107 1957 auto xobject = resources.getKey("/XObject");
... ... @@ -2116,8 +1966,7 @@ QPDFJob::doUnderOverlayForPage(
2116 1966 }
2117 1967  
2118 1968 void
2119   -QPDFJob::getUOPagenos(
2120   - QPDFJob::UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos)
  1969 +QPDFJob::getUOPagenos(QPDFJob::UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos)
2121 1970 {
2122 1971 size_t idx = 0;
2123 1972 size_t from_size = uo.from_pagenos.size();
... ... @@ -2126,8 +1975,7 @@ QPDFJob::getUOPagenos(
2126 1975 if (idx < from_size) {
2127 1976 pagenos[to_pageno].push_back(uo.from_pagenos.at(idx));
2128 1977 } else if (repeat_size) {
2129   - pagenos[to_pageno].push_back(
2130   - uo.repeat_pagenos.at((idx - from_size) % repeat_size));
  1978 + pagenos[to_pageno].push_back(uo.repeat_pagenos.at((idx - from_size) % repeat_size));
2131 1979 }
2132 1980 ++idx;
2133 1981 }
... ... @@ -2163,12 +2011,10 @@ QPDFJob::handleUnderOverlay(QPDF&amp; pdf)
2163 2011 v << prefix << ": processing underlay/overlay\n";
2164 2012 });
2165 2013 for (size_t i = 0; i < main_npages; ++i) {
2166   - doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2167   - v << " page " << 1 + i << "\n";
2168   - });
  2014 + doIfVerbose(
  2015 + [&](Pipeline& v, std::string const& prefix) { v << " page " << 1 + i << "\n"; });
2169 2016 auto pageno = QIntC::to_int(i) + 1;
2170   - if (!(underlay_pagenos.count(pageno) ||
2171   - overlay_pagenos.count(pageno))) {
  2017 + if (!(underlay_pagenos.count(pageno) || overlay_pagenos.count(pageno))) {
2172 2018 continue;
2173 2019 }
2174 2020 // This code converts the original page, any underlays, and
... ... @@ -2184,19 +2030,12 @@ QPDFJob::handleUnderOverlay(QPDF&amp; pdf)
2184 2030 // the original page, which we are going to replace. Therefore
2185 2031 // we have to explicitly copy it.
2186 2032 auto content_data = this_page_fo.getRawStreamData();
2187   - this_page_fo.replaceStreamData(
2188   - content_data, QPDFObjectHandle(), QPDFObjectHandle());
2189   - auto resources = dest_page_oh.replaceKeyAndGetNew(
2190   - "/Resources", "<< /XObject << >> >>"_qpdf);
  2033 + this_page_fo.replaceStreamData(content_data, QPDFObjectHandle(), QPDFObjectHandle());
  2034 + auto resources =
  2035 + dest_page_oh.replaceKeyAndGetNew("/Resources", "<< /XObject << >> >>"_qpdf);
2191 2036 resources.getKey("/XObject").replaceKeyAndGetNew("/Fx0", this_page_fo);
2192 2037 auto content = doUnderOverlayForPage(
2193   - pdf,
2194   - m->underlay,
2195   - underlay_pagenos,
2196   - i,
2197   - underlay_fo,
2198   - upages,
2199   - dest_page);
  2038 + pdf, m->underlay, underlay_pagenos, i, underlay_fo, upages, dest_page);
2200 2039 content += dest_page.placeFormXObject(
2201 2040 this_page_fo,
2202 2041 "/Fx0",
... ... @@ -2231,8 +2070,7 @@ QPDFJob::addAttachments(QPDF&amp; pdf)
2231 2070 continue;
2232 2071 }
2233 2072  
2234   - auto fs = QPDFFileSpecObjectHelper::createFileSpec(
2235   - pdf, to_add.filename, to_add.path);
  2073 + auto fs = QPDFFileSpecObjectHelper::createFileSpec(pdf, to_add.filename, to_add.path);
2236 2074 if (!to_add.description.empty()) {
2237 2075 fs.setDescription(to_add.description);
2238 2076 }
... ... @@ -2244,8 +2082,8 @@ QPDFJob::addAttachments(QPDF&amp; pdf)
2244 2082  
2245 2083 efdh.replaceEmbeddedFile(to_add.key, fs);
2246 2084 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2247   - v << prefix << ": attached " << to_add.path << " as "
2248   - << to_add.filename << " with key " << to_add.key << "\n";
  2085 + v << prefix << ": attached " << to_add.path << " as " << to_add.filename << " with key "
  2086 + << to_add.key << "\n";
2249 2087 });
2250 2088 }
2251 2089  
... ... @@ -2273,28 +2111,19 @@ QPDFJob::copyAttachments(QPDF&amp; pdf)
2273 2111 std::vector<std::string> duplicates;
2274 2112 for (auto const& to_copy: m->attachments_to_copy) {
2275 2113 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2276   - v << prefix << ": copying attachments from " << to_copy.path
2277   - << "\n";
  2114 + v << prefix << ": copying attachments from " << to_copy.path << "\n";
2278 2115 });
2279 2116 std::unique_ptr<QPDF> other;
2280   - processFile(
2281   - other,
2282   - to_copy.path.c_str(),
2283   - to_copy.password.c_str(),
2284   - false,
2285   - false);
  2117 + processFile(other, to_copy.path.c_str(), to_copy.password.c_str(), false, false);
2286 2118 QPDFEmbeddedFileDocumentHelper other_efdh(*other);
2287 2119 auto other_attachments = other_efdh.getEmbeddedFiles();
2288 2120 for (auto const& iter: other_attachments) {
2289 2121 std::string new_key = to_copy.prefix + iter.first;
2290 2122 if (efdh.getEmbeddedFile(new_key)) {
2291   - duplicates.push_back(
2292   - "file: " + to_copy.path + ", key: " + new_key);
  2123 + duplicates.push_back("file: " + to_copy.path + ", key: " + new_key);
2293 2124 } else {
2294   - auto new_fs_oh =
2295   - pdf.copyForeignObject(iter.second->getObjectHandle());
2296   - efdh.replaceEmbeddedFile(
2297   - new_key, QPDFFileSpecObjectHelper(new_fs_oh));
  2125 + auto new_fs_oh = pdf.copyForeignObject(iter.second->getObjectHandle());
  2126 + efdh.replaceEmbeddedFile(new_key, QPDFFileSpecObjectHelper(new_fs_oh));
2298 2127 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2299 2128 v << " " << iter.first << " -> " << new_key << "\n";
2300 2129 });
... ... @@ -2337,8 +2166,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2337 2166 if (m->remove_restrictions) {
2338 2167 pdf.removeSecurityRestrictions();
2339 2168 }
2340   - if (m->externalize_inline_images ||
2341   - (m->optimize_images && (!m->keep_inline_images))) {
  2169 + if (m->externalize_inline_images || (m->optimize_images && (!m->keep_inline_images))) {
2342 2170 for (auto& ph: dh.getAllPages()) {
2343 2171 ph.externalizeInlineImages(m->ii_min_bytes);
2344 2172 }
... ... @@ -2350,18 +2178,10 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2350 2178 ph.forEachImage(
2351 2179 true,
2352 2180 [this, pageno, &pdf](
2353   - QPDFObjectHandle& obj,
2354   - QPDFObjectHandle& xobj_dict,
2355   - std::string const& key) {
  2181 + QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key) {
2356 2182 auto io = std::make_unique<ImageOptimizer>(
2357   - *this,
2358   - m->oi_min_width,
2359   - m->oi_min_height,
2360   - m->oi_min_area,
2361   - obj);
2362   - if (io->evaluate(
2363   - "image " + key + " on page " +
2364   - std::to_string(pageno))) {
  2183 + *this, m->oi_min_width, m->oi_min_height, m->oi_min_area, obj);
  2184 + if (io->evaluate("image " + key + " on page " + std::to_string(pageno))) {
2365 2185 QPDFObjectHandle new_image = pdf.newStream();
2366 2186 new_image.replaceDict(obj.getDict().shallowCopy());
2367 2187 new_image.replaceStreamData(
... ... @@ -2378,8 +2198,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2378 2198 afdh->generateAppearancesIfNeeded();
2379 2199 }
2380 2200 if (m->flatten_annotations) {
2381   - dh.flattenAnnotations(
2382   - m->flatten_annotations_required, m->flatten_annotations_forbidden);
  2201 + dh.flattenAnnotations(m->flatten_annotations_required, m->flatten_annotations_forbidden);
2383 2202 }
2384 2203 if (m->coalesce_contents) {
2385 2204 for (auto& page: dh.getAllPages()) {
... ... @@ -2438,8 +2257,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2438 2257 QPDFObjGen::set nodes_seen; // loop detection
2439 2258  
2440 2259 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2441   - v << prefix << ": " << pdf.getFilename()
2442   - << ": checking for shared resources\n";
  2260 + v << prefix << ": " << pdf.getFilename() << ": checking for shared resources\n";
2443 2261 });
2444 2262  
2445 2263 std::list<QPDFObjectHandle> queue;
... ... @@ -2458,8 +2276,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2458 2276 if (dict.hasKey("/Resources")) {
2459 2277 QTC::TC("qpdf", "QPDFJob found resources in non-leaf");
2460 2278 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2461   - v << " found resources in non-leaf page node "
2462   - << og.unparse(' ') << "\n";
  2279 + v << " found resources in non-leaf page node " << og.unparse(' ') << "\n";
2463 2280 });
2464 2281 return true;
2465 2282 }
... ... @@ -2474,8 +2291,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2474 2291 if (!resources_seen.add(resources)) {
2475 2292 QTC::TC("qpdf", "QPDFJob found shared resources in leaf");
2476 2293 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2477   - v << " found shared resources in leaf node "
2478   - << og.unparse(' ') << ": "
  2294 + v << " found shared resources in leaf node " << og.unparse(' ') << ": "
2479 2295 << resources.getObjGen().unparse(' ') << "\n";
2480 2296 });
2481 2297 return true;
... ... @@ -2488,8 +2304,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2488 2304 if (!resources_seen.add(xobject)) {
2489 2305 QTC::TC("qpdf", "QPDFJob found shared xobject in leaf");
2490 2306 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2491   - v << " found shared xobject in leaf node "
2492   - << og.unparse(' ') << ": "
  2307 + v << " found shared xobject in leaf node " << og.unparse(' ') << ": "
2493 2308 << xobject.getObjGen().unparse(' ') << "\n";
2494 2309 });
2495 2310 return true;
... ... @@ -2531,8 +2346,7 @@ added_page(QPDF&amp; pdf, QPDFPageObjectHelper page)
2531 2346 }
2532 2347  
2533 2348 void
2534   -QPDFJob::handlePageSpecs(
2535   - QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap)
  2349 +QPDFJob::handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap)
2536 2350 {
2537 2351 // Parse all page specifications and translate them into lists of
2538 2352 // actual pages.
... ... @@ -2554,13 +2368,10 @@ QPDFJob::handlePageSpecs(
2554 2368 filenames.insert(page_spec.filename);
2555 2369 }
2556 2370 m->keep_files_open = (filenames.size() <= m->keep_files_open_threshold);
2557   - QTC::TC(
2558   - "qpdf",
2559   - "QPDFJob automatically set keep files open",
2560   - m->keep_files_open ? 0 : 1);
  2371 + QTC::TC("qpdf", "QPDFJob automatically set keep files open", m->keep_files_open ? 0 : 1);
2561 2372 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2562   - v << prefix << ": selecting --keep-open-files="
2563   - << (m->keep_files_open ? "y" : "n") << "\n";
  2373 + v << prefix << ": selecting --keep-open-files=" << (m->keep_files_open ? "y" : "n")
  2374 + << "\n";
2564 2375 });
2565 2376 }
2566 2377  
... ... @@ -2600,8 +2411,7 @@ QPDFJob::handlePageSpecs(
2600 2411 cis->stayOpen(true);
2601 2412 } else {
2602 2413 QTC::TC("qpdf", "QPDFJob keep files open y");
2603   - FileInputSource* fis =
2604   - new FileInputSource(page_spec.filename.c_str());
  2414 + FileInputSource* fis = new FileInputSource(page_spec.filename.c_str());
2605 2415 is = std::shared_ptr<InputSource>(fis);
2606 2416 }
2607 2417 std::unique_ptr<QPDF> qpdf_sp;
... ... @@ -2618,10 +2428,7 @@ QPDFJob::handlePageSpecs(
2618 2428 // associated with this occurrence of the file.
2619 2429 parsed_specs.push_back(
2620 2430 // line-break
2621   - QPDFPageData(
2622   - page_spec.filename,
2623   - page_spec_qpdfs[page_spec.filename],
2624   - page_spec.range));
  2431 + QPDFPageData(page_spec.filename, page_spec_qpdfs[page_spec.filename], page_spec.range));
2625 2432 }
2626 2433  
2627 2434 std::map<unsigned long long, bool> remove_unreferenced;
... ... @@ -2636,8 +2443,7 @@ QPDFJob::handlePageSpecs(
2636 2443 QPDF& other(*(iter.second));
2637 2444 auto other_uuid = other.getUniqueId();
2638 2445 if (remove_unreferenced.count(other_uuid) == 0) {
2639   - remove_unreferenced[other_uuid] =
2640   - shouldRemoveUnreferencedResources(other);
  2446 + remove_unreferenced[other_uuid] = shouldRemoveUnreferencedResources(other);
2641 2447 }
2642 2448 if (cis) {
2643 2449 cis->stayOpen(false);
... ... @@ -2676,9 +2482,7 @@ QPDFJob::handlePageSpecs(
2676 2482 got_pages = true;
2677 2483 new_parsed_specs.push_back(
2678 2484 // line-break
2679   - QPDFPageData(
2680   - page_data,
2681   - page_data.selected_pages.at(cur_page + j)));
  2485 + QPDFPageData(page_data, page_data.selected_pages.at(cur_page + j)));
2682 2486 }
2683 2487 }
2684 2488 }
... ... @@ -2694,8 +2498,7 @@ QPDFJob::handlePageSpecs(
2694 2498 std::vector<QPDFObjectHandle> new_labels;
2695 2499 bool any_page_labels = false;
2696 2500 int out_pageno = 0;
2697   - std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>
2698   - afdh_map;
  2501 + std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>> afdh_map;
2699 2502 auto this_afdh = get_afdh_for_qpdf(afdh_map, &pdf);
2700 2503 std::set<QPDFObjGen> referenced_fields;
2701 2504 for (auto& page_data: parsed_specs) {
... ... @@ -2716,10 +2519,8 @@ QPDFJob::handlePageSpecs(
2716 2519 // Pages are specified from 1 but numbered from 0 in the
2717 2520 // vector
2718 2521 int pageno = pageno_iter - 1;
2719   - pldh.getLabelsForPageRange(
2720   - pageno, pageno, out_pageno++, new_labels);
2721   - QPDFPageObjectHelper to_copy =
2722   - page_data.orig_pages.at(QIntC::to_size(pageno));
  2522 + pldh.getLabelsForPageRange(pageno, pageno, out_pageno++, new_labels);
  2523 + QPDFPageObjectHelper to_copy = page_data.orig_pages.at(QIntC::to_size(pageno));
2723 2524 QPDFObjGen to_copy_og = to_copy.getObjectHandle().getObjGen();
2724 2525 unsigned long long from_uuid = page_data.qpdf->getUniqueId();
2725 2526 if (copied_pages[from_uuid].count(to_copy_og)) {
... ... @@ -2754,8 +2555,7 @@ QPDFJob::handlePageSpecs(
2754 2555 // adjusted. If we copy any page from the original file
2755 2556 // more than once, that page would be in conflict with the
2756 2557 // previous copy of itself.
2757   - if (other_afdh->hasAcroForm() &&
2758   - ((!this_file) || (!first_copy_from_orig))) {
  2558 + if (other_afdh->hasAcroForm() && ((!this_file) || (!first_copy_from_orig))) {
2759 2559 if (!this_file) {
2760 2560 QTC::TC("qpdf", "QPDFJob copy fields not this file");
2761 2561 } else if (!first_copy_from_orig) {
... ... @@ -2763,10 +2563,7 @@ QPDFJob::handlePageSpecs(
2763 2563 }
2764 2564 try {
2765 2565 this_afdh->fixCopiedAnnotations(
2766   - new_page,
2767   - to_copy.getObjectHandle(),
2768   - *other_afdh,
2769   - &referenced_fields);
  2566 + new_page, to_copy.getObjectHandle(), *other_afdh, &referenced_fields);
2770 2567 } catch (std::exception& e) {
2771 2568 pdf.warn(
2772 2569 qpdf_e_damaged_pdf,
... ... @@ -2800,9 +2597,7 @@ QPDFJob::handlePageSpecs(
2800 2597 referenced_fields.insert(field.getObjectHandle().getObjGen());
2801 2598 }
2802 2599 } else {
2803   - pdf.replaceObject(
2804   - page.getObjectHandle().getObjGen(),
2805   - QPDFObjectHandle::newNull());
  2600 + pdf.replaceObject(page.getObjectHandle().getObjGen(), QPDFObjectHandle::newNull());
2806 2601 }
2807 2602 }
2808 2603 // Remove unreferenced form fields
... ... @@ -2843,8 +2638,7 @@ QPDFJob::handleRotations(QPDF&amp; pdf)
2843 2638 for (int pageno_iter: QUtil::parse_numrange(range.c_str(), npages)) {
2844 2639 int pageno = pageno_iter - 1;
2845 2640 if ((pageno >= 0) && (pageno < npages)) {
2846   - pages.at(QIntC::to_size(pageno))
2847   - .rotatePage(rspec.angle, rspec.relative);
  2641 + pages.at(QIntC::to_size(pageno)).rotatePage(rspec.angle, rspec.relative);
2848 2642 }
2849 2643 }
2850 2644 }
... ... @@ -2869,24 +2663,21 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password)
2869 2663 bool has_8bit_chars;
2870 2664 bool is_valid_utf8;
2871 2665 bool is_utf16;
2872   - QUtil::analyze_encoding(
2873   - password, has_8bit_chars, is_valid_utf8, is_utf16);
  2666 + QUtil::analyze_encoding(password, has_8bit_chars, is_valid_utf8, is_utf16);
2874 2667 if (!has_8bit_chars) {
2875 2668 return;
2876 2669 }
2877 2670 if (m->password_mode == QPDFJob::pm_unicode) {
2878 2671 if (!is_valid_utf8) {
2879 2672 QTC::TC("qpdf", "QPDFJob password not unicode");
2880   - throw std::runtime_error(
2881   - "supplied password is not valid UTF-8");
  2673 + throw std::runtime_error("supplied password is not valid UTF-8");
2882 2674 }
2883 2675 if (R < 5) {
2884 2676 std::string encoded;
2885 2677 if (!QUtil::utf8_to_pdf_doc(password, encoded)) {
2886 2678 QTC::TC("qpdf", "QPDFJob password not encodable");
2887   - throw std::runtime_error(
2888   - "supplied password cannot be encoded for"
2889   - " 40-bit or 128-bit encryption formats");
  2679 + throw std::runtime_error("supplied password cannot be encoded for"
  2680 + " 40-bit or 128-bit encryption formats");
2890 2681 }
2891 2682 password = encoded;
2892 2683 }
... ... @@ -2895,8 +2686,7 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password)
2895 2686 std::string encoded;
2896 2687 if (QUtil::utf8_to_pdf_doc(password, encoded)) {
2897 2688 QTC::TC("qpdf", "QPDFJob auto-encode password");
2898   - doIfVerbose([&](Pipeline& v,
2899   - std::string const& prefix) {
  2689 + doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2900 2690 v << prefix << ": automatically converting Unicode"
2901 2691 << " password to single-byte encoding as"
2902 2692 << " required for 40-bit or 128-bit"
... ... @@ -2905,25 +2695,23 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password)
2905 2695 password = encoded;
2906 2696 } else {
2907 2697 QTC::TC("qpdf", "QPDFJob bytes fallback warning");
2908   - *m->log->getError()
2909   - << m->message_prefix << ": WARNING: "
2910   - << "supplied password looks like a Unicode"
2911   - << " password with characters not allowed in"
2912   - << " passwords for 40-bit and 128-bit "
2913   - "encryption;"
2914   - << " most readers will not be able to open this"
2915   - << " file with the supplied password."
2916   - << " (Use --password-mode=bytes to suppress "
2917   - "this"
2918   - << " warning and use the password anyway.)\n";
  2698 + *m->log->getError() << m->message_prefix << ": WARNING: "
  2699 + << "supplied password looks like a Unicode"
  2700 + << " password with characters not allowed in"
  2701 + << " passwords for 40-bit and 128-bit "
  2702 + "encryption;"
  2703 + << " most readers will not be able to open this"
  2704 + << " file with the supplied password."
  2705 + << " (Use --password-mode=bytes to suppress "
  2706 + "this"
  2707 + << " warning and use the password anyway.)\n";
2919 2708 }
2920 2709 } else if ((R >= 5) && (!is_valid_utf8)) {
2921 2710 QTC::TC("qpdf", "QPDFJob invalid utf-8 in auto");
2922   - throw std::runtime_error(
2923   - "supplied password is not a valid Unicode password,"
2924   - " which is required for 256-bit encryption; to"
2925   - " really use this password, rerun with the"
2926   - " --password-mode=bytes option");
  2711 + throw std::runtime_error("supplied password is not a valid Unicode password,"
  2712 + " which is required for 256-bit encryption; to"
  2713 + " really use this password, rerun with the"
  2714 + " --password-mode=bytes option");
2927 2715 }
2928 2716 }
2929 2717 }
... ... @@ -2953,28 +2741,25 @@ QPDFJob::setEncryptionOptions(QPDF&amp; pdf, QPDFWriter&amp; w)
2953 2741 throw std::logic_error("bad encryption keylen");
2954 2742 }
2955 2743 if ((R > 3) && (m->r3_accessibility == false)) {
2956   - *m->log->getError()
2957   - << m->message_prefix << ": -accessibility=n is ignored for modern"
2958   - << " encryption formats\n";
  2744 + *m->log->getError() << m->message_prefix << ": -accessibility=n is ignored for modern"
  2745 + << " encryption formats\n";
2959 2746 }
2960 2747 maybeFixWritePassword(R, m->user_password);
2961 2748 maybeFixWritePassword(R, m->owner_password);
2962 2749 if ((R < 4) || ((R == 4) && (!m->use_aes))) {
2963 2750 if (!m->allow_weak_crypto) {
2964 2751 QTC::TC("qpdf", "QPDFJob weak crypto error");
2965   - *m->log->getError()
2966   - << m->message_prefix
2967   - << ": refusing to write a file with RC4, a weak "
2968   - "cryptographic "
2969   - "algorithm\n"
2970   - << "Please use 256-bit keys for better security.\n"
2971   - << "Pass --allow-weak-crypto to enable writing insecure "
2972   - "files.\n"
2973   - << "See also "
2974   - "https://qpdf.readthedocs.io/en/stable/"
2975   - "weak-crypto.html\n";
2976   - throw std::runtime_error(
2977   - "refusing to write a file with weak crypto");
  2752 + *m->log->getError() << m->message_prefix
  2753 + << ": refusing to write a file with RC4, a weak "
  2754 + "cryptographic "
  2755 + "algorithm\n"
  2756 + << "Please use 256-bit keys for better security.\n"
  2757 + << "Pass --allow-weak-crypto to enable writing insecure "
  2758 + "files.\n"
  2759 + << "See also "
  2760 + "https://qpdf.readthedocs.io/en/stable/"
  2761 + "weak-crypto.html\n";
  2762 + throw std::runtime_error("refusing to write a file with weak crypto");
2978 2763 }
2979 2764 }
2980 2765 switch (R) {
... ... @@ -3046,10 +2831,7 @@ QPDFJob::setEncryptionOptions(QPDF&amp; pdf, QPDFWriter&amp; w)
3046 2831 }
3047 2832  
3048 2833 static void
3049   -parse_version(
3050   - std::string const& full_version_string,
3051   - std::string& version,
3052   - int& extension_level)
  2834 +parse_version(std::string const& full_version_string, std::string& version, int& extension_level)
3053 2835 {
3054 2836 auto vp = QUtil::make_unique_cstr(full_version_string);
3055 2837 char* v = vp.get();
... ... @@ -3144,18 +2926,13 @@ QPDFJob::setWriterOptions(QPDF&amp; pdf, QPDFWriter&amp; w)
3144 2926 }
3145 2927 if (m->progress) {
3146 2928 if (m->progress_handler) {
3147   - w.registerProgressReporter(
3148   - std::shared_ptr<QPDFWriter::ProgressReporter>(
3149   - new QPDFWriter::FunctionProgressReporter(
3150   - m->progress_handler)));
  2929 + w.registerProgressReporter(std::shared_ptr<QPDFWriter::ProgressReporter>(
  2930 + new QPDFWriter::FunctionProgressReporter(m->progress_handler)));
3151 2931 } else {
3152   - char const* outfilename =
3153   - m->outfilename ? m->outfilename.get() : "standard output";
3154   - w.registerProgressReporter(
3155   - std::shared_ptr<QPDFWriter::ProgressReporter>(
3156   - // line-break
3157   - new ProgressReporter(
3158   - *m->log->getInfo(), m->message_prefix, outfilename)));
  2932 + char const* outfilename = m->outfilename ? m->outfilename.get() : "standard output";
  2933 + w.registerProgressReporter(std::shared_ptr<QPDFWriter::ProgressReporter>(
  2934 + // line-break
  2935 + new ProgressReporter(*m->log->getInfo(), m->message_prefix, outfilename)));
3159 2936 }
3160 2937 }
3161 2938 }
... ... @@ -3170,14 +2947,10 @@ QPDFJob::doSplitPages(QPDF&amp; pdf)
3170 2947 char* num_spot = strstr(const_cast<char*>(m->outfilename.get()), "%d");
3171 2948 if (num_spot != nullptr) {
3172 2949 QTC::TC("qpdf", "QPDFJob split-pages %d");
3173   - before = std::string(
3174   - m->outfilename.get(),
3175   - QIntC::to_size(num_spot - m->outfilename.get()));
  2950 + before = std::string(m->outfilename.get(), QIntC::to_size(num_spot - m->outfilename.get()));
3176 2951 after = num_spot + 2;
3177 2952 } else if (
3178   - (len >= 4) &&
3179   - (QUtil::str_compare_nocase(m->outfilename.get() + len - 4, ".pdf") ==
3180   - 0)) {
  2953 + (len >= 4) && (QUtil::str_compare_nocase(m->outfilename.get() + len - 4, ".pdf") == 0)) {
3181 2954 QTC::TC("qpdf", "QPDFJob split-pages .pdf");
3182 2955 before = std::string(m->outfilename.get(), len - 4) + "-";
3183 2956 after = m->outfilename.get() + len - 4;
... ... @@ -3232,24 +3005,18 @@ QPDFJob::doSplitPages(QPDF&amp; pdf)
3232 3005 if (pldh.hasPageLabels()) {
3233 3006 std::vector<QPDFObjectHandle> labels;
3234 3007 pldh.getLabelsForPageRange(
3235   - QIntC::to_longlong(first - 1),
3236   - QIntC::to_longlong(last - 1),
3237   - 0,
3238   - labels);
  3008 + QIntC::to_longlong(first - 1), QIntC::to_longlong(last - 1), 0, labels);
3239 3009 QPDFObjectHandle page_labels = QPDFObjectHandle::newDictionary();
3240 3010 page_labels.replaceKey("/Nums", QPDFObjectHandle::newArray(labels));
3241 3011 outpdf.getRoot().replaceKey("/PageLabels", page_labels);
3242 3012 }
3243   - std::string page_range =
3244   - QUtil::uint_to_string(first, QIntC::to_int(pageno_len));
  3013 + std::string page_range = QUtil::uint_to_string(first, QIntC::to_int(pageno_len));
3245 3014 if (m->split_pages > 1) {
3246   - page_range +=
3247   - "-" + QUtil::uint_to_string(last, QIntC::to_int(pageno_len));
  3015 + page_range += "-" + QUtil::uint_to_string(last, QIntC::to_int(pageno_len));
3248 3016 }
3249 3017 std::string outfile = before + page_range + after;
3250 3018 if (QUtil::same_file(m->infilename.get(), outfile.c_str())) {
3251   - throw std::runtime_error(
3252   - "split pages would overwrite input file with " + outfile);
  3019 + throw std::runtime_error("split pages would overwrite input file with " + outfile);
3253 3020 }
3254 3021 QPDFWriter w(outpdf, outfile.c_str());
3255 3022 setWriterOptions(outpdf, w);
... ... @@ -3268,8 +3035,7 @@ QPDFJob::writeOutfile(QPDF&amp; pdf)
3268 3035 // Append but don't prepend to the path to generate a
3269 3036 // temporary name. This saves us from having to split the path
3270 3037 // by directory and non-directory.
3271   - temp_out = QUtil::make_shared_cstr(
3272   - std::string(m->infilename.get()) + ".~qpdf-temp#");
  3038 + temp_out = QUtil::make_shared_cstr(std::string(m->infilename.get()) + ".~qpdf-temp#");
3273 3039 // m->outfilename will be restored to 0 before temp_out
3274 3040 // goes out of scope.
3275 3041 m->outfilename = temp_out;
... ... @@ -3312,17 +3078,14 @@ QPDFJob::writeOutfile(QPDF&amp; pdf)
3312 3078 QUtil::rename_file(m->infilename.get(), backup.c_str());
3313 3079 QUtil::rename_file(temp_out.get(), m->infilename.get());
3314 3080 if (warnings) {
3315   - *m->log->getError()
3316   - << m->message_prefix
3317   - << ": there are warnings; original file kept in " << backup
3318   - << "\n";
  3081 + *m->log->getError() << m->message_prefix
  3082 + << ": there are warnings; original file kept in " << backup << "\n";
3319 3083 } else {
3320 3084 try {
3321 3085 QUtil::remove_file(backup.c_str());
3322 3086 } catch (QPDFSystemError& e) {
3323 3087 *m->log->getError()
3324   - << m->message_prefix << ": unable to delete original file ("
3325   - << e.what() << ");"
  3088 + << m->message_prefix << ": unable to delete original file (" << e.what() << ");"
3326 3089 << " original file left in " << backup
3327 3090 << ", but the input was successfully replaced\n";
3328 3091 }
... ... @@ -3342,12 +3105,9 @@ QPDFJob::writeJSON(QPDF&amp; pdf)
3342 3105 if (m->json_stream_prefix.empty()) {
3343 3106 m->json_stream_prefix = m->outfilename.get();
3344 3107 }
3345   - fc = std::make_shared<QUtil::FileCloser>(
3346   - QUtil::safe_fopen(m->outfilename.get(), "w"));
  3108 + fc = std::make_shared<QUtil::FileCloser>(QUtil::safe_fopen(m->outfilename.get(), "w"));
3347 3109 fp = std::make_shared<Pl_StdioFile>("json output", fc->f);
3348   - } else if (
3349   - (m->json_stream_data == qpdf_sj_file) &&
3350   - m->json_stream_prefix.empty()) {
  3110 + } else if ((m->json_stream_data == qpdf_sj_file) && m->json_stream_prefix.empty()) {
3351 3111 QTC::TC("qpdf", "QPDFJob need json-stream-prefix for stdout");
3352 3112 usage("please specify --json-stream-prefix since the input file "
3353 3113 "name is unknown");
... ...
libqpdf/QPDFJob_argv.cc
... ... @@ -46,8 +46,7 @@ namespace
46 46 };
47 47 } // namespace
48 48  
49   -ArgParser::ArgParser(
50   - QPDFArgParser& ap, std::shared_ptr<QPDFJob::Config> c_main) :
  49 +ArgParser::ArgParser(QPDFArgParser& ap, std::shared_ptr<QPDFJob::Config> c_main) :
51 50 ap(ap),
52 51 c_main(c_main),
53 52 pages_password(nullptr),
... ... @@ -107,8 +106,7 @@ ArgParser::argVersion()
107 106 auto whoami = this->ap.getProgname();
108 107 *QPDFLogger::defaultLogger()->getInfo()
109 108 << whoami << " version " << QPDF::QPDFVersion() << "\n"
110   - << "Run " << whoami
111   - << " --copyright to see copyright and license information.\n";
  109 + << "Run " << whoami << " --copyright to see copyright and license information.\n";
112 110 }
113 111  
114 112 void
... ... @@ -152,8 +150,7 @@ ArgParser::argJsonHelp(std::string const&amp; parameter)
152 150 if ((version < 1) || (version > JSON::LATEST)) {
153 151 usage(std::string("unsupported json version ") + parameter);
154 152 }
155   - *QPDFLogger::defaultLogger()->getInfo()
156   - << QPDFJob::json_out_schema(version) << "\n";
  153 + *QPDFLogger::defaultLogger()->getInfo() << QPDFJob::json_out_schema(version) << "\n";
157 154 }
158 155  
159 156 void
... ... @@ -263,10 +260,7 @@ ArgParser::argPagesPositional(std::string const&amp; arg)
263 260 if (range_p == nullptr) {
264 261 if (arg.empty()) {
265 262 // The filename or password was the last argument
266   - QTC::TC(
267   - "qpdf",
268   - "QPDFJob pages range omitted at end",
269   - this->pages_password ? 0 : 1);
  263 + QTC::TC("qpdf", "QPDFJob pages range omitted at end", this->pages_password ? 0 : 1);
270 264 } else {
271 265 // We need to accumulate some more arguments
272 266 return;
... ...
libqpdf/QPDFJob_config.cc
... ... @@ -658,8 +658,7 @@ QPDFJob::Config::passwordFile(std::string const&amp; parameter)
658 658  
659 659 if (lines.size() > 1) {
660 660 *QPDFLogger::defaultLogger()->getError()
661   - << this->o.m->message_prefix
662   - << ": WARNING: all but the first line of"
  661 + << this->o.m->message_prefix << ": WARNING: all but the first line of"
663 662 << " the password file are ignored\n";
664 663 }
665 664 }
... ... @@ -751,8 +750,7 @@ QPDFJob::Config::removeUnreferencedResources(std::string const&amp; parameter)
751 750 QPDFJob::Config*
752 751 QPDFJob::Config::showObject(std::string const& parameter)
753 752 {
754   - QPDFJob::parse_object_id(
755   - parameter, o.m->show_trailer, o.m->show_obj, o.m->show_gen);
  753 + QPDFJob::parse_object_id(parameter, o.m->show_trailer, o.m->show_obj, o.m->show_gen);
756 754 o.m->require_outfile = false;
757 755 return this;
758 756 }
... ... @@ -761,13 +759,11 @@ QPDFJob::Config*
761 759 QPDFJob::Config::jobJsonFile(std::string const& parameter)
762 760 {
763 761 try {
764   - o.initializeFromJson(
765   - QUtil::read_file_into_string(parameter.c_str()), true);
  762 + o.initializeFromJson(QUtil::read_file_into_string(parameter.c_str()), true);
766 763 } catch (std::exception& e) {
767 764 throw std::runtime_error(
768   - "error with job-json file " + std::string(parameter) + ": " +
769   - e.what() + "\nRun " + this->o.m->message_prefix +
770   - " --job-json-help for information on the file format.");
  765 + "error with job-json file " + std::string(parameter) + ": " + e.what() + "\nRun " +
  766 + this->o.m->message_prefix + " --job-json-help for information on the file format.");
771 767 }
772 768 return this;
773 769 }
... ... @@ -900,8 +896,7 @@ QPDFJob::AttConfig::replace()
900 896 QPDFJob::Config*
901 897 QPDFJob::AttConfig::endAddAttachment()
902 898 {
903   - static std::string now =
904   - QUtil::qpdf_time_to_pdf_time(QUtil::get_current_qpdf_time());
  899 + static std::string now = QUtil::qpdf_time_to_pdf_time(QUtil::get_current_qpdf_time());
905 900 if (this->att.path.empty()) {
906 901 usage("add attachment: no file specified");
907 902 }
... ... @@ -953,8 +948,7 @@ QPDFJob::PagesConfig*
953 948 QPDFJob::PagesConfig::pageSpec(
954 949 std::string const& filename, std::string const& range, char const* password)
955 950 {
956   - this->config->o.m->page_specs.push_back(
957   - QPDFJob::PageSpec(filename, password, range));
  951 + this->config->o.m->page_specs.push_back(QPDFJob::PageSpec(filename, password, range));
958 952 return this;
959 953 }
960 954  
... ... @@ -1035,9 +1029,7 @@ QPDFJob::UOConfig::password(std::string const&amp; parameter)
1035 1029  
1036 1030 std::shared_ptr<QPDFJob::EncConfig>
1037 1031 QPDFJob::Config::encrypt(
1038   - int keylen,
1039   - std::string const& user_password,
1040   - std::string const& owner_password)
  1032 + int keylen, std::string const& user_password, std::string const& owner_password)
1041 1033 {
1042 1034 o.m->keylen = keylen;
1043 1035 if (keylen == 256) {
... ...