2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 02:49:00 +00:00

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() usage()
{ {
std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl
<< "Invert some images in infile.pdf;" << "Invert some images in infile.pdf; write output to outfile.pdf" << std::endl;
<< " write output to outfile.pdf" << std::endl;
exit(2); exit(2);
} }

View File

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

View File

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

View File

@ -42,7 +42,7 @@ main(int argc, char* argv[])
new_argv[1] = infile; new_argv[1] = infile;
new_argv[2] = outfile; new_argv[2] = outfile;
new_argv[3] = "--linearize"; 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[5] = "--compress-streams=n"; /* avoid dependency on zlib output */
new_argv[6] = NULL; new_argv[6] = NULL;

View File

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

View File

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

View File

@ -3018,10 +3018,9 @@ QPDFJob::writeOutfile(QPDF& pdf)
try { try {
QUtil::remove_file(backup.c_str()); QUtil::remove_file(backup.c_str());
} catch (QPDFSystemError& e) { } catch (QPDFSystemError& e) {
*m->log->getError() *m->log->getError() << m->message_prefix << ": unable to delete original file ("
<< m->message_prefix << ": unable to delete original file (" << e.what() << ");" << e.what() << ");" << " original file left in " << backup
<< " original file left in " << backup << ", but the input was successfully replaced\n";
<< ", 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)); QPDFObjectHandle dict = convertIIDict(QPDFObjectHandle::parse(dict_str));
dict.replaceKey("/Length", QPDFObjectHandle::newInteger(QIntC::to_longlong(len))); dict.replaceKey("/Length", QPDFObjectHandle::newInteger(QIntC::to_longlong(len)));
std::string name = resources.getUniqueResourceName("/IIm", this->min_suffix); std::string name = resources.getUniqueResourceName("/IIm", this->min_suffix);
QPDFObjectHandle image = QPDFObjectHandle image = QPDFObjectHandle::newStream(
QPDFObjectHandle::newStream(this->qpdf, std::make_shared<Buffer>(std::move(image_data))); this->qpdf, std::make_shared<Buffer>(std::move(image_data)));
image.replaceDict(dict); image.replaceDict(dict);
resources.getKey("/XObject").replaceKey(name, image); resources.getKey("/XObject").replaceKey(name, image);
write(name); write(name);

View File

@ -15,8 +15,7 @@
static void static void
print_values(long long byte_offset, size_t bit_offset, size_t bits_available) print_values(long long byte_offset, size_t bit_offset, size_t bits_available)
{ {
std::cout << "byte offset = " << byte_offset << ", " std::cout << "byte offset = " << byte_offset << ", " << "bit offset = " << bit_offset << ", "
<< "bit offset = " << bit_offset << ", "
<< "bits available = " << bits_available << std::endl; << "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:`.clang-format` file at the top of the source tree. The
:file:`format-code` script reformats all the source code in the :file:`format-code` script reformats all the source code in the
repository. You must have ``clang-format`` in your path, and it must 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 For emacs users, the :file:`.dir-locals.el` file configures emacs
``cc-mode`` for an indentation style that is similar to but not ``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(); xref_size = 1 + xref.size();
auto length = xref_size * esize; auto length = xref_size * esize;
std::cout << " /Length " << length << "\n" std::cout << " /Length " << length << "\n"
<< " /W [ 1 " << xref_f1_nbytes << " " << xref_f2_nbytes << " ]" << " /W [ 1 " << xref_f1_nbytes << " " << xref_f2_nbytes << " ]\n";
<< "\n";
state = st_in_xref_stream_dict; state = st_in_xref_stream_dict;
} }
} else if (state == st_in_ostream_dict) { } else if (state == st_in_ostream_dict) {

View File

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