Commit 7c0fdf8510fbc09a6a8f872d1c95f1d6e1709f28

Authored by Jay Berkenbilt
1 parent c0c7cef1

Format code, bump clang-format version to 18

examples/pdf-invert-images.cc
@@ -15,8 +15,7 @@ void @@ -15,8 +15,7 @@ void
15 usage() 15 usage()
16 { 16 {
17 std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl 17 std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl
18 - << "Invert some images in infile.pdf;"  
19 - << " write output to outfile.pdf" << std::endl; 18 + << "Invert some images in infile.pdf; write output to outfile.pdf" << std::endl;
20 exit(2); 19 exit(2);
21 } 20 }
22 21
examples/pdf-overlay-page.cc
@@ -16,8 +16,8 @@ void @@ -16,8 +16,8 @@ void
16 usage() 16 usage()
17 { 17 {
18 std::cerr << "Usage: " << whoami << " infile pagefile outfile" << std::endl 18 std::cerr << "Usage: " << whoami << " infile pagefile outfile" << std::endl
19 - << "Stamp page 1 of pagefile on every page of infile,"  
20 - << " writing to outfile" << std::endl; 19 + << "Stamp page 1 of pagefile on every page of infile, writing to outfile"
  20 + << std::endl;
21 exit(2); 21 exit(2);
22 } 22 }
23 23
examples/qpdf-job.cc
@@ -11,10 +11,10 @@ static void @@ -11,10 +11,10 @@ static void
11 usage() 11 usage()
12 { 12 {
13 std::cerr << "Usage: " << whoami << std::endl 13 std::cerr << "Usage: " << whoami << std::endl
14 - << "This program linearizes the first page of in.pdf to out1.pdf,"  
15 - << " out2.pdf, and" << std::endl  
16 - << " out3.pdf, each demonstrating a different way to use the"  
17 - << " QPDFJob API" << std::endl; 14 + << "This program linearizes the first page of in.pdf to out1.pdf, out2.pdf, and"
  15 + << std::endl
  16 + << " out3.pdf, each demonstrating a different way to use the QPDFJob API"
  17 + << std::endl;
18 exit(2); 18 exit(2);
19 } 19 }
20 20
@@ -43,7 +43,7 @@ main(int argc, char* argv[]) @@ -43,7 +43,7 @@ main(int argc, char* argv[])
43 ->pageSpec(".", "1") 43 ->pageSpec(".", "1")
44 ->endPages() 44 ->endPages()
45 ->linearize() 45 ->linearize()
46 - ->staticId() // for testing only 46 + ->staticId() // for testing only
47 ->compressStreams("n") // avoid dependency on zlib output 47 ->compressStreams("n") // avoid dependency on zlib output
48 ->checkConfiguration(); 48 ->checkConfiguration();
49 j.run(); 49 j.run();
examples/qpdfjob-c.c
@@ -42,7 +42,7 @@ main(int argc, char* argv[]) @@ -42,7 +42,7 @@ main(int argc, char* argv[])
42 new_argv[1] = infile; 42 new_argv[1] = infile;
43 new_argv[2] = outfile; 43 new_argv[2] = outfile;
44 new_argv[3] = "--linearize"; 44 new_argv[3] = "--linearize";
45 - new_argv[4] = "--static-id"; /* for testing only */ 45 + new_argv[4] = "--static-id"; /* for testing only */
46 new_argv[5] = "--compress-streams=n"; /* avoid dependency on zlib output */ 46 new_argv[5] = "--compress-streams=n"; /* avoid dependency on zlib output */
47 new_argv[6] = NULL; 47 new_argv[6] = NULL;
48 48
format-code
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 # are improvements, bump the minimum required version of clang-format 23 # are improvements, bump the minimum required version of clang-format
24 # here, and update manual/contributing.rst. There's a comment there 24 # here, and update manual/contributing.rst. There's a comment there
25 # that refers to this comment. See also .clang-format. 25 # that refers to this comment. See also .clang-format.
26 -min_version=16 26 +min_version=18
27 27
28 clang_version=$(clang-format --version | \ 28 clang_version=$(clang-format --version | \
29 awk '{for (i=1; i<=NF; i++) if ($i == "version") {print int($(i+1)); exit}}') 29 awk '{for (i=1; i<=NF; i++) if ($i == "version") {print int($(i+1)); exit}}')
include/qpdf/QPDF.hh
@@ -748,7 +748,8 @@ class QPDF @@ -748,7 +748,8 @@ class QPDF
748 int& O, 748 int& O,
749 bool compressed) 749 bool compressed)
750 { 750 {
751 - return qpdf.generateHintStream(xref, lengths, obj_renumber, hint_stream, S, O, compressed); 751 + return qpdf.generateHintStream(
  752 + xref, lengths, obj_renumber, hint_stream, S, O, compressed);
752 } 753 }
753 754
754 static void 755 static void
libqpdf/QPDF.cc
@@ -2423,8 +2423,7 @@ QPDF::pipeStreamData( @@ -2423,8 +2423,7 @@ QPDF::pipeStreamData(
2423 file->seek(offset, SEEK_SET); 2423 file->seek(offset, SEEK_SET);
2424 auto buf = std::make_unique<char[]>(length); 2424 auto buf = std::make_unique<char[]>(length);
2425 if (auto read = file->read(buf.get(), length); read != length) { 2425 if (auto read = file->read(buf.get(), length); read != length) {
2426 - throw damagedPDF(  
2427 - file, "", offset + toO(read), "unexpected EOF reading stream data"); 2426 + throw damagedPDF(file, "", offset + toO(read), "unexpected EOF reading stream data");
2428 } 2427 }
2429 pipeline->write(buf.get(), length); 2428 pipeline->write(buf.get(), length);
2430 attempted_finish = true; 2429 attempted_finish = true;
@@ -2463,7 +2462,7 @@ QPDF::pipeStreamData( @@ -2463,7 +2462,7 @@ QPDF::pipeStreamData(
2463 // ignore 2462 // ignore
2464 } 2463 }
2465 } 2464 }
2466 - return false ; 2465 + return false;
2467 } 2466 }
2468 2467
2469 bool 2468 bool
libqpdf/QPDFJob.cc
@@ -3018,10 +3018,9 @@ QPDFJob::writeOutfile(QPDF&amp; pdf) @@ -3018,10 +3018,9 @@ QPDFJob::writeOutfile(QPDF&amp; pdf)
3018 try { 3018 try {
3019 QUtil::remove_file(backup.c_str()); 3019 QUtil::remove_file(backup.c_str());
3020 } catch (QPDFSystemError& e) { 3020 } catch (QPDFSystemError& e) {
3021 - *m->log->getError()  
3022 - << m->message_prefix << ": unable to delete original file (" << e.what() << ");"  
3023 - << " original file left in " << backup  
3024 - << ", but the input was successfully replaced\n"; 3021 + *m->log->getError() << m->message_prefix << ": unable to delete original file ("
  3022 + << e.what() << ");" << " original file left in " << backup
  3023 + << ", but the input was successfully replaced\n";
3025 } 3024 }
3026 } 3025 }
3027 } 3026 }
libqpdf/QPDFPageObjectHelper.cc
@@ -178,8 +178,8 @@ InlineImageTracker::handleToken(QPDFTokenizer::Token const&amp; token) @@ -178,8 +178,8 @@ InlineImageTracker::handleToken(QPDFTokenizer::Token const&amp; token)
178 QPDFObjectHandle dict = convertIIDict(QPDFObjectHandle::parse(dict_str)); 178 QPDFObjectHandle dict = convertIIDict(QPDFObjectHandle::parse(dict_str));
179 dict.replaceKey("/Length", QPDFObjectHandle::newInteger(QIntC::to_longlong(len))); 179 dict.replaceKey("/Length", QPDFObjectHandle::newInteger(QIntC::to_longlong(len)));
180 std::string name = resources.getUniqueResourceName("/IIm", this->min_suffix); 180 std::string name = resources.getUniqueResourceName("/IIm", this->min_suffix);
181 - QPDFObjectHandle image =  
182 - QPDFObjectHandle::newStream(this->qpdf, std::make_shared<Buffer>(std::move(image_data))); 181 + QPDFObjectHandle image = QPDFObjectHandle::newStream(
  182 + this->qpdf, std::make_shared<Buffer>(std::move(image_data)));
