Format code, bump clang-format version to 18

This commit is contained in:
Jay Berkenbilt 2023-12-22 21:45:10 -05:00
parent c0c7cef16c
commit 7c0fdf8510
13 changed files with 25 additions and 30 deletions

View File

@ -15,8 +15,7 @@ void
usage()
{
std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl
<< "Invert some images in infile.pdf;"
<< " write output to outfile.pdf" << std::endl;
<< "Invert some images in infile.pdf; write output to outfile.pdf" << std::endl;
exit(2);
}

View File

@ -16,8 +16,8 @@ void
usage()
{
std::cerr << "Usage: " << whoami << " infile pagefile outfile" << std::endl
<< "Stamp page 1 of pagefile on every page of infile,"
<< " writing to outfile" << std::endl;
<< "Stamp page 1 of pagefile on every page of infile, writing to outfile"
<< std::endl;
exit(2);
}

View File

@ -11,10 +11,10 @@ static void
usage()
{
std::cerr << "Usage: " << whoami << std::endl
<< "This program linearizes the first page of in.pdf to out1.pdf,"
<< " out2.pdf, and" << std::endl
<< " out3.pdf, each demonstrating a different way to use the"
<< " QPDFJob API" << std::endl;
<< "This program linearizes the first page of in.pdf to out1.pdf, out2.pdf, and"
<< std::endl
<< " out3.pdf, each demonstrating a different way to use the QPDFJob API"
<< std::endl;
exit(2);
}
@ -43,7 +43,7 @@ main(int argc, char* argv[])
->pageSpec(".", "1")
->endPages()
->linearize()
->staticId() // for testing only
->staticId() // for testing only
->compressStreams("n") // avoid dependency on zlib output
->checkConfiguration();
j.run();

View File

@ -42,7 +42,7 @@ main(int argc, char* argv[])
new_argv[1] = infile;
new_argv[2] = outfile;
new_argv[3] = "--linearize";
new_argv[4] = "--static-id"; /* for testing only */
new_argv[4] = "--static-id"; /* for testing only */
new_argv[5] = "--compress-streams=n"; /* avoid dependency on zlib output */
new_argv[6] = NULL;

View File

@ -23,7 +23,7 @@
# are improvements, bump the minimum required version of clang-format
# here, and update manual/contributing.rst. There's a comment there
# that refers to this comment. See also .clang-format.
min_version=16
min_version=18
clang_version=$(clang-format --version | \
awk '{for (i=1; i<=NF; i++) if ($i == "version") {print int($(i+1)); exit}}')

View File

@ -748,7 +748,8 @@ class QPDF
int& O,
bool compressed)
{
return qpdf.generateHintStream(xref, lengths, obj_renumber, hint_stream, S, O, compressed);
return qpdf.generateHintStream(
xref, lengths, obj_renumber, hint_stream, S, O, compressed);
}
static void

View File

@ -2423,8 +2423,7 @@ QPDF::pipeStreamData(
file->seek(offset, SEEK_SET);
auto buf = std::make_unique<char[]>(length);
if (auto read = file->read(buf.get(), length); read != length) {
throw damagedPDF(
file, "", offset + toO(read), "unexpected EOF reading stream data");
throw damagedPDF(file, "", offset + toO(read), "unexpected EOF reading stream data");
}
pipeline->write(buf.get(), length);
attempted_finish = true;
@ -2463,7 +2462,7 @@ QPDF::pipeStreamData(
// ignore
}
}
return false ;
return false;
}
bool

View File

@ -3018,10 +3018,9 @@ QPDFJob::writeOutfile(QPDF& pdf)
try {
QUtil::remove_file(backup.c_str());
} catch (QPDFSystemError& e) {
*m->log->getError()
<< m->message_prefix << ": unable to delete original file (" << e.what() << ");"
<< " original file left in " << backup
<< ", but the input was successfully replaced\n";
*m->log->getError() << m->message_prefix << ": unable to delete original file ("
<< e.what() << ");" << " original file left in " << backup
<< ", but the input was successfully replaced\n";
}
}
}

View File

@ -178,8 +178,8 @@ InlineImageTracker::handleToken(QPDFTokenizer::Token const& token)
QPDFObjectHandle dict = convertIIDict(QPDFObjectHandle::parse(dict_str));
dict.replaceKey("/Length", QPDFObjectHandle::newInteger(QIntC::to_longlong(len)));
std::string name = resources.getUniqueResourceName("/IIm", this->min_suffix);
QPDFObjectHandle image =
QPDFObjectHandle::newStream(this->qpdf, std::make_shared<Buffer>(std::move(image_data)));
QPDFObjectHandle image = QPDFObjectHandle::newStream(
this->qpdf, std::make_shared<Buffer>(std::move(image_data)));
image.replaceDict(dict);
resources.getKey("/XObject").replaceKey(name, image);
write(name);

View File

@ -15,8 +15,7 @@
static void
print_values(long long byte_offset, size_t bit_offset, size_t bits_available)
{
std::cout << "byte offset = " << byte_offset << ", "
<< "bit offset = " << bit_offset << ", "
std::cout << "byte offset = " << byte_offset << ", " << "bit offset = " << bit_offset << ", "
<< "bits available = " << bits_available << std::endl;
}

View File

@ -27,7 +27,7 @@ The qpdf source code is formatted using clang-format with a
:file:`.clang-format` file at the top of the source tree. The
:file:`format-code` script reformats all the source code in the
repository. You must have ``clang-format`` in your path, and it must
be at least version 16.
be at least version 18.
For emacs users, the :file:`.dir-locals.el` file configures emacs
``cc-mode`` for an indentation style that is similar to but not

View File

@ -167,8 +167,7 @@ QdfFixer::processLines(std::string const& input)
xref_size = 1 + xref.size();
auto length = xref_size * esize;
std::cout << " /Length " << length << "\n"
<< " /W [ 1 " << xref_f1_nbytes << " " << xref_f2_nbytes << " ]"
<< "\n";
<< " /W [ 1 " << xref_f1_nbytes << " " << xref_f2_nbytes << " ]\n";
state = st_in_xref_stream_dict;
}
} else if (state == st_in_ostream_dict) {

View File

@ -15,10 +15,9 @@ void
usage()
{
std::cerr << "Usage: " << whoami << " { -uncompress | -compress[=n] }" << std::endl
<< "If n is specified with -compress, it is a"
<< " zlib compression level from" << std::endl
<< "1 to 9 where lower numbers are faster and"
<< " less compressed and higher" << std::endl
<< "If n is specified with -compress, it is a zlib compression level from"
<< std::endl
<< "1 to 9 where lower numbers are faster and less compressed and higher" << std::endl
<< "numbers are slower and more compressed" << std::endl;
exit(2);
}