183 image.replaceDict(dict); 183 image.replaceDict(dict);
184 resources.getKey("/XObject").replaceKey(name, image); 184 resources.getKey("/XObject").replaceKey(name, image);
185 write(name); 185 write(name);
libtests/bits.cc
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 static void 15 static void
16 print_values(long long byte_offset, size_t bit_offset, size_t bits_available) 16 print_values(long long byte_offset, size_t bit_offset, size_t bits_available)
17 { 17 {
18 - std::cout << "byte offset = " << byte_offset << ", "  
19 - << "bit offset = " << bit_offset << ", " 18 + std::cout << "byte offset = " << byte_offset << ", " << "bit offset = " << bit_offset << ", "
20 << "bits available = " << bits_available << std::endl; 19 << "bits available = " << bits_available << std::endl;
21 } 20 }
22 21
manual/contributing.rst
@@ -27,7 +27,7 @@ The qpdf source code is formatted using clang-format with a @@ -27,7 +27,7 @@ The qpdf source code is formatted using clang-format with a
27 :file:`.clang-format` file at the top of the source tree. The 27 :file:`.clang-format` file at the top of the source tree. The
28 :file:`format-code` script reformats all the source code in the 28 :file:`format-code` script reformats all the source code in the
29 repository. You must have ``clang-format`` in your path, and it must 29 repository. You must have ``clang-format`` in your path, and it must
30 -be at least version 16. 30 +be at least version 18.
31 31
32 For emacs users, the :file:`.dir-locals.el` file configures emacs 32 For emacs users, the :file:`.dir-locals.el` file configures emacs
33 ``cc-mode`` for an indentation style that is similar to but not 33 ``cc-mode`` for an indentation style that is similar to but not
qpdf/fix-qdf.cc
@@ -167,8 +167,7 @@ QdfFixer::processLines(std::string const&amp; input) @@ -167,8 +167,7 @@ QdfFixer::processLines(std::string const&amp; input)
167 xref_size = 1 + xref.size(); 167 xref_size = 1 + xref.size();
168 auto length = xref_size * esize; 168 auto length = xref_size * esize;
169 std::cout << " /Length " << length << "\n" 169 std::cout << " /Length " << length << "\n"
170 - << " /W [ 1 " << xref_f1_nbytes << " " << xref_f2_nbytes << " ]"  
171 - << "\n"; 170 + << " /W [ 1 " << xref_f1_nbytes << " " << xref_f2_nbytes << " ]\n";
172 state = st_in_xref_stream_dict; 171 state = st_in_xref_stream_dict;
173 } 172 }
174 } else if (state == st_in_ostream_dict) { 173 } else if (state == st_in_ostream_dict) {
zlib-flate/zlib-flate.cc
@@ -15,10 +15,9 @@ void @@ -15,10 +15,9 @@ void
15 usage() 15 usage()
16 { 16 {
17 std::cerr << "Usage: " << whoami << " { -uncompress | -compress[=n] }" << std::endl 17 std::cerr << "Usage: " << whoami << " { -uncompress | -compress[=n] }" << std::endl
18 - << "If n is specified with -compress, it is a"  
19 - << " zlib compression level from" << std::endl  
20 - << "1 to 9 where lower numbers are faster and"  
21 - << " less compressed and higher" << std::endl 18 + << "If n is specified with -compress, it is a zlib compression level from"
  19 + << std::endl
  20 + << "1 to 9 where lower numbers are faster and less compressed and higher" << std::endl
22 << "numbers are slower and more compressed" << std::endl; 21 << "numbers are slower and more compressed" << std::endl;
23 exit(2); 22 exit(2);
24 } 23 }