Commit 03ea948cebeb634b769df17199b43ad161f14d7c
1 parent
98c0b420
Replace std::endl with '\n' for consistent line endings.
This change updates all occurrences of `std::endl` to `\n` across various files for improved efficiency and consistency. It reduces unnecessary flushing of output buffers associated with `std::endl` while maintaining the same output format.
Showing
83 changed files
with
752 additions
and
769 deletions
compare-for-test/qpdf-test-compare.cc
| @@ -13,18 +13,14 @@ static char const* whoami = nullptr; | @@ -13,18 +13,14 @@ static char const* whoami = nullptr; | ||
| 13 | void | 13 | void |
| 14 | usage() | 14 | usage() |
| 15 | { | 15 | { |
| 16 | - std::cerr << "Usage: " << whoami << " actual expected" << std::endl | ||
| 17 | - << R"(Where "actual" is the actual output and "expected" is the expected)" | ||
| 18 | - << std::endl | ||
| 19 | - << "output of a test, compare the two PDF files. The files are considered" | ||
| 20 | - << std::endl | ||
| 21 | - << "to match if all their objects are identical except that, if a stream is" | ||
| 22 | - << std::endl | ||
| 23 | - << "compressed with FlateDecode, the uncompressed data must match." << std::endl | ||
| 24 | - << std::endl | ||
| 25 | - << "If the files match, the output is the expected file. Otherwise, it is" | ||
| 26 | - << std::endl | ||
| 27 | - << "the actual file. Read comments in the code for rationale." << std::endl; | 16 | + std::cerr << "Usage: " << whoami << " actual expected" << '\n' |
| 17 | + << R"(Where "actual" is the actual output and "expected" is the expected)" << '\n' | ||
| 18 | + << "output of a test, compare the two PDF files. The files are considered" << '\n' | ||
| 19 | + << "to match if all their objects are identical except that, if a stream is" << '\n' | ||
| 20 | + << "compressed with FlateDecode, the uncompressed data must match." << '\n' | ||
| 21 | + << '\n' | ||
| 22 | + << "If the files match, the output is the expected file. Otherwise, it is" << '\n' | ||
| 23 | + << "the actual file. Read comments in the code for rationale." << '\n'; | ||
| 28 | exit(2); | 24 | exit(2); |
| 29 | } | 25 | } |
| 30 | 26 | ||
| @@ -187,7 +183,7 @@ main(int argc, char* argv[]) | @@ -187,7 +183,7 @@ main(int argc, char* argv[]) | ||
| 187 | } | 183 | } |
| 188 | 184 | ||
| 189 | if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) { | 185 | if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) { |
| 190 | - std::cout << whoami << " from qpdf version " << QPDF::QPDFVersion() << std::endl; | 186 | + std::cout << whoami << " from qpdf version " << QPDF::QPDFVersion() << '\n'; |
| 191 | exit(0); | 187 | exit(0); |
| 192 | } | 188 | } |
| 193 | 189 | ||
| @@ -211,7 +207,7 @@ main(int argc, char* argv[]) | @@ -211,7 +207,7 @@ main(int argc, char* argv[]) | ||
| 211 | to_output = expected; | 207 | to_output = expected; |
| 212 | } else { | 208 | } else { |
| 213 | if (show_why) { | 209 | if (show_why) { |
| 214 | - std::cerr << difference << std::endl; | 210 | + std::cerr << difference << '\n'; |
| 215 | exit(2); | 211 | exit(2); |
| 216 | } | 212 | } |
| 217 | // The files differ; write the actual file. If it is determined that the actual file | 213 | // The files differ; write the actual file. If it is determined that the actual file |
| @@ -237,7 +233,7 @@ main(int argc, char* argv[]) | @@ -237,7 +233,7 @@ main(int argc, char* argv[]) | ||
| 237 | exit(2); | 233 | exit(2); |
| 238 | } | 234 | } |
| 239 | } catch (std::exception& e) { | 235 | } catch (std::exception& e) { |
| 240 | - std::cerr << whoami << ": " << e.what() << std::endl; | 236 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 241 | exit(2); | 237 | exit(2); |
| 242 | } | 238 | } |
| 243 | return 0; | 239 | return 0; |
examples/pdf-attach-file.cc
| @@ -19,15 +19,15 @@ static char const* whoami = nullptr; | @@ -19,15 +19,15 @@ static char const* whoami = nullptr; | ||
| 19 | static void | 19 | static void |
| 20 | usage(std::string const& msg) | 20 | usage(std::string const& msg) |
| 21 | { | 21 | { |
| 22 | - std::cerr << msg << std::endl | ||
| 23 | - << std::endl | ||
| 24 | - << "Usage: " << whoami << " options" << std::endl | ||
| 25 | - << "Options:" << std::endl | ||
| 26 | - << " --infile infile.pdf" << std::endl | ||
| 27 | - << " --outfile outfile.pdf" << std::endl | ||
| 28 | - << " --attachment attachment" << std::endl | ||
| 29 | - << " [--password infile-password]" << std::endl | ||
| 30 | - << " [--mimetype attachment mime type]" << std::endl; | 22 | + std::cerr << msg << '\n' |
| 23 | + << '\n' | ||
| 24 | + << "Usage: " << whoami << " options\n" | ||
| 25 | + << "Options:\n" | ||
| 26 | + << " --infile infile.pdf\n" | ||
| 27 | + << " --outfile outfile.pdf\n" | ||
| 28 | + << " --attachment attachment\n" | ||
| 29 | + << " [--password infile-password]\n" | ||
| 30 | + << " [--mimetype attachment mime type]\n"; | ||
| 31 | exit(2); | 31 | exit(2); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| @@ -69,7 +69,7 @@ process( | @@ -69,7 +69,7 @@ process( | ||
| 69 | 69 | ||
| 70 | // Create a file spec. | 70 | // Create a file spec. |
| 71 | std::string key = QUtil::path_basename(attachment); | 71 | std::string key = QUtil::path_basename(attachment); |
| 72 | - std::cout << whoami << ": attaching " << attachment << " as " << key << std::endl; | 72 | + std::cout << whoami << ": attaching " << attachment << " as " << key << '\n'; |
| 73 | auto fs = QPDFFileSpecObjectHelper::createFileSpec(q, key, attachment); | 73 | auto fs = QPDFFileSpecObjectHelper::createFileSpec(q, key, attachment); |
| 74 | 74 | ||
| 75 | if (mimetype) { | 75 | if (mimetype) { |
| @@ -208,7 +208,7 @@ main(int argc, char* argv[]) | @@ -208,7 +208,7 @@ main(int argc, char* argv[]) | ||
| 208 | try { | 208 | try { |
| 209 | process(infilename, password, attachment, mimetype, outfilename); | 209 | process(infilename, password, attachment, mimetype, outfilename); |
| 210 | } catch (std::exception& e) { | 210 | } catch (std::exception& e) { |
| 211 | - std::cerr << whoami << " exception: " << e.what() << std::endl; | 211 | + std::cerr << whoami << " exception: " << e.what() << '\n'; |
| 212 | exit(2); | 212 | exit(2); |
| 213 | } | 213 | } |
| 214 | 214 |
examples/pdf-bookmarks.cc
| @@ -23,12 +23,12 @@ static std::map<QPDFObjGen, int> page_map; | @@ -23,12 +23,12 @@ static std::map<QPDFObjGen, int> page_map; | ||
| 23 | void | 23 | void |
| 24 | usage() | 24 | usage() |
| 25 | { | 25 | { |
| 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; | 26 | + std::cerr << "Usage: " << whoami << " [options] file.pdf [password]\n" |
| 27 | + << "Options:\n" | ||
| 28 | + << " --numbers give bookmarks outline-style numbers\n" | ||
| 29 | + << " --lines draw lines to show bookmark hierarchy\n" | ||
| 30 | + << " --show-open indicate whether a bookmark is initially open\n" | ||
| 31 | + << " --show-targets show target if possible\n"; | ||
| 32 | exit(2); | 32 | exit(2); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| @@ -74,7 +74,7 @@ show_bookmark_details(QPDFOutlineObjectHelper outline, std::vector<int> numbers) | @@ -74,7 +74,7 @@ show_bookmark_details(QPDFOutlineObjectHelper outline, std::vector<int> numbers) | ||
| 74 | case st_lines: | 74 | case st_lines: |
| 75 | QTC::TC("examples", "pdf-bookmarks lines"); | 75 | QTC::TC("examples", "pdf-bookmarks lines"); |
| 76 | print_lines(numbers); | 76 | print_lines(numbers); |
| 77 | - std::cout << "|" << std::endl; | 77 | + std::cout << "|\n"; |
| 78 | print_lines(numbers); | 78 | print_lines(numbers); |
| 79 | std::cout << "+-+ "; | 79 | std::cout << "+-+ "; |
| 80 | break; | 80 | break; |
| @@ -136,7 +136,7 @@ main(int argc, char* argv[]) | @@ -136,7 +136,7 @@ main(int argc, char* argv[]) | ||
| 136 | whoami = QUtil::getWhoami(argv[0]); | 136 | whoami = QUtil::getWhoami(argv[0]); |
| 137 | 137 | ||
| 138 | if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) { | 138 | if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) { |
| 139 | - std::cout << whoami << " version 1.5" << std::endl; | 139 | + std::cout << whoami << " version 1.5\n"; |
| 140 | exit(0); | 140 | exit(0); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| @@ -185,10 +185,10 @@ main(int argc, char* argv[]) | @@ -185,10 +185,10 @@ main(int argc, char* argv[]) | ||
| 185 | } | 185 | } |
| 186 | extract_bookmarks(odh.getTopLevelOutlines(), numbers); | 186 | extract_bookmarks(odh.getTopLevelOutlines(), numbers); |
| 187 | } else { | 187 | } else { |
| 188 | - std::cout << filename << " has no bookmarks" << std::endl; | 188 | + std::cout << filename << " has no bookmarks\n"; |
| 189 | } | 189 | } |
| 190 | } catch (std::exception& e) { | 190 | } catch (std::exception& e) { |
| 191 | - std::cerr << whoami << " processing file " << filename << ": " << e.what() << std::endl; | 191 | + std::cerr << whoami << " processing file " << filename << ": " << e.what() << '\n'; |
| 192 | exit(2); | 192 | exit(2); |
| 193 | } | 193 | } |
| 194 | 194 |
examples/pdf-count-strings.cc
| @@ -18,8 +18,8 @@ static char const* whoami = nullptr; | @@ -18,8 +18,8 @@ static char const* whoami = nullptr; | ||
| 18 | void | 18 | void |
| 19 | usage() | 19 | usage() |
| 20 | { | 20 | { |
| 21 | - std::cerr << "Usage: " << whoami << " infile" << std::endl | ||
| 22 | - << "Applies token filters to infile" << std::endl; | 21 | + std::cerr << "Usage: " << whoami << " infile\n" |
| 22 | + << "Applies token filters to infile\n"; | ||
| 23 | exit(2); | 23 | exit(2); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| @@ -88,14 +88,14 @@ main(int argc, char* argv[]) | @@ -88,14 +88,14 @@ main(int argc, char* argv[]) | ||
| 88 | } else { | 88 | } else { |
| 89 | // Write output to stdout for even pages. | 89 | // Write output to stdout for even pages. |
| 90 | Pl_StdioFile out("stdout", stdout); | 90 | Pl_StdioFile out("stdout", stdout); |
| 91 | - std::cout << "% Contents of page " << pageno << std::endl; | 91 | + std::cout << "% Contents of page " << pageno << '\n'; |
| 92 | page.filterContents(&counter, &out); | 92 | page.filterContents(&counter, &out); |
| 93 | - std::cout << "\n% end " << pageno << std::endl; | 93 | + std::cout << "\n% end " << pageno << '\n'; |
| 94 | } | 94 | } |
| 95 | - std::cout << "Page " << pageno << ": strings = " << counter.getCount() << std::endl; | 95 | + std::cout << "Page " << pageno << ": strings = " << counter.getCount() << '\n'; |
| 96 | } | 96 | } |
| 97 | } catch (std::exception& e) { | 97 | } catch (std::exception& e) { |
| 98 | - std::cerr << whoami << ": " << e.what() << std::endl; | 98 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 99 | exit(2); | 99 | exit(2); |
| 100 | } | 100 | } |
| 101 | 101 |
examples/pdf-create.cc
| @@ -117,8 +117,8 @@ ImageProvider::provideStreamData(QPDFObjGen const&, Pipeline* pipeline) | @@ -117,8 +117,8 @@ ImageProvider::provideStreamData(QPDFObjGen const&, Pipeline* pipeline) | ||
| 117 | void | 117 | void |
| 118 | usage() | 118 | usage() |
| 119 | { | 119 | { |
| 120 | - std::cerr << "Usage: " << whoami << " filename" << std::endl | ||
| 121 | - << "Creates a simple PDF and writes it to filename" << std::endl; | 120 | + std::cerr << "Usage: " << whoami << " filename\n" |
| 121 | + << "Creates a simple PDF and writes it to filename\n"; | ||
| 122 | exit(2); | 122 | exit(2); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| @@ -257,12 +257,12 @@ check( | @@ -257,12 +257,12 @@ check( | ||
| 257 | if (!filter.isNameAndEquals(desired_filter)) { | 257 | if (!filter.isNameAndEquals(desired_filter)) { |
| 258 | this_errors = errors = true; | 258 | this_errors = errors = true; |
| 259 | std::cout << "page " << pageno << ": expected filter " << desired_filter | 259 | std::cout << "page " << pageno << ": expected filter " << desired_filter |
| 260 | - << "; actual filter = " << filter.unparse() << std::endl; | 260 | + << "; actual filter = " << filter.unparse() << '\n'; |
| 261 | } | 261 | } |
| 262 | if (!color_space.isNameAndEquals(desired_color_space)) { | 262 | if (!color_space.isNameAndEquals(desired_color_space)) { |
| 263 | this_errors = errors = true; | 263 | this_errors = errors = true; |
| 264 | std::cout << "page " << pageno << ": expected color space " << desired_color_space | 264 | std::cout << "page " << pageno << ": expected color space " << desired_color_space |
| 265 | - << "; actual color space = " << color_space.unparse() << std::endl; | 265 | + << "; actual color space = " << color_space.unparse() << '\n'; |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | if (!this_errors) { | 268 | if (!this_errors) { |
| @@ -275,7 +275,7 @@ check( | @@ -275,7 +275,7 @@ check( | ||
| 275 | std::shared_ptr<Buffer> desired_data(b_p.getBuffer()); | 275 | std::shared_ptr<Buffer> desired_data(b_p.getBuffer()); |
| 276 | 276 | ||
| 277 | if (desired_data->getSize() != actual_data->getSize()) { | 277 | if (desired_data->getSize() != actual_data->getSize()) { |
| 278 | - std::cout << "page " << pageno << ": image data length mismatch" << std::endl; | 278 | + std::cout << "page " << pageno << ": image data length mismatch\n"; |
| 279 | this_errors = errors = true; | 279 | this_errors = errors = true; |
| 280 | } else { | 280 | } else { |
| 281 | // Compare bytes. For JPEG, allow a certain number of the bytes to be off desired by | 281 | // Compare bytes. For JPEG, allow a certain number of the bytes to be off desired by |
| @@ -297,7 +297,7 @@ check( | @@ -297,7 +297,7 @@ check( | ||
| 297 | if (mismatches > threshold) { | 297 | if (mismatches > threshold) { |
| 298 | std::cout << "page " << pageno << ": " << desired_color_space << ", " | 298 | std::cout << "page " << pageno << ": " << desired_color_space << ", " |
| 299 | << desired_filter << ": mismatches: " << mismatches << " of " << len | 299 | << desired_filter << ": mismatches: " << mismatches << " of " << len |
| 300 | - << std::endl; | 300 | + << '\n'; |
| 301 | this_errors = errors = true; | 301 | this_errors = errors = true; |
| 302 | } | 302 | } |
| 303 | } | 303 | } |
| @@ -308,7 +308,7 @@ check( | @@ -308,7 +308,7 @@ check( | ||
| 308 | if (errors) { | 308 | if (errors) { |
| 309 | throw std::logic_error("errors found"); | 309 | throw std::logic_error("errors found"); |
| 310 | } else { | 310 | } else { |
| 311 | - std::cout << "all checks passed" << std::endl; | 311 | + std::cout << "all checks passed\n"; |
| 312 | } | 312 | } |
| 313 | } | 313 | } |
| 314 | 314 | ||
| @@ -366,7 +366,7 @@ main(int argc, char* argv[]) | @@ -366,7 +366,7 @@ main(int argc, char* argv[]) | ||
| 366 | try { | 366 | try { |
| 367 | create_pdf(filename); | 367 | create_pdf(filename); |
| 368 | } catch (std::exception& e) { | 368 | } catch (std::exception& e) { |
| 369 | - std::cerr << e.what() << std::endl; | 369 | + std::cerr << e.what() << '\n'; |
| 370 | exit(2); | 370 | exit(2); |
| 371 | } | 371 | } |
| 372 | 372 |
examples/pdf-custom-filter.cc
| @@ -116,7 +116,7 @@ SF_XORDecode::setDecodeParms(QPDFObjectHandle decode_parms) | @@ -116,7 +116,7 @@ SF_XORDecode::setDecodeParms(QPDFObjectHandle decode_parms) | ||
| 116 | this->key = buf->getBuffer()[0]; | 116 | this->key = buf->getBuffer()[0]; |
| 117 | return true; | 117 | return true; |
| 118 | } catch (std::exception& e) { | 118 | } catch (std::exception& e) { |
| 119 | - std::cerr << "Error extracting key for /XORDecode: " << e.what() << std::endl; | 119 | + std::cerr << "Error extracting key for /XORDecode: " << e.what() << '\n'; |
| 120 | } | 120 | } |
| 121 | return false; | 121 | return false; |
| 122 | } | 122 | } |
| @@ -361,15 +361,13 @@ process(char const* infilename, char const* outfilename, bool decode_specialized | @@ -361,15 +361,13 @@ process(char const* infilename, char const* outfilename, bool decode_specialized | ||
| 361 | // For the test suite, use static IDs. | 361 | // For the test suite, use static IDs. |
| 362 | w.setStaticID(true); // for testing only | 362 | w.setStaticID(true); // for testing only |
| 363 | w.write(); | 363 | w.write(); |
| 364 | - std::cout << whoami << ": new file written to " << outfilename << std::endl; | 364 | + std::cout << whoami << ": new file written to " << outfilename << '\n'; |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | static void | 367 | static void |
| 368 | usage() | 368 | usage() |
| 369 | { | 369 | { |
| 370 | - std::cerr << "\n" | ||
| 371 | - << "Usage: " << whoami << " [--decode-specialized] infile outfile\n" | ||
| 372 | - << std::endl; | 370 | + std::cerr << '\n' << "Usage: " << whoami << " [--decode-specialized] infile outfile\n" << '\n'; |
| 373 | exit(2); | 371 | exit(2); |
| 374 | } | 372 | } |
| 375 | 373 | ||
| @@ -404,7 +402,7 @@ main(int argc, char* argv[]) | @@ -404,7 +402,7 @@ main(int argc, char* argv[]) | ||
| 404 | // Do the actual processing. | 402 | // Do the actual processing. |
| 405 | process(infilename, outfilename, decode_specialized); | 403 | process(infilename, outfilename, decode_specialized); |
| 406 | } catch (std::exception& e) { | 404 | } catch (std::exception& e) { |
| 407 | - std::cerr << whoami << ": exception: " << e.what() << std::endl; | 405 | + std::cerr << whoami << ": exception: " << e.what() << '\n'; |
| 408 | exit(2); | 406 | exit(2); |
| 409 | } | 407 | } |
| 410 | 408 |
examples/pdf-double-page-size.cc
| @@ -13,8 +13,8 @@ static char const* whoami = nullptr; | @@ -13,8 +13,8 @@ static char const* whoami = nullptr; | ||
| 13 | void | 13 | void |
| 14 | usage() | 14 | usage() |
| 15 | { | 15 | { |
| 16 | - std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl | ||
| 17 | - << "Double size of all pages in infile.pdf; write output to outfile.pdf" << std::endl; | 16 | + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]\n" |
| 17 | + << "Double size of all pages in infile.pdf; write output to outfile.pdf\n"; | ||
| 18 | exit(2); | 18 | exit(2); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| @@ -87,9 +87,9 @@ main(int argc, char* argv[]) | @@ -87,9 +87,9 @@ main(int argc, char* argv[]) | ||
| 87 | w.setStreamDataMode(qpdf_s_uncompress); | 87 | w.setStreamDataMode(qpdf_s_uncompress); |
| 88 | } | 88 | } |
| 89 | w.write(); | 89 | w.write(); |
| 90 | - std::cout << whoami << ": new file written to " << outfilename << std::endl; | 90 | + std::cout << whoami << ": new file written to " << outfilename << '\n'; |
| 91 | } catch (std::exception& e) { | 91 | } catch (std::exception& e) { |
| 92 | - std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl; | 92 | + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << '\n'; |
| 93 | exit(2); | 93 | exit(2); |
| 94 | } | 94 | } |
| 95 | 95 |
examples/pdf-filter-tokens.cc
| @@ -20,8 +20,8 @@ static char const* whoami = nullptr; | @@ -20,8 +20,8 @@ static char const* whoami = nullptr; | ||
| 20 | void | 20 | void |
| 21 | usage() | 21 | usage() |
| 22 | { | 22 | { |
| 23 | - std::cerr << "Usage: " << whoami << " infile outfile" << std::endl | ||
| 24 | - << "Applies token filters to infile and writes outfile" << std::endl; | 23 | + std::cerr << "Usage: " << whoami << " infile outfile\n" |
| 24 | + << "Applies token filters to infile and writes outfile\n"; | ||
| 25 | exit(2); | 25 | exit(2); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| @@ -184,7 +184,7 @@ main(int argc, char* argv[]) | @@ -184,7 +184,7 @@ main(int argc, char* argv[]) | ||
| 184 | w.setQDFMode(true); | 184 | w.setQDFMode(true); |
| 185 | w.write(); | 185 | w.write(); |
| 186 | } catch (std::exception& e) { | 186 | } catch (std::exception& e) { |
| 187 | - std::cerr << whoami << ": " << e.what() << std::endl; | 187 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 188 | exit(2); | 188 | exit(2); |
| 189 | } | 189 | } |
| 190 | 190 |
examples/pdf-invert-images.cc
| @@ -14,8 +14,8 @@ static char const* whoami = nullptr; | @@ -14,8 +14,8 @@ static char const* whoami = nullptr; | ||
| 14 | void | 14 | void |
| 15 | usage() | 15 | usage() |
| 16 | { | 16 | { |
| 17 | - std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl | ||
| 18 | - << "Invert some images in infile.pdf; write output to outfile.pdf" << std::endl; | 17 | + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]\n" |
| 18 | + << "Invert some images in infile.pdf; write output to outfile.pdf\n"; | ||
| 19 | exit(2); | 19 | exit(2); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| @@ -137,9 +137,9 @@ main(int argc, char* argv[]) | @@ -137,9 +137,9 @@ main(int argc, char* argv[]) | ||
| 137 | w.setStaticID(true); // for testing only | 137 | w.setStaticID(true); // for testing only |
| 138 | } | 138 | } |
| 139 | w.write(); | 139 | w.write(); |
| 140 | - std::cout << whoami << ": new file written to " << outfilename << std::endl; | 140 | + std::cout << whoami << ": new file written to " << outfilename << '\n'; |
| 141 | } catch (std::exception& e) { | 141 | } catch (std::exception& e) { |
| 142 | - std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl; | 142 | + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << '\n'; |
| 143 | exit(2); | 143 | exit(2); |
| 144 | } | 144 | } |
| 145 | 145 |
examples/pdf-mod-info.cc
| @@ -39,7 +39,7 @@ dumpInfoDict(QPDF& pdf, std::ostream& os = std::cout, std::string const& sep = " | @@ -39,7 +39,7 @@ dumpInfoDict(QPDF& pdf, std::ostream& os = std::cout, std::string const& sep = " | ||
| 39 | { | 39 | { |
| 40 | val = it.second.unparseResolved(); | 40 | val = it.second.unparseResolved(); |
| 41 | } | 41 | } |
| 42 | - os << it.first.substr(1) << sep << val << std::endl; // skip '/' | 42 | + os << it.first.substr(1) << sep << val << '\n'; // skip '/' |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| @@ -52,7 +52,7 @@ pdfDumpInfoDict(char const* fname) | @@ -52,7 +52,7 @@ pdfDumpInfoDict(char const* fname) | ||
| 52 | pdf.processFile(fname); | 52 | pdf.processFile(fname); |
| 53 | dumpInfoDict(pdf); | 53 | dumpInfoDict(pdf); |
| 54 | } catch (std::exception& e) { | 54 | } catch (std::exception& e) { |
| 55 | - std::cerr << e.what() << std::endl; | 55 | + std::cerr << e.what() << '\n'; |
| 56 | exit(2); | 56 | exit(2); |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| @@ -66,7 +66,7 @@ main(int argc, char* argv[]) | @@ -66,7 +66,7 @@ main(int argc, char* argv[]) | ||
| 66 | whoami = QUtil::getWhoami(argv[0]); | 66 | whoami = QUtil::getWhoami(argv[0]); |
| 67 | 67 | ||
| 68 | if ((argc == 2) && (!strcmp(argv[1], "--version"))) { | 68 | if ((argc == 2) && (!strcmp(argv[1], "--version"))) { |
| 69 | - std::cout << whoami << " version " << version << std::endl; | 69 | + std::cout << whoami << " version " << version << '\n'; |
| 70 | exit(0); | 70 | exit(0); |
| 71 | } | 71 | } |
| 72 | if ((argc == 3) && (!strcmp(argv[1], "--dump"))) { | 72 | if ((argc == 3) && (!strcmp(argv[1], "--dump"))) { |
| @@ -155,7 +155,7 @@ main(int argc, char* argv[]) | @@ -155,7 +155,7 @@ main(int argc, char* argv[]) | ||
| 155 | w.setStaticID(static_id); // for testing only | 155 | w.setStaticID(static_id); // for testing only |
| 156 | w.write(); | 156 | w.write(); |
| 157 | } catch (std::exception& e) { | 157 | } catch (std::exception& e) { |
| 158 | - std::cerr << e.what() << std::endl; | 158 | + std::cerr << e.what() << '\n'; |
| 159 | exit(2); | 159 | exit(2); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| @@ -164,7 +164,7 @@ main(int argc, char* argv[]) | @@ -164,7 +164,7 @@ main(int argc, char* argv[]) | ||
| 164 | QUtil::os_wrapper( | 164 | QUtil::os_wrapper( |
| 165 | "rename " + fl_tmp + " " + std::string(fl_out), rename(fl_tmp.c_str(), fl_out)); | 165 | "rename " + fl_tmp + " " + std::string(fl_out), rename(fl_tmp.c_str(), fl_out)); |
| 166 | } catch (std::exception& e) { | 166 | } catch (std::exception& e) { |
| 167 | - std::cerr << e.what() << std::endl; | 167 | + std::cerr << e.what() << '\n'; |
| 168 | exit(2); | 168 | exit(2); |
| 169 | } | 169 | } |
| 170 | 170 |
examples/pdf-name-number-tree.cc
| @@ -10,8 +10,8 @@ static char const* whoami = nullptr; | @@ -10,8 +10,8 @@ static char const* whoami = nullptr; | ||
| 10 | void | 10 | void |
| 11 | usage() | 11 | usage() |
| 12 | { | 12 | { |
| 13 | - std::cerr << "Usage: " << whoami << " outfile.pdf" << std::endl | ||
| 14 | - << "Create some name/number trees and write to a file" << std::endl; | 13 | + std::cerr << "Usage: " << whoami << " outfile.pdf" << '\n' |
| 14 | + << "Create some name/number trees and write to a file\n"; | ||
| 15 | exit(2); | 15 | exit(2); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| @@ -57,64 +57,63 @@ main(int argc, char* argv[]) | @@ -57,64 +57,63 @@ main(int argc, char* argv[]) | ||
| 57 | name_tree.insert("N", QPDFObjectHandle::newUnicodeString("knight")); | 57 | name_tree.insert("N", QPDFObjectHandle::newUnicodeString("knight")); |
| 58 | auto iter = name_tree.insert("P", QPDFObjectHandle::newUnicodeString("pawn")); | 58 | auto iter = name_tree.insert("P", QPDFObjectHandle::newUnicodeString("pawn")); |
| 59 | // Look at the iterator | 59 | // Look at the iterator |
| 60 | - std::cout << "just inserted " << iter->first << " -> " << iter->second.unparse() << std::endl; | 60 | + std::cout << "just inserted " << iter->first << " -> " << iter->second.unparse() << '\n'; |
| 61 | --iter; | 61 | --iter; |
| 62 | - std::cout << "predecessor: " << iter->first << " -> " << iter->second.unparse() << std::endl; | 62 | + std::cout << "predecessor: " << iter->first << " -> " << iter->second.unparse() << '\n'; |
| 63 | ++iter; | 63 | ++iter; |
| 64 | ++iter; | 64 | ++iter; |
| 65 | - std::cout << "successor: " << iter->first << " -> " << iter->second.unparse() << std::endl; | 65 | + std::cout << "successor: " << iter->first << " -> " << iter->second.unparse() << '\n'; |
| 66 | 66 | ||
| 67 | // Use range-for iteration | 67 | // Use range-for iteration |
| 68 | - std::cout << "Name tree items:" << std::endl; | 68 | + std::cout << "Name tree items:\n"; |
| 69 | for (auto i: name_tree) { | 69 | for (auto i: name_tree) { |
| 70 | - std::cout << " " << i.first << " -> " << i.second.unparse() << std::endl; | 70 | + std::cout << " " << i.first << " -> " << i.second.unparse() << '\n'; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | // This is a small tree, so everything will be at the root. We can look at it using dictionary | 73 | // This is a small tree, so everything will be at the root. We can look at it using dictionary |
| 74 | // and array iterators. | 74 | // and array iterators. |
| 75 | - std::cout << "Keys in name tree object:" << std::endl; | 75 | + std::cout << "Keys in name tree object:\n"; |
| 76 | QPDFObjectHandle names; | 76 | QPDFObjectHandle names; |
| 77 | for (auto const& i: name_tree_oh.ditems()) { | 77 | for (auto const& i: name_tree_oh.ditems()) { |
| 78 | - std::cout << i.first << std::endl; | 78 | + std::cout << i.first << '\n'; |
| 79 | if (i.first == "/Names") { | 79 | if (i.first == "/Names") { |
| 80 | names = i.second; | 80 | names = i.second; |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | // Values in names array: | 83 | // Values in names array: |
| 84 | - std::cout << "Values in names:" << std::endl; | 84 | + std::cout << "Values in names:\n"; |
| 85 | for (auto& i: names.aitems()) { | 85 | for (auto& i: names.aitems()) { |
| 86 | - std::cout << " " << i.unparse() << std::endl; | 86 | + std::cout << " " << i.unparse() << '\n'; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | // pre 10.2 API | 89 | // pre 10.2 API |
| 90 | - std::cout << "Has Q?: " << name_tree.hasName("Q") << std::endl; | ||
| 91 | - std::cout << "Has W?: " << name_tree.hasName("W") << std::endl; | 90 | + std::cout << "Has Q?: " << name_tree.hasName("Q") << '\n'; |
| 91 | + std::cout << "Has W?: " << name_tree.hasName("W") << '\n'; | ||
| 92 | QPDFObjectHandle obj; | 92 | QPDFObjectHandle obj; |
| 93 | - std::cout << "Found W?: " << name_tree.findObject("W", obj) << std::endl; | ||
| 94 | - std::cout << "Found Q?: " << name_tree.findObject("Q", obj) << std::endl; | ||
| 95 | - std::cout << "Q: " << obj.unparse() << std::endl; | 93 | + std::cout << "Found W?: " << name_tree.findObject("W", obj) << '\n'; |
| 94 | + std::cout << "Found Q?: " << name_tree.findObject("Q", obj) << '\n'; | ||
| 95 | + std::cout << "Q: " << obj.unparse() << '\n'; | ||
| 96 | 96 | ||
| 97 | // 10.2 API | 97 | // 10.2 API |
| 98 | iter = name_tree.find("Q"); | 98 | iter = name_tree.find("Q"); |
| 99 | - std::cout << "Q: " << iter->first << " -> " << iter->second.unparse() << std::endl; | 99 | + std::cout << "Q: " << iter->first << " -> " << iter->second.unparse() << '\n'; |
| 100 | iter = name_tree.find("W"); | 100 | iter = name_tree.find("W"); |
| 101 | - std::cout << "W found: " << (iter != name_tree.end()) << std::endl; | 101 | + std::cout << "W found: " << (iter != name_tree.end()) << '\n'; |
| 102 | // Allow find to return predecessor | 102 | // Allow find to return predecessor |
| 103 | iter = name_tree.find("W", true); | 103 | iter = name_tree.find("W", true); |
| 104 | - std::cout << "W's predecessor: " << iter->first << " -> " << iter->second.unparse() | ||
| 105 | - << std::endl; | 104 | + std::cout << "W's predecessor: " << iter->first << " -> " << iter->second.unparse() << '\n'; |
| 106 | 105 | ||
| 107 | // We can also remove items | 106 | // We can also remove items |
| 108 | - std::cout << "Remove P: " << name_tree.remove("P", &obj) << std::endl; | ||
| 109 | - std::cout << "Value removed: " << obj.unparse() << std::endl; | ||
| 110 | - std::cout << "Has P?: " << name_tree.hasName("P") << std::endl; | 107 | + std::cout << "Remove P: " << name_tree.remove("P", &obj) << '\n'; |
| 108 | + std::cout << "Value removed: " << obj.unparse() << '\n'; | ||
| 109 | + std::cout << "Has P?: " << name_tree.hasName("P") << '\n'; | ||
| 111 | // Or we can remove using an iterator | 110 | // Or we can remove using an iterator |
| 112 | iter = name_tree.find("K"); | 111 | iter = name_tree.find("K"); |
| 113 | - std::cout << "Find K: " << iter->second.unparse() << std::endl; | 112 | + std::cout << "Find K: " << iter->second.unparse() << '\n'; |
| 114 | iter.remove(); | 113 | iter.remove(); |
| 115 | std::cout << "Iter after removing K: " << iter->first << " -> " << iter->second.unparse() | 114 | std::cout << "Iter after removing K: " << iter->first << " -> " << iter->second.unparse() |
| 116 | - << std::endl; | ||
| 117 | - std::cout << "Has K?: " << name_tree.hasName("K") << std::endl; | 115 | + << '\n'; |
| 116 | + std::cout << "Has K?: " << name_tree.hasName("K") << '\n'; | ||
| 118 | 117 | ||
| 119 | // Illustrate some more advanced usage using number trees. These calls work for name trees too. | 118 | // Illustrate some more advanced usage using number trees. These calls work for name trees too. |
| 120 | 119 | ||
| @@ -129,14 +128,14 @@ main(int argc, char* argv[]) | @@ -129,14 +128,14 @@ main(int argc, char* argv[]) | ||
| 129 | for (int i = 7; i <= 350; i += 7) { | 128 | for (int i = 7; i <= 350; i += 7) { |
| 130 | iter2.insertAfter(i, QPDFObjectHandle::newString("-" + std::to_string(i) + "-")); | 129 | iter2.insertAfter(i, QPDFObjectHandle::newString("-" + std::to_string(i) + "-")); |
| 131 | } | 130 | } |
| 132 | - std::cout << "Numbers:" << std::endl; | 131 | + std::cout << "Numbers:\n"; |
| 133 | int n = 1; | 132 | int n = 1; |
| 134 | for (auto& i: number_tree) { | 133 | for (auto& i: number_tree) { |
| 135 | std::cout << i.first << " -> " << i.second.getUTF8Value(); | 134 | std::cout << i.first << " -> " << i.second.getUTF8Value(); |
| 136 | if (n % 5) { | 135 | if (n % 5) { |
| 137 | std::cout << ", "; | 136 | std::cout << ", "; |
| 138 | } else { | 137 | } else { |
| 139 | - std::cout << std::endl; | 138 | + std::cout << '\n'; |
| 140 | } | 139 | } |
| 141 | ++n; | 140 | ++n; |
| 142 | } | 141 | } |
| @@ -151,14 +150,14 @@ main(int argc, char* argv[]) | @@ -151,14 +150,14 @@ main(int argc, char* argv[]) | ||
| 151 | ++iter2; | 150 | ++iter2; |
| 152 | } | 151 | } |
| 153 | } | 152 | } |
| 154 | - std::cout << "Numbers after filtering:" << std::endl; | 153 | + std::cout << "Numbers after filtering:\n"; |
| 155 | n = 1; | 154 | n = 1; |
| 156 | for (auto& i: number_tree) { | 155 | for (auto& i: number_tree) { |
| 157 | std::cout << i.first << " -> " << i.second.getUTF8Value(); | 156 | std::cout << i.first << " -> " << i.second.getUTF8Value(); |
| 158 | if (n % 5) { | 157 | if (n % 5) { |
| 159 | std::cout << ", "; | 158 | std::cout << ", "; |
| 160 | } else { | 159 | } else { |
| 161 | - std::cout << std::endl; | 160 | + std::cout << '\n'; |
| 162 | } | 161 | } |
| 163 | ++n; | 162 | ++n; |
| 164 | } | 163 | } |
examples/pdf-npages.cc
| @@ -10,8 +10,8 @@ static char const* whoami = nullptr; | @@ -10,8 +10,8 @@ static char const* whoami = nullptr; | ||
| 10 | void | 10 | void |
| 11 | usage() | 11 | usage() |
| 12 | { | 12 | { |
| 13 | - std::cerr << "Usage: " << whoami << " filename" << std::endl | ||
| 14 | - << "Prints the number of pages in filename" << std::endl; | 13 | + std::cerr << "Usage: " << whoami << " filename\n" |
| 14 | + << "Prints the number of pages in filename\n"; | ||
| 15 | exit(2); | 15 | exit(2); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| @@ -21,7 +21,7 @@ main(int argc, char* argv[]) | @@ -21,7 +21,7 @@ main(int argc, char* argv[]) | ||
| 21 | whoami = QUtil::getWhoami(argv[0]); | 21 | whoami = QUtil::getWhoami(argv[0]); |
| 22 | 22 | ||
| 23 | if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) { | 23 | if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) { |
| 24 | - std::cout << whoami << " version 1.3" << std::endl; | 24 | + std::cout << whoami << " version 1.3\n"; |
| 25 | exit(0); | 25 | exit(0); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| @@ -36,9 +36,9 @@ main(int argc, char* argv[]) | @@ -36,9 +36,9 @@ main(int argc, char* argv[]) | ||
| 36 | QPDFObjectHandle root = pdf.getRoot(); | 36 | QPDFObjectHandle root = pdf.getRoot(); |
| 37 | QPDFObjectHandle pages = root.getKey("/Pages"); | 37 | QPDFObjectHandle pages = root.getKey("/Pages"); |
| 38 | QPDFObjectHandle count = pages.getKey("/Count"); | 38 | QPDFObjectHandle count = pages.getKey("/Count"); |
| 39 | - std::cout << count.getIntValue() << std::endl; | 39 | + std::cout << count.getIntValue() << '\n'; |
| 40 | } catch (std::exception& e) { | 40 | } catch (std::exception& e) { |
| 41 | - std::cerr << whoami << ": " << e.what() << std::endl; | 41 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 42 | exit(2); | 42 | exit(2); |
| 43 | } | 43 | } |
| 44 | 44 |
examples/pdf-overlay-page.cc
| @@ -15,9 +15,8 @@ static char const* whoami = nullptr; | @@ -15,9 +15,8 @@ static char const* whoami = nullptr; | ||
| 15 | void | 15 | void |
| 16 | usage() | 16 | usage() |
| 17 | { | 17 | { |
| 18 | - std::cerr << "Usage: " << whoami << " infile pagefile outfile" << std::endl | ||
| 19 | - << "Stamp page 1 of pagefile on every page of infile, writing to outfile" | ||
| 20 | - << std::endl; | 18 | + std::cerr << "Usage: " << whoami << " infile pagefile outfile\n" |
| 19 | + << "Stamp page 1 of pagefile on every page of infile, writing to outfile\n"; | ||
| 21 | exit(2); | 20 | exit(2); |
| 22 | } | 21 | } |
| 23 | 22 | ||
| @@ -81,7 +80,7 @@ main(int argc, char* argv[]) | @@ -81,7 +80,7 @@ main(int argc, char* argv[]) | ||
| 81 | try { | 80 | try { |
| 82 | stamp_page(infile, stampfile, outfile); | 81 | stamp_page(infile, stampfile, outfile); |
| 83 | } catch (std::exception& e) { | 82 | } catch (std::exception& e) { |
| 84 | - std::cerr << whoami << ": " << e.what() << std::endl; | 83 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 85 | exit(2); | 84 | exit(2); |
| 86 | } | 85 | } |
| 87 | return 0; | 86 | return 0; |
examples/pdf-parse-content.cc
| @@ -12,10 +12,10 @@ static char const* whoami = nullptr; | @@ -12,10 +12,10 @@ static char const* whoami = nullptr; | ||
| 12 | void | 12 | void |
| 13 | usage() | 13 | usage() |
| 14 | { | 14 | { |
| 15 | - std::cerr << "Usage: " << whoami << " filename page-number" << std::endl | ||
| 16 | - << "Prints a dump of the objects in the content streams of the given page." | ||
| 17 | - << std::endl | ||
| 18 | - << "Pages are numbered from 1." << std::endl; | 15 | + std::cerr << "Usage: " << whoami << " filename page-number\n" |
| 16 | + << "Prints a dump of the objects in the content streams of the given page.\n" | ||
| 17 | + << '\n' | ||
| 18 | + << "Pages are numbered from 1.\n"; | ||
| 19 | exit(2); | 19 | exit(2); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| @@ -31,7 +31,7 @@ class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks | @@ -31,7 +31,7 @@ class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks | ||
| 31 | void | 31 | void |
| 32 | ParserCallbacks::contentSize(size_t size) | 32 | ParserCallbacks::contentSize(size_t size) |
| 33 | { | 33 | { |
| 34 | - std::cout << "content size: " << size << std::endl; | 34 | + std::cout << "content size: " << size << '\n'; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void | 37 | void |
| @@ -39,16 +39,16 @@ ParserCallbacks::handleObject(QPDFObjectHandle obj, size_t offset, size_t length | @@ -39,16 +39,16 @@ ParserCallbacks::handleObject(QPDFObjectHandle obj, size_t offset, size_t length | ||
| 39 | { | 39 | { |
| 40 | std::cout << obj.getTypeName() << ", offset=" << offset << ", length=" << length << ": "; | 40 | std::cout << obj.getTypeName() << ", offset=" << offset << ", length=" << length << ": "; |
| 41 | if (obj.isInlineImage()) { | 41 | if (obj.isInlineImage()) { |
| 42 | - std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << std::endl; | 42 | + std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << '\n'; |
| 43 | } else { | 43 | } else { |
| 44 | - std::cout << obj.unparse() << std::endl; | 44 | + std::cout << obj.unparse() << '\n'; |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void | 48 | void |
| 49 | ParserCallbacks::handleEOF() | 49 | ParserCallbacks::handleEOF() |
| 50 | { | 50 | { |
| 51 | - std::cout << "-EOF-" << std::endl; | 51 | + std::cout << "-EOF-\n"; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | int | 54 | int |
| @@ -74,7 +74,7 @@ main(int argc, char* argv[]) | @@ -74,7 +74,7 @@ main(int argc, char* argv[]) | ||
| 74 | ParserCallbacks cb; | 74 | ParserCallbacks cb; |
| 75 | page.parseContents(&cb); | 75 | page.parseContents(&cb); |
| 76 | } catch (std::exception& e) { | 76 | } catch (std::exception& e) { |
| 77 | - std::cerr << whoami << ": " << e.what() << std::endl; | 77 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 78 | exit(2); | 78 | exit(2); |
| 79 | } | 79 | } |
| 80 | 80 |
examples/pdf-set-form-values.cc
| @@ -11,8 +11,8 @@ static char const* whoami = nullptr; | @@ -11,8 +11,8 @@ static char const* whoami = nullptr; | ||
| 11 | void | 11 | void |
| 12 | usage() | 12 | usage() |
| 13 | { | 13 | { |
| 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; | 14 | + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf value\n" |
| 15 | + << "Set the value of all text fields to a specified value\n"; | ||
| 16 | exit(2); | 16 | exit(2); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| @@ -68,7 +68,7 @@ main(int argc, char* argv[]) | @@ -68,7 +68,7 @@ main(int argc, char* argv[]) | ||
| 68 | w.setStaticID(true); // for testing only | 68 | w.setStaticID(true); // for testing only |
| 69 | w.write(); | 69 | w.write(); |
| 70 | } catch (std::exception& e) { | 70 | } catch (std::exception& e) { |
| 71 | - std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl; | 71 | + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << '\n'; |
| 72 | exit(2); | 72 | exit(2); |
| 73 | } | 73 | } |
| 74 | 74 |
examples/pdf-split-pages.cc
| @@ -42,7 +42,7 @@ process(char const* whoami, char const* infile, std::string outprefix) | @@ -42,7 +42,7 @@ process(char const* whoami, char const* infile, std::string outprefix) | ||
| 42 | void | 42 | void |
| 43 | usage(char const* whoami) | 43 | usage(char const* whoami) |
| 44 | { | 44 | { |
| 45 | - std::cerr << "Usage: " << whoami << " infile outprefix" << std::endl; | 45 | + std::cerr << "Usage: " << whoami << " infile outprefix\n"; |
| 46 | exit(2); | 46 | exit(2); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| @@ -64,7 +64,7 @@ main(int argc, char* argv[]) | @@ -64,7 +64,7 @@ main(int argc, char* argv[]) | ||
| 64 | try { | 64 | try { |
| 65 | process(whoami, argv[1], argv[2]); | 65 | process(whoami, argv[1], argv[2]); |
| 66 | } catch (std::exception const& e) { | 66 | } catch (std::exception const& e) { |
| 67 | - std::cerr << whoami << ": exception: " << e.what() << std::endl; | 67 | + std::cerr << whoami << ": exception: " << e.what() << '\n'; |
| 68 | return 2; | 68 | return 2; |
| 69 | } | 69 | } |
| 70 | return 0; | 70 | return 0; |
examples/qpdf-job.cc
| @@ -10,11 +10,10 @@ static char const* whoami = nullptr; | @@ -10,11 +10,10 @@ static char const* whoami = nullptr; | ||
| 10 | static void | 10 | static void |
| 11 | usage() | 11 | usage() |
| 12 | { | 12 | { |
| 13 | - std::cerr << "Usage: " << whoami << std::endl | 13 | + std::cerr << "Usage: " << whoami << '\n' |
| 14 | << "This program linearizes the first page of in.pdf to out1.pdf, out2.pdf, and" | 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; | 15 | + << '\n' |
| 16 | + << " out3.pdf, each demonstrating a different way to use the QPDFJob API" << '\n'; | ||
| 18 | exit(2); | 17 | exit(2); |
| 19 | } | 18 | } |
| 20 | 19 | ||
| @@ -49,9 +48,9 @@ main(int argc, char* argv[]) | @@ -49,9 +48,9 @@ main(int argc, char* argv[]) | ||
| 49 | ->compressStreams("n") // avoid dependency on zlib output | 48 | ->compressStreams("n") // avoid dependency on zlib output |
| 50 | ->checkConfiguration(); | 49 | ->checkConfiguration(); |
| 51 | j.run(); | 50 | j.run(); |
| 52 | - std::cout << "out1 status: " << j.getExitCode() << std::endl; | 51 | + std::cout << "out1 status: " << j.getExitCode() << '\n'; |
| 53 | } catch (std::exception& e) { | 52 | } catch (std::exception& e) { |
| 54 | - std::cerr << "exception: " << e.what() << std::endl; | 53 | + std::cerr << "exception: " << e.what() << '\n'; |
| 55 | return 2; | 54 | return 2; |
| 56 | } | 55 | } |
| 57 | 56 | ||
| @@ -71,9 +70,9 @@ main(int argc, char* argv[]) | @@ -71,9 +70,9 @@ main(int argc, char* argv[]) | ||
| 71 | QPDFJob j; | 70 | QPDFJob j; |
| 72 | j.initializeFromArgv(new_argv); | 71 | j.initializeFromArgv(new_argv); |
| 73 | j.run(); | 72 | j.run(); |
| 74 | - std::cout << "out2 status: " << j.getExitCode() << std::endl; | 73 | + std::cout << "out2 status: " << j.getExitCode() << '\n'; |
| 75 | } catch (std::exception& e) { | 74 | } catch (std::exception& e) { |
| 76 | - std::cerr << "exception: " << e.what() << std::endl; | 75 | + std::cerr << "exception: " << e.what() << '\n'; |
| 77 | return 2; | 76 | return 2; |
| 78 | } | 77 | } |
| 79 | 78 | ||
| @@ -95,9 +94,9 @@ main(int argc, char* argv[]) | @@ -95,9 +94,9 @@ main(int argc, char* argv[]) | ||
| 95 | } | 94 | } |
| 96 | )"); | 95 | )"); |
| 97 | j.run(); | 96 | j.run(); |
| 98 | - std::cout << "out3 status: " << j.getExitCode() << std::endl; | 97 | + std::cout << "out3 status: " << j.getExitCode() << '\n'; |
| 99 | } catch (std::exception& e) { | 98 | } catch (std::exception& e) { |
| 100 | - std::cerr << "exception: " << e.what() << std::endl; | 99 | + std::cerr << "exception: " << e.what() << '\n'; |
| 101 | return 2; | 100 | return 2; |
| 102 | } | 101 | } |
| 103 | 102 |
examples/qpdfjob-save-attachment.cc
| @@ -13,7 +13,7 @@ main(int argc, char* argv[]) | @@ -13,7 +13,7 @@ main(int argc, char* argv[]) | ||
| 13 | auto whoami = QUtil::getWhoami(argv[0]); | 13 | auto whoami = QUtil::getWhoami(argv[0]); |
| 14 | 14 | ||
| 15 | if (argc != 4) { | 15 | if (argc != 4) { |
| 16 | - std::cerr << "Usage: " << whoami << " file attachment-key outfile" << std::endl; | 16 | + std::cerr << "Usage: " << whoami << " file attachment-key outfile" << '\n'; |
| 17 | exit(2); | 17 | exit(2); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| @@ -40,10 +40,10 @@ main(int argc, char* argv[]) | @@ -40,10 +40,10 @@ main(int argc, char* argv[]) | ||
| 40 | j.initializeFromArgv(j_argv); | 40 | j.initializeFromArgv(j_argv); |
| 41 | j.run(); | 41 | j.run(); |
| 42 | } catch (std::exception& e) { | 42 | } catch (std::exception& e) { |
| 43 | - std::cerr << whoami << ": " << e.what() << std::endl; | 43 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 44 | exit(2); | 44 | exit(2); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | - std::cout << whoami << ": wrote attachment to " << outfilename << std::endl; | 47 | + std::cout << whoami << ": wrote attachment to " << outfilename << '\n'; |
| 48 | return 0; | 48 | return 0; |
| 49 | } | 49 | } |
fuzz/ascii85_fuzzer.cc
| @@ -37,7 +37,7 @@ FuzzHelper::run() | @@ -37,7 +37,7 @@ FuzzHelper::run() | ||
| 37 | try { | 37 | try { |
| 38 | doChecks(); | 38 | doChecks(); |
| 39 | } catch (std::runtime_error const& e) { | 39 | } catch (std::runtime_error const& e) { |
| 40 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 40 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 |
fuzz/dct_fuzzer.cc
| @@ -49,7 +49,7 @@ FuzzHelper::run() | @@ -49,7 +49,7 @@ FuzzHelper::run() | ||
| 49 | try { | 49 | try { |
| 50 | doChecks(); | 50 | doChecks(); |
| 51 | } catch (std::runtime_error const& e) { | 51 | } catch (std::runtime_error const& e) { |
| 52 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 52 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | 55 |
fuzz/flate_fuzzer.cc
| @@ -37,7 +37,7 @@ FuzzHelper::run() | @@ -37,7 +37,7 @@ FuzzHelper::run() | ||
| 37 | try { | 37 | try { |
| 38 | doChecks(); | 38 | doChecks(); |
| 39 | } catch (std::runtime_error const& e) { | 39 | } catch (std::runtime_error const& e) { |
| 40 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 40 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 |
fuzz/hex_fuzzer.cc
| @@ -37,7 +37,7 @@ FuzzHelper::run() | @@ -37,7 +37,7 @@ FuzzHelper::run() | ||
| 37 | try { | 37 | try { |
| 38 | doChecks(); | 38 | doChecks(); |
| 39 | } catch (std::runtime_error const& e) { | 39 | } catch (std::runtime_error const& e) { |
| 40 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 40 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 |
fuzz/json_fuzzer.cc
| @@ -30,7 +30,7 @@ FuzzHelper::doChecks() | @@ -30,7 +30,7 @@ FuzzHelper::doChecks() | ||
| 30 | try { | 30 | try { |
| 31 | JSON::parse(std::string(reinterpret_cast<char const*>(data), size)); | 31 | JSON::parse(std::string(reinterpret_cast<char const*>(data), size)); |
| 32 | } catch (std::runtime_error& e) { | 32 | } catch (std::runtime_error& e) { |
| 33 | - std::cerr << "runtime_error parsing json: " << e.what() << std::endl; | 33 | + std::cerr << "runtime_error parsing json: " << e.what() << '\n'; |
| 34 | } | 34 | } |
| 35 | QPDF q; | 35 | QPDF q; |
| 36 | q.setMaxWarnings(1000); | 36 | q.setMaxWarnings(1000); |
| @@ -45,7 +45,7 @@ FuzzHelper::run() | @@ -45,7 +45,7 @@ FuzzHelper::run() | ||
| 45 | try { | 45 | try { |
| 46 | doChecks(); | 46 | doChecks(); |
| 47 | } catch (std::runtime_error const& e) { | 47 | } catch (std::runtime_error const& e) { |
| 48 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 48 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 49 | } | 49 | } |
| 50 | } | 50 | } |
| 51 | 51 |
fuzz/lzw_fuzzer.cc
| @@ -37,7 +37,7 @@ FuzzHelper::run() | @@ -37,7 +37,7 @@ FuzzHelper::run() | ||
| 37 | try { | 37 | try { |
| 38 | doChecks(); | 38 | doChecks(); |
| 39 | } catch (std::runtime_error const& e) { | 39 | } catch (std::runtime_error const& e) { |
| 40 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 40 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 |
fuzz/pngpredictor_fuzzer.cc
| @@ -37,7 +37,7 @@ FuzzHelper::run() | @@ -37,7 +37,7 @@ FuzzHelper::run() | ||
| 37 | try { | 37 | try { |
| 38 | doChecks(); | 38 | doChecks(); |
| 39 | } catch (std::runtime_error const& e) { | 39 | } catch (std::runtime_error const& e) { |
| 40 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 40 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 |
fuzz/qpdf_crypt_fuzzer.cc
| @@ -76,9 +76,9 @@ FuzzHelper::doWrite(std::shared_ptr<QPDFWriter> w) | @@ -76,9 +76,9 @@ FuzzHelper::doWrite(std::shared_ptr<QPDFWriter> w) | ||
| 76 | try { | 76 | try { |
| 77 | w->write(); | 77 | w->write(); |
| 78 | } catch (QPDFExc const& e) { | 78 | } catch (QPDFExc const& e) { |
| 79 | - std::cerr << e.what() << std::endl; | 79 | + std::cerr << e.what() << '\n'; |
| 80 | } catch (std::runtime_error const& e) { | 80 | } catch (std::runtime_error const& e) { |
| 81 | - std::cerr << e.what() << std::endl; | 81 | + std::cerr << e.what() << '\n'; |
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| 84 | 84 | ||
| @@ -135,9 +135,9 @@ FuzzHelper::run() | @@ -135,9 +135,9 @@ FuzzHelper::run() | ||
| 135 | try { | 135 | try { |
| 136 | doChecks(); | 136 | doChecks(); |
| 137 | } catch (QPDFExc const& e) { | 137 | } catch (QPDFExc const& e) { |
| 138 | - std::cerr << "QPDFExc: " << e.what() << std::endl; | 138 | + std::cerr << "QPDFExc: " << e.what() << '\n'; |
| 139 | } catch (std::runtime_error const& e) { | 139 | } catch (std::runtime_error const& e) { |
| 140 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 140 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | 143 |
fuzz/qpdf_crypt_insecure_fuzzer.cc
| @@ -75,9 +75,9 @@ FuzzHelper::doWrite(std::shared_ptr<QPDFWriter> w) | @@ -75,9 +75,9 @@ FuzzHelper::doWrite(std::shared_ptr<QPDFWriter> w) | ||
| 75 | try { | 75 | try { |
| 76 | w->write(); | 76 | w->write(); |
| 77 | } catch (QPDFExc const& e) { | 77 | } catch (QPDFExc const& e) { |
| 78 | - std::cerr << e.what() << std::endl; | 78 | + std::cerr << e.what() << '\n'; |
| 79 | } catch (std::runtime_error const& e) { | 79 | } catch (std::runtime_error const& e) { |
| 80 | - std::cerr << e.what() << std::endl; | 80 | + std::cerr << e.what() << '\n'; |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| @@ -135,9 +135,9 @@ FuzzHelper::run() | @@ -135,9 +135,9 @@ FuzzHelper::run() | ||
| 135 | try { | 135 | try { |
| 136 | doChecks(); | 136 | doChecks(); |
| 137 | } catch (QPDFExc const& e) { | 137 | } catch (QPDFExc const& e) { |
| 138 | - std::cerr << "QPDFExc: " << e.what() << std::endl; | 138 | + std::cerr << "QPDFExc: " << e.what() << '\n'; |
| 139 | } catch (std::runtime_error const& e) { | 139 | } catch (std::runtime_error const& e) { |
| 140 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 140 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | 143 |
fuzz/qpdf_fuzzer.cc
| @@ -75,9 +75,9 @@ FuzzHelper::doWrite(std::shared_ptr<QPDFWriter> w) | @@ -75,9 +75,9 @@ FuzzHelper::doWrite(std::shared_ptr<QPDFWriter> w) | ||
| 75 | try { | 75 | try { |
| 76 | w->write(); | 76 | w->write(); |
| 77 | } catch (QPDFExc const& e) { | 77 | } catch (QPDFExc const& e) { |
| 78 | - std::cerr << e.what() << std::endl; | 78 | + std::cerr << e.what() << '\n'; |
| 79 | } catch (std::runtime_error const& e) { | 79 | } catch (std::runtime_error const& e) { |
| 80 | - std::cerr << e.what() << std::endl; | 80 | + std::cerr << e.what() << '\n'; |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| @@ -133,9 +133,9 @@ FuzzHelper::run() | @@ -133,9 +133,9 @@ FuzzHelper::run() | ||
| 133 | try { | 133 | try { |
| 134 | doChecks(); | 134 | doChecks(); |
| 135 | } catch (QPDFExc const& e) { | 135 | } catch (QPDFExc const& e) { |
| 136 | - std::cerr << "QPDFExc: " << e.what() << std::endl; | 136 | + std::cerr << "QPDFExc: " << e.what() << '\n'; |
| 137 | } catch (std::runtime_error const& e) { | 137 | } catch (std::runtime_error const& e) { |
| 138 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 138 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 139 | } | 139 | } |
| 140 | } | 140 | } |
| 141 | 141 |
fuzz/qpdf_lin_fuzzer.cc
| @@ -75,9 +75,9 @@ FuzzHelper::doWrite(std::shared_ptr<QPDFWriter> w) | @@ -75,9 +75,9 @@ FuzzHelper::doWrite(std::shared_ptr<QPDFWriter> w) | ||
| 75 | try { | 75 | try { |
| 76 | w->write(); | 76 | w->write(); |
| 77 | } catch (QPDFExc const& e) { | 77 | } catch (QPDFExc const& e) { |
| 78 | - std::cerr << e.what() << std::endl; | 78 | + std::cerr << e.what() << '\n'; |
| 79 | } catch (std::runtime_error const& e) { | 79 | } catch (std::runtime_error const& e) { |
| 80 | - std::cerr << e.what() << std::endl; | 80 | + std::cerr << e.what() << '\n'; |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| @@ -134,9 +134,9 @@ FuzzHelper::run() | @@ -134,9 +134,9 @@ FuzzHelper::run() | ||
| 134 | try { | 134 | try { |
| 135 | doChecks(); | 135 | doChecks(); |
| 136 | } catch (QPDFExc const& e) { | 136 | } catch (QPDFExc const& e) { |
| 137 | - std::cerr << "QPDFExc: " << e.what() << std::endl; | 137 | + std::cerr << "QPDFExc: " << e.what() << '\n'; |
| 138 | } catch (std::runtime_error const& e) { | 138 | } catch (std::runtime_error const& e) { |
| 139 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 139 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 140 | } | 140 | } |
| 141 | } | 141 | } |
| 142 | 142 |
fuzz/qpdf_outlines_fuzzer.cc
| @@ -111,9 +111,9 @@ FuzzHelper::run() | @@ -111,9 +111,9 @@ FuzzHelper::run() | ||
| 111 | try { | 111 | try { |
| 112 | doChecks(); | 112 | doChecks(); |
| 113 | } catch (QPDFExc const& e) { | 113 | } catch (QPDFExc const& e) { |
| 114 | - std::cerr << "QPDFExc: " << e.what() << std::endl; | 114 | + std::cerr << "QPDFExc: " << e.what() << '\n'; |
| 115 | } catch (std::runtime_error const& e) { | 115 | } catch (std::runtime_error const& e) { |
| 116 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 116 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 117 | } | 117 | } |
| 118 | } | 118 | } |
| 119 | 119 |
fuzz/qpdf_pages_fuzzer.cc
| @@ -132,9 +132,9 @@ FuzzHelper::run() | @@ -132,9 +132,9 @@ FuzzHelper::run() | ||
| 132 | try { | 132 | try { |
| 133 | doChecks(); | 133 | doChecks(); |
| 134 | } catch (QPDFExc const& e) { | 134 | } catch (QPDFExc const& e) { |
| 135 | - std::cerr << "QPDFExc: " << e.what() << std::endl; | 135 | + std::cerr << "QPDFExc: " << e.what() << '\n'; |
| 136 | } catch (std::runtime_error const& e) { | 136 | } catch (std::runtime_error const& e) { |
| 137 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 137 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 138 | } | 138 | } |
| 139 | } | 139 | } |
| 140 | 140 |
fuzz/runlength_fuzzer.cc
| @@ -38,7 +38,7 @@ FuzzHelper::run() | @@ -38,7 +38,7 @@ FuzzHelper::run() | ||
| 38 | try { | 38 | try { |
| 39 | doChecks(); | 39 | doChecks(); |
| 40 | } catch (std::runtime_error const& e) { | 40 | } catch (std::runtime_error const& e) { |
| 41 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 41 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | 44 |
fuzz/standalone_fuzz_target_runner.cc
| @@ -12,7 +12,7 @@ main(int argc, char** argv) | @@ -12,7 +12,7 @@ main(int argc, char** argv) | ||
| 12 | size_t size = 0; | 12 | size_t size = 0; |
| 13 | QUtil::read_file_into_memory(argv[i], file_buf, size); | 13 | QUtil::read_file_into_memory(argv[i], file_buf, size); |
| 14 | LLVMFuzzerTestOneInput(reinterpret_cast<unsigned char*>(file_buf.get()), size); | 14 | LLVMFuzzerTestOneInput(reinterpret_cast<unsigned char*>(file_buf.get()), size); |
| 15 | - std::cout << argv[i] << " successful" << std::endl; | 15 | + std::cout << argv[i] << " successful" << '\n'; |
| 16 | } | 16 | } |
| 17 | return 0; | 17 | return 0; |
| 18 | } | 18 | } |
fuzz/tiffpredictor_fuzzer.cc
| @@ -41,7 +41,7 @@ FuzzHelper::run() | @@ -41,7 +41,7 @@ FuzzHelper::run() | ||
| 41 | try { | 41 | try { |
| 42 | doChecks(); | 42 | doChecks(); |
| 43 | } catch (std::runtime_error const& e) { | 43 | } catch (std::runtime_error const& e) { |
| 44 | - std::cerr << "runtime_error: " << e.what() << std::endl; | 44 | + std::cerr << "runtime_error: " << e.what() << '\n'; |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 |
libqpdf/QPDFArgParser.cc
| @@ -198,13 +198,13 @@ QPDFArgParser::completionCommon(bool zsh) | @@ -198,13 +198,13 @@ QPDFArgParser::completionCommon(bool zsh) | ||
| 198 | if (!zsh) { | 198 | if (!zsh) { |
| 199 | std::cout << " -o nospace"; | 199 | std::cout << " -o nospace"; |
| 200 | } | 200 | } |
| 201 | - std::cout << " -C \"" << progname << "\" " << m->whoami << std::endl; | 201 | + std::cout << " -C \"" << progname << "\" " << m->whoami << '\n'; |
| 202 | // Put output before error so calling from zsh works properly | 202 | // Put output before error so calling from zsh works properly |
| 203 | std::string path = progname; | 203 | std::string path = progname; |
| 204 | size_t slash = path.find('/'); | 204 | size_t slash = path.find('/'); |
| 205 | if ((slash != 0) && (slash != std::string::npos)) { | 205 | if ((slash != 0) && (slash != std::string::npos)) { |
| 206 | std::cerr << "WARNING: " << m->whoami << " completion enabled" | 206 | std::cerr << "WARNING: " << m->whoami << " completion enabled" |
| 207 | - << " using relative path to executable" << std::endl; | 207 | + << " using relative path to executable" << '\n'; |
| 208 | } | 208 | } |
| 209 | } | 209 | } |
| 210 | 210 | ||
| @@ -666,7 +666,7 @@ QPDFArgParser::handleCompletion() | @@ -666,7 +666,7 @@ QPDFArgParser::handleCompletion() | ||
| 666 | std::string prefix = extra_prefix + m->bash_cur; | 666 | std::string prefix = extra_prefix + m->bash_cur; |
| 667 | for (auto const& iter: m->completions) { | 667 | for (auto const& iter: m->completions) { |
| 668 | if (prefix.empty() || (iter.substr(0, prefix.length()) == prefix)) { | 668 | if (prefix.empty() || (iter.substr(0, prefix.length()) == prefix)) { |
| 669 | - std::cout << iter << std::endl; | 669 | + std::cout << iter << '\n'; |
| 670 | } | 670 | } |
| 671 | } | 671 | } |
| 672 | exit(0); | 672 | exit(0); |
| @@ -729,13 +729,13 @@ QPDFArgParser::addOptionHelp( | @@ -729,13 +729,13 @@ QPDFArgParser::addOptionHelp( | ||
| 729 | void | 729 | void |
| 730 | QPDFArgParser::getTopHelp(std::ostringstream& msg) | 730 | QPDFArgParser::getTopHelp(std::ostringstream& msg) |
| 731 | { | 731 | { |
| 732 | - msg << "Run \"" << m->whoami << " --help=topic\" for help on a topic." << std::endl | ||
| 733 | - << "Run \"" << m->whoami << " --help=--option\" for help on an option." << std::endl | ||
| 734 | - << "Run \"" << m->whoami << " --help=all\" to see all available help." << std::endl | ||
| 735 | - << std::endl | ||
| 736 | - << "Topics:" << std::endl; | 732 | + msg << "Run \"" << m->whoami << " --help=topic\" for help on a topic." << '\n' |
| 733 | + << "Run \"" << m->whoami << " --help=--option\" for help on an option." << '\n' | ||
| 734 | + << "Run \"" << m->whoami << " --help=all\" to see all available help." << '\n' | ||
| 735 | + << '\n' | ||
| 736 | + << "Topics:" << '\n'; | ||
| 737 | for (auto const& i: m->help_topics) { | 737 | for (auto const& i: m->help_topics) { |
| 738 | - msg << " " << i.first << ": " << i.second.short_text << std::endl; | 738 | + msg << " " << i.first << ": " << i.second.short_text << '\n'; |
| 739 | } | 739 | } |
| 740 | } | 740 | } |
| 741 | 741 | ||
| @@ -746,29 +746,27 @@ QPDFArgParser::getAllHelp(std::ostringstream& msg) | @@ -746,29 +746,27 @@ QPDFArgParser::getAllHelp(std::ostringstream& msg) | ||
| 746 | auto show = [this, &msg](std::map<std::string, HelpTopic>& topics) { | 746 | auto show = [this, &msg](std::map<std::string, HelpTopic>& topics) { |
| 747 | for (auto const& i: topics) { | 747 | for (auto const& i: topics) { |
| 748 | auto const& topic = i.first; | 748 | auto const& topic = i.first; |
| 749 | - msg << std::endl | ||
| 750 | - << "== " << topic << " (" << i.second.short_text << ") ==" << std::endl | ||
| 751 | - << std::endl; | 749 | + msg << '\n' << "== " << topic << " (" << i.second.short_text << ") ==" << '\n' << '\n'; |
| 752 | getTopicHelp(topic, i.second, msg); | 750 | getTopicHelp(topic, i.second, msg); |
| 753 | } | 751 | } |
| 754 | }; | 752 | }; |
| 755 | show(m->help_topics); | 753 | show(m->help_topics); |
| 756 | show(m->option_help); | 754 | show(m->option_help); |
| 757 | - msg << std::endl << "====" << std::endl; | 755 | + msg << '\n' << "====" << '\n'; |
| 758 | } | 756 | } |
| 759 | 757 | ||
| 760 | void | 758 | void |
| 761 | QPDFArgParser::getTopicHelp(std::string const& name, HelpTopic const& ht, std::ostringstream& msg) | 759 | QPDFArgParser::getTopicHelp(std::string const& name, HelpTopic const& ht, std::ostringstream& msg) |
| 762 | { | 760 | { |
| 763 | if (ht.long_text.empty()) { | 761 | if (ht.long_text.empty()) { |
| 764 | - msg << ht.short_text << std::endl; | 762 | + msg << ht.short_text << '\n'; |
| 765 | } else { | 763 | } else { |
| 766 | msg << ht.long_text; | 764 | msg << ht.long_text; |
| 767 | } | 765 | } |
| 768 | if (!ht.options.empty()) { | 766 | if (!ht.options.empty()) { |
| 769 | - msg << std::endl << "Related options:" << std::endl; | 767 | + msg << '\n' << "Related options:" << '\n'; |
| 770 | for (auto const& i: ht.options) { | 768 | for (auto const& i: ht.options) { |
| 771 | - msg << " " << i << ": " << m->option_help[i].short_text << std::endl; | 769 | + msg << " " << i << ": " << m->option_help[i].short_text << '\n'; |
| 772 | } | 770 | } |
| 773 | } | 771 | } |
| 774 | } | 772 | } |
libqpdf/QPDFJob_json.cc
| @@ -630,7 +630,7 @@ QPDFJob::initializeFromJson(std::string const& json, bool partial) | @@ -630,7 +630,7 @@ QPDFJob::initializeFromJson(std::string const& json, bool partial) | ||
| 630 | std::ostringstream msg; | 630 | std::ostringstream msg; |
| 631 | msg << m->message_prefix << ": job json has errors:"; | 631 | msg << m->message_prefix << ": job json has errors:"; |
| 632 | for (auto const& error: errors) { | 632 | for (auto const& error: errors) { |
| 633 | - msg << std::endl << " " << error; | 633 | + msg << "\n " << error; |
| 634 | } | 634 | } |
| 635 | throw std::runtime_error(msg.str()); | 635 | throw std::runtime_error(msg.str()); |
| 636 | } | 636 | } |
libqpdf/QPDF_json.cc
| @@ -161,7 +161,7 @@ QPDF::test_json_validators() | @@ -161,7 +161,7 @@ QPDF::test_json_validators() | ||
| 161 | auto check_fn = [&passed](char const* msg, bool expr) { | 161 | auto check_fn = [&passed](char const* msg, bool expr) { |
| 162 | if (!expr) { | 162 | if (!expr) { |
| 163 | passed = false; | 163 | passed = false; |
| 164 | - std::cerr << msg << std::endl; | 164 | + std::cerr << msg << '\n'; |
| 165 | } | 165 | } |
| 166 | }; | 166 | }; |
| 167 | #define check(expr) check_fn(#expr, expr) | 167 | #define check(expr) check_fn(#expr, expr) |
libtests/aes.cc
| @@ -11,15 +11,15 @@ | @@ -11,15 +11,15 @@ | ||
| 11 | static void | 11 | static void |
| 12 | usage() | 12 | usage() |
| 13 | { | 13 | { |
| 14 | - std::cerr << "Usage: aes options hex-key infile outfile" << std::endl | ||
| 15 | - << " -cbc -- disable CBC mode" << std::endl | ||
| 16 | - << " +cbc -- enable CBC mode" << std::endl | ||
| 17 | - << " -encrypt -- encrypt" << std::endl | ||
| 18 | - << " -decrypt -- decrypt CBC mode" << std::endl | ||
| 19 | - << " -zero-iv -- use zero initialization vector" << std::endl | ||
| 20 | - << " -static-iv -- use static initialization vector" << std::endl | ||
| 21 | - << " -no-padding -- disable padding" << std::endl | ||
| 22 | - << "Options must precede key and file names." << std::endl; | 14 | + std::cerr << "Usage: aes options hex-key infile outfile" << '\n' |
| 15 | + << " -cbc -- disable CBC mode" << '\n' | ||
| 16 | + << " +cbc -- enable CBC mode" << '\n' | ||
| 17 | + << " -encrypt -- encrypt" << '\n' | ||
| 18 | + << " -decrypt -- decrypt CBC mode" << '\n' | ||
| 19 | + << " -zero-iv -- use zero initialization vector" << '\n' | ||
| 20 | + << " -static-iv -- use static initialization vector" << '\n' | ||
| 21 | + << " -no-padding -- disable padding" << '\n' | ||
| 22 | + << "Options must precede key and file names." << '\n'; | ||
| 23 | exit(2); | 23 | exit(2); |
| 24 | } | 24 | } |
| 25 | 25 |
libtests/arg_parser.cc
| @@ -82,7 +82,7 @@ void | @@ -82,7 +82,7 @@ void | ||
| 82 | ArgParser::output(std::string const& msg) | 82 | ArgParser::output(std::string const& msg) |
| 83 | { | 83 | { |
| 84 | if (!this->ap.isCompleting()) { | 84 | if (!this->ap.isCompleting()) { |
| 85 | - std::cout << msg << std::endl; | 85 | + std::cout << msg << '\n'; |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | 88 | ||
| @@ -160,7 +160,7 @@ ArgParser::test_exceptions() | @@ -160,7 +160,7 @@ ArgParser::test_exceptions() | ||
| 160 | fn(); | 160 | fn(); |
| 161 | assert(msg == nullptr); | 161 | assert(msg == nullptr); |
| 162 | } catch (std::exception& e) { | 162 | } catch (std::exception& e) { |
| 163 | - std::cout << msg << ": " << e.what() << std::endl; | 163 | + std::cout << msg << ": " << e.what() << '\n'; |
| 164 | } | 164 | } |
| 165 | }; | 165 | }; |
| 166 | 166 | ||
| @@ -196,10 +196,10 @@ main(int argc, char* argv[]) | @@ -196,10 +196,10 @@ main(int argc, char* argv[]) | ||
| 196 | try { | 196 | try { |
| 197 | ap.parseArgs(); | 197 | ap.parseArgs(); |
| 198 | } catch (QPDFUsage& e) { | 198 | } catch (QPDFUsage& e) { |
| 199 | - std::cerr << "usage: " << e.what() << std::endl; | 199 | + std::cerr << "usage: " << e.what() << '\n'; |
| 200 | exit(2); | 200 | exit(2); |
| 201 | } catch (std::exception& e) { | 201 | } catch (std::exception& e) { |
| 202 | - std::cerr << "exception: " << e.what() << std::endl; | 202 | + std::cerr << "exception: " << e.what() << '\n'; |
| 203 | exit(3); | 203 | exit(3); |
| 204 | } | 204 | } |
| 205 | return 0; | 205 | return 0; |
libtests/ascii85.cc
libtests/base64.cc
| @@ -20,7 +20,7 @@ write_some(FILE* f, size_t bytes, Pipeline* p) | @@ -20,7 +20,7 @@ write_some(FILE* f, size_t bytes, Pipeline* p) | ||
| 20 | } | 20 | } |
| 21 | if (len < bytes) { | 21 | if (len < bytes) { |
| 22 | if (ferror(f)) { | 22 | if (ferror(f)) { |
| 23 | - std::cerr << "error reading file" << std::endl; | 23 | + std::cerr << "error reading file" << '\n'; |
| 24 | exit(2); | 24 | exit(2); |
| 25 | } | 25 | } |
| 26 | p->finish(); | 26 | p->finish(); |
| @@ -32,7 +32,7 @@ write_some(FILE* f, size_t bytes, Pipeline* p) | @@ -32,7 +32,7 @@ write_some(FILE* f, size_t bytes, Pipeline* p) | ||
| 32 | static void | 32 | static void |
| 33 | usage() | 33 | usage() |
| 34 | { | 34 | { |
| 35 | - std::cerr << "Usage: base64 encode|decode" << std::endl; | 35 | + std::cerr << "Usage: base64 encode|decode" << '\n'; |
| 36 | exit(2); | 36 | exit(2); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| @@ -74,7 +74,7 @@ main(int argc, char* argv[]) | @@ -74,7 +74,7 @@ main(int argc, char* argv[]) | ||
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | } catch (std::exception& e) { | 76 | } catch (std::exception& e) { |
| 77 | - std::cout << "exception: " << e.what() << std::endl; | 77 | + std::cout << "exception: " << e.what() << '\n'; |
| 78 | exit(2); | 78 | exit(2); |
| 79 | } | 79 | } |
| 80 | 80 |
libtests/bits.cc
| @@ -16,7 +16,7 @@ static void | @@ -16,7 +16,7 @@ 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 << ", " << "bit offset = " << bit_offset << ", " | 18 | std::cout << "byte offset = " << byte_offset << ", " << "bit offset = " << bit_offset << ", " |
| 19 | - << "bits available = " << bits_available << std::endl; | 19 | + << "bits available = " << bits_available << '\n'; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | static void | 22 | static void |
| @@ -29,7 +29,7 @@ test_read_bits( | @@ -29,7 +29,7 @@ test_read_bits( | ||
| 29 | { | 29 | { |
| 30 | unsigned long result = QIntC::to_ulong(read_bits(p, bit_offset, bits_available, bits_wanted)); | 30 | unsigned long result = QIntC::to_ulong(read_bits(p, bit_offset, bits_available, bits_wanted)); |
| 31 | 31 | ||
| 32 | - std::cout << "bits read: " << bits_wanted << ", result = " << result << std::endl; | 32 | + std::cout << "bits read: " << bits_wanted << ", result = " << result << '\n'; |
| 33 | print_values(p - buf, bit_offset, bits_available); | 33 | print_values(p - buf, bit_offset, bits_available); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -39,7 +39,7 @@ test_write_bits( | @@ -39,7 +39,7 @@ test_write_bits( | ||
| 39 | { | 39 | { |
| 40 | write_bits(ch, bit_offset, val, bits, bp); | 40 | write_bits(ch, bit_offset, val, bits, bp); |
| 41 | std::cout << "ch = " << QUtil::uint_to_string_base(ch, 16, 2) << ", bit_offset = " << bit_offset | 41 | std::cout << "ch = " << QUtil::uint_to_string_base(ch, 16, 2) << ", bit_offset = " << bit_offset |
| 42 | - << std::endl; | 42 | + << '\n'; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | static void | 45 | static void |
| @@ -52,7 +52,7 @@ print_buffer(Pl_Buffer* bp) | @@ -52,7 +52,7 @@ print_buffer(Pl_Buffer* bp) | ||
| 52 | for (unsigned long i = 0; i < l; ++i) { | 52 | for (unsigned long i = 0; i < l; ++i) { |
| 53 | std::cout << QUtil::uint_to_string_base(p[i], 16, 2) << ((i == l - 1) ? "\n" : " "); | 53 | std::cout << QUtil::uint_to_string_base(p[i], 16, 2) << ((i == l - 1) ? "\n" : " "); |
| 54 | } | 54 | } |
| 55 | - std::cout << std::endl; | 55 | + std::cout << '\n'; |
| 56 | delete b; | 56 | delete b; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -86,12 +86,12 @@ test() | @@ -86,12 +86,12 @@ test() | ||
| 86 | try { | 86 | try { |
| 87 | test_read_bits(buf, p, bit_offset, bits_available, 4); | 87 | test_read_bits(buf, p, bit_offset, bits_available, 4); |
| 88 | } catch (std::exception& e) { | 88 | } catch (std::exception& e) { |
| 89 | - std::cout << "exception: " << e.what() << std::endl; | 89 | + std::cout << "exception: " << e.what() << '\n'; |
| 90 | print_values(p - buf, bit_offset, bits_available); | 90 | print_values(p - buf, bit_offset, bits_available); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | test_read_bits(buf, p, bit_offset, bits_available, 3); | 93 | test_read_bits(buf, p, bit_offset, bits_available, 3); |
| 94 | - std::cout << std::endl; | 94 | + std::cout << '\n'; |
| 95 | 95 | ||
| 96 | // 11110101 00010101 01100101 01111001: 00010010 10001001 01110101 01001011 | 96 | // 11110101 00010101 01100101 01111001: 00010010 10001001 01110101 01001011 |
| 97 | 97 | ||
| @@ -101,29 +101,29 @@ test() | @@ -101,29 +101,29 @@ test() | ||
| 101 | print_values(p - buf, bit_offset, bits_available); | 101 | print_values(p - buf, bit_offset, bits_available); |
| 102 | test_read_bits(buf, p, bit_offset, bits_available, 32); | 102 | test_read_bits(buf, p, bit_offset, bits_available, 32); |
| 103 | test_read_bits(buf, p, bit_offset, bits_available, 32); | 103 | test_read_bits(buf, p, bit_offset, bits_available, 32); |
| 104 | - std::cout << std::endl; | 104 | + std::cout << '\n'; |
| 105 | 105 | ||
| 106 | BitStream b(buf, 8); | 106 | BitStream b(buf, 8); |
| 107 | - std::cout << b.getBits(32) << std::endl; | 107 | + std::cout << b.getBits(32) << '\n'; |
| 108 | b.reset(); | 108 | b.reset(); |
| 109 | - std::cout << b.getBits(32) << std::endl; | ||
| 110 | - std::cout << b.getBits(32) << std::endl; | ||
| 111 | - std::cout << std::endl; | 109 | + std::cout << b.getBits(32) << '\n'; |
| 110 | + std::cout << b.getBits(32) << '\n'; | ||
| 111 | + std::cout << '\n'; | ||
| 112 | 112 | ||
| 113 | b.reset(); | 113 | b.reset(); |
| 114 | - std::cout << b.getBits(6) << std::endl; | 114 | + std::cout << b.getBits(6) << '\n'; |
| 115 | b.skipToNextByte(); | 115 | b.skipToNextByte(); |
| 116 | - std::cout << b.getBits(8) << std::endl; | 116 | + std::cout << b.getBits(8) << '\n'; |
| 117 | b.skipToNextByte(); | 117 | b.skipToNextByte(); |
| 118 | - std::cout << b.getBits(8) << std::endl; | ||
| 119 | - std::cout << std::endl; | 118 | + std::cout << b.getBits(8) << '\n'; |
| 119 | + std::cout << '\n'; | ||
| 120 | b.reset(); | 120 | b.reset(); |
| 121 | - std::cout << b.getBitsSigned(3) << std::endl; | ||
| 122 | - std::cout << b.getBitsSigned(6) << std::endl; | ||
| 123 | - std::cout << b.getBitsSigned(5) << std::endl; | ||
| 124 | - std::cout << b.getBitsSigned(1) << std::endl; | ||
| 125 | - std::cout << b.getBitsSigned(17) << std::endl; | ||
| 126 | - std::cout << std::endl; | 121 | + std::cout << b.getBitsSigned(3) << '\n'; |
| 122 | + std::cout << b.getBitsSigned(6) << '\n'; | ||
| 123 | + std::cout << b.getBitsSigned(5) << '\n'; | ||
| 124 | + std::cout << b.getBitsSigned(1) << '\n'; | ||
| 125 | + std::cout << b.getBitsSigned(17) << '\n'; | ||
| 126 | + std::cout << '\n'; | ||
| 127 | 127 | ||
| 128 | // Write tests | 128 | // Write tests |
| 129 | 129 | ||
| @@ -176,9 +176,9 @@ main() | @@ -176,9 +176,9 @@ main() | ||
| 176 | try { | 176 | try { |
| 177 | test(); | 177 | test(); |
| 178 | } catch (std::exception& e) { | 178 | } catch (std::exception& e) { |
| 179 | - std::cout << "unexpected exception: " << e.what() << std::endl; | 179 | + std::cout << "unexpected exception: " << e.what() << '\n'; |
| 180 | exit(2); | 180 | exit(2); |
| 181 | } | 181 | } |
| 182 | - std::cout << "done" << std::endl; | 182 | + std::cout << "done" << '\n'; |
| 183 | return 0; | 183 | return 0; |
| 184 | } | 184 | } |
libtests/buffer.cc
| @@ -85,22 +85,22 @@ main() | @@ -85,22 +85,22 @@ main() | ||
| 85 | bp1.write(uc("12345"), 5); | 85 | bp1.write(uc("12345"), 5); |
| 86 | bp1.write(uc("67890"), 5); | 86 | bp1.write(uc("67890"), 5); |
| 87 | bp1.finish(); | 87 | bp1.finish(); |
| 88 | - std::cout << "count: " << count.getCount() << std::endl; | 88 | + std::cout << "count: " << count.getCount() << '\n'; |
| 89 | bp1.write(uc("abcde"), 5); | 89 | bp1.write(uc("abcde"), 5); |
| 90 | bp1.write(uc("fghij"), 6); | 90 | bp1.write(uc("fghij"), 6); |
| 91 | bp1.finish(); | 91 | bp1.finish(); |
| 92 | - std::cout << "count: " << count.getCount() << std::endl; | 92 | + std::cout << "count: " << count.getCount() << '\n'; |
| 93 | Buffer* b = bp1.getBuffer(); | 93 | Buffer* b = bp1.getBuffer(); |
| 94 | - std::cout << "size: " << b->getSize() << std::endl; | ||
| 95 | - std::cout << "data: " << b->getBuffer() << std::endl; | 94 | + std::cout << "size: " << b->getSize() << '\n'; |
| 95 | + std::cout << "data: " << b->getBuffer() << '\n'; | ||
| 96 | delete b; | 96 | delete b; |
| 97 | bp1.write(uc("qwert"), 5); | 97 | bp1.write(uc("qwert"), 5); |
| 98 | bp1.write(uc("yuiop"), 6); | 98 | bp1.write(uc("yuiop"), 6); |
| 99 | bp1.finish(); | 99 | bp1.finish(); |
| 100 | - std::cout << "count: " << count.getCount() << std::endl; | 100 | + std::cout << "count: " << count.getCount() << '\n'; |
| 101 | b = bp1.getBuffer(); | 101 | b = bp1.getBuffer(); |
| 102 | - std::cout << "size: " << b->getSize() << std::endl; | ||
| 103 | - std::cout << "data: " << b->getBuffer() << std::endl; | 102 | + std::cout << "size: " << b->getSize() << '\n'; |
| 103 | + std::cout << "data: " << b->getBuffer() << '\n'; | ||
| 104 | delete b; | 104 | delete b; |
| 105 | 105 | ||
| 106 | Pl_Buffer bp2("bp2"); | 106 | Pl_Buffer bp2("bp2"); |
| @@ -109,12 +109,12 @@ main() | @@ -109,12 +109,12 @@ main() | ||
| 109 | try { | 109 | try { |
| 110 | delete bp2.getBuffer(); | 110 | delete bp2.getBuffer(); |
| 111 | } catch (std::exception& e) { | 111 | } catch (std::exception& e) { |
| 112 | - std::cout << e.what() << std::endl; | 112 | + std::cout << e.what() << '\n'; |
| 113 | } | 113 | } |
| 114 | bp2.finish(); | 114 | bp2.finish(); |
| 115 | b = bp2.getBuffer(); | 115 | b = bp2.getBuffer(); |
| 116 | - std::cout << "size: " << b->getSize() << std::endl; | ||
| 117 | - std::cout << "data: " << b->getBuffer() << std::endl; | 116 | + std::cout << "size: " << b->getSize() << '\n'; |
| 117 | + std::cout << "data: " << b->getBuffer() << '\n'; | ||
| 118 | delete b; | 118 | delete b; |
| 119 | 119 | ||
| 120 | unsigned char lbuf[10]; | 120 | unsigned char lbuf[10]; |
| @@ -125,17 +125,17 @@ main() | @@ -125,17 +125,17 @@ main() | ||
| 125 | 125 | ||
| 126 | Pl_Buffer bp3("bp3"); | 126 | Pl_Buffer bp3("bp3"); |
| 127 | b = bp3.getBuffer(); | 127 | b = bp3.getBuffer(); |
| 128 | - std::cout << "size: " << b->getSize() << std::endl; | 128 | + std::cout << "size: " << b->getSize() << '\n'; |
| 129 | delete b; | 129 | delete b; |
| 130 | // Should be able to call getBuffer again and get an empty buffer | 130 | // Should be able to call getBuffer again and get an empty buffer |
| 131 | b = bp3.getBuffer(); | 131 | b = bp3.getBuffer(); |
| 132 | - std::cout << "size: " << b->getSize() << std::endl; | 132 | + std::cout << "size: " << b->getSize() << '\n'; |
| 133 | delete b; | 133 | delete b; |
| 134 | // Also can write 0 and do it. | 134 | // Also can write 0 and do it. |
| 135 | bp3.write(uc(""), 0); | 135 | bp3.write(uc(""), 0); |
| 136 | bp3.finish(); | 136 | bp3.finish(); |
| 137 | b = bp3.getBuffer(); | 137 | b = bp3.getBuffer(); |
| 138 | - std::cout << "size: " << b->getSize() << std::endl; | 138 | + std::cout << "size: " << b->getSize() << '\n'; |
| 139 | delete b; | 139 | delete b; |
| 140 | 140 | ||
| 141 | // Malloc buffer should behave similarly. | 141 | // Malloc buffer should behave similarly. |
| @@ -147,7 +147,7 @@ main() | @@ -147,7 +147,7 @@ main() | ||
| 147 | bp4.getMallocBuffer(&mbuf, &len); | 147 | bp4.getMallocBuffer(&mbuf, &len); |
| 148 | assert(false); | 148 | assert(false); |
| 149 | } catch (std::logic_error& e) { | 149 | } catch (std::logic_error& e) { |
| 150 | - std::cout << "malloc buffer logic error: " << e.what() << std::endl; | 150 | + std::cout << "malloc buffer logic error: " << e.what() << '\n'; |
| 151 | } | 151 | } |
| 152 | bp4.finish(); | 152 | bp4.finish(); |
| 153 | bp4.getMallocBuffer(&mbuf, &len); | 153 | bp4.getMallocBuffer(&mbuf, &len); |
| @@ -160,10 +160,10 @@ main() | @@ -160,10 +160,10 @@ main() | ||
| 160 | assert(mbuf == nullptr); | 160 | assert(mbuf == nullptr); |
| 161 | assert(len == 0); | 161 | assert(len == 0); |
| 162 | } catch (std::exception& e) { | 162 | } catch (std::exception& e) { |
| 163 | - std::cout << "unexpected exception: " << e.what() << std::endl; | 163 | + std::cout << "unexpected exception: " << e.what() << '\n'; |
| 164 | exit(2); | 164 | exit(2); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | - std::cout << "done" << std::endl; | 167 | + std::cout << "done" << '\n'; |
| 168 | return 0; | 168 | return 0; |
| 169 | } | 169 | } |
libtests/closed_file_input_source.cc
| @@ -8,7 +8,7 @@ void | @@ -8,7 +8,7 @@ void | ||
| 8 | check(std::string const& what, bool result) | 8 | check(std::string const& what, bool result) |
| 9 | { | 9 | { |
| 10 | if (!result) { | 10 | if (!result) { |
| 11 | - std::cout << "FAIL: " << what << std::endl; | 11 | + std::cout << "FAIL: " << what << '\n'; |
| 12 | } | 12 | } |
| 13 | } | 13 | } |
| 14 | 14 | ||
| @@ -73,6 +73,6 @@ main() | @@ -73,6 +73,6 @@ main() | ||
| 73 | std::cout << "testing with FileInputSource\n"; | 73 | std::cout << "testing with FileInputSource\n"; |
| 74 | FileInputSource f("input"); | 74 | FileInputSource f("input"); |
| 75 | do_tests(&f); | 75 | do_tests(&f); |
| 76 | - std::cout << "all assertions passed" << std::endl; | 76 | + std::cout << "all assertions passed" << '\n'; |
| 77 | return 0; | 77 | return 0; |
| 78 | } | 78 | } |
libtests/concatenate.cc
| @@ -31,9 +31,9 @@ main(int argc, char* argv[]) | @@ -31,9 +31,9 @@ main(int argc, char* argv[]) | ||
| 31 | auto b2_buf = b2.getBufferSharedPointer(); | 31 | auto b2_buf = b2.getBufferSharedPointer(); |
| 32 | std::string result(reinterpret_cast<char*>(b2_buf->getBuffer()), b2_buf->getSize()); | 32 | std::string result(reinterpret_cast<char*>(b2_buf->getBuffer()), b2_buf->getSize()); |
| 33 | if (result == "-one--two-") { | 33 | if (result == "-one--two-") { |
| 34 | - std::cout << "concatenate test passed" << std::endl; | 34 | + std::cout << "concatenate test passed" << '\n'; |
| 35 | } else { | 35 | } else { |
| 36 | - std::cout << "concatenate test failed: " << result << std::endl; | 36 | + std::cout << "concatenate test failed: " << result << '\n'; |
| 37 | } | 37 | } |
| 38 | return 0; | 38 | return 0; |
| 39 | } | 39 | } |
libtests/dct_compress.cc
| @@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
| 12 | static void | 12 | static void |
| 13 | usage() | 13 | usage() |
| 14 | { | 14 | { |
| 15 | - std::cerr << "Usage: dct_compress infile outfile width height {rgb|cmyk|gray}" << std::endl; | 15 | + std::cerr << "Usage: dct_compress infile outfile width height {rgb|cmyk|gray}" << '\n'; |
| 16 | exit(2); | 16 | exit(2); |
| 17 | } | 17 | } |
| 18 | 18 |
libtests/dct_uncompress.cc
| @@ -10,7 +10,7 @@ int | @@ -10,7 +10,7 @@ int | ||
| 10 | main(int argc, char* argv[]) | 10 | main(int argc, char* argv[]) |
| 11 | { | 11 | { |
| 12 | if (argc != 3) { | 12 | if (argc != 3) { |
| 13 | - std::cerr << "Usage: dct_uncompress infile outfile" << std::endl; | 13 | + std::cerr << "Usage: dct_uncompress infile outfile" << '\n'; |
| 14 | exit(2); | 14 | exit(2); |
| 15 | } | 15 | } |
| 16 | 16 |
libtests/flate.cc
| @@ -53,7 +53,7 @@ run(char const* filename) | @@ -53,7 +53,7 @@ run(char const* filename) | ||
| 53 | 53 | ||
| 54 | def3->finish(); | 54 | def3->finish(); |
| 55 | 55 | ||
| 56 | - std::cout << "bytes written to o3: " << count3->getCount() << std::endl; | 56 | + std::cout << "bytes written to o3: " << count3->getCount() << '\n'; |
| 57 | 57 | ||
| 58 | delete def3; | 58 | delete def3; |
| 59 | delete inf3; | 59 | delete inf3; |
| @@ -76,14 +76,14 @@ run(char const* filename) | @@ -76,14 +76,14 @@ run(char const* filename) | ||
| 76 | // At this point, filename, filename.2, and filename.3 should have | 76 | // At this point, filename, filename.2, and filename.3 should have |
| 77 | // identical contents. filename.1 should be a compressed version. | 77 | // identical contents. filename.1 should be a compressed version. |
| 78 | 78 | ||
| 79 | - std::cout << "done" << std::endl; | 79 | + std::cout << "done" << '\n'; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | int | 82 | int |
| 83 | main(int argc, char* argv[]) | 83 | main(int argc, char* argv[]) |
| 84 | { | 84 | { |
| 85 | if (argc != 2) { | 85 | if (argc != 2) { |
| 86 | - std::cerr << "Usage: pipeline filename" << std::endl; | 86 | + std::cerr << "Usage: pipeline filename" << '\n'; |
| 87 | exit(2); | 87 | exit(2); |
| 88 | } | 88 | } |
| 89 | char* filename = argv[1]; | 89 | char* filename = argv[1]; |
| @@ -91,7 +91,7 @@ main(int argc, char* argv[]) | @@ -91,7 +91,7 @@ main(int argc, char* argv[]) | ||
| 91 | try { | 91 | try { |
| 92 | run(filename); | 92 | run(filename); |
| 93 | } catch (std::exception& e) { | 93 | } catch (std::exception& e) { |
| 94 | - std::cout << e.what() << std::endl; | 94 | + std::cout << e.what() << '\n'; |
| 95 | } | 95 | } |
| 96 | return 0; | 96 | return 0; |
| 97 | } | 97 | } |
libtests/hex.cc
libtests/input_source.cc
| @@ -47,7 +47,7 @@ Finder::check() | @@ -47,7 +47,7 @@ Finder::check() | ||
| 47 | void | 47 | void |
| 48 | check(char const* description, bool expected, bool actual) | 48 | check(char const* description, bool expected, bool actual) |
| 49 | { | 49 | { |
| 50 | - std::cout << description << ": " << ((actual == expected) ? "PASS" : "FAIL") << std::endl; | 50 | + std::cout << description << ": " << ((actual == expected) ? "PASS" : "FAIL") << '\n'; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | int | 53 | int |
libtests/json.cc
| @@ -186,12 +186,12 @@ static void | @@ -186,12 +186,12 @@ static void | ||
| 186 | check_schema(JSON& obj, JSON& schema, unsigned long flags, bool exp, std::string const& description) | 186 | check_schema(JSON& obj, JSON& schema, unsigned long flags, bool exp, std::string const& description) |
| 187 | { | 187 | { |
| 188 | std::list<std::string> errors; | 188 | std::list<std::string> errors; |
| 189 | - std::cout << "--- " << description << std::endl; | 189 | + std::cout << "--- " << description << '\n'; |
| 190 | assert(exp == obj.checkSchema(schema, flags, errors)); | 190 | assert(exp == obj.checkSchema(schema, flags, errors)); |
| 191 | for (auto const& error: errors) { | 191 | for (auto const& error: errors) { |
| 192 | - std::cout << error << std::endl; | 192 | + std::cout << error << '\n'; |
| 193 | } | 193 | } |
| 194 | - std::cout << "---" << std::endl; | 194 | + std::cout << "---" << '\n'; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | static void | 197 | static void |
libtests/json_handler.cc
| @@ -8,43 +8,43 @@ | @@ -8,43 +8,43 @@ | ||
| 8 | static void | 8 | static void |
| 9 | print_null(std::string const& path) | 9 | print_null(std::string const& path) |
| 10 | { | 10 | { |
| 11 | - std::cout << path << ": null" << std::endl; | 11 | + std::cout << path << ": null" << '\n'; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | static void | 14 | static void |
| 15 | print_string(std::string const& path, std::string const& value) | 15 | print_string(std::string const& path, std::string const& value) |
| 16 | { | 16 | { |
| 17 | - std::cout << path << ": string: " << value << std::endl; | 17 | + std::cout << path << ": string: " << value << '\n'; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | static void | 20 | static void |
| 21 | print_number(std::string const& path, std::string const& value) | 21 | print_number(std::string const& path, std::string const& value) |
| 22 | { | 22 | { |
| 23 | - std::cout << path << ": number: " << value << std::endl; | 23 | + std::cout << path << ": number: " << value << '\n'; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | static void | 26 | static void |
| 27 | print_bool(std::string const& path, bool value) | 27 | print_bool(std::string const& path, bool value) |
| 28 | { | 28 | { |
| 29 | - std::cout << path << ": bool: " << (value ? "true" : "false") << std::endl; | 29 | + std::cout << path << ": bool: " << (value ? "true" : "false") << '\n'; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | static void | 32 | static void |
| 33 | print_json(std::string const& path, JSON value) | 33 | print_json(std::string const& path, JSON value) |
| 34 | { | 34 | { |
| 35 | - std::cout << path << ": json: " << value.unparse() << std::endl; | 35 | + std::cout << path << ": json: " << value.unparse() << '\n'; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static JSONHandler::void_handler_t | 38 | static JSONHandler::void_handler_t |
| 39 | make_print_message(std::string msg) | 39 | make_print_message(std::string msg) |
| 40 | { | 40 | { |
| 41 | - return [msg](std::string const& path) { std::cout << path << ": json: " << msg << std::endl; }; | 41 | + return [msg](std::string const& path) { std::cout << path << ": json: " << msg << '\n'; }; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | static void | 44 | static void |
| 45 | test_scalar() | 45 | test_scalar() |
| 46 | { | 46 | { |
| 47 | - std::cout << "-- scalar --" << std::endl; | 47 | + std::cout << "-- scalar --" << '\n'; |
| 48 | JSONHandler h; | 48 | JSONHandler h; |
| 49 | h.addStringHandler(print_string); | 49 | h.addStringHandler(print_string); |
| 50 | JSON j = JSON::parse("\"potato\""); | 50 | JSON j = JSON::parse("\"potato\""); |
| @@ -97,7 +97,7 @@ make_all_handler() | @@ -97,7 +97,7 @@ make_all_handler() | ||
| 97 | static void | 97 | static void |
| 98 | test_all() | 98 | test_all() |
| 99 | { | 99 | { |
| 100 | - std::cout << "-- all --" << std::endl; | 100 | + std::cout << "-- all --" << '\n'; |
| 101 | auto h = make_all_handler(); | 101 | auto h = make_all_handler(); |
| 102 | /* cSpell: ignore phour */ | 102 | /* cSpell: ignore phour */ |
| 103 | JSON j = JSON::parse(R"({ | 103 | JSON j = JSON::parse(R"({ |
| @@ -110,7 +110,7 @@ test_all() | @@ -110,7 +110,7 @@ test_all() | ||
| 110 | "six": {"a": {"b": "quack", "Q": "baaa"}, "b": "moo"} | 110 | "six": {"a": {"b": "quack", "Q": "baaa"}, "b": "moo"} |
| 111 | })"); | 111 | })"); |
| 112 | h->handle(".", j); | 112 | h->handle(".", j); |
| 113 | - std::cerr << "-- fallback --" << std::endl; | 113 | + std::cerr << "-- fallback --" << '\n'; |
| 114 | j = JSON::parse(R"({ | 114 | j = JSON::parse(R"({ |
| 115 | "five": "not-array" | 115 | "five": "not-array" |
| 116 | })"); | 116 | })"); |
| @@ -120,14 +120,14 @@ test_all() | @@ -120,14 +120,14 @@ test_all() | ||
| 120 | static void | 120 | static void |
| 121 | test_errors() | 121 | test_errors() |
| 122 | { | 122 | { |
| 123 | - std::cout << "-- errors --" << std::endl; | 123 | + std::cout << "-- errors --" << '\n'; |
| 124 | auto h = make_all_handler(); | 124 | auto h = make_all_handler(); |
| 125 | auto t = [h](std::string const& msg, std::function<void()> fn) { | 125 | auto t = [h](std::string const& msg, std::function<void()> fn) { |
| 126 | try { | 126 | try { |
| 127 | fn(); | 127 | fn(); |
| 128 | assert(false); | 128 | assert(false); |
| 129 | } catch (QPDFUsage& e) { | 129 | } catch (QPDFUsage& e) { |
| 130 | - std::cout << msg << ": " << e.what() << std::endl; | 130 | + std::cout << msg << ": " << e.what() << '\n'; |
| 131 | } | 131 | } |
| 132 | }; | 132 | }; |
| 133 | 133 |
libtests/json_parse.cc
| @@ -26,13 +26,13 @@ namespace | @@ -26,13 +26,13 @@ namespace | ||
| 26 | void | 26 | void |
| 27 | Reactor::dictionaryStart() | 27 | Reactor::dictionaryStart() |
| 28 | { | 28 | { |
| 29 | - std::cout << "dictionary start" << std::endl; | 29 | + std::cout << "dictionary start" << '\n'; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | void | 32 | void |
| 33 | Reactor::arrayStart() | 33 | Reactor::arrayStart() |
| 34 | { | 34 | { |
| 35 | - std::cout << "array start" << std::endl; | 35 | + std::cout << "array start" << '\n'; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | void | 38 | void |
| @@ -45,7 +45,7 @@ Reactor::containerEnd(JSON const& value) | @@ -45,7 +45,7 @@ Reactor::containerEnd(JSON const& value) | ||
| 45 | void | 45 | void |
| 46 | Reactor::topLevelScalar() | 46 | Reactor::topLevelScalar() |
| 47 | { | 47 | { |
| 48 | - std::cout << "top-level scalar" << std::endl; | 48 | + std::cout << "top-level scalar" << '\n'; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | bool | 51 | bool |
| @@ -74,13 +74,13 @@ Reactor::arrayItem(JSON const& value) | @@ -74,13 +74,13 @@ Reactor::arrayItem(JSON const& value) | ||
| 74 | void | 74 | void |
| 75 | Reactor::printItem(JSON const& j) | 75 | Reactor::printItem(JSON const& j) |
| 76 | { | 76 | { |
| 77 | - std::cout << "[" << j.getStart() << ", " << j.getEnd() << "): " << j.unparse() << std::endl; | 77 | + std::cout << "[" << j.getStart() << ", " << j.getEnd() << "): " << j.unparse() << '\n'; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static void | 80 | static void |
| 81 | usage() | 81 | usage() |
| 82 | { | 82 | { |
| 83 | - std::cerr << "Usage: json_parse file [--react]" << std::endl; | 83 | + std::cerr << "Usage: json_parse file [--react]" << '\n'; |
| 84 | exit(2); | 84 | exit(2); |
| 85 | } | 85 | } |
| 86 | 86 | ||
| @@ -102,9 +102,9 @@ main(int argc, char* argv[]) | @@ -102,9 +102,9 @@ main(int argc, char* argv[]) | ||
| 102 | } | 102 | } |
| 103 | try { | 103 | try { |
| 104 | FileInputSource is(filename); | 104 | FileInputSource is(filename); |
| 105 | - std::cout << JSON::parse(is, reactor.get()).unparse() << std::endl; | 105 | + std::cout << JSON::parse(is, reactor.get()).unparse() << '\n'; |
| 106 | } catch (std::exception& e) { | 106 | } catch (std::exception& e) { |
| 107 | - std::cerr << "exception: " << filename << ": " << e.what() << std::endl; | 107 | + std::cerr << "exception: " << filename << ": " << e.what() << '\n'; |
| 108 | return 2; | 108 | return 2; |
| 109 | } | 109 | } |
| 110 | return 0; | 110 | return 0; |
libtests/lzw.cc
| @@ -15,7 +15,7 @@ main(int argc, char* argv[]) | @@ -15,7 +15,7 @@ main(int argc, char* argv[]) | ||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | if (argc < 3) { | 17 | if (argc < 3) { |
| 18 | - std::cerr << "Usage: lzw infile outfile [ --no-early-code-change ]" << std::endl; | 18 | + std::cerr << "Usage: lzw infile outfile [ --no-early-code-change ]" << '\n'; |
| 19 | exit(2); | 19 | exit(2); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| @@ -41,7 +41,7 @@ main(int argc, char* argv[]) | @@ -41,7 +41,7 @@ main(int argc, char* argv[]) | ||
| 41 | } | 41 | } |
| 42 | decode.finish(); | 42 | decode.finish(); |
| 43 | } catch (std::exception& e) { | 43 | } catch (std::exception& e) { |
| 44 | - std::cerr << e.what() << std::endl; | 44 | + std::cerr << e.what() << '\n'; |
| 45 | exit(2); | 45 | exit(2); |
| 46 | } | 46 | } |
| 47 | 47 |
libtests/main_from_wmain.cc
| @@ -8,7 +8,7 @@ wmain_test() | @@ -8,7 +8,7 @@ wmain_test() | ||
| 8 | // writable args and function args | 8 | // writable args and function args |
| 9 | auto realmain = [](int argc, char* argv[]) { | 9 | auto realmain = [](int argc, char* argv[]) { |
| 10 | for (int i = 0; i < argc; ++i) { | 10 | for (int i = 0; i < argc; ++i) { |
| 11 | - std::cout << argv[i] << std::endl; | 11 | + std::cout << argv[i] << '\n'; |
| 12 | } | 12 | } |
| 13 | return 0; | 13 | return 0; |
| 14 | }; | 14 | }; |
| @@ -28,7 +28,7 @@ cwmain_test() | @@ -28,7 +28,7 @@ cwmain_test() | ||
| 28 | // const args and function args | 28 | // const args and function args |
| 29 | auto realmain = [](int argc, char const* const argv[]) { | 29 | auto realmain = [](int argc, char const* const argv[]) { |
| 30 | for (int i = 0; i < argc; ++i) { | 30 | for (int i = 0; i < argc; ++i) { |
| 31 | - std::cout << "const " << argv[i] << std::endl; | 31 | + std::cout << "const " << argv[i] << '\n'; |
| 32 | } | 32 | } |
| 33 | return 0; | 33 | return 0; |
| 34 | }; | 34 | }; |
| @@ -49,7 +49,7 @@ main(int argc, char* argv[]) | @@ -49,7 +49,7 @@ main(int argc, char* argv[]) | ||
| 49 | wmain_test(); | 49 | wmain_test(); |
| 50 | cwmain_test(); | 50 | cwmain_test(); |
| 51 | } catch (std::exception& e) { | 51 | } catch (std::exception& e) { |
| 52 | - std::cout << "unexpected exception: " << e.what() << std::endl; | 52 | + std::cout << "unexpected exception: " << e.what() << '\n'; |
| 53 | } | 53 | } |
| 54 | #endif // QPDF_NO_WCHAR_T | 54 | #endif // QPDF_NO_WCHAR_T |
| 55 | 55 |
libtests/matrix.cc
| @@ -9,7 +9,7 @@ check(QPDFMatrix const& m, std::string const& exp) | @@ -9,7 +9,7 @@ check(QPDFMatrix const& m, std::string const& exp) | ||
| 9 | { | 9 | { |
| 10 | std::string u = m.unparse(); | 10 | std::string u = m.unparse(); |
| 11 | if (u != exp) { | 11 | if (u != exp) { |
| 12 | - std::cout << "got " << u << ", wanted " << exp << std::endl; | 12 | + std::cout << "got " << u << ", wanted " << exp << '\n'; |
| 13 | } | 13 | } |
| 14 | } | 14 | } |
| 15 | 15 | ||
| @@ -18,7 +18,7 @@ check_xy(double x, double y, std::string const& exp) | @@ -18,7 +18,7 @@ check_xy(double x, double y, std::string const& exp) | ||
| 18 | { | 18 | { |
| 19 | std::string u = (QUtil::double_to_string(x, 2) + " " + QUtil::double_to_string(y, 2)); | 19 | std::string u = (QUtil::double_to_string(x, 2) + " " + QUtil::double_to_string(y, 2)); |
| 20 | if (u != exp) { | 20 | if (u != exp) { |
| 21 | - std::cout << "got " << u << ", wanted " << exp << std::endl; | 21 | + std::cout << "got " << u << ", wanted " << exp << '\n'; |
| 22 | } | 22 | } |
| 23 | } | 23 | } |
| 24 | 24 | ||
| @@ -32,7 +32,7 @@ check_rect(QPDFObjectHandle::Rectangle const& r, double llx, double lly, double | @@ -32,7 +32,7 @@ check_rect(QPDFObjectHandle::Rectangle const& r, double llx, double lly, double | ||
| 32 | (QUtil::double_to_string(llx, 2) + " " + QUtil::double_to_string(lly, 2) + " " + | 32 | (QUtil::double_to_string(llx, 2) + " " + QUtil::double_to_string(lly, 2) + " " + |
| 33 | QUtil::double_to_string(urx, 2) + " " + QUtil::double_to_string(ury, 2)); | 33 | QUtil::double_to_string(urx, 2) + " " + QUtil::double_to_string(ury, 2)); |
| 34 | if (actual != wanted) { | 34 | if (actual != wanted) { |
| 35 | - std::cout << "got " << actual << ", wanted " << wanted << std::endl; | 35 | + std::cout << "got " << actual << ", wanted " << wanted << '\n'; |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| @@ -78,6 +78,6 @@ main() | @@ -78,6 +78,6 @@ main() | ||
| 78 | m.translate(200, -100); | 78 | m.translate(200, -100); |
| 79 | check_rect(m.transformRectangle(QPDFObjectHandle::Rectangle(10, 20, 30, 50)), 50, 210, 80, 230); | 79 | check_rect(m.transformRectangle(QPDFObjectHandle::Rectangle(10, 20, 30, 50)), 50, 210, 80, 230); |
| 80 | 80 | ||
| 81 | - std::cout << "matrix tests done" << std::endl; | 81 | + std::cout << "matrix tests done" << '\n'; |
| 82 | return 0; | 82 | return 0; |
| 83 | } | 83 | } |
libtests/md5.cc
| @@ -29,16 +29,16 @@ main(int, char*[]) | @@ -29,16 +29,16 @@ main(int, char*[]) | ||
| 29 | "1234567890123456789012345678901234567890"); | 29 | "1234567890123456789012345678901234567890"); |
| 30 | MD5 a; | 30 | MD5 a; |
| 31 | a.encodeFile("md5.in"); | 31 | a.encodeFile("md5.in"); |
| 32 | - std::cout << a.unparse() << std::endl; | 32 | + std::cout << a.unparse() << '\n'; |
| 33 | MD5 b; | 33 | MD5 b; |
| 34 | b.encodeFile("md5.in", 100); | 34 | b.encodeFile("md5.in", 100); |
| 35 | - std::cout << b.unparse() << std::endl; | 35 | + std::cout << b.unparse() << '\n'; |
| 36 | 36 | ||
| 37 | - std::cout << MD5::checkDataChecksum("900150983cd24fb0d6963f7d28e17f72", "abc", 3) << std::endl | ||
| 38 | - << MD5::checkFileChecksum("5f4b4321873433daae578f85c72f9e74", "md5.in") << std::endl | ||
| 39 | - << MD5::checkFileChecksum("6f4b4321873433daae578f85c72f9e74", "md5.in") << std::endl | ||
| 40 | - << MD5::checkDataChecksum("000150983cd24fb0d6963f7d28e17f72", "abc", 3) << std::endl | ||
| 41 | - << MD5::checkFileChecksum("6f4b4321873433daae578f85c72f9e74", "glerbl") << std::endl; | 37 | + std::cout << MD5::checkDataChecksum("900150983cd24fb0d6963f7d28e17f72", "abc", 3) << '\n' |
| 38 | + << MD5::checkFileChecksum("5f4b4321873433daae578f85c72f9e74", "md5.in") << '\n' | ||
| 39 | + << MD5::checkFileChecksum("6f4b4321873433daae578f85c72f9e74", "md5.in") << '\n' | ||
| 40 | + << MD5::checkDataChecksum("000150983cd24fb0d6963f7d28e17f72", "abc", 3) << '\n' | ||
| 41 | + << MD5::checkFileChecksum("6f4b4321873433daae578f85c72f9e74", "glerbl") << '\n'; | ||
| 42 | 42 | ||
| 43 | Pl_Discard d; | 43 | Pl_Discard d; |
| 44 | Pl_MD5 p("MD5", &d); | 44 | Pl_MD5 p("MD5", &d); |
| @@ -63,7 +63,7 @@ main(int, char*[]) | @@ -63,7 +63,7 @@ main(int, char*[]) | ||
| 63 | p2.write(buf, len); | 63 | p2.write(buf, len); |
| 64 | if (i == 1) { | 64 | if (i == 1) { |
| 65 | // Partial digest -- resets after each call to write | 65 | // Partial digest -- resets after each call to write |
| 66 | - std::cout << p.getHexDigest() << std::endl; | 66 | + std::cout << p.getHexDigest() << '\n'; |
| 67 | } | 67 | } |
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| @@ -72,10 +72,10 @@ main(int, char*[]) | @@ -72,10 +72,10 @@ main(int, char*[]) | ||
| 72 | p2.finish(); | 72 | p2.finish(); |
| 73 | // Make sure calling getHexDigest twice with no intervening | 73 | // Make sure calling getHexDigest twice with no intervening |
| 74 | // writes results in the same result each time. | 74 | // writes results in the same result each time. |
| 75 | - std::cout << p.getHexDigest() << std::endl; | ||
| 76 | - std::cout << p.getHexDigest() << std::endl; | 75 | + std::cout << p.getHexDigest() << '\n'; |
| 76 | + std::cout << p.getHexDigest() << '\n'; | ||
| 77 | } | 77 | } |
| 78 | - std::cout << p2.getHexDigest() << std::endl; | 78 | + std::cout << p2.getHexDigest() << '\n'; |
| 79 | 79 | ||
| 80 | return 0; | 80 | return 0; |
| 81 | } | 81 | } |
libtests/nntree.cc
| @@ -20,7 +20,7 @@ report(QPDF& q, QPDFObjectHandle oh, long long item, long long exp_item) | @@ -20,7 +20,7 @@ report(QPDF& q, QPDFObjectHandle oh, long long item, long long exp_item) | ||
| 20 | auto show = [&failed, &oh, &item]() { | 20 | auto show = [&failed, &oh, &item]() { |
| 21 | if (!failed) { | 21 | if (!failed) { |
| 22 | failed = true; | 22 | failed = true; |
| 23 | - std::cout << "key = " << item << ", oh = " << oh.unparseResolved() << std::endl; | 23 | + std::cout << "key = " << item << ", oh = " << oh.unparseResolved() << '\n'; |
| 24 | } | 24 | } |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| @@ -37,11 +37,11 @@ report(QPDF& q, QPDFObjectHandle oh, long long item, long long exp_item) | @@ -37,11 +37,11 @@ report(QPDF& q, QPDFObjectHandle oh, long long item, long long exp_item) | ||
| 37 | 37 | ||
| 38 | if (i1_wanted != i1_actual) { | 38 | if (i1_wanted != i1_actual) { |
| 39 | show(); | 39 | show(); |
| 40 | - std::cout << "i1: wanted " << i1_wanted << ", got " << i1_actual << std::endl; | 40 | + std::cout << "i1: wanted " << i1_wanted << ", got " << i1_actual << '\n'; |
| 41 | } | 41 | } |
| 42 | if (i2_wanted != i2_actual) { | 42 | if (i2_wanted != i2_actual) { |
| 43 | show(); | 43 | show(); |
| 44 | - std::cout << "i2: wanted " << i2_wanted << ", got " << i2_actual << std::endl; | 44 | + std::cout << "i2: wanted " << i2_wanted << ", got " << i2_actual << '\n'; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | return failed; | 47 | return failed; |
| @@ -106,7 +106,7 @@ test_bsearch() | @@ -106,7 +106,7 @@ test_bsearch() | ||
| 106 | r(d, 25, 20); | 106 | r(d, 25, 20); |
| 107 | 107 | ||
| 108 | if (!any_failures) { | 108 | if (!any_failures) { |
| 109 | - std::cout << "bsearch tests passed" << std::endl; | 109 | + std::cout << "bsearch tests passed" << '\n'; |
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | 112 | ||
| @@ -128,7 +128,7 @@ check_find(QPDFNameTreeObjectHelper& nh, std::string const& key, bool prev_if_no | @@ -128,7 +128,7 @@ check_find(QPDFNameTreeObjectHelper& nh, std::string const& key, bool prev_if_no | ||
| 128 | } else { | 128 | } else { |
| 129 | std::cout << (*i).first << " -> " << (*i).second.unparse(); | 129 | std::cout << (*i).first << " -> " << (*i).second.unparse(); |
| 130 | } | 130 | } |
| 131 | - std::cout << std::endl; | 131 | + std::cout << '\n'; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | void | 134 | void |
| @@ -183,13 +183,13 @@ test_depth() | @@ -183,13 +183,13 @@ test_depth() | ||
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | QPDFNameTreeObjectHelper nh(n0, q); | 185 | QPDFNameTreeObjectHelper nh(n0, q); |
| 186 | - std::cout << "--- forward ---" << std::endl; | 186 | + std::cout << "--- forward ---" << '\n'; |
| 187 | for (auto i: nh) { | 187 | for (auto i: nh) { |
| 188 | - std::cout << i.first << " -> " << i.second.unparse() << std::endl; | 188 | + std::cout << i.first << " -> " << i.second.unparse() << '\n'; |
| 189 | } | 189 | } |
| 190 | - std::cout << "--- backward ---" << std::endl; | 190 | + std::cout << "--- backward ---" << '\n'; |
| 191 | for (auto i = nh.last(); i.valid(); --i) { | 191 | for (auto i = nh.last(); i.valid(); --i) { |
| 192 | - std::cout << (*i).first << " -> " << (*i).second.unparse() << std::endl; | 192 | + std::cout << (*i).first << " -> " << (*i).second.unparse() << '\n'; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | // Find | 195 | // Find |
libtests/numrange.cc
| @@ -5,14 +5,14 @@ static void | @@ -5,14 +5,14 @@ static void | ||
| 5 | test_numrange(char const* range) | 5 | test_numrange(char const* range) |
| 6 | { | 6 | { |
| 7 | if (range == nullptr) { | 7 | if (range == nullptr) { |
| 8 | - std::cout << "null" << std::endl; | 8 | + std::cout << "null" << '\n'; |
| 9 | } else { | 9 | } else { |
| 10 | std::vector<int> result = QUtil::parse_numrange(range, 15); | 10 | std::vector<int> result = QUtil::parse_numrange(range, 15); |
| 11 | std::cout << "numeric range " << range << " ->"; | 11 | std::cout << "numeric range " << range << " ->"; |
| 12 | for (int i: result) { | 12 | for (int i: result) { |
| 13 | std::cout << " " << i; | 13 | std::cout << " " << i; |
| 14 | } | 14 | } |
| 15 | - std::cout << std::endl; | 15 | + std::cout << '\n'; |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | 18 | ||
| @@ -22,7 +22,7 @@ main(int argc, char* argv[]) | @@ -22,7 +22,7 @@ main(int argc, char* argv[]) | ||
| 22 | try { | 22 | try { |
| 23 | test_numrange(argv[1]); | 23 | test_numrange(argv[1]); |
| 24 | } catch (std::exception& e) { | 24 | } catch (std::exception& e) { |
| 25 | - std::cout << e.what() << std::endl; | 25 | + std::cout << e.what() << '\n'; |
| 26 | return 2; | 26 | return 2; |
| 27 | } | 27 | } |
| 28 | 28 |
libtests/pdf_version.cc
| @@ -48,6 +48,6 @@ main() | @@ -48,6 +48,6 @@ main() | ||
| 48 | assert(PDFVersion(2, 0) == PDFVersion(2, 0)); | 48 | assert(PDFVersion(2, 0) == PDFVersion(2, 0)); |
| 49 | assert(PDFVersion(2, 0, 1) == PDFVersion(2, 0, 1)); | 49 | assert(PDFVersion(2, 0, 1) == PDFVersion(2, 0, 1)); |
| 50 | 50 | ||
| 51 | - std::cout << "PDFVersion assertions passed" << std::endl; | 51 | + std::cout << "PDFVersion assertions passed" << '\n'; |
| 52 | return 0; | 52 | return 0; |
| 53 | } | 53 | } |
libtests/pl_function.cc
| @@ -18,7 +18,7 @@ f(unsigned char const* data, size_t len, void* udata) | @@ -18,7 +18,7 @@ f(unsigned char const* data, size_t len, void* udata) | ||
| 18 | { | 18 | { |
| 19 | auto c = reinterpret_cast<Count*>(udata); | 19 | auto c = reinterpret_cast<Count*>(udata); |
| 20 | ++c->count; | 20 | ++c->count; |
| 21 | - std::cout << "got " << data << "(" << len << ")" << std::endl; | 21 | + std::cout << "got " << data << "(" << len << ")" << '\n'; |
| 22 | if (c->count == 3) { | 22 | if (c->count == 3) { |
| 23 | return 1; | 23 | return 1; |
| 24 | } | 24 | } |
| @@ -30,7 +30,7 @@ g(char const* data, size_t len, void* udata) | @@ -30,7 +30,7 @@ g(char const* data, size_t len, void* udata) | ||
| 30 | { | 30 | { |
| 31 | auto c = reinterpret_cast<Count*>(udata); | 31 | auto c = reinterpret_cast<Count*>(udata); |
| 32 | ++c->count; | 32 | ++c->count; |
| 33 | - std::cout << "signed got " << data << "(" << len << ")" << std::endl; | 33 | + std::cout << "signed got " << data << "(" << len << ")" << '\n'; |
| 34 | if (c->count == 2) { | 34 | if (c->count == 2) { |
| 35 | return 2; | 35 | return 2; |
| 36 | } | 36 | } |
| @@ -41,7 +41,7 @@ int | @@ -41,7 +41,7 @@ int | ||
| 41 | main(int argc, char* argv[]) | 41 | main(int argc, char* argv[]) |
| 42 | { | 42 | { |
| 43 | Pl_Function p1("p1", nullptr, [](unsigned char const* data, size_t len) { | 43 | Pl_Function p1("p1", nullptr, [](unsigned char const* data, size_t len) { |
| 44 | - std::cout << "p1: " << len << ": " << data << std::endl; | 44 | + std::cout << "p1: " << len << ": " << data << '\n'; |
| 45 | }); | 45 | }); |
| 46 | p1.write(reinterpret_cast<unsigned char const*>("potato"), 6); | 46 | p1.write(reinterpret_cast<unsigned char const*>("potato"), 6); |
| 47 | 47 | ||
| @@ -49,7 +49,7 @@ main(int argc, char* argv[]) | @@ -49,7 +49,7 @@ main(int argc, char* argv[]) | ||
| 49 | Pl_String ps("string", nullptr, s); | 49 | Pl_String ps("string", nullptr, s); |
| 50 | Pl_Base64 b("base64", &ps, Pl_Base64::a_encode); | 50 | Pl_Base64 b("base64", &ps, Pl_Base64::a_encode); |
| 51 | Pl_Function p2("p2", &b, [](unsigned char const* data, size_t len) { | 51 | Pl_Function p2("p2", &b, [](unsigned char const* data, size_t len) { |
| 52 | - std::cout << "p2: " << len << ": " << data << std::endl; | 52 | + std::cout << "p2: " << len << ": " << data << '\n'; |
| 53 | }); | 53 | }); |
| 54 | p2.write(reinterpret_cast<unsigned char const*>("salad"), 5); | 54 | p2.write(reinterpret_cast<unsigned char const*>("salad"), 5); |
| 55 | p2.finish(); | 55 | p2.finish(); |
| @@ -63,7 +63,7 @@ main(int argc, char* argv[]) | @@ -63,7 +63,7 @@ main(int argc, char* argv[]) | ||
| 63 | p3 << "three"; | 63 | p3 << "three"; |
| 64 | assert(false); | 64 | assert(false); |
| 65 | } catch (std::runtime_error& e) { | 65 | } catch (std::runtime_error& e) { |
| 66 | - std::cout << "three threw " << e.what() << std::endl; | 66 | + std::cout << "three threw " << e.what() << '\n'; |
| 67 | } | 67 | } |
| 68 | p3 << "four"; | 68 | p3 << "four"; |
| 69 | p3.finish(); | 69 | p3.finish(); |
| @@ -76,7 +76,7 @@ main(int argc, char* argv[]) | @@ -76,7 +76,7 @@ main(int argc, char* argv[]) | ||
| 76 | p4 << "salad"; | 76 | p4 << "salad"; |
| 77 | assert(false); | 77 | assert(false); |
| 78 | } catch (std::runtime_error& e) { | 78 | } catch (std::runtime_error& e) { |
| 79 | - std::cout << "salad threw " << e.what() << std::endl; | 79 | + std::cout << "salad threw " << e.what() << '\n'; |
| 80 | } | 80 | } |
| 81 | p4 << "quack"; | 81 | p4 << "quack"; |
| 82 | p4.finish(); | 82 | p4.finish(); |
libtests/pointer_holder.cc
| @@ -26,24 +26,24 @@ int Object::next_id = 0; | @@ -26,24 +26,24 @@ int Object::next_id = 0; | ||
| 26 | Object::Object() | 26 | Object::Object() |
| 27 | { | 27 | { |
| 28 | this->id = ++next_id; | 28 | this->id = ++next_id; |
| 29 | - std::cout << "created Object, id " << this->id << std::endl; | 29 | + std::cout << "created Object, id " << this->id << '\n'; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | Object::~Object() | 32 | Object::~Object() |
| 33 | { | 33 | { |
| 34 | - std::cout << "destroyed Object, id " << this->id << std::endl; | 34 | + std::cout << "destroyed Object, id " << this->id << '\n'; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void | 37 | void |
| 38 | Object::hello() | 38 | Object::hello() |
| 39 | { | 39 | { |
| 40 | - std::cout << "calling Object::hello for " << this->id << std::endl; | 40 | + std::cout << "calling Object::hello for " << this->id << '\n'; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | void | 43 | void |
| 44 | Object::hello() const | 44 | Object::hello() const |
| 45 | { | 45 | { |
| 46 | - std::cout << "calling Object::hello const for " << this->id << std::endl; | 46 | + std::cout << "calling Object::hello const for " << this->id << '\n'; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | typedef PointerHolder<Object> ObjectHolder; | 49 | typedef PointerHolder<Object> ObjectHolder; |
| @@ -71,27 +71,27 @@ test_ph() | @@ -71,27 +71,27 @@ test_ph() | ||
| 71 | 71 | ||
| 72 | ObjectHolder oh0; | 72 | ObjectHolder oh0; |
| 73 | { | 73 | { |
| 74 | - std::cout << "hello" << std::endl; | 74 | + std::cout << "hello" << '\n'; |
| 75 | auto* o1 = new Object; | 75 | auto* o1 = new Object; |
| 76 | ObjectHolder oh1(o1); | 76 | ObjectHolder oh1(o1); |
| 77 | - std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl; | 77 | + std::cout << "oh1 refcount = " << oh1.getRefcount() << '\n'; |
| 78 | ObjectHolder oh2(oh1); | 78 | ObjectHolder oh2(oh1); |
| 79 | - std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl; | ||
| 80 | - std::cout << "oh2 refcount = " << oh2.use_count() << std::endl; | 79 | + std::cout << "oh1 refcount = " << oh1.getRefcount() << '\n'; |
| 80 | + std::cout << "oh2 refcount = " << oh2.use_count() << '\n'; | ||
| 81 | ObjectHolder oh3(new Object); | 81 | ObjectHolder oh3(new Object); |
| 82 | ObjectHolder oh4; | 82 | ObjectHolder oh4; |
| 83 | ObjectHolder oh5; | 83 | ObjectHolder oh5; |
| 84 | - std::cout << "oh5 refcount = " << oh5.getRefcount() << std::endl; | 84 | + std::cout << "oh5 refcount = " << oh5.getRefcount() << '\n'; |
| 85 | if (oh4 == oh5) { | 85 | if (oh4 == oh5) { |
| 86 | - std::cout << "nulls equal" << std::endl; | 86 | + std::cout << "nulls equal" << '\n'; |
| 87 | } | 87 | } |
| 88 | oh3 = oh1; | 88 | oh3 = oh1; |
| 89 | oh4 = oh2; | 89 | oh4 = oh2; |
| 90 | if (oh3 == oh4) { | 90 | if (oh3 == oh4) { |
| 91 | - std::cout << "equal okay" << std::endl; | 91 | + std::cout << "equal okay" << '\n'; |
| 92 | } | 92 | } |
| 93 | if ((!(oh3 < oh4)) && (!(oh4 < oh3))) { | 93 | if ((!(oh3 < oh4)) && (!(oh4 < oh3))) { |
| 94 | - std::cout << "less than okay" << std::endl; | 94 | + std::cout << "less than okay" << '\n'; |
| 95 | } | 95 | } |
| 96 | ol1.push_back(oh3); | 96 | ol1.push_back(oh3); |
| 97 | ol1.push_back(oh3); | 97 | ol1.push_back(oh3); |
| @@ -107,9 +107,9 @@ test_ph() | @@ -107,9 +107,9 @@ test_ph() | ||
| 107 | callHello(ol1.front()); | 107 | callHello(ol1.front()); |
| 108 | callHelloWithGet(ol1.front()); | 108 | callHelloWithGet(ol1.front()); |
| 109 | ol1.pop_front(); | 109 | ol1.pop_front(); |
| 110 | - std::cout << "array" << std::endl; | 110 | + std::cout << "array" << '\n'; |
| 111 | PointerHolder<Object> o_arr1_ph(true, new Object[2]); | 111 | PointerHolder<Object> o_arr1_ph(true, new Object[2]); |
| 112 | - std::cout << "goodbye" << std::endl; | 112 | + std::cout << "goodbye" << '\n'; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | PointerHolder<Object> | 115 | PointerHolder<Object> |
| @@ -165,7 +165,7 @@ ph_sp_compat() | @@ -165,7 +165,7 @@ ph_sp_compat() | ||
| 165 | { | 165 | { |
| 166 | // Ensure bidirectional compatibility between PointerHolder and | 166 | // Ensure bidirectional compatibility between PointerHolder and |
| 167 | // shared_ptr. | 167 | // shared_ptr. |
| 168 | - std::cout << "compat" << std::endl; | 168 | + std::cout << "compat" << '\n'; |
| 169 | PointerHolder<Object> ph_from_ph = make_object_ph(); | 169 | PointerHolder<Object> ph_from_ph = make_object_ph(); |
| 170 | std::shared_ptr<Object> sp_from_ph = make_object_ph(); | 170 | std::shared_ptr<Object> sp_from_ph = make_object_ph(); |
| 171 | PointerHolder<Object> ph_from_sp = make_object_sp(); | 171 | PointerHolder<Object> ph_from_sp = make_object_sp(); |
| @@ -184,21 +184,21 @@ ph_sp_compat() | @@ -184,21 +184,21 @@ ph_sp_compat() | ||
| 184 | hello_ph_const(sp_const_from_sp); | 184 | hello_ph_const(sp_const_from_sp); |
| 185 | PointerHolder<Object> arr1_ph; | 185 | PointerHolder<Object> arr1_ph; |
| 186 | { | 186 | { |
| 187 | - std::cout << "initialize ph array from shared_ptr" << std::endl; | 187 | + std::cout << "initialize ph array from shared_ptr" << '\n'; |
| 188 | std::shared_ptr<Object> arr1(new Object[2], std::default_delete<Object[]>()); | 188 | std::shared_ptr<Object> arr1(new Object[2], std::default_delete<Object[]>()); |
| 189 | arr1_ph = arr1; | 189 | arr1_ph = arr1; |
| 190 | } | 190 | } |
| 191 | - std::cout << "delete ph array" << std::endl; | 191 | + std::cout << "delete ph array" << '\n'; |
| 192 | arr1_ph = nullptr; | 192 | arr1_ph = nullptr; |
| 193 | std::shared_ptr<Object> arr2_sp; | 193 | std::shared_ptr<Object> arr2_sp; |
| 194 | { | 194 | { |
| 195 | - std::cout << "initialize sp array from PointerHolder" << std::endl; | 195 | + std::cout << "initialize sp array from PointerHolder" << '\n'; |
| 196 | PointerHolder<Object> arr2(true, new Object[2]); | 196 | PointerHolder<Object> arr2(true, new Object[2]); |
| 197 | arr2_sp = arr2; | 197 | arr2_sp = arr2; |
| 198 | } | 198 | } |
| 199 | - std::cout << "delete sp array" << std::endl; | 199 | + std::cout << "delete sp array" << '\n'; |
| 200 | arr2_sp = nullptr; | 200 | arr2_sp = nullptr; |
| 201 | - std::cout << "end compat" << std::endl; | 201 | + std::cout << "end compat" << '\n'; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | std::list<PointerHolder<Object>> | 204 | std::list<PointerHolder<Object>> |
| @@ -224,13 +224,13 @@ get_sp_list() | @@ -224,13 +224,13 @@ get_sp_list() | ||
| 224 | void | 224 | void |
| 225 | ph_sp_containers() | 225 | ph_sp_containers() |
| 226 | { | 226 | { |
| 227 | - std::cout << "containers" << std::endl; | 227 | + std::cout << "containers" << '\n'; |
| 228 | // Demonstrate that using auto makes it easy to switch interfaces | 228 | // Demonstrate that using auto makes it easy to switch interfaces |
| 229 | // from using a container of one shared pointer type to a | 229 | // from using a container of one shared pointer type to a |
| 230 | // container of the other. | 230 | // container of the other. |
| 231 | auto phl1 = get_ph_list(); | 231 | auto phl1 = get_ph_list(); |
| 232 | auto phl2 = get_sp_list(); | 232 | auto phl2 = get_sp_list(); |
| 233 | - std::cout << "end containers" << std::endl; | 233 | + std::cout << "end containers" << '\n'; |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | int | 236 | int |
libtests/predictors.cc
| @@ -39,7 +39,7 @@ run(char const* filename, | @@ -39,7 +39,7 @@ run(char const* filename, | ||
| 39 | samples_per_pixel, | 39 | samples_per_pixel, |
| 40 | bits_per_sample); | 40 | bits_per_sample); |
| 41 | } else { | 41 | } else { |
| 42 | - std::cerr << "unknown filter " << filter << std::endl; | 42 | + std::cerr << "unknown filter " << filter << '\n'; |
| 43 | exit(2); | 43 | exit(2); |
| 44 | } | 44 | } |
| 45 | assert((2 * (columns + 1)) < 1024); | 45 | assert((2 * (columns + 1)) < 1024); |
| @@ -69,7 +69,7 @@ run(char const* filename, | @@ -69,7 +69,7 @@ run(char const* filename, | ||
| 69 | fclose(o1); | 69 | fclose(o1); |
| 70 | fclose(in); | 70 | fclose(in); |
| 71 | 71 | ||
| 72 | - std::cout << "done" << std::endl; | 72 | + std::cout << "done" << '\n'; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | int | 75 | int |
| @@ -77,7 +77,7 @@ main(int argc, char* argv[]) | @@ -77,7 +77,7 @@ main(int argc, char* argv[]) | ||
| 77 | { | 77 | { |
| 78 | if (argc != 7) { | 78 | if (argc != 7) { |
| 79 | std::cerr << "Usage: predictor {png|tiff} {en,de}code filename" | 79 | std::cerr << "Usage: predictor {png|tiff} {en,de}code filename" |
| 80 | - << " columns samples-per-pixel bits-per-sample" << std::endl; | 80 | + << " columns samples-per-pixel bits-per-sample" << '\n'; |
| 81 | exit(2); | 81 | exit(2); |
| 82 | } | 82 | } |
| 83 | char* filter = argv[1]; | 83 | char* filter = argv[1]; |
| @@ -95,7 +95,7 @@ main(int argc, char* argv[]) | @@ -95,7 +95,7 @@ main(int argc, char* argv[]) | ||
| 95 | QIntC::to_uint(bits_per_sample), | 95 | QIntC::to_uint(bits_per_sample), |
| 96 | QIntC::to_uint(samples_per_pixel)); | 96 | QIntC::to_uint(samples_per_pixel)); |
| 97 | } catch (std::exception& e) { | 97 | } catch (std::exception& e) { |
| 98 | - std::cout << e.what() << std::endl; | 98 | + std::cout << e.what() << '\n'; |
| 99 | } | 99 | } |
| 100 | return 0; | 100 | return 0; |
| 101 | } | 101 | } |
libtests/qintc.cc
| @@ -18,7 +18,7 @@ try_convert_real(char const* description, bool exp_pass, To (*fn)(From const&), | @@ -18,7 +18,7 @@ try_convert_real(char const* description, bool exp_pass, To (*fn)(From const&), | ||
| 18 | std::cout << description << ": " << e.what(); | 18 | std::cout << description << ": " << e.what(); |
| 19 | passed = false; | 19 | passed = false; |
| 20 | } | 20 | } |
| 21 | - std::cout << ((passed == exp_pass) ? " PASSED" : " FAILED") << std::endl; | 21 | + std::cout << ((passed == exp_pass) ? " PASSED" : " FAILED") << '\n'; |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | #define try_range_check(exp_pass, a, b) try_range_check_real(#a " + " #b, exp_pass, a, b) | 24 | #define try_range_check(exp_pass, a, b) try_range_check_real(#a " + " #b, exp_pass, a, b) |
| @@ -36,7 +36,7 @@ try_range_check_real(char const* description, bool exp_pass, T const& a, T const | @@ -36,7 +36,7 @@ try_range_check_real(char const* description, bool exp_pass, T const& a, T const | ||
| 36 | std::cout << description << ": " << e.what(); | 36 | std::cout << description << ": " << e.what(); |
| 37 | passed = false; | 37 | passed = false; |
| 38 | } | 38 | } |
| 39 | - std::cout << ((passed == exp_pass) ? " PASSED" : " FAILED") << std::endl; | 39 | + std::cout << ((passed == exp_pass) ? " PASSED" : " FAILED") << '\n'; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | #define try_range_check_subtract(exp_pass, a, b) \ | 42 | #define try_range_check_subtract(exp_pass, a, b) \ |
| @@ -55,7 +55,7 @@ try_range_check_subtract_real(char const* description, bool exp_pass, T const& a | @@ -55,7 +55,7 @@ try_range_check_subtract_real(char const* description, bool exp_pass, T const& a | ||
| 55 | std::cout << description << ": " << e.what(); | 55 | std::cout << description << ": " << e.what(); |
| 56 | passed = false; | 56 | passed = false; |
| 57 | } | 57 | } |
| 58 | - std::cout << ((passed == exp_pass) ? " PASSED" : " FAILED") << std::endl; | 58 | + std::cout << ((passed == exp_pass) ? " PASSED" : " FAILED") << '\n'; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | int | 61 | int |
libtests/qutil.cc
| @@ -32,13 +32,13 @@ test_to_number(char const* str, int_T wanted, bool error, int_T (*fn)(char const | @@ -32,13 +32,13 @@ test_to_number(char const* str, int_T wanted, bool error, int_T (*fn)(char const | ||
| 32 | } | 32 | } |
| 33 | if (threw) { | 33 | if (threw) { |
| 34 | if (error) { | 34 | if (error) { |
| 35 | - std::cout << str << " to int threw (" << msg << "): PASSED" << std::endl; | 35 | + std::cout << str << " to int threw (" << msg << "): PASSED" << '\n'; |
| 36 | } else { | 36 | } else { |
| 37 | std::cout << str << " to int threw but wanted " << wanted << std::endl; | 37 | std::cout << str << " to int threw but wanted " << wanted << std::endl; |
| 38 | } | 38 | } |
| 39 | } else { | 39 | } else { |
| 40 | if (worked) { | 40 | if (worked) { |
| 41 | - std::cout << str << " to int: PASSED" << std::endl; | 41 | + std::cout << str << " to int: PASSED" << '\n'; |
| 42 | } else { | 42 | } else { |
| 43 | std::cout << str << " to int failed; got " << result << std::endl; | 43 | std::cout << str << " to int failed; got " << result << std::endl; |
| 44 | } | 44 | } |
| @@ -97,51 +97,51 @@ string_conversion_test() | @@ -97,51 +97,51 @@ string_conversion_test() | ||
| 97 | // Make sure the code produces consistent results even if we load | 97 | // Make sure the code produces consistent results even if we load |
| 98 | // a non-C locale. | 98 | // a non-C locale. |
| 99 | set_locale(); | 99 | set_locale(); |
| 100 | - std::cout << QUtil::int_to_string(16059) << std::endl | ||
| 101 | - << QUtil::int_to_string(16059, 7) << std::endl | ||
| 102 | - << QUtil::int_to_string(16059, -7) << std::endl | ||
| 103 | - << QUtil::double_to_string(3.14159, 0, false) << std::endl | ||
| 104 | - << QUtil::double_to_string(3.14159, 3) << std::endl | ||
| 105 | - << QUtil::double_to_string(1000.123, -1024, false) << std::endl | ||
| 106 | - << QUtil::double_to_string(.1234, 5, false) << std::endl | ||
| 107 | - << QUtil::double_to_string(.0001234, 5) << std::endl | ||
| 108 | - << QUtil::double_to_string(.123456, 5) << std::endl | ||
| 109 | - << QUtil::double_to_string(.000123456, 5) << std::endl | ||
| 110 | - << QUtil::double_to_string(1.01020, 5, true) << std::endl | ||
| 111 | - << QUtil::double_to_string(1.00000, 5, true) << std::endl | ||
| 112 | - << QUtil::double_to_string(1, 5, true) << std::endl | ||
| 113 | - << QUtil::double_to_string(1, 5, false) << std::endl | ||
| 114 | - << QUtil::double_to_string(10, 2, false) << std::endl | ||
| 115 | - << QUtil::double_to_string(10, 2, true) << std::endl | ||
| 116 | - << QUtil::int_to_string_base(16059, 10) << std::endl | ||
| 117 | - << QUtil::int_to_string_base(16059, 8) << std::endl | ||
| 118 | - << QUtil::int_to_string_base(16059, 16) << std::endl | ||
| 119 | - << QUtil::int_to_string_base(5000093552LL, 10) << std::endl; | 100 | + std::cout << QUtil::int_to_string(16059) << '\n' |
| 101 | + << QUtil::int_to_string(16059, 7) << '\n' | ||
| 102 | + << QUtil::int_to_string(16059, -7) << '\n' | ||
| 103 | + << QUtil::double_to_string(3.14159, 0, false) << '\n' | ||
| 104 | + << QUtil::double_to_string(3.14159, 3) << '\n' | ||
| 105 | + << QUtil::double_to_string(1000.123, -1024, false) << '\n' | ||
| 106 | + << QUtil::double_to_string(.1234, 5, false) << '\n' | ||
| 107 | + << QUtil::double_to_string(.0001234, 5) << '\n' | ||
| 108 | + << QUtil::double_to_string(.123456, 5) << '\n' | ||
| 109 | + << QUtil::double_to_string(.000123456, 5) << '\n' | ||
| 110 | + << QUtil::double_to_string(1.01020, 5, true) << '\n' | ||
| 111 | + << QUtil::double_to_string(1.00000, 5, true) << '\n' | ||
| 112 | + << QUtil::double_to_string(1, 5, true) << '\n' | ||
| 113 | + << QUtil::double_to_string(1, 5, false) << '\n' | ||
| 114 | + << QUtil::double_to_string(10, 2, false) << '\n' | ||
| 115 | + << QUtil::double_to_string(10, 2, true) << '\n' | ||
| 116 | + << QUtil::int_to_string_base(16059, 10) << '\n' | ||
| 117 | + << QUtil::int_to_string_base(16059, 8) << '\n' | ||
| 118 | + << QUtil::int_to_string_base(16059, 16) << '\n' | ||
| 119 | + << QUtil::int_to_string_base(5000093552LL, 10) << '\n'; | ||
| 120 | 120 | ||
| 121 | std::string embedded_null = "one"; | 121 | std::string embedded_null = "one"; |
| 122 | embedded_null += '\0'; | 122 | embedded_null += '\0'; |
| 123 | embedded_null += "two"; | 123 | embedded_null += "two"; |
| 124 | - std::cout << embedded_null.c_str() << std::endl; | ||
| 125 | - std::cout << embedded_null.length() << std::endl; | 124 | + std::cout << embedded_null.c_str() << '\n'; |
| 125 | + std::cout << embedded_null.length() << '\n'; | ||
| 126 | char* tmp = QUtil::copy_string(embedded_null); | 126 | char* tmp = QUtil::copy_string(embedded_null); |
| 127 | if (memcmp(tmp, embedded_null.c_str(), 7) == 0) { | 127 | if (memcmp(tmp, embedded_null.c_str(), 7) == 0) { |
| 128 | - std::cout << "compare okay" << std::endl; | 128 | + std::cout << "compare okay" << '\n'; |
| 129 | } else { | 129 | } else { |
| 130 | - std::cout << "compare failed" << std::endl; | 130 | + std::cout << "compare failed" << '\n'; |
| 131 | } | 131 | } |
| 132 | delete[] tmp; | 132 | delete[] tmp; |
| 133 | // Also test with make_shared_cstr and make_unique_cstr | 133 | // Also test with make_shared_cstr and make_unique_cstr |
| 134 | auto tmp2 = QUtil::make_shared_cstr(embedded_null); | 134 | auto tmp2 = QUtil::make_shared_cstr(embedded_null); |
| 135 | if (memcmp(tmp2.get(), embedded_null.c_str(), 7) == 0) { | 135 | if (memcmp(tmp2.get(), embedded_null.c_str(), 7) == 0) { |
| 136 | - std::cout << "compare okay" << std::endl; | 136 | + std::cout << "compare okay" << '\n'; |
| 137 | } else { | 137 | } else { |
| 138 | - std::cout << "compare failed" << std::endl; | 138 | + std::cout << "compare failed" << '\n'; |
| 139 | } | 139 | } |
| 140 | auto tmp3 = QUtil::make_unique_cstr(embedded_null); | 140 | auto tmp3 = QUtil::make_unique_cstr(embedded_null); |
| 141 | if (memcmp(tmp3.get(), embedded_null.c_str(), 7) == 0) { | 141 | if (memcmp(tmp3.get(), embedded_null.c_str(), 7) == 0) { |
| 142 | - std::cout << "compare okay" << std::endl; | 142 | + std::cout << "compare okay" << '\n'; |
| 143 | } else { | 143 | } else { |
| 144 | - std::cout << "compare failed" << std::endl; | 144 | + std::cout << "compare failed" << '\n'; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | std::string int_max_str = QUtil::int_to_string(INT_MAX); | 147 | std::string int_max_str = QUtil::int_to_string(INT_MAX); |
| @@ -171,11 +171,11 @@ void | @@ -171,11 +171,11 @@ void | ||
| 171 | os_wrapper_test() | 171 | os_wrapper_test() |
| 172 | { | 172 | { |
| 173 | try { | 173 | try { |
| 174 | - std::cout << "before remove" << std::endl; | 174 | + std::cout << "before remove" << '\n'; |
| 175 | QUtil::os_wrapper("remove file", remove("/this/file/does/not/exist")); | 175 | QUtil::os_wrapper("remove file", remove("/this/file/does/not/exist")); |
| 176 | - std::cout << "after remove" << std::endl; | 176 | + std::cout << "after remove" << '\n'; |
| 177 | } catch (std::runtime_error& s) { | 177 | } catch (std::runtime_error& s) { |
| 178 | - std::cout << "exception: " << s.what() << std::endl; | 178 | + std::cout << "exception: " << s.what() << '\n'; |
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | 181 | ||
| @@ -183,12 +183,12 @@ void | @@ -183,12 +183,12 @@ void | ||
| 183 | fopen_wrapper_test() | 183 | fopen_wrapper_test() |
| 184 | { | 184 | { |
| 185 | try { | 185 | try { |
| 186 | - std::cout << "before fopen" << std::endl; | 186 | + std::cout << "before fopen" << '\n'; |
| 187 | FILE* f = QUtil::safe_fopen("/this/file/does/not/exist", "r"); | 187 | FILE* f = QUtil::safe_fopen("/this/file/does/not/exist", "r"); |
| 188 | - std::cout << "after fopen" << std::endl; | 188 | + std::cout << "after fopen" << '\n'; |
| 189 | (void)fclose(f); | 189 | (void)fclose(f); |
| 190 | } catch (QPDFSystemError& s) { | 190 | } catch (QPDFSystemError& s) { |
| 191 | - std::cout << "exception: " << s.what() << std::endl; | 191 | + std::cout << "exception: " << s.what() << '\n'; |
| 192 | assert(s.getErrno() != 0); | 192 | assert(s.getErrno() != 0); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| @@ -200,10 +200,9 @@ void | @@ -200,10 +200,9 @@ void | ||
| 200 | getenv_test() | 200 | getenv_test() |
| 201 | { | 201 | { |
| 202 | std::string val; | 202 | std::string val; |
| 203 | - std::cout << "IN_TESTSUITE: " << QUtil::get_env("IN_TESTSUITE", &val) << ": " << val | ||
| 204 | - << std::endl; | 203 | + std::cout << "IN_TESTSUITE: " << QUtil::get_env("IN_TESTSUITE", &val) << ": " << val << '\n'; |
| 205 | // Hopefully this environment variable is not defined. | 204 | // Hopefully this environment variable is not defined. |
| 206 | - std::cout << "HAGOOGAMAGOOGLE: " << QUtil::get_env("HAGOOGAMAGOOGLE") << std::endl; | 205 | + std::cout << "HAGOOGAMAGOOGLE: " << QUtil::get_env("HAGOOGAMAGOOGLE") << '\n'; |
| 207 | } | 206 | } |
| 208 | 207 | ||
| 209 | static void | 208 | static void |
| @@ -223,7 +222,7 @@ print_utf8(unsigned long val) | @@ -223,7 +222,7 @@ print_utf8(unsigned long val) | ||
| 223 | static_cast<int>(static_cast<unsigned char>(ch)), 16, 2); | 222 | static_cast<int>(static_cast<unsigned char>(ch)), 16, 2); |
| 224 | } | 223 | } |
| 225 | } | 224 | } |
| 226 | - std::cout << std::endl; | 225 | + std::cout << '\n'; |
| 227 | 226 | ||
| 228 | // Boundary conditions for QUtil::get_next_utf8_codepoint, which is | 227 | // Boundary conditions for QUtil::get_next_utf8_codepoint, which is |
| 229 | // also tested indirectly through test_pdf_unicode.cc. | 228 | // also tested indirectly through test_pdf_unicode.cc. |
| @@ -264,7 +263,7 @@ to_utf8_test() | @@ -264,7 +263,7 @@ to_utf8_test() | ||
| 264 | try { | 263 | try { |
| 265 | print_utf8(0x80000000UL); | 264 | print_utf8(0x80000000UL); |
| 266 | } catch (std::runtime_error& e) { | 265 | } catch (std::runtime_error& e) { |
| 267 | - std::cout << "0x80000000: " << e.what() << std::endl; | 266 | + std::cout << "0x80000000: " << e.what() << '\n'; |
| 268 | } | 267 | } |
| 269 | 268 | ||
| 270 | // Overlong characters: characters represented by more bytes than necessary. | 269 | // Overlong characters: characters represented by more bytes than necessary. |
| @@ -296,7 +295,7 @@ print_utf16(unsigned long val) | @@ -296,7 +295,7 @@ print_utf16(unsigned long val) | ||
| 296 | << QUtil::int_to_string_base( | 295 | << QUtil::int_to_string_base( |
| 297 | static_cast<int>(static_cast<unsigned char>(ch)), 16, 2); | 296 | static_cast<int>(static_cast<unsigned char>(ch)), 16, 2); |
| 298 | } | 297 | } |
| 299 | - std::cout << std::endl; | 298 | + std::cout << '\n'; |
| 300 | } | 299 | } |
| 301 | 300 | ||
| 302 | void | 301 | void |
| @@ -311,24 +310,24 @@ to_utf16_test() | @@ -311,24 +310,24 @@ to_utf16_test() | ||
| 311 | print_utf16(0x80000000UL); | 310 | print_utf16(0x80000000UL); |
| 312 | 311 | ||
| 313 | std::string s(QUtil::utf8_to_utf16("\xcf\x80")); | 312 | std::string s(QUtil::utf8_to_utf16("\xcf\x80")); |
| 314 | - std::cout << QUtil::utf16_to_utf8(s) << std::endl; | ||
| 315 | - std::cout << QUtil::utf16_to_utf8(s + ".") << std::endl; | ||
| 316 | - std::cout << "LE: " << QUtil::utf16_to_utf8("\xff\xfe\xc0\x03") << std::endl; | 313 | + std::cout << QUtil::utf16_to_utf8(s) << '\n'; |
| 314 | + std::cout << QUtil::utf16_to_utf8(s + ".") << '\n'; | ||
| 315 | + std::cout << "LE: " << QUtil::utf16_to_utf8("\xff\xfe\xc0\x03") << '\n'; | ||
| 317 | } | 316 | } |
| 318 | 317 | ||
| 319 | void | 318 | void |
| 320 | utf8_to_ascii_test() | 319 | utf8_to_ascii_test() |
| 321 | { | 320 | { |
| 322 | char const* input = "\302\277Does \317\200 have fingers?"; | 321 | char const* input = "\302\277Does \317\200 have fingers?"; |
| 323 | - std::cout << input << std::endl | ||
| 324 | - << QUtil::utf8_to_ascii(input) << std::endl | ||
| 325 | - << QUtil::utf8_to_ascii(input, '*') << std::endl; | 322 | + std::cout << input << '\n' |
| 323 | + << QUtil::utf8_to_ascii(input) << '\n' | ||
| 324 | + << QUtil::utf8_to_ascii(input, '*') << '\n'; | ||
| 326 | std::string a = QUtil::utf8_to_win_ansi(input, '*'); | 325 | std::string a = QUtil::utf8_to_win_ansi(input, '*'); |
| 327 | std::string b = QUtil::utf8_to_mac_roman(input, '*'); | 326 | std::string b = QUtil::utf8_to_mac_roman(input, '*'); |
| 328 | std::cout << "<" << QUtil::int_to_string_base(static_cast<unsigned char>(a.at(0)), 16, 2) << ">" | 327 | std::cout << "<" << QUtil::int_to_string_base(static_cast<unsigned char>(a.at(0)), 16, 2) << ">" |
| 329 | - << a.substr(1) << std::endl | 328 | + << a.substr(1) << '\n' |
| 330 | << "<" << QUtil::int_to_string_base(static_cast<unsigned char>(b.at(0)), 16, 2) << ">" | 329 | << "<" << QUtil::int_to_string_base(static_cast<unsigned char>(b.at(0)), 16, 2) << ">" |
| 331 | - << b.substr(1) << std::endl; | 330 | + << b.substr(1) << '\n'; |
| 332 | } | 331 | } |
| 333 | 332 | ||
| 334 | void | 333 | void |
| @@ -349,7 +348,7 @@ transcoding_test( | @@ -349,7 +348,7 @@ transcoding_test( | ||
| 349 | back = (*from_utf8)(out, '?'); | 348 | back = (*from_utf8)(out, '?'); |
| 350 | if (back != wanted) { | 349 | if (back != wanted) { |
| 351 | std::cout << i << ": " << in << " -> " << out << " -> " << back << " (wanted " << wanted | 350 | std::cout << i << ": " << in << " -> " << out << " -> " << back << " (wanted " << wanted |
| 352 | - << ")" << std::endl; | 351 | + << ")" << '\n'; |
| 353 | } | 352 | } |
| 354 | } | 353 | } |
| 355 | } | 354 | } |
| @@ -363,7 +362,7 @@ check_analyze(std::string const& str, bool has8bit, bool utf8, bool utf16) | @@ -363,7 +362,7 @@ check_analyze(std::string const& str, bool has8bit, bool utf8, bool utf16) | ||
| 363 | QUtil::analyze_encoding(str, has_8bit_chars, is_valid_utf8, is_utf16); | 362 | QUtil::analyze_encoding(str, has_8bit_chars, is_valid_utf8, is_utf16); |
| 364 | if (!((has_8bit_chars == has8bit) && (is_valid_utf8 == utf8) && (is_utf16 == utf16))) { | 363 | if (!((has_8bit_chars == has8bit) && (is_valid_utf8 == utf8) && (is_utf16 == utf16))) { |
| 365 | std::cout << "analysis failed: " << str << ": 8bit: " << has_8bit_chars | 364 | std::cout << "analysis failed: " << str << ": 8bit: " << has_8bit_chars |
| 366 | - << ", utf8: " << is_valid_utf8 << ", utf16: " << is_utf16 << std::endl; | 365 | + << ", utf8: " << is_valid_utf8 << ", utf16: " << is_utf16 << '\n'; |
| 367 | } | 366 | } |
| 368 | } | 367 | } |
| 369 | 368 | ||
| @@ -373,7 +372,7 @@ print_alternatives(std::string const& str) | @@ -373,7 +372,7 @@ print_alternatives(std::string const& str) | ||
| 373 | std::vector<std::string> result = QUtil::possible_repaired_encodings(str); | 372 | std::vector<std::string> result = QUtil::possible_repaired_encodings(str); |
| 374 | size_t n = result.size(); | 373 | size_t n = result.size(); |
| 375 | for (size_t i = 0; i < n; ++i) { | 374 | for (size_t i = 0; i < n; ++i) { |
| 376 | - std::cout << i << ": " << QUtil::hex_encode(result.at(i)) << std::endl; | 375 | + std::cout << i << ": " << QUtil::hex_encode(result.at(i)) << '\n'; |
| 377 | } | 376 | } |
| 378 | } | 377 | } |
| 379 | 378 | ||
| @@ -381,20 +380,20 @@ void | @@ -381,20 +380,20 @@ void | ||
| 381 | transcoding_test() | 380 | transcoding_test() |
| 382 | { | 381 | { |
| 383 | transcoding_test(&QUtil::pdf_doc_to_utf8, &QUtil::utf8_to_pdf_doc, 127, 160, "\x9f"); | 382 | transcoding_test(&QUtil::pdf_doc_to_utf8, &QUtil::utf8_to_pdf_doc, 127, 160, "\x9f"); |
| 384 | - std::cout << "bidirectional pdf doc done" << std::endl; | 383 | + std::cout << "bidirectional pdf doc done" << '\n'; |
| 385 | transcoding_test(&QUtil::pdf_doc_to_utf8, &QUtil::utf8_to_pdf_doc, 24, 31, "?"); | 384 | transcoding_test(&QUtil::pdf_doc_to_utf8, &QUtil::utf8_to_pdf_doc, 24, 31, "?"); |
| 386 | - std::cout << "bidirectional pdf doc low done" << std::endl; | 385 | + std::cout << "bidirectional pdf doc low done" << '\n'; |
| 387 | transcoding_test(&QUtil::win_ansi_to_utf8, &QUtil::utf8_to_win_ansi, 128, 160, "?"); | 386 | transcoding_test(&QUtil::win_ansi_to_utf8, &QUtil::utf8_to_win_ansi, 128, 160, "?"); |
| 388 | - std::cout << "bidirectional win ansi done" << std::endl; | 387 | + std::cout << "bidirectional win ansi done" << '\n'; |
| 389 | transcoding_test(&QUtil::mac_roman_to_utf8, &QUtil::utf8_to_mac_roman, 128, 255, "?"); | 388 | transcoding_test(&QUtil::mac_roman_to_utf8, &QUtil::utf8_to_mac_roman, 128, 255, "?"); |
| 390 | - std::cout << "bidirectional mac roman done" << std::endl; | 389 | + std::cout << "bidirectional mac roman done" << '\n'; |
| 391 | check_analyze("pi = \317\200", true, true, false); | 390 | check_analyze("pi = \317\200", true, true, false); |
| 392 | check_analyze("pi != \317", true, false, false); | 391 | check_analyze("pi != \317", true, false, false); |
| 393 | check_analyze("pi != 22/7", false, false, false); | 392 | check_analyze("pi != 22/7", false, false, false); |
| 394 | check_analyze("\xE0\x80\x82", true, false, false); | 393 | check_analyze("\xE0\x80\x82", true, false, false); |
| 395 | check_analyze(std::string("\xfe\xff\x00\x51", 4), true, false, true); | 394 | check_analyze(std::string("\xfe\xff\x00\x51", 4), true, false, true); |
| 396 | check_analyze(std::string("\xff\xfe\x51\x00", 4), true, false, true); | 395 | check_analyze(std::string("\xff\xfe\x51\x00", 4), true, false, true); |
| 397 | - std::cout << "analysis done" << std::endl; | 396 | + std::cout << "analysis done" << '\n'; |
| 398 | std::string input1("a\302\277b"); | 397 | std::string input1("a\302\277b"); |
| 399 | std::string input2("a\317\200b"); | 398 | std::string input2("a\317\200b"); |
| 400 | std::string input3("ab"); | 399 | std::string input3("ab"); |
| @@ -411,7 +410,7 @@ transcoding_test() | @@ -411,7 +410,7 @@ transcoding_test() | ||
| 411 | assert(QUtil::utf8_to_pdf_doc(input1, output)); | 410 | assert(QUtil::utf8_to_pdf_doc(input1, output)); |
| 412 | assert(!QUtil::utf8_to_pdf_doc(input2, output)); | 411 | assert(!QUtil::utf8_to_pdf_doc(input2, output)); |
| 413 | assert(QUtil::utf8_to_pdf_doc(input3, output)); | 412 | assert(QUtil::utf8_to_pdf_doc(input3, output)); |
| 414 | - std::cout << "alternatives" << std::endl; | 413 | + std::cout << "alternatives" << '\n'; |
| 415 | // char name mac win pdf-doc | 414 | // char name mac win pdf-doc |
| 416 | // U+0192 florin 304 203 206 | 415 | // U+0192 florin 304 203 206 |
| 417 | // U+00A9 copyright 251 251 251 | 416 | // U+00A9 copyright 251 251 251 |
| @@ -422,18 +421,18 @@ transcoding_test() | @@ -422,18 +421,18 @@ transcoding_test() | ||
| 422 | print_alternatives(pdfdoc); | 421 | print_alternatives(pdfdoc); |
| 423 | print_alternatives(utf8); | 422 | print_alternatives(utf8); |
| 424 | print_alternatives("quack"); | 423 | print_alternatives("quack"); |
| 425 | - std::cout << "done alternatives" << std::endl; | 424 | + std::cout << "done alternatives" << '\n'; |
| 426 | // These are characters are either valid in PDFDoc and invalid in | 425 | // These are characters are either valid in PDFDoc and invalid in |
| 427 | // UTF-8 or the other way around. | 426 | // UTF-8 or the other way around. |
| 428 | std::string other("w\x18w\x19w\x1aw\x1bw\x1cw\x1dw\x1ew\x1fw\x7fw"); | 427 | std::string other("w\x18w\x19w\x1aw\x1bw\x1cw\x1dw\x1ew\x1fw\x7fw"); |
| 429 | // cSpell: ignore xadw | 428 | // cSpell: ignore xadw |
| 430 | std::string other_doc = other + "\x9fw\xadw"; | 429 | std::string other_doc = other + "\x9fw\xadw"; |
| 431 | - std::cout << QUtil::pdf_doc_to_utf8(other_doc) << std::endl; | 430 | + std::cout << QUtil::pdf_doc_to_utf8(other_doc) << '\n'; |
| 432 | std::string other_utf8 = other + QUtil::toUTF8(0x9f) + "w" + QUtil::toUTF8(0xad) + "w"; | 431 | std::string other_utf8 = other + QUtil::toUTF8(0x9f) + "w" + QUtil::toUTF8(0xad) + "w"; |
| 433 | std::string other_to_utf8; | 432 | std::string other_to_utf8; |
| 434 | assert(!QUtil::utf8_to_pdf_doc(other_utf8, other_to_utf8)); | 433 | assert(!QUtil::utf8_to_pdf_doc(other_utf8, other_to_utf8)); |
| 435 | - std::cout << other_to_utf8 << std::endl; | ||
| 436 | - std::cout << "done other characters" << std::endl; | 434 | + std::cout << other_to_utf8 << '\n'; |
| 435 | + std::cout << "done other characters" << '\n'; | ||
| 437 | // These valid UTF8 strings when converted to PDFDoc would end up | 436 | // These valid UTF8 strings when converted to PDFDoc would end up |
| 438 | // with a byte sequence that would be recognized as UTF-8 or | 437 | // with a byte sequence that would be recognized as UTF-8 or |
| 439 | // UTF-16 rather than PDFDoc. A special case is required to store | 438 | // UTF-16 rather than PDFDoc. A special case is required to store |
| @@ -455,7 +454,7 @@ void | @@ -455,7 +454,7 @@ void | ||
| 455 | print_whoami(char const* str) | 454 | print_whoami(char const* str) |
| 456 | { | 455 | { |
| 457 | auto dup = QUtil::make_unique_cstr(str); | 456 | auto dup = QUtil::make_unique_cstr(str); |
| 458 | - std::cout << QUtil::getWhoami(dup.get()) << std::endl; | 457 | + std::cout << QUtil::getWhoami(dup.get()) << '\n'; |
| 459 | } | 458 | } |
| 460 | 459 | ||
| 461 | void | 460 | void |
| @@ -473,7 +472,7 @@ assert_same_file(char const* file1, char const* file2, bool expected) | @@ -473,7 +472,7 @@ assert_same_file(char const* file1, char const* file2, bool expected) | ||
| 473 | bool actual = QUtil::same_file(file1, file2); | 472 | bool actual = QUtil::same_file(file1, file2); |
| 474 | std::cout << "file1: -" << (file1 ? file1 : "(null)") << "-, file2: -" | 473 | std::cout << "file1: -" << (file1 ? file1 : "(null)") << "-, file2: -" |
| 475 | << (file2 ? file2 : "(null)") << "-; same: " << actual << ": " | 474 | << (file2 ? file2 : "(null)") << "-; same: " << actual << ": " |
| 476 | - << ((actual == expected) ? "PASS" : "FAIL") << std::endl; | 475 | + << ((actual == expected) ? "PASS" : "FAIL") << '\n'; |
| 477 | } | 476 | } |
| 478 | 477 | ||
| 479 | void | 478 | void |
| @@ -501,7 +500,7 @@ path_test() | @@ -501,7 +500,7 @@ path_test() | ||
| 501 | auto check = [](bool print, std::string const& a, std::string const& b) { | 500 | auto check = [](bool print, std::string const& a, std::string const& b) { |
| 502 | auto result = QUtil::path_basename(a); | 501 | auto result = QUtil::path_basename(a); |
| 503 | if (print) { | 502 | if (print) { |
| 504 | - std::cout << a << " -> " << result << std::endl; | 503 | + std::cout << a << " -> " << result << '\n'; |
| 505 | } | 504 | } |
| 506 | assert(result == b); | 505 | assert(result == b); |
| 507 | }; | 506 | }; |
| @@ -523,7 +522,7 @@ read_from_file_test() | @@ -523,7 +522,7 @@ read_from_file_test() | ||
| 523 | { | 522 | { |
| 524 | std::list<std::string> lines = QUtil::read_lines_from_file("other-file"); | 523 | std::list<std::string> lines = QUtil::read_lines_from_file("other-file"); |
| 525 | for (auto const& line: lines) { | 524 | for (auto const& line: lines) { |
| 526 | - std::cout << line << std::endl; | 525 | + std::cout << line << '\n'; |
| 527 | } | 526 | } |
| 528 | // Test the other versions and make sure we get the same results | 527 | // Test the other versions and make sure we get the same results |
| 529 | { | 528 | { |
| @@ -561,7 +560,7 @@ read_from_file_test() | @@ -561,7 +560,7 @@ read_from_file_test() | ||
| 561 | std::shared_ptr<char> buf; | 560 | std::shared_ptr<char> buf; |
| 562 | size_t size = 0; | 561 | size_t size = 0; |
| 563 | QUtil::read_file_into_memory("other-file", buf, size); | 562 | QUtil::read_file_into_memory("other-file", buf, size); |
| 564 | - std::cout << "read " << size << " bytes" << std::endl; | 563 | + std::cout << "read " << size << " bytes" << '\n'; |
| 565 | char const* p = buf.get(); | 564 | char const* p = buf.get(); |
| 566 | assert(size == 24652); | 565 | assert(size == 24652); |
| 567 | assert(memcmp(p, "This file is used for qutil testing.", 36) == 0); | 566 | assert(memcmp(p, "This file is used for qutil testing.", 36) == 0); |
| @@ -575,7 +574,7 @@ read_from_file_test() | @@ -575,7 +574,7 @@ read_from_file_test() | ||
| 575 | assert(memcmp(buf2->getBuffer(), p, size) == 0); | 574 | assert(memcmp(buf2->getBuffer(), p, size) == 0); |
| 576 | 575 | ||
| 577 | auto s = QUtil::read_file_into_string("other-file"); | 576 | auto s = QUtil::read_file_into_string("other-file"); |
| 578 | - std::cout << "read " << s.size() << " bytes" << std::endl; | 577 | + std::cout << "read " << s.size() << " bytes" << '\n'; |
| 579 | assert(s.size() == 24652); | 578 | assert(s.size() == 24652); |
| 580 | assert(s.substr(0, 36) == "This file is used for qutil testing."); | 579 | assert(s.substr(0, 36) == "This file is used for qutil testing."); |
| 581 | assert(s.substr(24641, 10) == "very long."); | 580 | assert(s.substr(24641, 10) == "very long."); |
| @@ -587,7 +586,7 @@ assert_hex_encode(std::string const& input, std::string const& expected) | @@ -587,7 +586,7 @@ assert_hex_encode(std::string const& input, std::string const& expected) | ||
| 587 | std::string actual = QUtil::hex_encode(input); | 586 | std::string actual = QUtil::hex_encode(input); |
| 588 | if (expected != actual) { | 587 | if (expected != actual) { |
| 589 | std::cout << "hex encode " << input << ": expected = " << expected | 588 | std::cout << "hex encode " << input << ": expected = " << expected |
| 590 | - << "; actual = " << actual << std::endl; | 589 | + << "; actual = " << actual << '\n'; |
| 591 | } | 590 | } |
| 592 | } | 591 | } |
| 593 | 592 | ||
| @@ -597,7 +596,7 @@ assert_hex_decode(std::string const& input, std::string const& expected) | @@ -597,7 +596,7 @@ assert_hex_decode(std::string const& input, std::string const& expected) | ||
| 597 | std::string actual = QUtil::hex_decode(input); | 596 | std::string actual = QUtil::hex_decode(input); |
| 598 | if (expected != actual) { | 597 | if (expected != actual) { |
| 599 | std::cout << "hex encode " << input << ": expected = " << expected | 598 | std::cout << "hex encode " << input << ": expected = " << expected |
| 600 | - << "; actual = " << actual << std::endl; | 599 | + << "; actual = " << actual << '\n'; |
| 601 | } | 600 | } |
| 602 | } | 601 | } |
| 603 | 602 | ||
| @@ -639,31 +638,31 @@ rename_delete_test() | @@ -639,31 +638,31 @@ rename_delete_test() | ||
| 639 | } catch (QPDFSystemError&) { | 638 | } catch (QPDFSystemError&) { |
| 640 | } | 639 | } |
| 641 | assert_no_file("old\xcf\x80"); | 640 | assert_no_file("old\xcf\x80"); |
| 642 | - std::cout << "create file" << std::endl; | 641 | + std::cout << "create file" << '\n'; |
| 643 | ; | 642 | ; |
| 644 | FILE* f1 = QUtil::safe_fopen("old\xcf\x80", "w"); | 643 | FILE* f1 = QUtil::safe_fopen("old\xcf\x80", "w"); |
| 645 | fprintf(f1, "one"); | 644 | fprintf(f1, "one"); |
| 646 | fclose(f1); | 645 | fclose(f1); |
| 647 | QUtil::read_file_into_memory("old\xcf\x80", buf, size); | 646 | QUtil::read_file_into_memory("old\xcf\x80", buf, size); |
| 648 | assert(memcmp(buf.get(), "one", 3) == 0); | 647 | assert(memcmp(buf.get(), "one", 3) == 0); |
| 649 | - std::cout << "rename file" << std::endl; | 648 | + std::cout << "rename file" << '\n'; |
| 650 | ; | 649 | ; |
| 651 | QUtil::rename_file("old\xcf\x80", "old\xcf\x80.~tmp"); | 650 | QUtil::rename_file("old\xcf\x80", "old\xcf\x80.~tmp"); |
| 652 | QUtil::read_file_into_memory("old\xcf\x80.~tmp", buf, size); | 651 | QUtil::read_file_into_memory("old\xcf\x80.~tmp", buf, size); |
| 653 | assert(memcmp(buf.get(), "one", 3) == 0); | 652 | assert(memcmp(buf.get(), "one", 3) == 0); |
| 654 | assert_no_file("old\xcf\x80"); | 653 | assert_no_file("old\xcf\x80"); |
| 655 | - std::cout << "create file" << std::endl; | 654 | + std::cout << "create file" << '\n'; |
| 656 | ; | 655 | ; |
| 657 | f1 = QUtil::safe_fopen("old\xcf\x80", "w"); | 656 | f1 = QUtil::safe_fopen("old\xcf\x80", "w"); |
| 658 | fprintf(f1, "two"); | 657 | fprintf(f1, "two"); |
| 659 | fclose(f1); | 658 | fclose(f1); |
| 660 | - std::cout << "rename over existing" << std::endl; | 659 | + std::cout << "rename over existing" << '\n'; |
| 661 | ; | 660 | ; |
| 662 | QUtil::rename_file("old\xcf\x80", "old\xcf\x80.~tmp"); | 661 | QUtil::rename_file("old\xcf\x80", "old\xcf\x80.~tmp"); |
| 663 | QUtil::read_file_into_memory("old\xcf\x80.~tmp", buf, size); | 662 | QUtil::read_file_into_memory("old\xcf\x80.~tmp", buf, size); |
| 664 | assert(memcmp(buf.get(), "two", 3) == 0); | 663 | assert(memcmp(buf.get(), "two", 3) == 0); |
| 665 | assert_no_file("old\xcf\x80"); | 664 | assert_no_file("old\xcf\x80"); |
| 666 | - std::cout << "delete file" << std::endl; | 665 | + std::cout << "delete file" << '\n'; |
| 667 | ; | 666 | ; |
| 668 | QUtil::remove_file("old\xcf\x80.~tmp"); | 667 | QUtil::remove_file("old\xcf\x80.~tmp"); |
| 669 | assert_no_file("old\xcf\x80"); | 668 | assert_no_file("old\xcf\x80"); |
| @@ -676,7 +675,7 @@ timestamp_test() | @@ -676,7 +675,7 @@ timestamp_test() | ||
| 676 | auto check = [](QUtil::QPDFTime const& t) { | 675 | auto check = [](QUtil::QPDFTime const& t) { |
| 677 | std::string pdf = QUtil::qpdf_time_to_pdf_time(t); | 676 | std::string pdf = QUtil::qpdf_time_to_pdf_time(t); |
| 678 | std::string iso8601 = QUtil::qpdf_time_to_iso8601(t); | 677 | std::string iso8601 = QUtil::qpdf_time_to_iso8601(t); |
| 679 | - std::cout << pdf << std::endl << iso8601 << std::endl; | 678 | + std::cout << pdf << '\n' << iso8601 << '\n'; |
| 680 | QUtil::QPDFTime t2; | 679 | QUtil::QPDFTime t2; |
| 681 | std::string iso8601_2; | 680 | std::string iso8601_2; |
| 682 | assert(QUtil::pdf_time_to_qpdf_time(pdf, &t2)); | 681 | assert(QUtil::pdf_time_to_qpdf_time(pdf, &t2)); |
| @@ -704,7 +703,7 @@ is_long_long_test() | @@ -704,7 +703,7 @@ is_long_long_test() | ||
| 704 | { | 703 | { |
| 705 | auto check = [](char const* s, bool v) { | 704 | auto check = [](char const* s, bool v) { |
| 706 | if (QUtil::is_long_long(s) != v) { | 705 | if (QUtil::is_long_long(s) != v) { |
| 707 | - std::cout << "failed: " << s << std::endl; | 706 | + std::cout << "failed: " << s << '\n'; |
| 708 | } | 707 | } |
| 709 | }; | 708 | }; |
| 710 | check("12312312", true); | 709 | check("12312312", true); |
| @@ -719,7 +718,7 @@ is_long_long_test() | @@ -719,7 +718,7 @@ is_long_long_test() | ||
| 719 | check("123123123123123123123123123123123123", false); | 718 | check("123123123123123123123123123123123123", false); |
| 720 | check("potato", false); | 719 | check("potato", false); |
| 721 | check("0123", false); | 720 | check("0123", false); |
| 722 | - std::cout << "done" << std::endl; | 721 | + std::cout << "done" << '\n'; |
| 723 | } | 722 | } |
| 724 | 723 | ||
| 725 | void | 724 | void |
| @@ -731,49 +730,49 @@ memory_usage_test() | @@ -731,49 +730,49 @@ memory_usage_test() | ||
| 731 | auto u2 = QUtil::get_max_memory_usage(); | 730 | auto u2 = QUtil::get_max_memory_usage(); |
| 732 | assert(u2 > u1); | 731 | assert(u2 > u1); |
| 733 | } | 732 | } |
| 734 | - std::cout << "memory usage okay" << std::endl; | 733 | + std::cout << "memory usage okay" << '\n'; |
| 735 | } | 734 | } |
| 736 | 735 | ||
| 737 | int | 736 | int |
| 738 | main(int argc, char* argv[]) | 737 | main(int argc, char* argv[]) |
| 739 | { | 738 | { |
| 740 | try { | 739 | try { |
| 741 | - std::cout << "---- string conversion" << std::endl; | 740 | + std::cout << "---- string conversion" << '\n'; |
| 742 | string_conversion_test(); | 741 | string_conversion_test(); |
| 743 | - std::cout << "---- os wrapper" << std::endl; | 742 | + std::cout << "---- os wrapper" << '\n'; |
| 744 | os_wrapper_test(); | 743 | os_wrapper_test(); |
| 745 | - std::cout << "---- fopen" << std::endl; | 744 | + std::cout << "---- fopen" << '\n'; |
| 746 | fopen_wrapper_test(); | 745 | fopen_wrapper_test(); |
| 747 | - std::cout << "---- getenv" << std::endl; | 746 | + std::cout << "---- getenv" << '\n'; |
| 748 | getenv_test(); | 747 | getenv_test(); |
| 749 | - std::cout << "---- utf8" << std::endl; | 748 | + std::cout << "---- utf8" << '\n'; |
| 750 | to_utf8_test(); | 749 | to_utf8_test(); |
| 751 | - std::cout << "---- utf16" << std::endl; | 750 | + std::cout << "---- utf16" << '\n'; |
| 752 | to_utf16_test(); | 751 | to_utf16_test(); |
| 753 | - std::cout << "---- utf8_to_ascii" << std::endl; | 752 | + std::cout << "---- utf8_to_ascii" << '\n'; |
| 754 | utf8_to_ascii_test(); | 753 | utf8_to_ascii_test(); |
| 755 | - std::cout << "---- transcoding" << std::endl; | 754 | + std::cout << "---- transcoding" << '\n'; |
| 756 | transcoding_test(); | 755 | transcoding_test(); |
| 757 | - std::cout << "---- whoami" << std::endl; | 756 | + std::cout << "---- whoami" << '\n'; |
| 758 | get_whoami_test(); | 757 | get_whoami_test(); |
| 759 | - std::cout << "---- file" << std::endl; | 758 | + std::cout << "---- file" << '\n'; |
| 760 | same_file_test(); | 759 | same_file_test(); |
| 761 | - std::cout << "---- path" << std::endl; | 760 | + std::cout << "---- path" << '\n'; |
| 762 | path_test(); | 761 | path_test(); |
| 763 | - std::cout << "---- read from file" << std::endl; | 762 | + std::cout << "---- read from file" << '\n'; |
| 764 | read_from_file_test(); | 763 | read_from_file_test(); |
| 765 | - std::cout << "---- hex encode/decode" << std::endl; | 764 | + std::cout << "---- hex encode/decode" << '\n'; |
| 766 | hex_encode_decode_test(); | 765 | hex_encode_decode_test(); |
| 767 | - std::cout << "---- rename/delete" << std::endl; | 766 | + std::cout << "---- rename/delete" << '\n'; |
| 768 | rename_delete_test(); | 767 | rename_delete_test(); |
| 769 | - std::cout << "---- timestamp" << std::endl; | 768 | + std::cout << "---- timestamp" << '\n'; |
| 770 | timestamp_test(); | 769 | timestamp_test(); |
| 771 | - std::cout << "---- is_long_long" << std::endl; | 770 | + std::cout << "---- is_long_long" << '\n'; |
| 772 | is_long_long_test(); | 771 | is_long_long_test(); |
| 773 | - std::cout << "---- memory usage" << std::endl; | 772 | + std::cout << "---- memory usage" << '\n'; |
| 774 | memory_usage_test(); | 773 | memory_usage_test(); |
| 775 | } catch (std::exception& e) { | 774 | } catch (std::exception& e) { |
| 776 | - std::cout << "unexpected exception: " << e.what() << std::endl; | 775 | + std::cout << "unexpected exception: " << e.what() << '\n'; |
| 777 | } | 776 | } |
| 778 | 777 | ||
| 779 | return 0; | 778 | return 0; |
libtests/rc4.cc
| @@ -20,7 +20,7 @@ other_tests() | @@ -20,7 +20,7 @@ other_tests() | ||
| 20 | memcpy(data.get(), "potato", 6); | 20 | memcpy(data.get(), "potato", 6); |
| 21 | r.process(data.get(), 6, data.get()); | 21 | r.process(data.get(), 6, data.get()); |
| 22 | assert(memcmp(data.get(), "\xa5\x6f\xe7\x27\x2b\x5c", 6) == 0); | 22 | assert(memcmp(data.get(), "\xa5\x6f\xe7\x27\x2b\x5c", 6) == 0); |
| 23 | - std::cout << "passed" << std::endl; | 23 | + std::cout << "passed" << '\n'; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | int | 26 | int |
| @@ -32,7 +32,7 @@ main(int argc, char* argv[]) | @@ -32,7 +32,7 @@ main(int argc, char* argv[]) | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | if (argc != 4) { | 34 | if (argc != 4) { |
| 35 | - std::cerr << "Usage: rc4 hex-key infile outfile" << std::endl; | 35 | + std::cerr << "Usage: rc4 hex-key infile outfile" << '\n'; |
| 36 | exit(2); | 36 | exit(2); |
| 37 | } | 37 | } |
| 38 | 38 |
libtests/runlength.cc
| @@ -11,7 +11,7 @@ int | @@ -11,7 +11,7 @@ int | ||
| 11 | main(int argc, char* argv[]) | 11 | main(int argc, char* argv[]) |
| 12 | { | 12 | { |
| 13 | if (argc != 4) { | 13 | if (argc != 4) { |
| 14 | - std::cerr << "Usage: runlength {-encode|-decode} infile outfile" << std::endl; | 14 | + std::cerr << "Usage: runlength {-encode|-decode} infile outfile" << '\n'; |
| 15 | exit(2); | 15 | exit(2); |
| 16 | } | 16 | } |
| 17 | 17 |
libtests/sparse_array.cc
qpdf/fix-qdf.cc
| @@ -81,7 +81,7 @@ QdfFixer::QdfFixer(std::string const& filename, std::ostream& out) : | @@ -81,7 +81,7 @@ QdfFixer::QdfFixer(std::string const& filename, std::ostream& out) : | ||
| 81 | void | 81 | void |
| 82 | QdfFixer::fatal(std::string const& msg) | 82 | QdfFixer::fatal(std::string const& msg) |
| 83 | { | 83 | { |
| 84 | - std::cerr << msg << std::endl; | 84 | + std::cerr << msg << '\n'; |
| 85 | exit(2); | 85 | exit(2); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| @@ -380,7 +380,7 @@ realmain(int argc, char* argv[]) | @@ -380,7 +380,7 @@ realmain(int argc, char* argv[]) | ||
| 380 | if (argc > 3) { | 380 | if (argc > 3) { |
| 381 | usage(); | 381 | usage(); |
| 382 | } else if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) { | 382 | } else if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) { |
| 383 | - std::cout << whoami << " from qpdf version " << QPDF::QPDFVersion() << std::endl; | 383 | + std::cout << whoami << " from qpdf version " << QPDF::QPDFVersion() << '\n'; |
| 384 | return 0; | 384 | return 0; |
| 385 | } else if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) { | 385 | } else if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) { |
| 386 | usage(); | 386 | usage(); |
| @@ -411,7 +411,7 @@ realmain(int argc, char* argv[]) | @@ -411,7 +411,7 @@ realmain(int argc, char* argv[]) | ||
| 411 | QdfFixer qf(filename, out ? *out : std::cout); | 411 | QdfFixer qf(filename, out ? *out : std::cout); |
| 412 | qf.processLines(input); | 412 | qf.processLines(input); |
| 413 | } catch (std::exception& e) { | 413 | } catch (std::exception& e) { |
| 414 | - std::cerr << whoami << ": error: " << e.what() << std::endl; | 414 | + std::cerr << whoami << ": error: " << e.what() << '\n'; |
| 415 | exit(qpdf_exit_error); | 415 | exit(qpdf_exit_error); |
| 416 | } | 416 | } |
| 417 | return 0; | 417 | return 0; |
qpdf/pdf_from_scratch.cc
| @@ -14,7 +14,7 @@ static char const* whoami = nullptr; | @@ -14,7 +14,7 @@ static char const* whoami = nullptr; | ||
| 14 | void | 14 | void |
| 15 | usage() | 15 | usage() |
| 16 | { | 16 | { |
| 17 | - std::cerr << "Usage: " << whoami << " n" << std::endl; | 17 | + std::cerr << "Usage: " << whoami << " n\n"; |
| 18 | exit(2); | 18 | exit(2); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| @@ -77,7 +77,7 @@ runtest(int n) | @@ -77,7 +77,7 @@ runtest(int n) | ||
| 77 | throw std::runtime_error(std::string("invalid test ") + std::to_string(n)); | 77 | throw std::runtime_error(std::string("invalid test ") + std::to_string(n)); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | - std::cout << "test " << n << " done" << std::endl; | 80 | + std::cout << "test " << n << " done\n"; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | int | 83 | int |
| @@ -98,7 +98,7 @@ main(int argc, char* argv[]) | @@ -98,7 +98,7 @@ main(int argc, char* argv[]) | ||
| 98 | int n = QUtil::string_to_int(argv[1]); | 98 | int n = QUtil::string_to_int(argv[1]); |
| 99 | runtest(n); | 99 | runtest(n); |
| 100 | } catch (std::exception& e) { | 100 | } catch (std::exception& e) { |
| 101 | - std::cerr << e.what() << std::endl; | 101 | + std::cerr << e.what() << '\n'; |
| 102 | exit(2); | 102 | exit(2); |
| 103 | } | 103 | } |
| 104 | 104 |
qpdf/qpdf.cc
| @@ -11,15 +11,15 @@ static char const* whoami = nullptr; | @@ -11,15 +11,15 @@ static char const* whoami = nullptr; | ||
| 11 | static void | 11 | static void |
| 12 | usageExit(std::string const& msg) | 12 | usageExit(std::string const& msg) |
| 13 | { | 13 | { |
| 14 | - std::cerr << std::endl | ||
| 15 | - << whoami << ": " << msg << std::endl | ||
| 16 | - << std::endl | ||
| 17 | - << "For help:" << std::endl | ||
| 18 | - << " " << whoami << " --help=usage usage information" << std::endl | ||
| 19 | - << " " << whoami << " --help=topic help on a topic" << std::endl | ||
| 20 | - << " " << whoami << " --help=--option help on an option" << std::endl | ||
| 21 | - << " " << whoami << " --help general help and a topic list" << std::endl | ||
| 22 | - << std::endl; | 14 | + std::cerr << '\n' |
| 15 | + << whoami << ": " << msg << '\n' | ||
| 16 | + << '\n' | ||
| 17 | + << "For help:\n" | ||
| 18 | + << " " << whoami << " --help=usage usage information\n" | ||
| 19 | + << " " << whoami << " --help=topic help on a topic\n" | ||
| 20 | + << " " << whoami << " --help=--option help on an option\n" | ||
| 21 | + << " " << whoami << " --help general help and a topic list\n" | ||
| 22 | + << '\n'; | ||
| 23 | exit(QPDFJob::EXIT_ERROR); | 23 | exit(QPDFJob::EXIT_ERROR); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| @@ -37,7 +37,7 @@ realmain(int argc, char* argv[]) | @@ -37,7 +37,7 @@ realmain(int argc, char* argv[]) | ||
| 37 | } catch (QPDFUsage& e) { | 37 | } catch (QPDFUsage& e) { |
| 38 | usageExit(e.what()); | 38 | usageExit(e.what()); |
| 39 | } catch (std::exception& e) { | 39 | } catch (std::exception& e) { |
| 40 | - std::cerr << whoami << ": " << e.what() << std::endl; | 40 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 41 | return QPDFJob::EXIT_ERROR; | 41 | return QPDFJob::EXIT_ERROR; |
| 42 | } | 42 | } |
| 43 | return j.getExitCode(); | 43 | return j.getExitCode(); |
qpdf/test_driver.cc
| @@ -39,7 +39,7 @@ static char const* whoami = nullptr; | @@ -39,7 +39,7 @@ static char const* whoami = nullptr; | ||
| 39 | void | 39 | void |
| 40 | usage() | 40 | usage() |
| 41 | { | 41 | { |
| 42 | - std::cerr << "Usage: " << whoami << " n filename1 [arg2]" << std::endl; | 42 | + std::cerr << "Usage: " << whoami << " n filename1 [arg2]" << '\n'; |
| 43 | exit(2); | 43 | exit(2); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| @@ -58,7 +58,7 @@ ExtendNameTree::ExtendNameTree(QPDFObjectHandle o, QPDF& q) : | @@ -58,7 +58,7 @@ ExtendNameTree::ExtendNameTree(QPDFObjectHandle o, QPDF& q) : | ||
| 58 | 58 | ||
| 59 | ExtendNameTree::~ExtendNameTree() | 59 | ExtendNameTree::~ExtendNameTree() |
| 60 | { | 60 | { |
| 61 | - std::cout << "~ExtendNameTree called" << std::endl; | 61 | + std::cout << "~ExtendNameTree called" << '\n'; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | class Provider: public QPDFObjectHandle::StreamDataProvider | 64 | class Provider: public QPDFObjectHandle::StreamDataProvider |
| @@ -104,30 +104,30 @@ class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks | @@ -104,30 +104,30 @@ class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks | ||
| 104 | void | 104 | void |
| 105 | ParserCallbacks::contentSize(size_t size) | 105 | ParserCallbacks::contentSize(size_t size) |
| 106 | { | 106 | { |
| 107 | - std::cout << "content size: " << size << std::endl; | 107 | + std::cout << "content size: " << size << '\n'; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | void | 110 | void |
| 111 | ParserCallbacks::handleObject(QPDFObjectHandle obj, size_t offset, size_t length) | 111 | ParserCallbacks::handleObject(QPDFObjectHandle obj, size_t offset, size_t length) |
| 112 | { | 112 | { |
| 113 | if (obj.isName() && (obj.getName() == "/Abort")) { | 113 | if (obj.isName() && (obj.getName() == "/Abort")) { |
| 114 | - std::cout << "test suite: terminating parsing" << std::endl; | 114 | + std::cout << "test suite: terminating parsing" << '\n'; |
| 115 | terminateParsing(); | 115 | terminateParsing(); |
| 116 | } | 116 | } |
| 117 | std::cout << obj.getTypeName() << ", offset=" << offset << ", length=" << length << ": "; | 117 | std::cout << obj.getTypeName() << ", offset=" << offset << ", length=" << length << ": "; |
| 118 | if (obj.isInlineImage()) { | 118 | if (obj.isInlineImage()) { |
| 119 | // Exercise getTypeCode | 119 | // Exercise getTypeCode |
| 120 | assert(obj.getTypeCode() == ::ot_inlineimage); | 120 | assert(obj.getTypeCode() == ::ot_inlineimage); |
| 121 | - std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << std::endl; | 121 | + std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << '\n'; |
| 122 | } else { | 122 | } else { |
| 123 | - std::cout << obj.unparse() << std::endl; | 123 | + std::cout << obj.unparse() << '\n'; |
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | void | 127 | void |
| 128 | ParserCallbacks::handleEOF() | 128 | ParserCallbacks::handleEOF() |
| 129 | { | 129 | { |
| 130 | - std::cout << "-EOF-" << std::endl; | 130 | + std::cout << "-EOF-" << '\n'; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | class TokenFilter: public QPDFObjectHandle::TokenFilter | 133 | class TokenFilter: public QPDFObjectHandle::TokenFilter |
| @@ -165,7 +165,7 @@ checkPageContents(QPDFObjectHandle page, std::string const& wanted_string) | @@ -165,7 +165,7 @@ checkPageContents(QPDFObjectHandle page, std::string const& wanted_string) | ||
| 165 | { | 165 | { |
| 166 | std::string contents = getPageContents(page); | 166 | std::string contents = getPageContents(page); |
| 167 | if (contents.find(wanted_string) == std::string::npos) { | 167 | if (contents.find(wanted_string) == std::string::npos) { |
| 168 | - std::cout << "didn't find " << wanted_string << " in " << contents << std::endl; | 168 | + std::cout << "didn't find " << wanted_string << " in " << contents << '\n'; |
| 169 | } | 169 | } |
| 170 | } | 170 | } |
| 171 | 171 | ||
| @@ -207,77 +207,77 @@ test_0_1(QPDF& pdf, char const* arg2) | @@ -207,77 +207,77 @@ test_0_1(QPDF& pdf, char const* arg2) | ||
| 207 | // any difference between a key that is present and null | 207 | // any difference between a key that is present and null |
| 208 | // and a key that is absent. | 208 | // and a key that is absent. |
| 209 | QTC::TC("qpdf", "main QTest implicit"); | 209 | QTC::TC("qpdf", "main QTest implicit"); |
| 210 | - std::cout << "/QTest is implicit" << std::endl; | 210 | + std::cout << "/QTest is implicit" << '\n'; |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | QTC::TC("qpdf", "main QTest indirect", qtest.isIndirect() ? 1 : 0); | 213 | QTC::TC("qpdf", "main QTest indirect", qtest.isIndirect() ? 1 : 0); |
| 214 | std::cout << "/QTest is " << (qtest.isIndirect() ? "in" : "") << "direct and has type " | 214 | std::cout << "/QTest is " << (qtest.isIndirect() ? "in" : "") << "direct and has type " |
| 215 | - << qtest.getTypeName() << " (" << qtest.getTypeCode() << ")" << std::endl; | 215 | + << qtest.getTypeName() << " (" << qtest.getTypeCode() << ")" << '\n'; |
| 216 | 216 | ||
| 217 | if (qtest.isNull()) { | 217 | if (qtest.isNull()) { |
| 218 | QTC::TC("qpdf", "main QTest null"); | 218 | QTC::TC("qpdf", "main QTest null"); |
| 219 | - std::cout << "/QTest is null" << std::endl; | 219 | + std::cout << "/QTest is null" << '\n'; |
| 220 | } else if (qtest.isBool()) { | 220 | } else if (qtest.isBool()) { |
| 221 | QTC::TC("qpdf", "main QTest bool", qtest.getBoolValue() ? 1 : 0); | 221 | QTC::TC("qpdf", "main QTest bool", qtest.getBoolValue() ? 1 : 0); |
| 222 | std::cout << "/QTest is Boolean with value " << (qtest.getBoolValue() ? "true" : "false") | 222 | std::cout << "/QTest is Boolean with value " << (qtest.getBoolValue() ? "true" : "false") |
| 223 | - << std::endl; | 223 | + << '\n'; |
| 224 | } else if (qtest.isInteger()) { | 224 | } else if (qtest.isInteger()) { |
| 225 | QTC::TC("qpdf", "main QTest int"); | 225 | QTC::TC("qpdf", "main QTest int"); |
| 226 | - std::cout << "/QTest is an integer with value " << qtest.getIntValue() << std::endl; | 226 | + std::cout << "/QTest is an integer with value " << qtest.getIntValue() << '\n'; |
| 227 | } else if (qtest.isReal()) { | 227 | } else if (qtest.isReal()) { |
| 228 | QTC::TC("qpdf", "main QTest real"); | 228 | QTC::TC("qpdf", "main QTest real"); |
| 229 | - std::cout << "/QTest is a real number with value " << qtest.getRealValue() << std::endl; | 229 | + std::cout << "/QTest is a real number with value " << qtest.getRealValue() << '\n'; |
| 230 | } else if (qtest.isName()) { | 230 | } else if (qtest.isName()) { |
| 231 | QTC::TC("qpdf", "main QTest name"); | 231 | QTC::TC("qpdf", "main QTest name"); |
| 232 | - std::cout << "/QTest is a name with value " << qtest.getName() << std::endl; | 232 | + std::cout << "/QTest is a name with value " << qtest.getName() << '\n'; |
| 233 | } else if (qtest.isString()) { | 233 | } else if (qtest.isString()) { |
| 234 | QTC::TC("qpdf", "main QTest string"); | 234 | QTC::TC("qpdf", "main QTest string"); |
| 235 | - std::cout << "/QTest is a string with value " << qtest.getStringValue() << std::endl; | 235 | + std::cout << "/QTest is a string with value " << qtest.getStringValue() << '\n'; |
| 236 | } else if (qtest.isArray()) { | 236 | } else if (qtest.isArray()) { |
| 237 | QTC::TC("qpdf", "main QTest array"); | 237 | QTC::TC("qpdf", "main QTest array"); |
| 238 | - std::cout << "/QTest is an array with " << qtest.getArrayNItems() << " items" << std::endl; | 238 | + std::cout << "/QTest is an array with " << qtest.getArrayNItems() << " items" << '\n'; |
| 239 | int i = 0; | 239 | int i = 0; |
| 240 | for (auto& iter: qtest.aitems()) { | 240 | for (auto& iter: qtest.aitems()) { |
| 241 | QTC::TC("qpdf", "main QTest array indirect", iter.isIndirect() ? 1 : 0); | 241 | QTC::TC("qpdf", "main QTest array indirect", iter.isIndirect() ? 1 : 0); |
| 242 | std::cout << " item " << i << " is " << (iter.isIndirect() ? "in" : "") << "direct" | 242 | std::cout << " item " << i << " is " << (iter.isIndirect() ? "in" : "") << "direct" |
| 243 | - << std::endl; | 243 | + << '\n'; |
| 244 | ++i; | 244 | ++i; |
| 245 | } | 245 | } |
| 246 | } else if (qtest.isDictionary()) { | 246 | } else if (qtest.isDictionary()) { |
| 247 | QTC::TC("qpdf", "main QTest dictionary"); | 247 | QTC::TC("qpdf", "main QTest dictionary"); |
| 248 | - std::cout << "/QTest is a dictionary" << std::endl; | 248 | + std::cout << "/QTest is a dictionary" << '\n'; |
| 249 | for (auto& iter: qtest.ditems()) { | 249 | for (auto& iter: qtest.ditems()) { |
| 250 | QTC::TC("qpdf", "main QTest dictionary indirect", iter.second.isIndirect() ? 1 : 0); | 250 | QTC::TC("qpdf", "main QTest dictionary indirect", iter.second.isIndirect() ? 1 : 0); |
| 251 | std::cout << " " << iter.first << " is " << (iter.second.isIndirect() ? "in" : "") | 251 | std::cout << " " << iter.first << " is " << (iter.second.isIndirect() ? "in" : "") |
| 252 | - << "direct" << std::endl; | 252 | + << "direct" << '\n'; |
| 253 | } | 253 | } |
| 254 | } else if (qtest.isStream()) { | 254 | } else if (qtest.isStream()) { |
| 255 | QTC::TC("qpdf", "main QTest stream"); | 255 | QTC::TC("qpdf", "main QTest stream"); |
| 256 | - std::cout << "/QTest is a stream. Dictionary: " << qtest.getDict().unparse() << std::endl; | 256 | + std::cout << "/QTest is a stream. Dictionary: " << qtest.getDict().unparse() << '\n'; |
| 257 | 257 | ||
| 258 | - std::cout << "Raw stream data:" << std::endl; | 258 | + std::cout << "Raw stream data:" << '\n'; |
| 259 | std::cout.flush(); | 259 | std::cout.flush(); |
| 260 | QUtil::binary_stdout(); | 260 | QUtil::binary_stdout(); |
| 261 | auto out = std::make_shared<Pl_StdioFile>("raw", stdout); | 261 | auto out = std::make_shared<Pl_StdioFile>("raw", stdout); |
| 262 | qtest.pipeStreamData(out.get(), 0, qpdf_dl_none); | 262 | qtest.pipeStreamData(out.get(), 0, qpdf_dl_none); |
| 263 | 263 | ||
| 264 | - std::cout << std::endl << "Uncompressed stream data:" << std::endl; | 264 | + std::cout << '\n' << "Uncompressed stream data:" << '\n'; |
| 265 | if (qtest.pipeStreamData(nullptr, 0, qpdf_dl_all)) { | 265 | if (qtest.pipeStreamData(nullptr, 0, qpdf_dl_all)) { |
| 266 | std::cout.flush(); | 266 | std::cout.flush(); |
| 267 | QUtil::binary_stdout(); | 267 | QUtil::binary_stdout(); |
| 268 | out = std::make_shared<Pl_StdioFile>("filtered", stdout); | 268 | out = std::make_shared<Pl_StdioFile>("filtered", stdout); |
| 269 | qtest.pipeStreamData(out.get(), 0, qpdf_dl_all); | 269 | qtest.pipeStreamData(out.get(), 0, qpdf_dl_all); |
| 270 | - std::cout << std::endl << "End of stream data" << std::endl; | 270 | + std::cout << '\n' << "End of stream data" << '\n'; |
| 271 | } else { | 271 | } else { |
| 272 | - std::cout << "Stream data is not filterable." << std::endl; | 272 | + std::cout << "Stream data is not filterable." << '\n'; |
| 273 | } | 273 | } |
| 274 | } else { | 274 | } else { |
| 275 | // Should not happen! | 275 | // Should not happen! |
| 276 | - std::cout << "/QTest is an unknown object" << std::endl; | 276 | + std::cout << "/QTest is an unknown object" << '\n'; |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | - std::cout << "unparse: " << qtest.unparse() << std::endl | ||
| 280 | - << "unparseResolved: " << qtest.unparseResolved() << std::endl; | 279 | + std::cout << "unparse: " << qtest.unparse() << '\n' |
| 280 | + << "unparseResolved: " << qtest.unparseResolved() << '\n'; | ||
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | static void | 283 | static void |
| @@ -287,12 +287,12 @@ test_2(QPDF& pdf, char const* arg2) | @@ -287,12 +287,12 @@ test_2(QPDF& pdf, char const* arg2) | ||
| 287 | // PDF file. | 287 | // PDF file. |
| 288 | 288 | ||
| 289 | QPDFObjectHandle trailer = pdf.getTrailer(); | 289 | QPDFObjectHandle trailer = pdf.getTrailer(); |
| 290 | - std::cout << trailer.getKey("/Info").getKey("/CreationDate").getStringValue() << std::endl; | ||
| 291 | - std::cout << trailer.getKey("/Info").getKey("/Producer").getStringValue() << std::endl; | 290 | + std::cout << trailer.getKey("/Info").getKey("/CreationDate").getStringValue() << '\n'; |
| 291 | + std::cout << trailer.getKey("/Info").getKey("/Producer").getStringValue() << '\n'; | ||
| 292 | 292 | ||
| 293 | QPDFObjectHandle encrypt = trailer.getKey("/Encrypt"); | 293 | QPDFObjectHandle encrypt = trailer.getKey("/Encrypt"); |
| 294 | - std::cout << encrypt.getKey("/O").unparse() << std::endl; | ||
| 295 | - std::cout << encrypt.getKey("/U").unparse() << std::endl; | 294 | + std::cout << encrypt.getKey("/O").unparse() << '\n'; |
| 295 | + std::cout << encrypt.getKey("/U").unparse() << '\n'; | ||
| 296 | 296 | ||
| 297 | QPDFObjectHandle root = pdf.getRoot(); | 297 | QPDFObjectHandle root = pdf.getRoot(); |
| 298 | QPDFObjectHandle pages = root.getKey("/Pages"); | 298 | QPDFObjectHandle pages = root.getKey("/Pages"); |
| @@ -310,7 +310,7 @@ test_3(QPDF& pdf, char const* arg2) | @@ -310,7 +310,7 @@ test_3(QPDF& pdf, char const* arg2) | ||
| 310 | QPDFObjectHandle streams = pdf.getTrailer().getKey("/QStreams"); | 310 | QPDFObjectHandle streams = pdf.getTrailer().getKey("/QStreams"); |
| 311 | for (int i = 0; i < streams.getArrayNItems(); ++i) { | 311 | for (int i = 0; i < streams.getArrayNItems(); ++i) { |
| 312 | QPDFObjectHandle stream = streams.getArrayItem(i); | 312 | QPDFObjectHandle stream = streams.getArrayItem(i); |
| 313 | - std::cout << "-- stream " << i << " --" << std::endl; | 313 | + std::cout << "-- stream " << i << " --" << '\n'; |
| 314 | std::cout.flush(); | 314 | std::cout.flush(); |
| 315 | QUtil::binary_stdout(); | 315 | QUtil::binary_stdout(); |
| 316 | auto out = std::make_shared<Pl_StdioFile>("tokenized stream", stdout); | 316 | auto out = std::make_shared<Pl_StdioFile>("tokenized stream", stdout); |
| @@ -374,44 +374,44 @@ test_5(QPDF& pdf, char const* arg2) | @@ -374,44 +374,44 @@ test_5(QPDF& pdf, char const* arg2) | ||
| 374 | int pageno = 0; | 374 | int pageno = 0; |
| 375 | for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) { | 375 | for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) { |
| 376 | ++pageno; | 376 | ++pageno; |
| 377 | - std::cout << "page " << pageno << ":" << std::endl; | ||
| 378 | - std::cout << " images:" << std::endl; | 377 | + std::cout << "page " << pageno << ":" << '\n'; |
| 378 | + std::cout << " images:" << '\n'; | ||
| 379 | for (auto const& iter2: page.getImages()) { | 379 | for (auto const& iter2: page.getImages()) { |
| 380 | std::string const& name = iter2.first; | 380 | std::string const& name = iter2.first; |
| 381 | QPDFObjectHandle image = iter2.second; | 381 | QPDFObjectHandle image = iter2.second; |
| 382 | QPDFObjectHandle dict = image.getDict(); | 382 | QPDFObjectHandle dict = image.getDict(); |
| 383 | long long width = dict.getKey("/Width").getIntValue(); | 383 | long long width = dict.getKey("/Width").getIntValue(); |
| 384 | long long height = dict.getKey("/Height").getIntValue(); | 384 | long long height = dict.getKey("/Height").getIntValue(); |
| 385 | - std::cout << " " << name << ": " << width << " x " << height << std::endl; | 385 | + std::cout << " " << name << ": " << width << " x " << height << '\n'; |
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | - std::cout << " content:" << std::endl; | 388 | + std::cout << " content:" << '\n'; |
| 389 | std::vector<QPDFObjectHandle> content = page.getPageContents(); | 389 | std::vector<QPDFObjectHandle> content = page.getPageContents(); |
| 390 | for (auto& iter2: content) { | 390 | for (auto& iter2: content) { |
| 391 | - std::cout << " " << iter2.unparse() << std::endl; | 391 | + std::cout << " " << iter2.unparse() << '\n'; |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | - std::cout << "end page " << pageno << std::endl; | 394 | + std::cout << "end page " << pageno << '\n'; |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | QPDFObjectHandle root = pdf.getRoot(); | 397 | QPDFObjectHandle root = pdf.getRoot(); |
| 398 | QPDFObjectHandle qstrings = root.getKey("/QStrings"); | 398 | QPDFObjectHandle qstrings = root.getKey("/QStrings"); |
| 399 | if (qstrings.isArray()) { | 399 | if (qstrings.isArray()) { |
| 400 | - std::cout << "QStrings:" << std::endl; | 400 | + std::cout << "QStrings:" << '\n'; |
| 401 | int nitems = qstrings.getArrayNItems(); | 401 | int nitems = qstrings.getArrayNItems(); |
| 402 | for (int i = 0; i < nitems; ++i) { | 402 | for (int i = 0; i < nitems; ++i) { |
| 403 | - std::cout << qstrings.getArrayItem(i).getUTF8Value() << std::endl; | 403 | + std::cout << qstrings.getArrayItem(i).getUTF8Value() << '\n'; |
| 404 | } | 404 | } |
| 405 | } | 405 | } |
| 406 | 406 | ||
| 407 | QPDFObjectHandle qnumbers = root.getKey("/QNumbers"); | 407 | QPDFObjectHandle qnumbers = root.getKey("/QNumbers"); |
| 408 | if (qnumbers.isArray()) { | 408 | if (qnumbers.isArray()) { |
| 409 | - std::cout << "QNumbers:" << std::endl; | 409 | + std::cout << "QNumbers:" << '\n'; |
| 410 | int nitems = qnumbers.getArrayNItems(); | 410 | int nitems = qnumbers.getArrayNItems(); |
| 411 | for (int i = 0; i < nitems; ++i) { | 411 | for (int i = 0; i < nitems; ++i) { |
| 412 | std::cout << QUtil::double_to_string( | 412 | std::cout << QUtil::double_to_string( |
| 413 | qnumbers.getArrayItem(i).getNumericValue(), 3, false) | 413 | qnumbers.getArrayItem(i).getNumericValue(), 3, false) |
| 414 | - << std::endl; | 414 | + << '\n'; |
| 415 | } | 415 | } |
| 416 | } | 416 | } |
| 417 | } | 417 | } |
| @@ -432,7 +432,7 @@ test_6(QPDF& pdf, char const* arg2) | @@ -432,7 +432,7 @@ test_6(QPDF& pdf, char const* arg2) | ||
| 432 | cleartext = true; | 432 | cleartext = true; |
| 433 | } | 433 | } |
| 434 | std::cout << "encrypted=" << (pdf.isEncrypted() ? 1 : 0) | 434 | std::cout << "encrypted=" << (pdf.isEncrypted() ? 1 : 0) |
| 435 | - << "; cleartext=" << (cleartext ? 1 : 0) << std::endl; | 435 | + << "; cleartext=" << (cleartext ? 1 : 0) << '\n'; |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | static void | 438 | static void |
| @@ -483,9 +483,9 @@ test_8(QPDF& pdf, char const* arg2) | @@ -483,9 +483,9 @@ test_8(QPDF& pdf, char const* arg2) | ||
| 483 | provider->badLength(true); | 483 | provider->badLength(true); |
| 484 | try { | 484 | try { |
| 485 | qstream.getStreamData(); | 485 | qstream.getStreamData(); |
| 486 | - std::cout << "oops -- getStreamData didn't throw" << std::endl; | 486 | + std::cout << "oops -- getStreamData didn't throw" << '\n'; |
| 487 | } catch (std::exception const& e) { | 487 | } catch (std::exception const& e) { |
| 488 | - std::cout << "exception: " << e.what() << std::endl; | 488 | + std::cout << "exception: " << e.what() << '\n'; |
| 489 | } | 489 | } |
| 490 | } | 490 | } |
| 491 | 491 | ||
| @@ -501,9 +501,9 @@ test_9(QPDF& pdf, char const* arg2) | @@ -501,9 +501,9 @@ test_9(QPDF& pdf, char const* arg2) | ||
| 501 | QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf); | 501 | QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf); |
| 502 | try { | 502 | try { |
| 503 | rstream.getStreamData(); | 503 | rstream.getStreamData(); |
| 504 | - std::cout << "oops -- getStreamData didn't throw" << std::endl; | 504 | + std::cout << "oops -- getStreamData didn't throw" << '\n'; |
| 505 | } catch (std::logic_error const& e) { | 505 | } catch (std::logic_error const& e) { |
| 506 | - std::cout << "exception: " << e.what() << std::endl; | 506 | + std::cout << "exception: " << e.what() << '\n'; |
| 507 | } | 507 | } |
| 508 | rstream.replaceStreamData( | 508 | rstream.replaceStreamData( |
| 509 | "data for other stream\n", QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | 509 | "data for other stream\n", QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); |
| @@ -539,10 +539,10 @@ test_11(QPDF& pdf, char const* arg2) | @@ -539,10 +539,10 @@ test_11(QPDF& pdf, char const* arg2) | ||
| 539 | std::shared_ptr<Buffer> b1 = qstream.getStreamData(); | 539 | std::shared_ptr<Buffer> b1 = qstream.getStreamData(); |
| 540 | std::shared_ptr<Buffer> b2 = qstream.getRawStreamData(); | 540 | std::shared_ptr<Buffer> b2 = qstream.getRawStreamData(); |
| 541 | if ((b1->getSize() == 7) && (memcmp(b1->getBuffer(), "potato\n", 7) == 0)) { | 541 | if ((b1->getSize() == 7) && (memcmp(b1->getBuffer(), "potato\n", 7) == 0)) { |
| 542 | - std::cout << "filtered stream data okay" << std::endl; | 542 | + std::cout << "filtered stream data okay" << '\n'; |
| 543 | } | 543 | } |
| 544 | if ((b2->getSize() == 15) && (memcmp(b2->getBuffer(), "706F7461746F0A\n", 15) == 0)) { | 544 | if ((b2->getSize() == 15) && (memcmp(b2->getBuffer(), "706F7461746F0A\n", 15) == 0)) { |
| 545 | - std::cout << "raw stream data okay" << std::endl; | 545 | + std::cout << "raw stream data okay" << '\n'; |
| 546 | } | 546 | } |
| 547 | } | 547 | } |
| 548 | 548 | ||
| @@ -580,9 +580,7 @@ test_13(QPDF& pdf, char const* arg2) | @@ -580,9 +580,7 @@ test_13(QPDF& pdf, char const* arg2) | ||
| 580 | # pragma GCC diagnostic pop | 580 | # pragma GCC diagnostic pop |
| 581 | #endif | 581 | #endif |
| 582 | pdf.showLinearizationData(); | 582 | pdf.showLinearizationData(); |
| 583 | - std::cout << "---output---" << std::endl | ||
| 584 | - << out.str() << "---error---" << std::endl | ||
| 585 | - << err.str(); | 583 | + std::cout << "---output---" << '\n' << out.str() << "---error---" << '\n' << err.str(); |
| 586 | } | 584 | } |
| 587 | 585 | ||
| 588 | static void | 586 | static void |
| @@ -614,27 +612,27 @@ test_14(QPDF& pdf, char const* arg2) | @@ -614,27 +612,27 @@ test_14(QPDF& pdf, char const* arg2) | ||
| 614 | // Do it wrong first... | 612 | // Do it wrong first... |
| 615 | pdf.replaceObject(qdict.getObjGen(), qdict); | 613 | pdf.replaceObject(qdict.getObjGen(), qdict); |
| 616 | } catch (std::logic_error const&) { | 614 | } catch (std::logic_error const&) { |
| 617 | - std::cout << "caught logic error as expected" << std::endl; | 615 | + std::cout << "caught logic error as expected" << '\n'; |
| 618 | } | 616 | } |
| 619 | pdf.replaceObject(qdict.getObjGen(), new_dict); | 617 | pdf.replaceObject(qdict.getObjGen(), new_dict); |
| 620 | // Now qdict points to the new dictionary | 618 | // Now qdict points to the new dictionary |
| 621 | - std::cout << "old dict: " << qdict.getKey("/NewDict").getIntValue() << std::endl; | 619 | + std::cout << "old dict: " << qdict.getKey("/NewDict").getIntValue() << '\n'; |
| 622 | // Swap dict and array | 620 | // Swap dict and array |
| 623 | pdf.swapObjects(qdict.getObjGen(), qarray.getObjGen()); | 621 | pdf.swapObjects(qdict.getObjGen(), qarray.getObjGen()); |
| 624 | // Now qarray will resolve to new object and qdict resolves to | 622 | // Now qarray will resolve to new object and qdict resolves to |
| 625 | // the array | 623 | // the array |
| 626 | - std::cout << "swapped array: " << qdict.getArrayItem(0).getName() << std::endl; | ||
| 627 | - std::cout << "new dict: " << qarray.getKey("/NewDict").getIntValue() << std::endl; | 624 | + std::cout << "swapped array: " << qdict.getArrayItem(0).getName() << '\n'; |
| 625 | + std::cout << "new dict: " << qarray.getKey("/NewDict").getIntValue() << '\n'; | ||
| 628 | // Reread qdict, still pointing to an array | 626 | // Reread qdict, still pointing to an array |
| 629 | qdict = pdf.getObjectByObjGen(qdict.getObjGen()); | 627 | qdict = pdf.getObjectByObjGen(qdict.getObjGen()); |
| 630 | - std::cout << "swapped array: " << qdict.getArrayItem(0).getName() << std::endl; | 628 | + std::cout << "swapped array: " << qdict.getArrayItem(0).getName() << '\n'; |
| 631 | 629 | ||
| 632 | // Exercise getAsMap and getAsArray | 630 | // Exercise getAsMap and getAsArray |
| 633 | std::vector<QPDFObjectHandle> array_elements = qdict.getArrayAsVector(); | 631 | std::vector<QPDFObjectHandle> array_elements = qdict.getArrayAsVector(); |
| 634 | std::map<std::string, QPDFObjectHandle> dict_items = qarray.getDictAsMap(); | 632 | std::map<std::string, QPDFObjectHandle> dict_items = qarray.getDictAsMap(); |
| 635 | if ((array_elements.size() == 1) && (array_elements.at(0).getName() == "/Array") && | 633 | if ((array_elements.size() == 1) && (array_elements.at(0).getName() == "/Array") && |
| 636 | (dict_items.size() == 1) && (dict_items["/NewDict"].getIntValue() == 2)) { | 634 | (dict_items.size() == 1) && (dict_items["/NewDict"].getIntValue() == 2)) { |
| 637 | - std::cout << "array and dictionary contents are correct" << std::endl; | 635 | + std::cout << "array and dictionary contents are correct" << '\n'; |
| 638 | } | 636 | } |
| 639 | 637 | ||
| 640 | // Exercise writing to memory buffer | 638 | // Exercise writing to memory buffer |
| @@ -853,7 +851,7 @@ test_21(QPDF& pdf, char const* arg2) | @@ -853,7 +851,7 @@ test_21(QPDF& pdf, char const* arg2) | ||
| 853 | QPDFObjectHandle page = pages.at(0); | 851 | QPDFObjectHandle page = pages.at(0); |
| 854 | QPDFObjectHandle contents = page.getKey("/Contents"); | 852 | QPDFObjectHandle contents = page.getKey("/Contents"); |
| 855 | contents.shallowCopy(); | 853 | contents.shallowCopy(); |
| 856 | - std::cout << "you can't see this" << std::endl; | 854 | + std::cout << "you can't see this" << '\n'; |
| 857 | } | 855 | } |
| 858 | 856 | ||
| 859 | static void | 857 | static void |
| @@ -865,7 +863,7 @@ test_22(QPDF& pdf, char const* arg2) | @@ -865,7 +863,7 @@ test_22(QPDF& pdf, char const* arg2) | ||
| 865 | QPDFPageObjectHelper& page = pages.at(0); | 863 | QPDFPageObjectHelper& page = pages.at(0); |
| 866 | dh.removePage(page); | 864 | dh.removePage(page); |
| 867 | dh.removePage(page); | 865 | dh.removePage(page); |
| 868 | - std::cout << "you can't see this" << std::endl; | 866 | + std::cout << "you can't see this" << '\n'; |
| 869 | } | 867 | } |
| 870 | 868 | ||
| 871 | static void | 869 | static void |
| @@ -895,44 +893,44 @@ test_24(QPDF& pdf, char const* arg2) | @@ -895,44 +893,44 @@ test_24(QPDF& pdf, char const* arg2) | ||
| 895 | // Make sure trying to ask questions about a reserved object | 893 | // Make sure trying to ask questions about a reserved object |
| 896 | // doesn't break it. | 894 | // doesn't break it. |
| 897 | if (res1.isArray()) { | 895 | if (res1.isArray()) { |
| 898 | - std::cout << "oops -- res1 is an array" << std::endl; | 896 | + std::cout << "oops -- res1 is an array" << '\n'; |
| 899 | } | 897 | } |
| 900 | if (res1.isReserved()) { | 898 | if (res1.isReserved()) { |
| 901 | - std::cout << "res1 is still reserved after checking if array" << std::endl; | 899 | + std::cout << "res1 is still reserved after checking if array" << '\n'; |
| 902 | } | 900 | } |
| 903 | pdf.replaceReserved(res1, array1); | 901 | pdf.replaceReserved(res1, array1); |
| 904 | if (res1.isReserved()) { | 902 | if (res1.isReserved()) { |
| 905 | - std::cout << "oops -- res1 is still reserved" << std::endl; | 903 | + std::cout << "oops -- res1 is still reserved" << '\n'; |
| 906 | } else { | 904 | } else { |
| 907 | - std::cout << "res1 is no longer reserved" << std::endl; | 905 | + std::cout << "res1 is no longer reserved" << '\n'; |
| 908 | } | 906 | } |
| 909 | res1.assertArray(); | 907 | res1.assertArray(); |
| 910 | - std::cout << "res1 is an array" << std::endl; | 908 | + std::cout << "res1 is an array" << '\n'; |
| 911 | 909 | ||
| 912 | try { | 910 | try { |
| 913 | res2.unparseResolved(); | 911 | res2.unparseResolved(); |
| 914 | - std::cout << "oops -- didn't throw" << std::endl; | 912 | + std::cout << "oops -- didn't throw" << '\n'; |
| 915 | } catch (std::logic_error const& e) { | 913 | } catch (std::logic_error const& e) { |
| 916 | - std::cout << "logic error: " << e.what() << std::endl; | 914 | + std::cout << "logic error: " << e.what() << '\n'; |
| 917 | } | 915 | } |
| 918 | try { | 916 | try { |
| 919 | res2.makeDirect(); | 917 | res2.makeDirect(); |
| 920 | - std::cout << "oops -- didn't throw" << std::endl; | 918 | + std::cout << "oops -- didn't throw" << '\n'; |
| 921 | } catch (std::logic_error const& e) { | 919 | } catch (std::logic_error const& e) { |
| 922 | - std::cout << "logic error: " << e.what() << std::endl; | 920 | + std::cout << "logic error: " << e.what() << '\n'; |
| 923 | } | 921 | } |
| 924 | 922 | ||
| 925 | pdf.replaceReserved(res2, array2); | 923 | pdf.replaceReserved(res2, array2); |
| 926 | 924 | ||
| 927 | res2.assertArray(); | 925 | res2.assertArray(); |
| 928 | - std::cout << "res2 is an array" << std::endl; | 926 | + std::cout << "res2 is an array" << '\n'; |
| 929 | 927 | ||
| 930 | // Verify that the previously added reserved keys can be | 928 | // Verify that the previously added reserved keys can be |
| 931 | // dereferenced properly now | 929 | // dereferenced properly now |
| 932 | int i1 = res1.getArrayItem(0).getArrayItem(1).getIntValueAsInt(); | 930 | int i1 = res1.getArrayItem(0).getArrayItem(1).getIntValueAsInt(); |
| 933 | int i2 = res2.getArrayItem(0).getArrayItem(1).getIntValueAsInt(); | 931 | int i2 = res2.getArrayItem(0).getArrayItem(1).getIntValueAsInt(); |
| 934 | if ((i1 == 2) && (i2 == 1)) { | 932 | if ((i1 == 2) && (i2 == 1)) { |
| 935 | - std::cout << "circular access and lazy resolution worked" << std::endl; | 933 | + std::cout << "circular access and lazy resolution worked" << '\n'; |
| 936 | } | 934 | } |
| 937 | 935 | ||
| 938 | QPDFWriter w(pdf, "a.pdf"); | 936 | QPDFWriter w(pdf, "a.pdf"); |
| @@ -1078,15 +1076,15 @@ test_28(QPDF& pdf, char const* arg2) | @@ -1078,15 +1076,15 @@ test_28(QPDF& pdf, char const* arg2) | ||
| 1078 | // Copy foreign object errors | 1076 | // Copy foreign object errors |
| 1079 | try { | 1077 | try { |
| 1080 | pdf.copyForeignObject(pdf.getTrailer().getKey("/QTest")); | 1078 | pdf.copyForeignObject(pdf.getTrailer().getKey("/QTest")); |
| 1081 | - std::cout << "oops -- didn't throw" << std::endl; | 1079 | + std::cout << "oops -- didn't throw" << '\n'; |
| 1082 | } catch (std::logic_error const& e) { | 1080 | } catch (std::logic_error const& e) { |
| 1083 | - std::cout << "logic error: " << e.what() << std::endl; | 1081 | + std::cout << "logic error: " << e.what() << '\n'; |
| 1084 | } | 1082 | } |
| 1085 | try { | 1083 | try { |
| 1086 | pdf.copyForeignObject(QPDFObjectHandle::newInteger(1)); | 1084 | pdf.copyForeignObject(QPDFObjectHandle::newInteger(1)); |
| 1087 | - std::cout << "oops -- didn't throw" << std::endl; | 1085 | + std::cout << "oops -- didn't throw" << '\n'; |
| 1088 | } catch (std::logic_error const& e) { | 1086 | } catch (std::logic_error const& e) { |
| 1089 | - std::cout << "logic error: " << e.what() << std::endl; | 1087 | + std::cout << "logic error: " << e.what() << '\n'; |
| 1090 | } | 1088 | } |
| 1091 | } | 1089 | } |
| 1092 | 1090 | ||
| @@ -1111,9 +1109,9 @@ test_29(QPDF& pdf, char const* arg2) | @@ -1111,9 +1109,9 @@ test_29(QPDF& pdf, char const* arg2) | ||
| 1111 | try { | 1109 | try { |
| 1112 | QPDFWriter w(*other, "a.pdf"); | 1110 | QPDFWriter w(*other, "a.pdf"); |
| 1113 | w.write(); | 1111 | w.write(); |
| 1114 | - std::cout << "oops -- didn't throw" << std::endl; | 1112 | + std::cout << "oops -- didn't throw" << '\n'; |
| 1115 | } catch (std::logic_error const& e) { | 1113 | } catch (std::logic_error const& e) { |
| 1116 | - std::cout << "logic error: " << e.what() << std::endl; | 1114 | + std::cout << "logic error: " << e.what() << '\n'; |
| 1117 | } | 1115 | } |
| 1118 | 1116 | ||
| 1119 | // Make sure deleting the other source doesn't prevent detection. | 1117 | // Make sure deleting the other source doesn't prevent detection. |
| @@ -1126,9 +1124,9 @@ test_29(QPDF& pdf, char const* arg2) | @@ -1126,9 +1124,9 @@ test_29(QPDF& pdf, char const* arg2) | ||
| 1126 | try { | 1124 | try { |
| 1127 | QPDFWriter w(*other, "a.pdf"); | 1125 | QPDFWriter w(*other, "a.pdf"); |
| 1128 | w.write(); | 1126 | w.write(); |
| 1129 | - std::cout << "oops -- didn't throw" << std::endl; | 1127 | + std::cout << "oops -- didn't throw" << '\n'; |
| 1130 | } catch (std::logic_error const& e) { | 1128 | } catch (std::logic_error const& e) { |
| 1131 | - std::cout << "logic error: " << e.what() << std::endl; | 1129 | + std::cout << "logic error: " << e.what() << '\n'; |
| 1132 | } | 1130 | } |
| 1133 | 1131 | ||
| 1134 | // Detect adding a foreign object | 1132 | // Detect adding a foreign object |
| @@ -1137,7 +1135,7 @@ test_29(QPDF& pdf, char const* arg2) | @@ -1137,7 +1135,7 @@ test_29(QPDF& pdf, char const* arg2) | ||
| 1137 | try { | 1135 | try { |
| 1138 | root1.replaceKey("/Oops", root2); | 1136 | root1.replaceKey("/Oops", root2); |
| 1139 | } catch (std::logic_error const& e) { | 1137 | } catch (std::logic_error const& e) { |
| 1140 | - std::cout << "logic error: " << e.what() << std::endl; | 1138 | + std::cout << "logic error: " << e.what() << '\n'; |
| 1141 | } | 1139 | } |
| 1142 | } | 1140 | } |
| 1143 | 1141 | ||
| @@ -1160,10 +1158,10 @@ test_30(QPDF& pdf, char const* arg2) | @@ -1160,10 +1158,10 @@ test_30(QPDF& pdf, char const* arg2) | ||
| 1160 | pages = final.getAllPages(); | 1158 | pages = final.getAllPages(); |
| 1161 | std::string new_contents = getPageContents(pages.at(0)); | 1159 | std::string new_contents = getPageContents(pages.at(0)); |
| 1162 | if (orig_contents != new_contents) { | 1160 | if (orig_contents != new_contents) { |
| 1163 | - std::cout << "oops -- page contents don't match" << std::endl | 1161 | + std::cout << "oops -- page contents don't match" << '\n' |
| 1164 | << "original:\n" | 1162 | << "original:\n" |
| 1165 | << orig_contents << "new:\n" | 1163 | << orig_contents << "new:\n" |
| 1166 | - << new_contents << std::endl; | 1164 | + << new_contents << '\n'; |
| 1167 | } | 1165 | } |
| 1168 | } | 1166 | } |
| 1169 | 1167 | ||
| @@ -1172,20 +1170,20 @@ test_31(QPDF& pdf, char const* arg2) | @@ -1172,20 +1170,20 @@ test_31(QPDF& pdf, char const* arg2) | ||
| 1172 | { | 1170 | { |
| 1173 | auto o1 = "[/name 16059 3.14159 false\n" | 1171 | auto o1 = "[/name 16059 3.14159 false\n" |
| 1174 | " << /key true /other [ (string1) (string2) ] >> null]"_qpdf; | 1172 | " << /key true /other [ (string1) (string2) ] >> null]"_qpdf; |
| 1175 | - std::cout << o1.unparse() << std::endl; | 1173 | + std::cout << o1.unparse() << '\n'; |
| 1176 | QPDFObjectHandle o2 = QPDFObjectHandle::parse(" 12345 \f "); | 1174 | QPDFObjectHandle o2 = QPDFObjectHandle::parse(" 12345 \f "); |
| 1177 | assert(o2.isInteger() && (o2.getIntValue() == 12345)); | 1175 | assert(o2.isInteger() && (o2.getIntValue() == 12345)); |
| 1178 | try { | 1176 | try { |
| 1179 | QPDFObjectHandle::parse("[1 0 R]", "indirect test"); | 1177 | QPDFObjectHandle::parse("[1 0 R]", "indirect test"); |
| 1180 | - std::cout << "oops -- didn't throw" << std::endl; | 1178 | + std::cout << "oops -- didn't throw" << '\n'; |
| 1181 | } catch (std::logic_error const& e) { | 1179 | } catch (std::logic_error const& e) { |
| 1182 | - std::cout << "logic error parsing indirect: " << e.what() << std::endl; | 1180 | + std::cout << "logic error parsing indirect: " << e.what() << '\n'; |
| 1183 | } | 1181 | } |
| 1184 | try { | 1182 | try { |
| 1185 | QPDFObjectHandle::parse("0 trailing", "trailing test"); | 1183 | QPDFObjectHandle::parse("0 trailing", "trailing test"); |
| 1186 | - std::cout << "oops -- didn't throw" << std::endl; | 1184 | + std::cout << "oops -- didn't throw" << '\n'; |
| 1187 | } catch (std::runtime_error const& e) { | 1185 | } catch (std::runtime_error const& e) { |
| 1188 | - std::cout << "trailing data: " << e.what() << std::endl; | 1186 | + std::cout << "trailing data: " << e.what() << '\n'; |
| 1189 | } | 1187 | } |
| 1190 | assert(QPDFObjectHandle::parse(&pdf, "[5 0 R]").getArrayItem(0).isInteger()); | 1188 | assert(QPDFObjectHandle::parse(&pdf, "[5 0 R]").getArrayItem(0).isInteger()); |
| 1191 | assert(!QPDFObjectHandle::parse(&pdf, "[5 0 R]").getArrayItem(0).isDirectNull()); | 1189 | assert(!QPDFObjectHandle::parse(&pdf, "[5 0 R]").getArrayItem(0).isDirectNull()); |
| @@ -1218,9 +1216,9 @@ test_32(QPDF& pdf, char const* arg2) | @@ -1218,9 +1216,9 @@ test_32(QPDF& pdf, char const* arg2) | ||
| 1218 | bool newline = ((i & 2) != 0); | 1216 | bool newline = ((i & 2) != 0); |
| 1219 | QPDFWriter w(pdf, filenames[i]); | 1217 | QPDFWriter w(pdf, filenames[i]); |
| 1220 | w.setStaticID(true); | 1218 | w.setStaticID(true); |
| 1221 | - std::cout << "file: " << filenames[i] << std::endl | ||
| 1222 | - << "linearized: " << (linearized ? "yes" : "no") << std::endl | ||
| 1223 | - << "newline: " << (newline ? "yes" : "no") << std::endl; | 1219 | + std::cout << "file: " << filenames[i] << '\n' |
| 1220 | + << "linearized: " << (linearized ? "yes" : "no") << '\n' | ||
| 1221 | + << "newline: " << (newline ? "yes" : "no") << '\n'; | ||
| 1224 | w.setLinearization(linearized); | 1222 | w.setLinearization(linearized); |
| 1225 | if (linearized) { | 1223 | if (linearized) { |
| 1226 | w.setCompressStreams(false); // avoid dependency on zlib's output | 1224 | w.setCompressStreams(false); // avoid dependency on zlib's output |
| @@ -1249,14 +1247,14 @@ static void | @@ -1249,14 +1247,14 @@ static void | ||
| 1249 | test_34(QPDF& pdf, char const* arg2) | 1247 | test_34(QPDF& pdf, char const* arg2) |
| 1250 | { | 1248 | { |
| 1251 | // Look at Extensions dictionary | 1249 | // Look at Extensions dictionary |
| 1252 | - std::cout << "version: " << pdf.getPDFVersion() << std::endl | ||
| 1253 | - << "extension level: " << pdf.getExtensionLevel() << std::endl | ||
| 1254 | - << pdf.getRoot().getKey("/Extensions").unparse() << std::endl; | 1250 | + std::cout << "version: " << pdf.getPDFVersion() << '\n' |
| 1251 | + << "extension level: " << pdf.getExtensionLevel() << '\n' | ||
| 1252 | + << pdf.getRoot().getKey("/Extensions").unparse() << '\n'; | ||
| 1255 | auto v = pdf.getVersionAsPDFVersion(); | 1253 | auto v = pdf.getVersionAsPDFVersion(); |
| 1256 | std::string v_string; | 1254 | std::string v_string; |
| 1257 | int extension_level; | 1255 | int extension_level; |
| 1258 | v.getVersion(v_string, extension_level); | 1256 | v.getVersion(v_string, extension_level); |
| 1259 | - std::cout << "As PDFVersion: " << v_string << "/" << extension_level << std::endl; | 1257 | + std::cout << "As PDFVersion: " << v_string << "/" << extension_level << '\n'; |
| 1260 | } | 1258 | } |
| 1261 | 1259 | ||
| 1262 | static void | 1260 | static void |
| @@ -1350,7 +1348,7 @@ test_38(QPDF& pdf, char const* arg2) | @@ -1350,7 +1348,7 @@ test_38(QPDF& pdf, char const* arg2) | ||
| 1350 | // Designed for override-compressed-object.pdf | 1348 | // Designed for override-compressed-object.pdf |
| 1351 | QPDFObjectHandle qtest = pdf.getRoot().getKey("/QTest"); | 1349 | QPDFObjectHandle qtest = pdf.getRoot().getKey("/QTest"); |
| 1352 | for (int i = 0; i < qtest.getArrayNItems(); ++i) { | 1350 | for (int i = 0; i < qtest.getArrayNItems(); ++i) { |
| 1353 | - std::cout << qtest.getArrayItem(i).unparseResolved() << std::endl; | 1351 | + std::cout << qtest.getArrayItem(i).unparseResolved() << '\n'; |
| 1354 | } | 1352 | } |
| 1355 | } | 1353 | } |
| 1356 | 1354 | ||
| @@ -1360,13 +1358,13 @@ test_39(QPDF& pdf, char const* arg2) | @@ -1360,13 +1358,13 @@ test_39(QPDF& pdf, char const* arg2) | ||
| 1360 | // Display image filter and color set for each image on each page | 1358 | // Display image filter and color set for each image on each page |
| 1361 | int pageno = 0; | 1359 | int pageno = 0; |
| 1362 | for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) { | 1360 | for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) { |
| 1363 | - std::cout << "page " << ++pageno << std::endl; | 1361 | + std::cout << "page " << ++pageno << '\n'; |
| 1364 | std::map<std::string, QPDFObjectHandle> images = page.getImages(); | 1362 | std::map<std::string, QPDFObjectHandle> images = page.getImages(); |
| 1365 | for (auto& i_iter: images) { | 1363 | for (auto& i_iter: images) { |
| 1366 | QPDFObjectHandle image_dict = i_iter.second.getDict(); | 1364 | QPDFObjectHandle image_dict = i_iter.second.getDict(); |
| 1367 | std::cout << "filter: " << image_dict.getKey("/Filter").unparseResolved() | 1365 | std::cout << "filter: " << image_dict.getKey("/Filter").unparseResolved() |
| 1368 | << ", color space: " << image_dict.getKey("/ColorSpace").unparseResolved() | 1366 | << ", color space: " << image_dict.getKey("/ColorSpace").unparseResolved() |
| 1369 | - << std::endl; | 1367 | + << '\n'; |
| 1370 | } | 1368 | } |
| 1371 | } | 1369 | } |
| 1372 | } | 1370 | } |
| @@ -1578,51 +1576,51 @@ test_43(QPDF& pdf, char const* arg2) | @@ -1578,51 +1576,51 @@ test_43(QPDF& pdf, char const* arg2) | ||
| 1578 | } | 1576 | } |
| 1579 | std::cout << "iterating over form fields\n"; | 1577 | std::cout << "iterating over form fields\n"; |
| 1580 | for (auto& ffh: afdh.getFormFields()) { | 1578 | for (auto& ffh: afdh.getFormFields()) { |
| 1581 | - std::cout << "Field: " << ffh.getObjectHandle().unparse() << std::endl; | 1579 | + std::cout << "Field: " << ffh.getObjectHandle().unparse() << '\n'; |
| 1582 | QPDFFormFieldObjectHelper node = ffh; | 1580 | QPDFFormFieldObjectHelper node = ffh; |
| 1583 | while (!node.isNull()) { | 1581 | while (!node.isNull()) { |
| 1584 | QPDFFormFieldObjectHelper parent(node.getParent()); | 1582 | QPDFFormFieldObjectHelper parent(node.getParent()); |
| 1585 | std::cout << " Parent: " | 1583 | std::cout << " Parent: " |
| 1586 | << (parent.isNull() ? std::string("none") | 1584 | << (parent.isNull() ? std::string("none") |
| 1587 | : parent.getObjectHandle().unparse()) | 1585 | : parent.getObjectHandle().unparse()) |
| 1588 | - << std::endl; | 1586 | + << '\n'; |
| 1589 | node = parent; | 1587 | node = parent; |
| 1590 | } | 1588 | } |
| 1591 | - std::cout << " Fully qualified name: " << ffh.getFullyQualifiedName() << std::endl; | ||
| 1592 | - std::cout << " Partial name: " << ffh.getPartialName() << std::endl; | ||
| 1593 | - std::cout << " Alternative name: " << ffh.getAlternativeName() << std::endl; | ||
| 1594 | - std::cout << " Mapping name: " << ffh.getMappingName() << std::endl; | ||
| 1595 | - std::cout << " Field type: " << ffh.getFieldType() << std::endl; | ||
| 1596 | - std::cout << " Value: " << ffh.getValue().unparse() << std::endl; | ||
| 1597 | - std::cout << " Value as string: " << ffh.getValueAsString() << std::endl; | ||
| 1598 | - std::cout << " Default value: " << ffh.getDefaultValue().unparse() << std::endl; | ||
| 1599 | - std::cout << " Default value as string: " << ffh.getDefaultValueAsString() << std::endl; | ||
| 1600 | - std::cout << " Default appearance: " << ffh.getDefaultAppearance() << std::endl; | ||
| 1601 | - std::cout << " Quadding: " << ffh.getQuadding() << std::endl; | 1589 | + std::cout << " Fully qualified name: " << ffh.getFullyQualifiedName() << '\n'; |
| 1590 | + std::cout << " Partial name: " << ffh.getPartialName() << '\n'; | ||
| 1591 | + std::cout << " Alternative name: " << ffh.getAlternativeName() << '\n'; | ||
| 1592 | + std::cout << " Mapping name: " << ffh.getMappingName() << '\n'; | ||
| 1593 | + std::cout << " Field type: " << ffh.getFieldType() << '\n'; | ||
| 1594 | + std::cout << " Value: " << ffh.getValue().unparse() << '\n'; | ||
| 1595 | + std::cout << " Value as string: " << ffh.getValueAsString() << '\n'; | ||
| 1596 | + std::cout << " Default value: " << ffh.getDefaultValue().unparse() << '\n'; | ||
| 1597 | + std::cout << " Default value as string: " << ffh.getDefaultValueAsString() << '\n'; | ||
| 1598 | + std::cout << " Default appearance: " << ffh.getDefaultAppearance() << '\n'; | ||
| 1599 | + std::cout << " Quadding: " << ffh.getQuadding() << '\n'; | ||
| 1602 | std::vector<QPDFAnnotationObjectHelper> annotations = afdh.getAnnotationsForField(ffh); | 1600 | std::vector<QPDFAnnotationObjectHelper> annotations = afdh.getAnnotationsForField(ffh); |
| 1603 | for (auto& aoh: annotations) { | 1601 | for (auto& aoh: annotations) { |
| 1604 | - std::cout << " Annotation: " << aoh.getObjectHandle().unparse() << std::endl; | 1602 | + std::cout << " Annotation: " << aoh.getObjectHandle().unparse() << '\n'; |
| 1605 | } | 1603 | } |
| 1606 | } | 1604 | } |
| 1607 | std::cout << "iterating over annotations per page\n"; | 1605 | std::cout << "iterating over annotations per page\n"; |
| 1608 | for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) { | 1606 | for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) { |
| 1609 | - std::cout << "Page: " << page.getObjectHandle().unparse() << std::endl; | 1607 | + std::cout << "Page: " << page.getObjectHandle().unparse() << '\n'; |
| 1610 | for (auto& ah: afdh.getWidgetAnnotationsForPage(page)) { | 1608 | for (auto& ah: afdh.getWidgetAnnotationsForPage(page)) { |
| 1611 | - std::cout << " Annotation: " << ah.getObjectHandle().unparse() << std::endl; | 1609 | + std::cout << " Annotation: " << ah.getObjectHandle().unparse() << '\n'; |
| 1612 | std::cout << " Field: " | 1610 | std::cout << " Field: " |
| 1613 | - << (afdh.getFieldForAnnotation(ah).getObjectHandle().unparse()) << std::endl; | ||
| 1614 | - std::cout << " Subtype: " << ah.getSubtype() << std::endl; | 1611 | + << (afdh.getFieldForAnnotation(ah).getObjectHandle().unparse()) << '\n'; |
| 1612 | + std::cout << " Subtype: " << ah.getSubtype() << '\n'; | ||
| 1615 | std::cout << " Rect: "; | 1613 | std::cout << " Rect: "; |
| 1616 | print_rect(std::cout, ah.getRect()); | 1614 | print_rect(std::cout, ah.getRect()); |
| 1617 | - std::cout << std::endl; | 1615 | + std::cout << '\n'; |
| 1618 | std::string state = ah.getAppearanceState(); | 1616 | std::string state = ah.getAppearanceState(); |
| 1619 | if (!state.empty()) { | 1617 | if (!state.empty()) { |
| 1620 | - std::cout << " Appearance state: " << state << std::endl; | 1618 | + std::cout << " Appearance state: " << state << '\n'; |
| 1621 | } | 1619 | } |
| 1622 | std::cout << " Appearance stream (/N): " << ah.getAppearanceStream("/N").unparse() | 1620 | std::cout << " Appearance stream (/N): " << ah.getAppearanceStream("/N").unparse() |
| 1623 | - << std::endl; | 1621 | + << '\n'; |
| 1624 | std::cout << " Appearance stream (/N, /3): " | 1622 | std::cout << " Appearance stream (/N, /3): " |
| 1625 | - << ah.getAppearanceStream("/N", "/3").unparse() << std::endl; | 1623 | + << ah.getAppearanceStream("/N", "/3").unparse() << '\n'; |
| 1626 | } | 1624 | } |
| 1627 | } | 1625 | } |
| 1628 | } | 1626 | } |
| @@ -1637,7 +1635,7 @@ test_44(QPDF& pdf, char const* arg2) | @@ -1637,7 +1635,7 @@ test_44(QPDF& pdf, char const* arg2) | ||
| 1637 | // \xc3\xb7 is utf-8 for U+00F7 (divided by) | 1635 | // \xc3\xb7 is utf-8 for U+00F7 (divided by) |
| 1638 | field.setV("3.14 \xc3\xb7 0"); | 1636 | field.setV("3.14 \xc3\xb7 0"); |
| 1639 | std::cout << "Set field value: " << field.getFullyQualifiedName() << " -> " | 1637 | std::cout << "Set field value: " << field.getFullyQualifiedName() << " -> " |
| 1640 | - << field.getValueAsString() << std::endl; | 1638 | + << field.getValueAsString() << '\n'; |
| 1641 | } | 1639 | } |
| 1642 | } | 1640 | } |
| 1643 | QPDFWriter w(pdf, "a.pdf"); | 1641 | QPDFWriter w(pdf, "a.pdf"); |
| @@ -1669,11 +1667,11 @@ test_46(QPDF& pdf, char const* arg2) | @@ -1669,11 +1667,11 @@ test_46(QPDF& pdf, char const* arg2) | ||
| 1669 | QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest"); | 1667 | QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest"); |
| 1670 | QPDFNumberTreeObjectHelper ntoh(qtest, pdf); | 1668 | QPDFNumberTreeObjectHelper ntoh(qtest, pdf); |
| 1671 | for (auto& iter: ntoh) { | 1669 | for (auto& iter: ntoh) { |
| 1672 | - std::cout << iter.first << " " << iter.second.getStringValue() << std::endl; | 1670 | + std::cout << iter.first << " " << iter.second.getStringValue() << '\n'; |
| 1673 | } | 1671 | } |
| 1674 | QPDFNumberTreeObjectHelper::idx_map ntoh_map = ntoh.getAsMap(); | 1672 | QPDFNumberTreeObjectHelper::idx_map ntoh_map = ntoh.getAsMap(); |
| 1675 | for (auto& iter: ntoh_map) { | 1673 | for (auto& iter: ntoh_map) { |
| 1676 | - std::cout << iter.first << " " << iter.second.getStringValue() << std::endl; | 1674 | + std::cout << iter.first << " " << iter.second.getStringValue() << '\n'; |
| 1677 | } | 1675 | } |
| 1678 | assert(1 == ntoh.getMin()); | 1676 | assert(1 == ntoh.getMin()); |
| 1679 | assert(29 == ntoh.getMax()); | 1677 | assert(29 == ntoh.getMax()); |
| @@ -1719,7 +1717,7 @@ test_46(QPDF& pdf, char const* arg2) | @@ -1719,7 +1717,7 @@ test_46(QPDF& pdf, char const* arg2) | ||
| 1719 | --iter1; | 1717 | --iter1; |
| 1720 | assert(iter1->first == 2); | 1718 | assert(iter1->first == 2); |
| 1721 | 1719 | ||
| 1722 | - std::cout << "insertAfter" << std::endl; | 1720 | + std::cout << "insertAfter" << '\n'; |
| 1723 | auto new2 = QPDFNumberTreeObjectHelper::newEmpty(pdf); | 1721 | auto new2 = QPDFNumberTreeObjectHelper::newEmpty(pdf); |
| 1724 | auto iter2 = new2.begin(); | 1722 | auto iter2 = new2.begin(); |
| 1725 | assert(iter2 == new2.end()); | 1723 | assert(iter2 == new2.end()); |
| @@ -1728,23 +1726,23 @@ test_46(QPDF& pdf, char const* arg2) | @@ -1728,23 +1726,23 @@ test_46(QPDF& pdf, char const* arg2) | ||
| 1728 | iter2.insertAfter(4, QPDFObjectHandle::newString("4!")); | 1726 | iter2.insertAfter(4, QPDFObjectHandle::newString("4!")); |
| 1729 | assert(iter2->first == 4); | 1727 | assert(iter2->first == 4); |
| 1730 | for (auto& i: new2) { | 1728 | for (auto& i: new2) { |
| 1731 | - std::cout << i.first << " " << i.second.unparse() << std::endl; | 1729 | + std::cout << i.first << " " << i.second.unparse() << '\n'; |
| 1732 | } | 1730 | } |
| 1733 | 1731 | ||
| 1734 | - std::cout << "/Bad1" << std::endl; | 1732 | + std::cout << "/Bad1" << '\n'; |
| 1735 | auto bad1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf); | 1733 | auto bad1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf); |
| 1736 | assert(bad1.begin() == bad1.end()); | 1734 | assert(bad1.begin() == bad1.end()); |
| 1737 | assert(bad1.last() == bad1.end()); | 1735 | assert(bad1.last() == bad1.end()); |
| 1738 | 1736 | ||
| 1739 | - std::cout << "/Bad2" << std::endl; | 1737 | + std::cout << "/Bad2" << '\n'; |
| 1740 | auto bad2 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad2"), pdf); | 1738 | auto bad2 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad2"), pdf); |
| 1741 | for (auto& i: bad2) { | 1739 | for (auto& i: bad2) { |
| 1742 | - std::cout << i.first << " " << i.second.unparse() << std::endl; | 1740 | + std::cout << i.first << " " << i.second.unparse() << '\n'; |
| 1743 | } | 1741 | } |
| 1744 | 1742 | ||
| 1745 | std::vector<std::string> empties = {"/Empty1", "/Empty2"}; | 1743 | std::vector<std::string> empties = {"/Empty1", "/Empty2"}; |
| 1746 | for (auto const& k: empties) { | 1744 | for (auto const& k: empties) { |
| 1747 | - std::cout << k << std::endl; | 1745 | + std::cout << k << '\n'; |
| 1748 | auto empty = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey(k), pdf); | 1746 | auto empty = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey(k), pdf); |
| 1749 | assert(empty.begin() == empty.end()); | 1747 | assert(empty.begin() == empty.end()); |
| 1750 | assert(empty.last() == empty.end()); | 1748 | assert(empty.last() == empty.end()); |
| @@ -1765,37 +1763,37 @@ test_46(QPDF& pdf, char const* arg2) | @@ -1765,37 +1763,37 @@ test_46(QPDF& pdf, char const* arg2) | ||
| 1765 | assert(empty.last()->first == 6); | 1763 | assert(empty.last()->first == 6); |
| 1766 | assert(empty.last()->second.getStringValue() == "6"); | 1764 | assert(empty.last()->second.getStringValue() == "6"); |
| 1767 | } | 1765 | } |
| 1768 | - std::cout << "Insert into invalid" << std::endl; | 1766 | + std::cout << "Insert into invalid" << '\n'; |
| 1769 | auto invalid1 = QPDFNumberTreeObjectHelper(QPDFObjectHandle::newDictionary(), pdf); | 1767 | auto invalid1 = QPDFNumberTreeObjectHelper(QPDFObjectHandle::newDictionary(), pdf); |
| 1770 | try { | 1768 | try { |
| 1771 | invalid1.insert(1, QPDFObjectHandle::newNull()); | 1769 | invalid1.insert(1, QPDFObjectHandle::newNull()); |
| 1772 | } catch (QPDFExc& e) { | 1770 | } catch (QPDFExc& e) { |
| 1773 | - std::cout << e.what() << std::endl; | 1771 | + std::cout << e.what() << '\n'; |
| 1774 | } | 1772 | } |
| 1775 | 1773 | ||
| 1776 | - std::cout << "/Bad3, no repair" << std::endl; | 1774 | + std::cout << "/Bad3, no repair" << '\n'; |
| 1777 | auto bad3_oh = pdf.getTrailer().getKey("/Bad3"); | 1775 | auto bad3_oh = pdf.getTrailer().getKey("/Bad3"); |
| 1778 | auto bad3 = QPDFNumberTreeObjectHelper(bad3_oh, pdf, false); | 1776 | auto bad3 = QPDFNumberTreeObjectHelper(bad3_oh, pdf, false); |
| 1779 | for (auto& i: bad3) { | 1777 | for (auto& i: bad3) { |
| 1780 | - std::cout << i.first << " " << i.second.unparse() << std::endl; | 1778 | + std::cout << i.first << " " << i.second.unparse() << '\n'; |
| 1781 | } | 1779 | } |
| 1782 | assert(!bad3_oh.getKey("/Kids").getArrayItem(0).isIndirect()); | 1780 | assert(!bad3_oh.getKey("/Kids").getArrayItem(0).isIndirect()); |
| 1783 | 1781 | ||
| 1784 | - std::cout << "/Bad3, repair" << std::endl; | 1782 | + std::cout << "/Bad3, repair" << '\n'; |
| 1785 | bad3 = QPDFNumberTreeObjectHelper(bad3_oh, pdf, true); | 1783 | bad3 = QPDFNumberTreeObjectHelper(bad3_oh, pdf, true); |
| 1786 | for (auto& i: bad3) { | 1784 | for (auto& i: bad3) { |
| 1787 | - std::cout << i.first << " " << i.second.unparse() << std::endl; | 1785 | + std::cout << i.first << " " << i.second.unparse() << '\n'; |
| 1788 | } | 1786 | } |
| 1789 | assert(bad3_oh.getKey("/Kids").getArrayItem(0).isIndirect()); | 1787 | assert(bad3_oh.getKey("/Kids").getArrayItem(0).isIndirect()); |
| 1790 | 1788 | ||
| 1791 | - std::cout << "/Bad4 -- missing limits" << std::endl; | 1789 | + std::cout << "/Bad4 -- missing limits" << '\n'; |
| 1792 | auto bad4 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad4"), pdf); | 1790 | auto bad4 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad4"), pdf); |
| 1793 | bad4.insert(5, QPDFObjectHandle::newString("5")); | 1791 | bad4.insert(5, QPDFObjectHandle::newString("5")); |
| 1794 | for (auto& i: bad4) { | 1792 | for (auto& i: bad4) { |
| 1795 | - std::cout << i.first << " " << i.second.unparse() << std::endl; | 1793 | + std::cout << i.first << " " << i.second.unparse() << '\n'; |
| 1796 | } | 1794 | } |
| 1797 | 1795 | ||
| 1798 | - std::cout << "/Bad5 -- limit errors" << std::endl; | 1796 | + std::cout << "/Bad5 -- limit errors" << '\n'; |
| 1799 | auto bad5 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad5"), pdf); | 1797 | auto bad5 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad5"), pdf); |
| 1800 | assert(bad5.find(10) == bad5.end()); | 1798 | assert(bad5.find(10) == bad5.end()); |
| 1801 | } | 1799 | } |
| @@ -1810,7 +1808,7 @@ test_47(QPDF& pdf, char const* arg2) | @@ -1810,7 +1808,7 @@ test_47(QPDF& pdf, char const* arg2) | ||
| 1810 | pldh.getLabelsForPageRange(0, npages - 1, 1, labels); | 1808 | pldh.getLabelsForPageRange(0, npages - 1, 1, labels); |
| 1811 | assert(labels.size() % 2 == 0); | 1809 | assert(labels.size() % 2 == 0); |
| 1812 | for (size_t i = 0; i < labels.size(); i += 2) { | 1810 | for (size_t i = 0; i < labels.size(); i += 2) { |
| 1813 | - std::cout << labels.at(i).getIntValue() << " " << labels.at(i + 1).unparse() << std::endl; | 1811 | + std::cout << labels.at(i).getIntValue() << " " << labels.at(i + 1).unparse() << '\n'; |
| 1814 | } | 1812 | } |
| 1815 | } | 1813 | } |
| 1816 | 1814 | ||
| @@ -1822,11 +1820,11 @@ test_48(QPDF& pdf, char const* arg2) | @@ -1822,11 +1820,11 @@ test_48(QPDF& pdf, char const* arg2) | ||
| 1822 | QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest"); | 1820 | QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest"); |
| 1823 | QPDFNameTreeObjectHelper ntoh(qtest, pdf); | 1821 | QPDFNameTreeObjectHelper ntoh(qtest, pdf); |
| 1824 | for (auto& iter: ntoh) { | 1822 | for (auto& iter: ntoh) { |
| 1825 | - std::cout << iter.first << " -> " << iter.second.getStringValue() << std::endl; | 1823 | + std::cout << iter.first << " -> " << iter.second.getStringValue() << '\n'; |
| 1826 | } | 1824 | } |
| 1827 | std::map<std::string, QPDFObjectHandle> ntoh_map = ntoh.getAsMap(); | 1825 | std::map<std::string, QPDFObjectHandle> ntoh_map = ntoh.getAsMap(); |
| 1828 | for (auto& iter: ntoh_map) { | 1826 | for (auto& iter: ntoh_map) { |
| 1829 | - std::cout << iter.first << " -> " << iter.second.getStringValue() << std::endl; | 1827 | + std::cout << iter.first << " -> " << iter.second.getStringValue() << '\n'; |
| 1830 | } | 1828 | } |
| 1831 | assert(ntoh.hasName("11 elephant")); | 1829 | assert(ntoh.hasName("11 elephant")); |
| 1832 | assert(ntoh.hasName("07 sev\xe2\x80\xa2n")); | 1830 | assert(ntoh.hasName("07 sev\xe2\x80\xa2n")); |
| @@ -1869,7 +1867,7 @@ test_48(QPDF& pdf, char const* arg2) | @@ -1869,7 +1867,7 @@ test_48(QPDF& pdf, char const* arg2) | ||
| 1869 | --iter1; | 1867 | --iter1; |
| 1870 | assert(iter1->first == "2"); | 1868 | assert(iter1->first == "2"); |
| 1871 | 1869 | ||
| 1872 | - std::cout << "insertAfter" << std::endl; | 1870 | + std::cout << "insertAfter" << '\n'; |
| 1873 | auto new2 = QPDFNameTreeObjectHelper::newEmpty(pdf); | 1871 | auto new2 = QPDFNameTreeObjectHelper::newEmpty(pdf); |
| 1874 | auto iter2 = new2.begin(); | 1872 | auto iter2 = new2.begin(); |
| 1875 | assert(iter2 == new2.end()); | 1873 | assert(iter2 == new2.end()); |
| @@ -1878,12 +1876,12 @@ test_48(QPDF& pdf, char const* arg2) | @@ -1878,12 +1876,12 @@ test_48(QPDF& pdf, char const* arg2) | ||
| 1878 | iter2.insertAfter("4", QPDFObjectHandle::newString("4!")); | 1876 | iter2.insertAfter("4", QPDFObjectHandle::newString("4!")); |
| 1879 | assert(iter2->first == "4"); | 1877 | assert(iter2->first == "4"); |
| 1880 | for (auto& i: new2) { | 1878 | for (auto& i: new2) { |
| 1881 | - std::cout << i.first << " " << i.second.unparse() << std::endl; | 1879 | + std::cout << i.first << " " << i.second.unparse() << '\n'; |
| 1882 | } | 1880 | } |
| 1883 | 1881 | ||
| 1884 | std::vector<std::string> empties = {"/Empty1", "/Empty2"}; | 1882 | std::vector<std::string> empties = {"/Empty1", "/Empty2"}; |
| 1885 | for (auto const& k: empties) { | 1883 | for (auto const& k: empties) { |
| 1886 | - std::cout << k << std::endl; | 1884 | + std::cout << k << '\n'; |
| 1887 | auto empty = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey(k), pdf); | 1885 | auto empty = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey(k), pdf); |
| 1888 | assert(empty.begin() == empty.end()); | 1886 | assert(empty.begin() == empty.end()); |
| 1889 | assert(empty.last() == empty.end()); | 1887 | assert(empty.last() == empty.end()); |
| @@ -1905,36 +1903,36 @@ test_48(QPDF& pdf, char const* arg2) | @@ -1905,36 +1903,36 @@ test_48(QPDF& pdf, char const* arg2) | ||
| 1905 | assert(empty.last()->second.getStringValue() == "6"); | 1903 | assert(empty.last()->second.getStringValue() == "6"); |
| 1906 | } | 1904 | } |
| 1907 | 1905 | ||
| 1908 | - std::cout << "/Bad1 -- wrong key type" << std::endl; | 1906 | + std::cout << "/Bad1 -- wrong key type" << '\n'; |
| 1909 | auto bad1 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf); | 1907 | auto bad1 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf); |
| 1910 | assert(bad1.find("G", true)->first == "A"); | 1908 | assert(bad1.find("G", true)->first == "A"); |
| 1911 | for (auto const& i: bad1) { | 1909 | for (auto const& i: bad1) { |
| 1912 | - std::cout << i.first << std::endl; | 1910 | + std::cout << i.first << '\n'; |
| 1913 | } | 1911 | } |
| 1914 | 1912 | ||
| 1915 | - std::cout << "/Bad2 -- invalid kid" << std::endl; | 1913 | + std::cout << "/Bad2 -- invalid kid" << '\n'; |
| 1916 | auto bad2 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad2"), pdf); | 1914 | auto bad2 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad2"), pdf); |
| 1917 | assert(bad2.find("G", true)->first == "B"); | 1915 | assert(bad2.find("G", true)->first == "B"); |
| 1918 | for (auto const& i: bad2) { | 1916 | for (auto const& i: bad2) { |
| 1919 | - std::cout << i.first << std::endl; | 1917 | + std::cout << i.first << '\n'; |
| 1920 | } | 1918 | } |
| 1921 | 1919 | ||
| 1922 | - std::cout << "/Bad3 -- invalid kid" << std::endl; | 1920 | + std::cout << "/Bad3 -- invalid kid" << '\n'; |
| 1923 | auto bad3 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad3"), pdf); | 1921 | auto bad3 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad3"), pdf); |
| 1924 | assert(bad3.find("G", true) == bad3.end()); | 1922 | assert(bad3.find("G", true) == bad3.end()); |
| 1925 | 1923 | ||
| 1926 | - std::cout << "/Bad4 -- invalid kid" << std::endl; | 1924 | + std::cout << "/Bad4 -- invalid kid" << '\n'; |
| 1927 | auto bad4 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad4"), pdf); | 1925 | auto bad4 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad4"), pdf); |
| 1928 | assert(bad4.find("F", true)->first == "C"); | 1926 | assert(bad4.find("F", true)->first == "C"); |
| 1929 | for (auto const& i: bad4) { | 1927 | for (auto const& i: bad4) { |
| 1930 | - std::cout << i.first << std::endl; | 1928 | + std::cout << i.first << '\n'; |
| 1931 | } | 1929 | } |
| 1932 | 1930 | ||
| 1933 | - std::cout << "/Bad5 -- loop in find" << std::endl; | 1931 | + std::cout << "/Bad5 -- loop in find" << '\n'; |
| 1934 | auto bad5 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad5"), pdf); | 1932 | auto bad5 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad5"), pdf); |
| 1935 | assert(bad5.find("F", true)->first == "D"); | 1933 | assert(bad5.find("F", true)->first == "D"); |
| 1936 | 1934 | ||
| 1937 | - std::cout << "/Bad6 -- bad limits" << std::endl; | 1935 | + std::cout << "/Bad6 -- bad limits" << '\n'; |
| 1938 | auto bad6 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad6"), pdf); | 1936 | auto bad6 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Bad6"), pdf); |
| 1939 | assert(bad6.insert("H", QPDFObjectHandle::newNull())->first == "H"); | 1937 | assert(bad6.insert("H", QPDFObjectHandle::newNull())->first == "H"); |
| 1940 | } | 1938 | } |
| @@ -1949,7 +1947,7 @@ test_49(QPDF& pdf, char const* arg2) | @@ -1949,7 +1947,7 @@ test_49(QPDF& pdf, char const* arg2) | ||
| 1949 | auto outlines = odh.getOutlinesForPage(page.getObjectHandle().getObjGen()); | 1947 | auto outlines = odh.getOutlinesForPage(page.getObjectHandle().getObjGen()); |
| 1950 | for (auto& ol: outlines) { | 1948 | for (auto& ol: outlines) { |
| 1951 | std::cout << "page " << pageno << ": " << ol.getTitle() << " -> " | 1949 | std::cout << "page " << pageno << ": " << ol.getTitle() << " -> " |
| 1952 | - << ol.getDest().unparseResolved() << std::endl; | 1950 | + << ol.getDest().unparseResolved() << '\n'; |
| 1953 | } | 1951 | } |
| 1954 | ++pageno; | 1952 | ++pageno; |
| 1955 | } | 1953 | } |
| @@ -1963,11 +1961,11 @@ test_50(QPDF& pdf, char const* arg2) | @@ -1963,11 +1961,11 @@ test_50(QPDF& pdf, char const* arg2) | ||
| 1963 | QPDFObjectHandle d1 = pdf.getTrailer().getKey("/Dict1"); | 1961 | QPDFObjectHandle d1 = pdf.getTrailer().getKey("/Dict1"); |
| 1964 | QPDFObjectHandle d2 = pdf.getTrailer().getKey("/Dict2"); | 1962 | QPDFObjectHandle d2 = pdf.getTrailer().getKey("/Dict2"); |
| 1965 | d1.mergeResources(d2); | 1963 | d1.mergeResources(d2); |
| 1966 | - std::cout << d1.getJSON(JSON::LATEST).unparse() << std::endl; | 1964 | + std::cout << d1.getJSON(JSON::LATEST).unparse() << '\n'; |
| 1967 | // Top-level type mismatch | 1965 | // Top-level type mismatch |
| 1968 | d1.mergeResources(d2.getKey("/k1")); | 1966 | d1.mergeResources(d2.getKey("/k1")); |
| 1969 | for (auto const& name: d1.getResourceNames()) { | 1967 | for (auto const& name: d1.getResourceNames()) { |
| 1970 | - std::cout << name << std::endl; | 1968 | + std::cout << name << '\n'; |
| 1971 | } | 1969 | } |
| 1972 | } | 1970 | } |
| 1973 | 1971 | ||
| @@ -2047,10 +2045,10 @@ test_53(QPDF& pdf, char const* arg2) | @@ -2047,10 +2045,10 @@ test_53(QPDF& pdf, char const* arg2) | ||
| 2047 | QPDFObjectHandle root = pdf.getRoot(); | 2045 | QPDFObjectHandle root = pdf.getRoot(); |
| 2048 | auto new_obj = pdf.makeIndirectObject(QPDFObjectHandle::newString("potato")); | 2046 | auto new_obj = pdf.makeIndirectObject(QPDFObjectHandle::newString("potato")); |
| 2049 | root.replaceKey("/Q1", new_obj); | 2047 | root.replaceKey("/Q1", new_obj); |
| 2050 | - std::cout << "new object: " << new_obj.unparse() << std::endl; | ||
| 2051 | - std::cout << "all objects" << std::endl; | 2048 | + std::cout << "new object: " << new_obj.unparse() << '\n'; |
| 2049 | + std::cout << "all objects" << '\n'; | ||
| 2052 | for (auto& obj: pdf.getAllObjects()) { | 2050 | for (auto& obj: pdf.getAllObjects()) { |
| 2053 | - std::cout << obj.unparse() << std::endl; | 2051 | + std::cout << obj.unparse() << '\n'; |
| 2054 | } | 2052 | } |
| 2055 | 2053 | ||
| 2056 | QPDFWriter w(pdf, "a.pdf"); | 2054 | QPDFWriter w(pdf, "a.pdf"); |
| @@ -2068,7 +2066,7 @@ test_54(QPDF& pdf, char const* arg2) | @@ -2068,7 +2066,7 @@ test_54(QPDF& pdf, char const* arg2) | ||
| 2068 | assert(pdf.getPDFVersion() != "1.5"); | 2066 | assert(pdf.getPDFVersion() != "1.5"); |
| 2069 | w.setObjectStreamMode(qpdf_o_generate); | 2067 | w.setObjectStreamMode(qpdf_o_generate); |
| 2070 | if (w.getFinalVersion() != "1.5") { | 2068 | if (w.getFinalVersion() != "1.5") { |
| 2071 | - std::cout << "oops: " << w.getFinalVersion() << std::endl; | 2069 | + std::cout << "oops: " << w.getFinalVersion() << '\n'; |
| 2072 | } | 2070 | } |
| 2073 | } | 2071 | } |
| 2074 | 2072 | ||
| @@ -2193,11 +2191,11 @@ test_60(QPDF& pdf, char const* arg2) | @@ -2193,11 +2191,11 @@ test_60(QPDF& pdf, char const* arg2) | ||
| 2193 | 2191 | ||
| 2194 | std::map<std::string, std::map<std::string, std::string>> conflicts; | 2192 | std::map<std::string, std::map<std::string, std::string>> conflicts; |
| 2195 | auto show_conflicts = [&](std::string const& msg) { | 2193 | auto show_conflicts = [&](std::string const& msg) { |
| 2196 | - std::cout << msg << std::endl; | 2194 | + std::cout << msg << '\n'; |
| 2197 | for (auto const& i1: conflicts) { | 2195 | for (auto const& i1: conflicts) { |
| 2198 | - std::cout << i1.first << ":" << std::endl; | 2196 | + std::cout << i1.first << ":" << '\n'; |
| 2199 | for (auto const& i2: i1.second) { | 2197 | for (auto const& i2: i1.second) { |
| 2200 | - std::cout << " " << i2.first << " -> " << i2.second << std::endl; | 2198 | + std::cout << " " << i2.first << " -> " << i2.second << '\n'; |
| 2201 | } | 2199 | } |
| 2202 | } | 2200 | } |
| 2203 | }; | 2201 | }; |
| @@ -2242,22 +2240,22 @@ test_61(QPDF& pdf, char const* arg2) | @@ -2242,22 +2240,22 @@ test_61(QPDF& pdf, char const* arg2) | ||
| 2242 | try { | 2240 | try { |
| 2243 | pdf.processMemoryFile("empty", "", 0); | 2241 | pdf.processMemoryFile("empty", "", 0); |
| 2244 | } catch (QPDFExc const&) { | 2242 | } catch (QPDFExc const&) { |
| 2245 | - std::cout << "Caught QPDFExc as expected" << std::endl; | 2243 | + std::cout << "Caught QPDFExc as expected" << '\n'; |
| 2246 | } | 2244 | } |
| 2247 | try { | 2245 | try { |
| 2248 | QUtil::safe_fopen("/does/not/exist", "r"); | 2246 | QUtil::safe_fopen("/does/not/exist", "r"); |
| 2249 | } catch (QPDFSystemError const&) { | 2247 | } catch (QPDFSystemError const&) { |
| 2250 | - std::cout << "Caught QPDFSystemError as expected" << std::endl; | 2248 | + std::cout << "Caught QPDFSystemError as expected" << '\n'; |
| 2251 | } | 2249 | } |
| 2252 | try { | 2250 | try { |
| 2253 | QUtil::int_to_string_base(0, 12); | 2251 | QUtil::int_to_string_base(0, 12); |
| 2254 | } catch (std::logic_error const&) { | 2252 | } catch (std::logic_error const&) { |
| 2255 | - std::cout << "Caught logic_error as expected" << std::endl; | 2253 | + std::cout << "Caught logic_error as expected" << '\n'; |
| 2256 | } | 2254 | } |
| 2257 | try { | 2255 | try { |
| 2258 | QUtil::toUTF8(0xffffffff); | 2256 | QUtil::toUTF8(0xffffffff); |
| 2259 | } catch (std::runtime_error const&) { | 2257 | } catch (std::runtime_error const&) { |
| 2260 | - std::cout << "Caught runtime_error as expected" << std::endl; | 2258 | + std::cout << "Caught runtime_error as expected" << '\n'; |
| 2261 | } | 2259 | } |
| 2262 | 2260 | ||
| 2263 | // Spot check RTTI for dynamic cast. We intend to have pipelines | 2261 | // Spot check RTTI for dynamic cast. We intend to have pipelines |
| @@ -2389,18 +2387,18 @@ test_68(QPDF& pdf, char const* arg2) | @@ -2389,18 +2387,18 @@ test_68(QPDF& pdf, char const* arg2) | ||
| 2389 | QPDFObjectHandle qstream = root.getKey("/QStream"); | 2387 | QPDFObjectHandle qstream = root.getKey("/QStream"); |
| 2390 | try { | 2388 | try { |
| 2391 | qstream.getStreamData(); | 2389 | qstream.getStreamData(); |
| 2392 | - std::cout << "oops -- didn't throw" << std::endl; | 2390 | + std::cout << "oops -- didn't throw" << '\n'; |
| 2393 | } catch (std::exception& e) { | 2391 | } catch (std::exception& e) { |
| 2394 | - std::cout << "get unfilterable stream: " << e.what() << std::endl; | 2392 | + std::cout << "get unfilterable stream: " << e.what() << '\n'; |
| 2395 | } | 2393 | } |
| 2396 | std::shared_ptr<Buffer> b1 = qstream.getStreamData(qpdf_dl_all); | 2394 | std::shared_ptr<Buffer> b1 = qstream.getStreamData(qpdf_dl_all); |
| 2397 | if ((b1->getSize() > 10) && (memcmp(b1->getBuffer(), "wwwwwwwww", 9) == 0)) { | 2395 | if ((b1->getSize() > 10) && (memcmp(b1->getBuffer(), "wwwwwwwww", 9) == 0)) { |
| 2398 | - std::cout << "filtered stream data okay" << std::endl; | 2396 | + std::cout << "filtered stream data okay" << '\n'; |
| 2399 | } | 2397 | } |
| 2400 | std::shared_ptr<Buffer> b2 = qstream.getRawStreamData(); | 2398 | std::shared_ptr<Buffer> b2 = qstream.getRawStreamData(); |
| 2401 | if ((b2->getSize() > 10) && | 2399 | if ((b2->getSize() > 10) && |
| 2402 | (memcmp(b2->getBuffer(), "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46", 10) == 0)) { | 2400 | (memcmp(b2->getBuffer(), "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46", 10) == 0)) { |
| 2403 | - std::cout << "raw stream data okay" << std::endl; | 2401 | + std::cout << "raw stream data okay" << '\n'; |
| 2404 | } | 2402 | } |
| 2405 | } | 2403 | } |
| 2406 | 2404 | ||
| @@ -2436,42 +2434,42 @@ static void | @@ -2436,42 +2434,42 @@ static void | ||
| 2436 | test_71(QPDF& pdf, char const* arg2) | 2434 | test_71(QPDF& pdf, char const* arg2) |
| 2437 | { | 2435 | { |
| 2438 | auto show = [](QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key) { | 2436 | auto show = [](QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key) { |
| 2439 | - std::cout << xobj_dict.unparse() << " -> " << key << " -> " << obj.unparse() << std::endl; | 2437 | + std::cout << xobj_dict.unparse() << " -> " << key << " -> " << obj.unparse() << '\n'; |
| 2440 | }; | 2438 | }; |
| 2441 | auto page = QPDFPageDocumentHelper(pdf).getAllPages().at(0); | 2439 | auto page = QPDFPageDocumentHelper(pdf).getAllPages().at(0); |
| 2442 | - std::cout << "--- recursive, all ---" << std::endl; | 2440 | + std::cout << "--- recursive, all ---" << '\n'; |
| 2443 | page.forEachXObject(true, show); | 2441 | page.forEachXObject(true, show); |
| 2444 | - std::cout << "--- non-recursive, all ---" << std::endl; | 2442 | + std::cout << "--- non-recursive, all ---" << '\n'; |
| 2445 | page.forEachXObject(false, show); | 2443 | page.forEachXObject(false, show); |
| 2446 | - std::cout << "--- recursive, images ---" << std::endl; | 2444 | + std::cout << "--- recursive, images ---" << '\n'; |
| 2447 | page.forEachImage(true, show); | 2445 | page.forEachImage(true, show); |
| 2448 | - std::cout << "--- non-recursive, images ---" << std::endl; | 2446 | + std::cout << "--- non-recursive, images ---" << '\n'; |
| 2449 | page.forEachImage(false, show); | 2447 | page.forEachImage(false, show); |
| 2450 | - std::cout << "--- recursive, form XObjects ---" << std::endl; | 2448 | + std::cout << "--- recursive, form XObjects ---" << '\n'; |
| 2451 | page.forEachFormXObject(true, show); | 2449 | page.forEachFormXObject(true, show); |
| 2452 | - std::cout << "--- non-recursive, form XObjects ---" << std::endl; | 2450 | + std::cout << "--- non-recursive, form XObjects ---" << '\n'; |
| 2453 | page.forEachFormXObject(false, show); | 2451 | page.forEachFormXObject(false, show); |
| 2454 | auto fx1 = QPDFPageObjectHelper( | 2452 | auto fx1 = QPDFPageObjectHelper( |
| 2455 | page.getObjectHandle().getKey("/Resources").getKey("/XObject").getKey("/Fx1")); | 2453 | page.getObjectHandle().getKey("/Resources").getKey("/XObject").getKey("/Fx1")); |
| 2456 | - std::cout << "--- recursive, all, from fx1 ---" << std::endl; | 2454 | + std::cout << "--- recursive, all, from fx1 ---" << '\n'; |
| 2457 | fx1.forEachXObject(true, show); | 2455 | fx1.forEachXObject(true, show); |
| 2458 | - std::cout << "--- non-recursive, all, from fx1 ---" << std::endl; | 2456 | + std::cout << "--- non-recursive, all, from fx1 ---" << '\n'; |
| 2459 | fx1.forEachXObject(false, show); | 2457 | fx1.forEachXObject(false, show); |
| 2460 | - std::cout << "--- get images, page ---" << std::endl; | 2458 | + std::cout << "--- get images, page ---" << '\n'; |
| 2461 | for (auto& i: page.getImages()) { | 2459 | for (auto& i: page.getImages()) { |
| 2462 | - std::cout << i.first << " -> " << i.second.unparse() << std::endl; | 2460 | + std::cout << i.first << " -> " << i.second.unparse() << '\n'; |
| 2463 | } | 2461 | } |
| 2464 | - std::cout << "--- get images, fx ---" << std::endl; | 2462 | + std::cout << "--- get images, fx ---" << '\n'; |
| 2465 | for (auto& i: fx1.getImages()) { | 2463 | for (auto& i: fx1.getImages()) { |
| 2466 | - std::cout << i.first << " -> " << i.second.unparse() << std::endl; | 2464 | + std::cout << i.first << " -> " << i.second.unparse() << '\n'; |
| 2467 | } | 2465 | } |
| 2468 | - std::cout << "--- get form XObjects, page ---" << std::endl; | 2466 | + std::cout << "--- get form XObjects, page ---" << '\n'; |
| 2469 | for (auto& i: page.getFormXObjects()) { | 2467 | for (auto& i: page.getFormXObjects()) { |
| 2470 | - std::cout << i.first << " -> " << i.second.unparse() << std::endl; | 2468 | + std::cout << i.first << " -> " << i.second.unparse() << '\n'; |
| 2471 | } | 2469 | } |
| 2472 | - std::cout << "--- get form XObjects, fx ---" << std::endl; | 2470 | + std::cout << "--- get form XObjects, fx ---" << '\n'; |
| 2473 | for (auto& i: fx1.getFormXObjects()) { | 2471 | for (auto& i: fx1.getFormXObjects()) { |
| 2474 | - std::cout << i.first << " -> " << i.second.unparse() << std::endl; | 2472 | + std::cout << i.first << " -> " << i.second.unparse() << '\n'; |
| 2475 | } | 2473 | } |
| 2476 | } | 2474 | } |
| 2477 | 2475 | ||
| @@ -2482,7 +2480,7 @@ test_72(QPDF& pdf, char const* arg2) | @@ -2482,7 +2480,7 @@ test_72(QPDF& pdf, char const* arg2) | ||
| 2482 | auto page = QPDFPageDocumentHelper(pdf).getAllPages().at(0); | 2480 | auto page = QPDFPageDocumentHelper(pdf).getAllPages().at(0); |
| 2483 | auto fx1 = QPDFPageObjectHelper( | 2481 | auto fx1 = QPDFPageObjectHelper( |
| 2484 | page.getObjectHandle().getKey("/Resources").getKey("/XObject").getKey("/Fx1")); | 2482 | page.getObjectHandle().getKey("/Resources").getKey("/XObject").getKey("/Fx1")); |
| 2485 | - std::cout << "--- parseContents ---" << std::endl; | 2483 | + std::cout << "--- parseContents ---" << '\n'; |
| 2486 | ParserCallbacks cb; | 2484 | ParserCallbacks cb; |
| 2487 | fx1.parseContents(&cb); | 2485 | fx1.parseContents(&cb); |
| 2488 | // Do this once with addContentTokenFilter and once with | 2486 | // Do this once with addContentTokenFilter and once with |
| @@ -2511,7 +2509,7 @@ test_73(QPDF& pdf, char const* arg2) | @@ -2511,7 +2509,7 @@ test_73(QPDF& pdf, char const* arg2) | ||
| 2511 | QPDF pdf2; | 2509 | QPDF pdf2; |
| 2512 | pdf2.getRoot(); | 2510 | pdf2.getRoot(); |
| 2513 | } catch (std::exception& e) { | 2511 | } catch (std::exception& e) { |
| 2514 | - std::cerr << "getRoot: " << e.what() << std::endl; | 2512 | + std::cerr << "getRoot: " << e.what() << '\n'; |
| 2515 | } | 2513 | } |
| 2516 | 2514 | ||
| 2517 | pdf.closeInputSource(); | 2515 | pdf.closeInputSource(); |
| @@ -2522,7 +2520,7 @@ static void | @@ -2522,7 +2520,7 @@ static void | ||
| 2522 | test_74(QPDF& pdf, char const* arg2) | 2520 | test_74(QPDF& pdf, char const* arg2) |
| 2523 | { | 2521 | { |
| 2524 | // This test is crafted to work with split-nntree.pdf | 2522 | // This test is crafted to work with split-nntree.pdf |
| 2525 | - std::cout << "/Split1" << std::endl; | 2523 | + std::cout << "/Split1" << '\n'; |
| 2526 | auto split1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Split1"), pdf); | 2524 | auto split1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Split1"), pdf); |
| 2527 | split1.setSplitThreshold(4); | 2525 | split1.setSplitThreshold(4); |
| 2528 | auto check_split1 = [&split1](int k) { | 2526 | auto check_split1 = [&split1](int k) { |
| @@ -2533,10 +2531,10 @@ test_74(QPDF& pdf, char const* arg2) | @@ -2533,10 +2531,10 @@ test_74(QPDF& pdf, char const* arg2) | ||
| 2533 | check_split1(35); | 2531 | check_split1(35); |
| 2534 | check_split1(125); | 2532 | check_split1(125); |
| 2535 | for (auto const& i: split1) { | 2533 | for (auto const& i: split1) { |
| 2536 | - std::cout << i.first << std::endl; | 2534 | + std::cout << i.first << '\n'; |
| 2537 | } | 2535 | } |
| 2538 | 2536 | ||
| 2539 | - std::cout << "/Split2" << std::endl; | 2537 | + std::cout << "/Split2" << '\n'; |
| 2540 | auto split2 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Split2"), pdf); | 2538 | auto split2 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Split2"), pdf); |
| 2541 | split2.setSplitThreshold(4); | 2539 | split2.setSplitThreshold(4); |
| 2542 | auto check_split2 = [](QPDFNameTreeObjectHelper& noh, std::string const& k) { | 2540 | auto check_split2 = [](QPDFNameTreeObjectHelper& noh, std::string const& k) { |
| @@ -2545,16 +2543,16 @@ test_74(QPDF& pdf, char const* arg2) | @@ -2545,16 +2543,16 @@ test_74(QPDF& pdf, char const* arg2) | ||
| 2545 | }; | 2543 | }; |
| 2546 | check_split2(split2, "C"); | 2544 | check_split2(split2, "C"); |
| 2547 | for (auto const& i: split2) { | 2545 | for (auto const& i: split2) { |
| 2548 | - std::cout << i.first << std::endl; | 2546 | + std::cout << i.first << '\n'; |
| 2549 | } | 2547 | } |
| 2550 | 2548 | ||
| 2551 | - std::cout << "/Split3" << std::endl; | 2549 | + std::cout << "/Split3" << '\n'; |
| 2552 | auto split3 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Split3"), pdf); | 2550 | auto split3 = QPDFNameTreeObjectHelper(pdf.getTrailer().getKey("/Split3"), pdf); |
| 2553 | split3.setSplitThreshold(4); | 2551 | split3.setSplitThreshold(4); |
| 2554 | check_split2(split3, "P"); | 2552 | check_split2(split3, "P"); |
| 2555 | check_split2(split3, "\xcf\x80"); | 2553 | check_split2(split3, "\xcf\x80"); |
| 2556 | for (auto& i: split3) { | 2554 | for (auto& i: split3) { |
| 2557 | - std::cout << i.first << " " << i.second.unparse() << std::endl; | 2555 | + std::cout << i.first << " " << i.second.unparse() << '\n'; |
| 2558 | } | 2556 | } |
| 2559 | 2557 | ||
| 2560 | QPDFWriter w(pdf, "a.pdf"); | 2558 | QPDFWriter w(pdf, "a.pdf"); |
| @@ -2655,7 +2653,7 @@ test_76(QPDF& pdf, char const* arg2) | @@ -2655,7 +2653,7 @@ test_76(QPDF& pdf, char const* arg2) | ||
| 2655 | assert(QUtil::hex_encode(efs2.getChecksum()) == "2fce9c8228e360ba9b04a1bd1bf63d6b"); | 2653 | assert(QUtil::hex_encode(efs2.getChecksum()) == "2fce9c8228e360ba9b04a1bd1bf63d6b"); |
| 2656 | 2654 | ||
| 2657 | for (auto const& iter: efdh.getEmbeddedFiles()) { | 2655 | for (auto const& iter: efdh.getEmbeddedFiles()) { |
| 2658 | - std::cout << iter.first << " -> " << iter.second->getFilename() << std::endl; | 2656 | + std::cout << iter.first << " -> " << iter.second->getFilename() << '\n'; |
| 2659 | } | 2657 | } |
| 2660 | assert(efdh.getEmbeddedFile("att1")->getFilename() == "att1.txt"); | 2658 | assert(efdh.getEmbeddedFile("att1")->getFilename() == "att1.txt"); |
| 2661 | assert(!efdh.getEmbeddedFile("potato")); | 2659 | assert(!efdh.getEmbeddedFile("potato")); |
| @@ -2689,17 +2687,17 @@ test_78(QPDF& pdf, char const* arg2) | @@ -2689,17 +2687,17 @@ test_78(QPDF& pdf, char const* arg2) | ||
| 2689 | p->finish(); | 2687 | p->finish(); |
| 2690 | }; | 2688 | }; |
| 2691 | auto f2 = [](Pipeline* p, bool suppress_warnings, bool will_retry) { | 2689 | auto f2 = [](Pipeline* p, bool suppress_warnings, bool will_retry) { |
| 2692 | - std::cerr << "f2" << std::endl; | 2690 | + std::cerr << "f2" << '\n'; |
| 2693 | if (will_retry) { | 2691 | if (will_retry) { |
| 2694 | - std::cerr << "failing" << std::endl; | 2692 | + std::cerr << "failing" << '\n'; |
| 2695 | return false; | 2693 | return false; |
| 2696 | } | 2694 | } |
| 2697 | if (!suppress_warnings) { | 2695 | if (!suppress_warnings) { |
| 2698 | - std::cerr << "warning" << std::endl; | 2696 | + std::cerr << "warning" << '\n'; |
| 2699 | } | 2697 | } |
| 2700 | p->writeCStr("salad"); | 2698 | p->writeCStr("salad"); |
| 2701 | p->finish(); | 2699 | p->finish(); |
| 2702 | - std::cerr << "f2 done" << std::endl; | 2700 | + std::cerr << "f2 done" << '\n'; |
| 2703 | return true; | 2701 | return true; |
| 2704 | }; | 2702 | }; |
| 2705 | 2703 | ||
| @@ -2709,11 +2707,11 @@ test_78(QPDF& pdf, char const* arg2) | @@ -2709,11 +2707,11 @@ test_78(QPDF& pdf, char const* arg2) | ||
| 2709 | auto s2 = QPDFObjectHandle::newStream(&pdf); | 2707 | auto s2 = QPDFObjectHandle::newStream(&pdf); |
| 2710 | s2.replaceStreamData(f2, null, null); | 2708 | s2.replaceStreamData(f2, null, null); |
| 2711 | pdf.getTrailer().replaceKey("/Streams", QPDFObjectHandle::newArray({s1, s2})); | 2709 | pdf.getTrailer().replaceKey("/Streams", QPDFObjectHandle::newArray({s1, s2})); |
| 2712 | - std::cout << "piping with warning suppression" << std::endl; | 2710 | + std::cout << "piping with warning suppression" << '\n'; |
| 2713 | Pl_Discard d; | 2711 | Pl_Discard d; |
| 2714 | s2.pipeStreamData(&d, nullptr, 0, qpdf_dl_all, true, false); | 2712 | s2.pipeStreamData(&d, nullptr, 0, qpdf_dl_all, true, false); |
| 2715 | 2713 | ||
| 2716 | - std::cout << "writing" << std::endl; | 2714 | + std::cout << "writing" << '\n'; |
| 2717 | QPDFWriter w(pdf, "a.pdf"); | 2715 | QPDFWriter w(pdf, "a.pdf"); |
| 2718 | w.setStaticID(true); | 2716 | w.setStaticID(true); |
| 2719 | w.setQDFMode(true); | 2717 | w.setQDFMode(true); |
| @@ -2890,13 +2888,13 @@ test_83(QPDF& pdf, char const* arg2) | @@ -2890,13 +2888,13 @@ test_83(QPDF& pdf, char const* arg2) | ||
| 2890 | size_t size; | 2888 | size_t size; |
| 2891 | QUtil::read_file_into_memory(arg2, file_buf, size); | 2889 | QUtil::read_file_into_memory(arg2, file_buf, size); |
| 2892 | try { | 2890 | try { |
| 2893 | - std::cout << "calling initializeFromJson" << std::endl; | 2891 | + std::cout << "calling initializeFromJson" << '\n'; |
| 2894 | j.initializeFromJson(std::string(file_buf.get(), size)); | 2892 | j.initializeFromJson(std::string(file_buf.get(), size)); |
| 2895 | - std::cout << "called initializeFromJson" << std::endl; | 2893 | + std::cout << "called initializeFromJson" << '\n'; |
| 2896 | } catch (QPDFUsage& e) { | 2894 | } catch (QPDFUsage& e) { |
| 2897 | - std::cerr << "usage: " << e.what() << std::endl; | 2895 | + std::cerr << "usage: " << e.what() << '\n'; |
| 2898 | } catch (std::exception& e) { | 2896 | } catch (std::exception& e) { |
| 2899 | - std::cerr << "exception: " << e.what() << std::endl; | 2897 | + std::cerr << "exception: " << e.what() << '\n'; |
| 2900 | } | 2898 | } |
| 2901 | } | 2899 | } |
| 2902 | 2900 | ||
| @@ -2905,7 +2903,7 @@ test_84(QPDF& pdf, char const* arg2) | @@ -2905,7 +2903,7 @@ test_84(QPDF& pdf, char const* arg2) | ||
| 2905 | { | 2903 | { |
| 2906 | // Test QPDFJob API | 2904 | // Test QPDFJob API |
| 2907 | 2905 | ||
| 2908 | - std::cout << "normal" << std::endl; | 2906 | + std::cout << "normal" << '\n'; |
| 2909 | { | 2907 | { |
| 2910 | QPDFJob j; | 2908 | QPDFJob j; |
| 2911 | j.config() | 2909 | j.config() |
| @@ -2922,11 +2920,11 @@ test_84(QPDF& pdf, char const* arg2) | @@ -2922,11 +2920,11 @@ test_84(QPDF& pdf, char const* arg2) | ||
| 2922 | assert(j.getEncryptionStatus() == 0); | 2920 | assert(j.getEncryptionStatus() == 0); |
| 2923 | } | 2921 | } |
| 2924 | 2922 | ||
| 2925 | - std::cout << "custom progress reporter" << std::endl; | 2923 | + std::cout << "custom progress reporter" << '\n'; |
| 2926 | { | 2924 | { |
| 2927 | QPDFJob j; | 2925 | QPDFJob j; |
| 2928 | j.registerProgressReporter( | 2926 | j.registerProgressReporter( |
| 2929 | - [](int p) { std::cout << "custom write progress: " << p << "%" << std::endl; }); | 2927 | + [](int p) { std::cout << "custom write progress: " << p << "%" << '\n'; }); |
| 2930 | j.config() | 2928 | j.config() |
| 2931 | ->inputFile("minimal.pdf") | 2929 | ->inputFile("minimal.pdf") |
| 2932 | ->outputFile("a.pdf") | 2930 | ->outputFile("a.pdf") |
| @@ -2941,29 +2939,29 @@ test_84(QPDF& pdf, char const* arg2) | @@ -2941,29 +2939,29 @@ test_84(QPDF& pdf, char const* arg2) | ||
| 2941 | assert(j.getEncryptionStatus() == 0); | 2939 | assert(j.getEncryptionStatus() == 0); |
| 2942 | } | 2940 | } |
| 2943 | 2941 | ||
| 2944 | - std::cout << "error caught by check" << std::endl; | 2942 | + std::cout << "error caught by check" << '\n'; |
| 2945 | try { | 2943 | try { |
| 2946 | QPDFJob j; | 2944 | QPDFJob j; |
| 2947 | j.config()->outputFile("a.pdf")->qdf(); | 2945 | j.config()->outputFile("a.pdf")->qdf(); |
| 2948 | - std::cout << "finished config" << std::endl; | 2946 | + std::cout << "finished config" << '\n'; |
| 2949 | j.checkConfiguration(); | 2947 | j.checkConfiguration(); |
| 2950 | assert(false); | 2948 | assert(false); |
| 2951 | } catch (QPDFUsage& e) { | 2949 | } catch (QPDFUsage& e) { |
| 2952 | - std::cout << "usage: " << e.what() << std::endl; | 2950 | + std::cout << "usage: " << e.what() << '\n'; |
| 2953 | } | 2951 | } |
| 2954 | 2952 | ||
| 2955 | - std::cout << "error caught by run" << std::endl; | 2953 | + std::cout << "error caught by run" << '\n'; |
| 2956 | try { | 2954 | try { |
| 2957 | QPDFJob j; | 2955 | QPDFJob j; |
| 2958 | j.config()->outputFile("a.pdf")->qdf(); | 2956 | j.config()->outputFile("a.pdf")->qdf(); |
| 2959 | - std::cout << "finished config" << std::endl; | 2957 | + std::cout << "finished config" << '\n'; |
| 2960 | j.run(); | 2958 | j.run(); |
| 2961 | assert(false); | 2959 | assert(false); |
| 2962 | } catch (QPDFUsage& e) { | 2960 | } catch (QPDFUsage& e) { |
| 2963 | - std::cout << "usage: " << e.what() << std::endl; | 2961 | + std::cout << "usage: " << e.what() << '\n'; |
| 2964 | } | 2962 | } |
| 2965 | 2963 | ||
| 2966 | - std::cout << "output capture" << std::endl; | 2964 | + std::cout << "output capture" << '\n'; |
| 2967 | std::ostringstream cout; | 2965 | std::ostringstream cout; |
| 2968 | std::ostringstream cerr; | 2966 | std::ostringstream cerr; |
| 2969 | { | 2967 | { |
| @@ -2980,11 +2978,11 @@ test_84(QPDF& pdf, char const* arg2) | @@ -2980,11 +2978,11 @@ test_84(QPDF& pdf, char const* arg2) | ||
| 2980 | # pragma GCC diagnostic pop | 2978 | # pragma GCC diagnostic pop |
| 2981 | #endif | 2979 | #endif |
| 2982 | j.config()->inputFile("bad2.pdf")->showObject("4,0")->checkConfiguration(); | 2980 | j.config()->inputFile("bad2.pdf")->showObject("4,0")->checkConfiguration(); |
| 2983 | - std::cout << "calling run" << std::endl; | 2981 | + std::cout << "calling run" << '\n'; |
| 2984 | j.run(); | 2982 | j.run(); |
| 2985 | - std::cout << "captured stdout" << std::endl; | 2983 | + std::cout << "captured stdout" << '\n'; |
| 2986 | std::cout << cout.str(); | 2984 | std::cout << cout.str(); |
| 2987 | - std::cout << "captured stderr" << std::endl; | 2985 | + std::cout << "captured stderr" << '\n'; |
| 2988 | std::cout << cerr.str(); | 2986 | std::cout << cerr.str(); |
| 2989 | } | 2987 | } |
| 2990 | } | 2988 | } |
| @@ -3478,7 +3476,7 @@ test_99(QPDF& pdf, char const* arg2) | @@ -3478,7 +3476,7 @@ test_99(QPDF& pdf, char const* arg2) | ||
| 3478 | // Designed for no-space-compressed-object.pdf | 3476 | // Designed for no-space-compressed-object.pdf |
| 3479 | QPDFObjectHandle qtest = pdf.getRoot().getKey("/QTest"); | 3477 | QPDFObjectHandle qtest = pdf.getRoot().getKey("/QTest"); |
| 3480 | for (int i = 0; i < qtest.getArrayNItems(); ++i) { | 3478 | for (int i = 0; i < qtest.getArrayNItems(); ++i) { |
| 3481 | - std::cout << qtest.getArrayItem(i).unparseResolved() << std::endl; | 3479 | + std::cout << qtest.getArrayItem(i).unparseResolved() << '\n'; |
| 3482 | } | 3480 | } |
| 3483 | } | 3481 | } |
| 3484 | 3482 | ||
| @@ -3669,7 +3667,7 @@ runtest(int n, char const* filename1, char const* arg2) | @@ -3669,7 +3667,7 @@ runtest(int n, char const* filename1, char const* arg2) | ||
| 3669 | if (filep) { | 3667 | if (filep) { |
| 3670 | fclose(filep); | 3668 | fclose(filep); |
| 3671 | } | 3669 | } |
| 3672 | - std::cout << "test " << n << " done" << std::endl; | 3670 | + std::cout << "test " << n << " done" << '\n'; |
| 3673 | } | 3671 | } |
| 3674 | 3672 | ||
| 3675 | int | 3673 | int |
| @@ -3692,7 +3690,7 @@ main(int argc, char* argv[]) | @@ -3692,7 +3690,7 @@ main(int argc, char* argv[]) | ||
| 3692 | char const* arg2 = argv[3]; | 3690 | char const* arg2 = argv[3]; |
| 3693 | runtest(n, filename1, arg2); | 3691 | runtest(n, filename1, arg2); |
| 3694 | } catch (std::exception& e) { | 3692 | } catch (std::exception& e) { |
| 3695 | - std::cerr << e.what() << std::endl; | 3693 | + std::cerr << e.what() << '\n'; |
| 3696 | exit(2); | 3694 | exit(2); |
| 3697 | } | 3695 | } |
| 3698 | 3696 |
qpdf/test_large_file.cc
| @@ -94,7 +94,7 @@ void | @@ -94,7 +94,7 @@ void | ||
| 94 | ImageChecker::finish() | 94 | ImageChecker::finish() |
| 95 | { | 95 | { |
| 96 | if (!okay) { | 96 | if (!okay) { |
| 97 | - std::cout << "errors found checking image data for page " << n << std::endl; | 97 | + std::cout << "errors found checking image data for page " << n << '\n'; |
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| 100 | 100 | ||
| @@ -120,7 +120,7 @@ ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline) | @@ -120,7 +120,7 @@ ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline) | ||
| 120 | if (buf == nullptr) { | 120 | if (buf == nullptr) { |
| 121 | buf = new unsigned char[width * stripesize]; | 121 | buf = new unsigned char[width * stripesize]; |
| 122 | } | 122 | } |
| 123 | - std::cout << "page " << n << " of " << npages << std::endl; | 123 | + std::cout << "page " << n << " of " << npages << '\n'; |
| 124 | for (size_t y = 0; y < nstripes; ++y) { | 124 | for (size_t y = 0; y < nstripes; ++y) { |
| 125 | unsigned char color = get_pixel_color(n, y); | 125 | unsigned char color = get_pixel_color(n, y); |
| 126 | memset(buf, color, width * stripesize); | 126 | memset(buf, color, width * stripesize); |
| @@ -132,7 +132,7 @@ ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline) | @@ -132,7 +132,7 @@ ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline) | ||
| 132 | void | 132 | void |
| 133 | usage() | 133 | usage() |
| 134 | { | 134 | { |
| 135 | - std::cerr << "Usage: " << whoami << " {read|write} {large|small} outfile" << std::endl; | 135 | + std::cerr << "Usage: " << whoami << " {read|write} {large|small} outfile" << '\n'; |
| 136 | exit(2); | 136 | exit(2); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| @@ -247,7 +247,7 @@ check_page_contents(size_t pageno, QPDFObjectHandle page) | @@ -247,7 +247,7 @@ check_page_contents(size_t pageno, QPDFObjectHandle page) | ||
| 247 | std::string(reinterpret_cast<char*>(buf->getBuffer()), buf->getSize()); | 247 | std::string(reinterpret_cast<char*>(buf->getBuffer()), buf->getSize()); |
| 248 | std::string expected_contents = generate_page_contents(pageno); | 248 | std::string expected_contents = generate_page_contents(pageno); |
| 249 | if (expected_contents != actual_contents) { | 249 | if (expected_contents != actual_contents) { |
| 250 | - std::cout << "page contents wrong for page " << pageno << std::endl | 250 | + std::cout << "page contents wrong for page " << pageno << '\n' |
| 251 | << "ACTUAL: " << actual_contents << "EXPECTED: " << expected_contents << "----\n"; | 251 | << "ACTUAL: " << actual_contents << "EXPECTED: " << expected_contents << "----\n"; |
| 252 | } | 252 | } |
| 253 | } | 253 | } |
| @@ -269,7 +269,7 @@ check_pdf(char const* filename) | @@ -269,7 +269,7 @@ check_pdf(char const* filename) | ||
| 269 | assert(pages.size() == QIntC::to_size(npages)); | 269 | assert(pages.size() == QIntC::to_size(npages)); |
| 270 | for (size_t i = 0; i < npages; ++i) { | 270 | for (size_t i = 0; i < npages; ++i) { |
| 271 | size_t pageno = i + 1; | 271 | size_t pageno = i + 1; |
| 272 | - std::cout << "page " << pageno << " of " << npages << std::endl; | 272 | + std::cout << "page " << pageno << " of " << npages << '\n'; |
| 273 | check_page_contents(pageno, pages.at(i)); | 273 | check_page_contents(pageno, pages.at(i)); |
| 274 | check_image(pageno, pages.at(i)); | 274 | check_image(pageno, pages.at(i)); |
| 275 | } | 275 | } |
| @@ -316,7 +316,7 @@ main(int argc, char* argv[]) | @@ -316,7 +316,7 @@ main(int argc, char* argv[]) | ||
| 316 | check_pdf(filename); | 316 | check_pdf(filename); |
| 317 | } | 317 | } |
| 318 | } catch (std::exception& e) { | 318 | } catch (std::exception& e) { |
| 319 | - std::cerr << e.what() << std::endl; | 319 | + std::cerr << e.what() << '\n'; |
| 320 | exit(2); | 320 | exit(2); |
| 321 | } | 321 | } |
| 322 | 322 |
qpdf/test_many_nulls.cc
| @@ -10,7 +10,7 @@ main(int argc, char* argv[]) | @@ -10,7 +10,7 @@ main(int argc, char* argv[]) | ||
| 10 | { | 10 | { |
| 11 | auto whoami = QUtil::getWhoami(argv[0]); | 11 | auto whoami = QUtil::getWhoami(argv[0]); |
| 12 | if (argc != 2) { | 12 | if (argc != 2) { |
| 13 | - std::cerr << "Usage: " << whoami << " outfile.pdf" << std::endl; | 13 | + std::cerr << "Usage: " << whoami << " outfile.pdf" << '\n'; |
| 14 | exit(2); | 14 | exit(2); |
| 15 | } | 15 | } |
| 16 | char const* outfile = argv[1]; | 16 | char const* outfile = argv[1]; |
qpdf/test_parsedoffset.cc
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | void | 13 | void |
| 14 | usage() | 14 | usage() |
| 15 | { | 15 | { |
| 16 | - std::cerr << "Usage: test_parsedoffset INPUT.pdf" << std::endl; | 16 | + std::cerr << "Usage: test_parsedoffset INPUT.pdf" << '\n'; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | std::string | 19 | std::string |
| @@ -79,7 +79,7 @@ process(std::string fn, std::vector<std::vector<std::pair<qpdf_offset_t, std::st | @@ -79,7 +79,7 @@ process(std::string fn, std::vector<std::vector<std::pair<qpdf_offset_t, std::st | ||
| 79 | for (auto const& oh: qpdf.getAllObjects()) { | 79 | for (auto const& oh: qpdf.getAllObjects()) { |
| 80 | if (!xrefs.contains(oh.getObjGen())) { | 80 | if (!xrefs.contains(oh.getObjGen())) { |
| 81 | std::cerr << oh.getObjectID() << "/" << oh.getGeneration() | 81 | std::cerr << oh.getObjectID() << "/" << oh.getGeneration() |
| 82 | - << " is not found in xref table" << std::endl; | 82 | + << " is not found in xref table" << '\n'; |
| 83 | std::exit(2); | 83 | std::exit(2); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| @@ -89,7 +89,7 @@ process(std::string fn, std::vector<std::vector<std::pair<qpdf_offset_t, std::st | @@ -89,7 +89,7 @@ process(std::string fn, std::vector<std::vector<std::pair<qpdf_offset_t, std::st | ||
| 89 | switch (xref.getType()) { | 89 | switch (xref.getType()) { |
| 90 | case 0: | 90 | case 0: |
| 91 | std::cerr << oh.getObjectID() << "/" << oh.getGeneration() << " xref entry is free" | 91 | std::cerr << oh.getObjectID() << "/" << oh.getGeneration() << " xref entry is free" |
| 92 | - << std::endl; | 92 | + << '\n'; |
| 93 | std::exit(2); | 93 | std::exit(2); |
| 94 | case 1: | 94 | case 1: |
| 95 | stream_number = 0; | 95 | stream_number = 0; |
| @@ -98,7 +98,7 @@ process(std::string fn, std::vector<std::vector<std::pair<qpdf_offset_t, std::st | @@ -98,7 +98,7 @@ process(std::string fn, std::vector<std::vector<std::pair<qpdf_offset_t, std::st | ||
| 98 | stream_number = static_cast<size_t>(xref.getObjStreamNumber()); | 98 | stream_number = static_cast<size_t>(xref.getObjStreamNumber()); |
| 99 | break; | 99 | break; |
| 100 | default: | 100 | default: |
| 101 | - std::cerr << "unknown xref entry type" << std::endl; | 101 | + std::cerr << "unknown xref entry type" << '\n'; |
| 102 | std::exit(2); | 102 | std::exit(2); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| @@ -126,19 +126,19 @@ main(int argc, char* argv[]) | @@ -126,19 +126,19 @@ main(int argc, char* argv[]) | ||
| 126 | 126 | ||
| 127 | std::sort(table[i].begin(), table[i].end()); | 127 | std::sort(table[i].begin(), table[i].end()); |
| 128 | if (i == 0) { | 128 | if (i == 0) { |
| 129 | - std::cout << "--- objects not in streams ---" << std::endl; | 129 | + std::cout << "--- objects not in streams ---" << '\n'; |
| 130 | } else { | 130 | } else { |
| 131 | - std::cout << "--- objects in stream " << i << " ---" << std::endl; | 131 | + std::cout << "--- objects in stream " << i << " ---" << '\n'; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | for (auto const& iter: table[i]) { | 134 | for (auto const& iter: table[i]) { |
| 135 | - std::cout << iter.second << std::endl; | 135 | + std::cout << iter.second << '\n'; |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | - std::cout << "succeeded" << std::endl; | 139 | + std::cout << "succeeded" << '\n'; |
| 140 | } catch (std::exception& e) { | 140 | } catch (std::exception& e) { |
| 141 | - std::cerr << e.what() << std::endl; | 141 | + std::cerr << e.what() << '\n'; |
| 142 | std::exit(2); | 142 | std::exit(2); |
| 143 | } | 143 | } |
| 144 | 144 |
qpdf/test_pdf_doc_encoding.cc
| @@ -9,7 +9,7 @@ static char const* whoami = nullptr; | @@ -9,7 +9,7 @@ static char const* whoami = nullptr; | ||
| 9 | void | 9 | void |
| 10 | usage() | 10 | usage() |
| 11 | { | 11 | { |
| 12 | - std::cerr << "Usage: " << whoami << " infile" << std::endl; | 12 | + std::cerr << "Usage: " << whoami << " infile" << '\n'; |
| 13 | exit(2); | 13 | exit(2); |
| 14 | } | 14 | } |
| 15 | 15 | ||
| @@ -28,7 +28,7 @@ main(int argc, char* argv[]) | @@ -28,7 +28,7 @@ main(int argc, char* argv[]) | ||
| 28 | char const* infilename = argv[1]; | 28 | char const* infilename = argv[1]; |
| 29 | for (auto const& line: QUtil::read_lines_from_file(infilename)) { | 29 | for (auto const& line: QUtil::read_lines_from_file(infilename)) { |
| 30 | QPDFObjectHandle str = QPDFObjectHandle::newString(line); | 30 | QPDFObjectHandle str = QPDFObjectHandle::newString(line); |
| 31 | - std::cout << str.getUTF8Value() << std::endl; | 31 | + std::cout << str.getUTF8Value() << '\n'; |
| 32 | } | 32 | } |
| 33 | return 0; | 33 | return 0; |
| 34 | } | 34 | } |
qpdf/test_pdf_unicode.cc
| @@ -9,7 +9,7 @@ static char const* whoami = nullptr; | @@ -9,7 +9,7 @@ static char const* whoami = nullptr; | ||
| 9 | void | 9 | void |
| 10 | usage() | 10 | usage() |
| 11 | { | 11 | { |
| 12 | - std::cerr << "Usage: " << whoami << " infile" << std::endl; | 12 | + std::cerr << "Usage: " << whoami << " infile" << '\n'; |
| 13 | exit(2); | 13 | exit(2); |
| 14 | } | 14 | } |
| 15 | 15 | ||
| @@ -28,7 +28,7 @@ main(int argc, char* argv[]) | @@ -28,7 +28,7 @@ main(int argc, char* argv[]) | ||
| 28 | char const* infilename = argv[1]; | 28 | char const* infilename = argv[1]; |
| 29 | for (auto const& line: QUtil::read_lines_from_file(infilename)) { | 29 | for (auto const& line: QUtil::read_lines_from_file(infilename)) { |
| 30 | QPDFObjectHandle str = QPDFObjectHandle::newUnicodeString(line); | 30 | QPDFObjectHandle str = QPDFObjectHandle::newUnicodeString(line); |
| 31 | - std::cout << str.getUTF8Value() << " // " << str.unparseBinary() << std::endl; | 31 | + std::cout << str.getUTF8Value() << " // " << str.unparseBinary() << '\n'; |
| 32 | } | 32 | } |
| 33 | return 0; | 33 | return 0; |
| 34 | } | 34 | } |
qpdf/test_renumber.cc
| @@ -14,11 +14,11 @@ | @@ -14,11 +14,11 @@ | ||
| 14 | void | 14 | void |
| 15 | usage() | 15 | usage() |
| 16 | { | 16 | { |
| 17 | - std::cerr << "Usage: test_renumber [OPTION] INPUT.pdf" << std::endl | ||
| 18 | - << "Option:" << std::endl | ||
| 19 | - << " --object-streams=preserve|disable|generate" << std::endl | ||
| 20 | - << " --linearize" << std::endl | ||
| 21 | - << " --preserve-unreferenced" << std::endl; | 17 | + std::cerr << "Usage: test_renumber [OPTION] INPUT.pdf" << '\n' |
| 18 | + << "Option:" << '\n' | ||
| 19 | + << " --object-streams=preserve|disable|generate" << '\n' | ||
| 20 | + << " --linearize" << '\n' | ||
| 21 | + << " --preserve-unreferenced" << '\n'; | ||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | bool | 24 | bool |
| @@ -33,38 +33,38 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b) | @@ -33,38 +33,38 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b) | ||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | if (a.getTypeCode() != b.getTypeCode()) { | 35 | if (a.getTypeCode() != b.getTypeCode()) { |
| 36 | - std::cerr << "different type code" << std::endl; | 36 | + std::cerr << "different type code" << '\n'; |
| 37 | return false; | 37 | return false; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | switch (a.getTypeCode()) { | 40 | switch (a.getTypeCode()) { |
| 41 | case ::ot_boolean: | 41 | case ::ot_boolean: |
| 42 | if (a.getBoolValue() != b.getBoolValue()) { | 42 | if (a.getBoolValue() != b.getBoolValue()) { |
| 43 | - std::cerr << "different boolean" << std::endl; | 43 | + std::cerr << "different boolean" << '\n'; |
| 44 | return false; | 44 | return false; |
| 45 | } | 45 | } |
| 46 | break; | 46 | break; |
| 47 | case ::ot_integer: | 47 | case ::ot_integer: |
| 48 | if (a.getIntValue() != b.getIntValue()) { | 48 | if (a.getIntValue() != b.getIntValue()) { |
| 49 | - std::cerr << "different integer" << std::endl; | 49 | + std::cerr << "different integer" << '\n'; |
| 50 | return false; | 50 | return false; |
| 51 | } | 51 | } |
| 52 | break; | 52 | break; |
| 53 | case ::ot_real: | 53 | case ::ot_real: |
| 54 | if (a.getRealValue() != b.getRealValue()) { | 54 | if (a.getRealValue() != b.getRealValue()) { |
| 55 | - std::cerr << "different real" << std::endl; | 55 | + std::cerr << "different real" << '\n'; |
| 56 | return false; | 56 | return false; |
| 57 | } | 57 | } |
| 58 | break; | 58 | break; |
| 59 | case ::ot_string: | 59 | case ::ot_string: |
| 60 | if (a.getStringValue() != b.getStringValue()) { | 60 | if (a.getStringValue() != b.getStringValue()) { |
| 61 | - std::cerr << "different string" << std::endl; | 61 | + std::cerr << "different string" << '\n'; |
| 62 | return false; | 62 | return false; |
| 63 | } | 63 | } |
| 64 | break; | 64 | break; |
| 65 | case ::ot_name: | 65 | case ::ot_name: |
| 66 | if (a.getName() != b.getName()) { | 66 | if (a.getName() != b.getName()) { |
| 67 | - std::cerr << "different name" << std::endl; | 67 | + std::cerr << "different name" << '\n'; |
| 68 | return false; | 68 | return false; |
| 69 | } | 69 | } |
| 70 | break; | 70 | break; |
| @@ -74,13 +74,13 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b) | @@ -74,13 +74,13 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b) | ||
| 74 | std::vector<QPDFObjectHandle> objs_b = b.getArrayAsVector(); | 74 | std::vector<QPDFObjectHandle> objs_b = b.getArrayAsVector(); |
| 75 | size_t items = objs_a.size(); | 75 | size_t items = objs_a.size(); |
| 76 | if (items != objs_b.size()) { | 76 | if (items != objs_b.size()) { |
| 77 | - std::cerr << "different array size" << std::endl; | 77 | + std::cerr << "different array size" << '\n'; |
| 78 | return false; | 78 | return false; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | for (size_t i = 0; i < items; ++i) { | 81 | for (size_t i = 0; i < items; ++i) { |
| 82 | if (!compare(objs_a[i], objs_b[i])) { | 82 | if (!compare(objs_a[i], objs_b[i])) { |
| 83 | - std::cerr << "different array item" << std::endl; | 83 | + std::cerr << "different array item" << '\n'; |
| 84 | return false; | 84 | return false; |
| 85 | } | 85 | } |
| 86 | } | 86 | } |
| @@ -91,13 +91,13 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b) | @@ -91,13 +91,13 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b) | ||
| 91 | std::set<std::string> keys_a = a.getKeys(); | 91 | std::set<std::string> keys_a = a.getKeys(); |
| 92 | std::set<std::string> keys_b = b.getKeys(); | 92 | std::set<std::string> keys_b = b.getKeys(); |
| 93 | if (keys_a != keys_b) { | 93 | if (keys_a != keys_b) { |
| 94 | - std::cerr << "different dictionary keys" << std::endl; | 94 | + std::cerr << "different dictionary keys" << '\n'; |
| 95 | return false; | 95 | return false; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | for (auto const& key: keys_a) { | 98 | for (auto const& key: keys_a) { |
| 99 | if (!compare(a.getKey(key), b.getKey(key))) { | 99 | if (!compare(a.getKey(key), b.getKey(key))) { |
| 100 | - std::cerr << "different dictionary item" << std::endl; | 100 | + std::cerr << "different dictionary item" << '\n'; |
| 101 | return false; | 101 | return false; |
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| @@ -106,10 +106,10 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b) | @@ -106,10 +106,10 @@ compare(QPDFObjectHandle a, QPDFObjectHandle b) | ||
| 106 | case ::ot_null: | 106 | case ::ot_null: |
| 107 | break; | 107 | break; |
| 108 | case ::ot_stream: | 108 | case ::ot_stream: |
| 109 | - std::cout << "stream objects are not compared" << std::endl; | 109 | + std::cout << "stream objects are not compared" << '\n'; |
| 110 | break; | 110 | break; |
| 111 | default: | 111 | default: |
| 112 | - std::cerr << "unknown object type" << std::endl; | 112 | + std::cerr << "unknown object type" << '\n'; |
| 113 | std::exit(2); | 113 | std::exit(2); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| @@ -120,23 +120,22 @@ bool | @@ -120,23 +120,22 @@ bool | ||
| 120 | compare_xref_table(std::map<QPDFObjGen, QPDFXRefEntry> a, std::map<QPDFObjGen, QPDFXRefEntry> b) | 120 | compare_xref_table(std::map<QPDFObjGen, QPDFXRefEntry> a, std::map<QPDFObjGen, QPDFXRefEntry> b) |
| 121 | { | 121 | { |
| 122 | if (a.size() != b.size()) { | 122 | if (a.size() != b.size()) { |
| 123 | - std::cerr << "different size" << std::endl; | 123 | + std::cerr << "different size" << '\n'; |
| 124 | return false; | 124 | return false; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | for (auto const& iter: a) { | 127 | for (auto const& iter: a) { |
| 128 | - std::cout << "xref entry for " << iter.first.getObj() << "/" << iter.first.getGen() | ||
| 129 | - << std::endl; | 128 | + std::cout << "xref entry for " << iter.first.getObj() << "/" << iter.first.getGen() << '\n'; |
| 130 | 129 | ||
| 131 | if (!b.contains(iter.first)) { | 130 | if (!b.contains(iter.first)) { |
| 132 | - std::cerr << "not found" << std::endl; | 131 | + std::cerr << "not found" << '\n'; |
| 133 | return false; | 132 | return false; |
| 134 | } | 133 | } |
| 135 | 134 | ||
| 136 | QPDFXRefEntry xref_a = iter.second; | 135 | QPDFXRefEntry xref_a = iter.second; |
| 137 | QPDFXRefEntry xref_b = b[iter.first]; | 136 | QPDFXRefEntry xref_b = b[iter.first]; |
| 138 | if (xref_a.getType() != xref_b.getType()) { | 137 | if (xref_a.getType() != xref_b.getType()) { |
| 139 | - std::cerr << "different xref entry type" << std::endl; | 138 | + std::cerr << "different xref entry type" << '\n'; |
| 140 | return false; | 139 | return false; |
| 141 | } | 140 | } |
| 142 | 141 | ||
| @@ -145,19 +144,19 @@ compare_xref_table(std::map<QPDFObjGen, QPDFXRefEntry> a, std::map<QPDFObjGen, Q | @@ -145,19 +144,19 @@ compare_xref_table(std::map<QPDFObjGen, QPDFXRefEntry> a, std::map<QPDFObjGen, Q | ||
| 145 | break; | 144 | break; |
| 146 | case 1: | 145 | case 1: |
| 147 | if (xref_a.getOffset() != xref_a.getOffset()) { | 146 | if (xref_a.getOffset() != xref_a.getOffset()) { |
| 148 | - std::cerr << "different offset" << std::endl; | 147 | + std::cerr << "different offset" << '\n'; |
| 149 | return false; | 148 | return false; |
| 150 | } | 149 | } |
| 151 | break; | 150 | break; |
| 152 | case 2: | 151 | case 2: |
| 153 | if (xref_a.getObjStreamNumber() != xref_a.getObjStreamNumber() || | 152 | if (xref_a.getObjStreamNumber() != xref_a.getObjStreamNumber() || |
| 154 | xref_a.getObjStreamIndex() != xref_a.getObjStreamIndex()) { | 153 | xref_a.getObjStreamIndex() != xref_a.getObjStreamIndex()) { |
| 155 | - std::cerr << "different stream number or index" << std::endl; | 154 | + std::cerr << "different stream number or index" << '\n'; |
| 156 | return false; | 155 | return false; |
| 157 | } | 156 | } |
| 158 | break; | 157 | break; |
| 159 | default: | 158 | default: |
| 160 | - std::cerr << "unknown xref entry type" << std::endl; | 159 | + std::cerr << "unknown xref entry type" << '\n'; |
| 161 | std::exit(2); | 160 | std::exit(2); |
| 162 | } | 161 | } |
| 163 | } | 162 | } |
| @@ -223,36 +222,36 @@ main(int argc, char* argv[]) | @@ -223,36 +222,36 @@ main(int argc, char* argv[]) | ||
| 223 | "renumbered", reinterpret_cast<char*>(buf->getBuffer()), buf->getSize()); | 222 | "renumbered", reinterpret_cast<char*>(buf->getBuffer()), buf->getSize()); |
| 224 | std::map<QPDFObjGen, QPDFXRefEntry> xrefs_ren = qpdf_ren.getXRefTable(); | 223 | std::map<QPDFObjGen, QPDFXRefEntry> xrefs_ren = qpdf_ren.getXRefTable(); |
| 225 | 224 | ||
| 226 | - std::cout << "--- compare between input and renumbered objects ---" << std::endl; | 225 | + std::cout << "--- compare between input and renumbered objects ---" << '\n'; |
| 227 | for (auto const& iter: objs_in) { | 226 | for (auto const& iter: objs_in) { |
| 228 | QPDFObjGen og_in = iter.getObjGen(); | 227 | QPDFObjGen og_in = iter.getObjGen(); |
| 229 | QPDFObjGen og_ren = w.getRenumberedObjGen(og_in); | 228 | QPDFObjGen og_ren = w.getRenumberedObjGen(og_in); |
| 230 | 229 | ||
| 231 | std::cout << "input " << og_in.getObj() << "/" << og_in.getGen() << " -> renumbered " | 230 | std::cout << "input " << og_in.getObj() << "/" << og_in.getGen() << " -> renumbered " |
| 232 | - << og_ren.getObj() << "/" << og_ren.getGen() << std::endl; | 231 | + << og_ren.getObj() << "/" << og_ren.getGen() << '\n'; |
| 233 | 232 | ||
| 234 | if (og_ren.getObj() == 0) { | 233 | if (og_ren.getObj() == 0) { |
| 235 | - std::cout << "deleted" << std::endl; | 234 | + std::cout << "deleted" << '\n'; |
| 236 | continue; | 235 | continue; |
| 237 | } | 236 | } |
| 238 | 237 | ||
| 239 | if (!compare(iter, qpdf_ren.getObjectByObjGen(og_ren))) { | 238 | if (!compare(iter, qpdf_ren.getObjectByObjGen(og_ren))) { |
| 240 | - std::cerr << "different" << std::endl; | 239 | + std::cerr << "different" << '\n'; |
| 241 | std::exit(2); | 240 | std::exit(2); |
| 242 | } | 241 | } |
| 243 | } | 242 | } |
| 244 | - std::cout << "complete" << std::endl; | 243 | + std::cout << "complete" << '\n'; |
| 245 | 244 | ||
| 246 | - std::cout << "--- compare between written and reloaded xref tables ---" << std::endl; | 245 | + std::cout << "--- compare between written and reloaded xref tables ---" << '\n'; |
| 247 | if (!compare_xref_table(xrefs_w, xrefs_ren)) { | 246 | if (!compare_xref_table(xrefs_w, xrefs_ren)) { |
| 248 | - std::cerr << "different" << std::endl; | 247 | + std::cerr << "different" << '\n'; |
| 249 | std::exit(2); | 248 | std::exit(2); |
| 250 | } | 249 | } |
| 251 | - std::cout << "complete" << std::endl; | 250 | + std::cout << "complete" << '\n'; |
| 252 | 251 | ||
| 253 | - std::cout << "succeeded" << std::endl; | 252 | + std::cout << "succeeded" << '\n'; |
| 254 | } catch (std::exception& e) { | 253 | } catch (std::exception& e) { |
| 255 | - std::cerr << e.what() << std::endl; | 254 | + std::cerr << e.what() << '\n'; |
| 256 | std::exit(2); | 255 | std::exit(2); |
| 257 | } | 256 | } |
| 258 | 257 |
qpdf/test_shell_glob.cc
| @@ -32,11 +32,11 @@ realmain(int argc, char* argv[]) | @@ -32,11 +32,11 @@ realmain(int argc, char* argv[]) | ||
| 32 | bool passed = (found_star && (argc == 2)); | 32 | bool passed = (found_star && (argc == 2)); |
| 33 | #endif | 33 | #endif |
| 34 | if (passed) { | 34 | if (passed) { |
| 35 | - std::cout << "PASSED" << std::endl; | 35 | + std::cout << "PASSED" << '\n'; |
| 36 | } else { | 36 | } else { |
| 37 | - std::cout << "FAILED" << std::endl; | 37 | + std::cout << "FAILED" << '\n'; |
| 38 | for (int i = 1; i < argc; ++i) { | 38 | for (int i = 1; i < argc; ++i) { |
| 39 | - std::cout << argv[i] << std::endl; | 39 | + std::cout << argv[i] << '\n'; |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | return 0; | 42 | return 0; |
qpdf/test_tokenizer.cc
| @@ -16,7 +16,7 @@ static char const* whoami = nullptr; | @@ -16,7 +16,7 @@ static char const* whoami = nullptr; | ||
| 16 | void | 16 | void |
| 17 | usage() | 17 | usage() |
| 18 | { | 18 | { |
| 19 | - std::cerr << "Usage: " << whoami << " [-maxlen len | -no-ignorable] filename" << std::endl; | 19 | + std::cerr << "Usage: " << whoami << " [-maxlen len | -no-ignorable] filename" << '\n'; |
| 20 | exit(2); | 20 | exit(2); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| @@ -115,10 +115,10 @@ try_skipping( | @@ -115,10 +115,10 @@ try_skipping( | ||
| 115 | char const* what, | 115 | char const* what, |
| 116 | Finder& f) | 116 | Finder& f) |
| 117 | { | 117 | { |
| 118 | - std::cout << "skipping to " << what << std::endl; | 118 | + std::cout << "skipping to " << what << '\n'; |
| 119 | qpdf_offset_t offset = is->tell(); | 119 | qpdf_offset_t offset = is->tell(); |
| 120 | if (!is->findFirst(what, offset, 0, f)) { | 120 | if (!is->findFirst(what, offset, 0, f)) { |
| 121 | - std::cout << what << " not found" << std::endl; | 121 | + std::cout << what << " not found" << '\n'; |
| 122 | is->seek(offset, SEEK_SET); | 122 | is->seek(offset, SEEK_SET); |
| 123 | } | 123 | } |
| 124 | } | 124 | } |
| @@ -133,7 +133,7 @@ dump_tokens( | @@ -133,7 +133,7 @@ dump_tokens( | ||
| 133 | bool skip_inline_images) | 133 | bool skip_inline_images) |
| 134 | { | 134 | { |
| 135 | Finder f1(is, "endstream"); | 135 | Finder f1(is, "endstream"); |
| 136 | - std::cout << "--- BEGIN " << label << " ---" << std::endl; | 136 | + std::cout << "--- BEGIN " << label << " ---" << '\n'; |
| 137 | bool done = false; | 137 | bool done = false; |
| 138 | QPDFTokenizer tokenizer; | 138 | QPDFTokenizer tokenizer; |
| 139 | tokenizer.allowEOF(); | 139 | tokenizer.allowEOF(); |
| @@ -145,7 +145,7 @@ dump_tokens( | @@ -145,7 +145,7 @@ dump_tokens( | ||
| 145 | QPDFTokenizer::Token token = | 145 | QPDFTokenizer::Token token = |
| 146 | tokenizer.readToken(is, "test", true, inline_image_offset ? 0 : max_len); | 146 | tokenizer.readToken(is, "test", true, inline_image_offset ? 0 : max_len); |
| 147 | if (inline_image_offset && (token.getType() == QPDFTokenizer::tt_bad)) { | 147 | if (inline_image_offset && (token.getType() == QPDFTokenizer::tt_bad)) { |
| 148 | - std::cout << "EI not found; resuming normal scanning" << std::endl; | 148 | + std::cout << "EI not found; resuming normal scanning" << '\n'; |
| 149 | is->seek(inline_image_offset, SEEK_SET); | 149 | is->seek(inline_image_offset, SEEK_SET); |
| 150 | inline_image_offset = 0; | 150 | inline_image_offset = 0; |
| 151 | continue; | 151 | continue; |
| @@ -163,7 +163,7 @@ dump_tokens( | @@ -163,7 +163,7 @@ dump_tokens( | ||
| 163 | if (!token.getErrorMessage().empty()) { | 163 | if (!token.getErrorMessage().empty()) { |
| 164 | std::cout << " (" << token.getErrorMessage() << ")"; | 164 | std::cout << " (" << token.getErrorMessage() << ")"; |
| 165 | } | 165 | } |
| 166 | - std::cout << std::endl; | 166 | + std::cout << '\n'; |
| 167 | if (skip_streams && (token == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "stream"))) { | 167 | if (skip_streams && (token == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "stream"))) { |
| 168 | try_skipping(tokenizer, is, max_len, "endstream", f1); | 168 | try_skipping(tokenizer, is, max_len, "endstream", f1); |
| 169 | } else if ( | 169 | } else if ( |
| @@ -176,7 +176,7 @@ dump_tokens( | @@ -176,7 +176,7 @@ dump_tokens( | ||
| 176 | done = true; | 176 | done = true; |
| 177 | } | 177 | } |
| 178 | } | 178 | } |
| 179 | - std::cout << "--- END " << label << " ---" << std::endl; | 179 | + std::cout << "--- END " << label << " ---" << '\n'; |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | static void | 182 | static void |
qpdf/test_unicode_filenames.cc
| @@ -13,7 +13,7 @@ static void | @@ -13,7 +13,7 @@ static void | ||
| 13 | do_copy(FILE* in, FILE* out) | 13 | do_copy(FILE* in, FILE* out) |
| 14 | { | 14 | { |
| 15 | if ((in == nullptr) || (out == nullptr)) { | 15 | if ((in == nullptr) || (out == nullptr)) { |
| 16 | - std::cerr << "errors opening files" << std::endl; | 16 | + std::cerr << "errors opening files" << '\n'; |
| 17 | exit(2); | 17 | exit(2); |
| 18 | } | 18 | } |
| 19 | char buf[10240]; | 19 | char buf[10240]; |
| @@ -22,7 +22,7 @@ do_copy(FILE* in, FILE* out) | @@ -22,7 +22,7 @@ do_copy(FILE* in, FILE* out) | ||
| 22 | fwrite(buf, 1, len, out); | 22 | fwrite(buf, 1, len, out); |
| 23 | } | 23 | } |
| 24 | if (len != 0) { | 24 | if (len != 0) { |
| 25 | - std::cerr << "errors reading or writing" << std::endl; | 25 | + std::cerr << "errors reading or writing" << '\n'; |
| 26 | exit(2); | 26 | exit(2); |
| 27 | } | 27 | } |
| 28 | fclose(in); | 28 | fclose(in); |
| @@ -76,7 +76,7 @@ main(int argc, char* argv[]) | @@ -76,7 +76,7 @@ main(int argc, char* argv[]) | ||
| 76 | char const* f2 = "auto-\xc3\xb6\xcf\x80.pdf"; | 76 | char const* f2 = "auto-\xc3\xb6\xcf\x80.pdf"; |
| 77 | copy(f1); | 77 | copy(f1); |
| 78 | copy(f2); | 78 | copy(f2); |
| 79 | - std::cout << "created Unicode filenames" << std::endl; | 79 | + std::cout << "created Unicode filenames" << '\n'; |
| 80 | return 0; | 80 | return 0; |
| 81 | } | 81 | } |
| 82 | 82 |
qpdf/test_xref.cc
| @@ -8,7 +8,7 @@ int | @@ -8,7 +8,7 @@ int | ||
| 8 | main(int argc, char* argv[]) | 8 | main(int argc, char* argv[]) |
| 9 | { | 9 | { |
| 10 | if (argc != 2) { | 10 | if (argc != 2) { |
| 11 | - std::cerr << "usage: test_xref INPUT.pdf" << std::endl; | 11 | + std::cerr << "usage: test_xref INPUT.pdf" << '\n'; |
| 12 | std::exit(2); | 12 | std::exit(2); |
| 13 | } | 13 | } |
| 14 | 14 | ||
| @@ -20,23 +20,23 @@ main(int argc, char* argv[]) | @@ -20,23 +20,23 @@ main(int argc, char* argv[]) | ||
| 20 | std::cout << iter.first.getObj() << "/" << iter.first.getGen() << ", "; | 20 | std::cout << iter.first.getObj() << "/" << iter.first.getGen() << ", "; |
| 21 | switch (iter.second.getType()) { | 21 | switch (iter.second.getType()) { |
| 22 | case 0: | 22 | case 0: |
| 23 | - std::cout << "free entry" << std::endl; | 23 | + std::cout << "free entry" << '\n'; |
| 24 | break; | 24 | break; |
| 25 | case 1: | 25 | case 1: |
| 26 | std::cout << "uncompressed, offset = " << iter.second.getOffset() << " (0x" | 26 | std::cout << "uncompressed, offset = " << iter.second.getOffset() << " (0x" |
| 27 | - << std::hex << iter.second.getOffset() << std::dec << ")" << std::endl; | 27 | + << std::hex << iter.second.getOffset() << std::dec << ")" << '\n'; |
| 28 | break; | 28 | break; |
| 29 | case 2: | 29 | case 2: |
| 30 | std::cout << "compressed, stream number = " << iter.second.getObjStreamNumber() | 30 | std::cout << "compressed, stream number = " << iter.second.getObjStreamNumber() |
| 31 | - << ", stream index = " << iter.second.getObjStreamIndex() << std::endl; | 31 | + << ", stream index = " << iter.second.getObjStreamIndex() << '\n'; |
| 32 | break; | 32 | break; |
| 33 | default: | 33 | default: |
| 34 | - std::cerr << "unknown" << std::endl; | 34 | + std::cerr << "unknown" << '\n'; |
| 35 | std::exit(2); | 35 | std::exit(2); |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | } catch (std::exception& e) { | 38 | } catch (std::exception& e) { |
| 39 | - std::cerr << e.what() << std::endl; | 39 | + std::cerr << e.what() << '\n'; |
| 40 | std::exit(2); | 40 | std::exit(2); |
| 41 | } | 41 | } |
| 42 | 42 |
zlib-flate/zlib-flate.cc
| @@ -13,11 +13,10 @@ static char const* whoami = nullptr; | @@ -13,11 +13,10 @@ static char const* whoami = nullptr; | ||
| 13 | void | 13 | void |
| 14 | usage() | 14 | usage() |
| 15 | { | 15 | { |
| 16 | - std::cerr << "Usage: " << whoami << " { -uncompress | -compress[=n] }" << std::endl | ||
| 17 | - << "If n is specified with -compress, it is a zlib compression level from" | ||
| 18 | - << std::endl | ||
| 19 | - << "1 to 9 where lower numbers are faster and less compressed and higher" << std::endl | ||
| 20 | - << "numbers are slower and more compressed" << std::endl; | 16 | + std::cerr << "Usage: " << whoami << " { -uncompress | -compress[=n] }" << '\n' |
| 17 | + << "If n is specified with -compress, it is a zlib compression level from" << '\n' | ||
| 18 | + << "1 to 9 where lower numbers are faster and less compressed and higher" << '\n' | ||
| 19 | + << "numbers are slower and more compressed" << '\n'; | ||
| 21 | exit(2); | 20 | exit(2); |
| 22 | } | 21 | } |
| 23 | 22 | ||
| @@ -31,7 +30,7 @@ main(int argc, char* argv[]) | @@ -31,7 +30,7 @@ main(int argc, char* argv[]) | ||
| 31 | } | 30 | } |
| 32 | 31 | ||
| 33 | if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) { | 32 | if ((argc == 2) && (strcmp(argv[1], "--version") == 0)) { |
| 34 | - std::cout << whoami << " from qpdf version " << QPDF::QPDFVersion() << std::endl; | 33 | + std::cout << whoami << " from qpdf version " << QPDF::QPDFVersion() << '\n'; |
| 35 | exit(0); | 34 | exit(0); |
| 36 | } | 35 | } |
| 37 | 36 | ||
| @@ -53,7 +52,7 @@ main(int argc, char* argv[]) | @@ -53,7 +52,7 @@ main(int argc, char* argv[]) | ||
| 53 | // Undocumented option, but that doesn't mean someone doesn't use it... | 52 | // Undocumented option, but that doesn't mean someone doesn't use it... |
| 54 | // This is primarily here to support the test suite. | 53 | // This is primarily here to support the test suite. |
| 55 | std::cout << (Pl_Flate::zopfli_supported() ? "1" : "0") | 54 | std::cout << (Pl_Flate::zopfli_supported() ? "1" : "0") |
| 56 | - << (Pl_Flate::zopfli_enabled() ? "1" : "0") << std::endl; | 55 | + << (Pl_Flate::zopfli_enabled() ? "1" : "0") << '\n'; |
| 57 | return 0; | 56 | return 0; |
| 58 | } else { | 57 | } else { |
| 59 | usage(); | 58 | usage(); |
| @@ -68,8 +67,7 @@ main(int argc, char* argv[]) | @@ -68,8 +67,7 @@ main(int argc, char* argv[]) | ||
| 68 | auto flate = std::make_shared<Pl_Flate>("flate", out.get(), action); | 67 | auto flate = std::make_shared<Pl_Flate>("flate", out.get(), action); |
| 69 | flate->setWarnCallback([&warn](char const* msg, int code) { | 68 | flate->setWarnCallback([&warn](char const* msg, int code) { |
| 70 | warn = true; | 69 | warn = true; |
| 71 | - std::cerr << whoami << ": WARNING: zlib code " << code << ", msg = " << msg | ||
| 72 | - << std::endl; | 70 | + std::cerr << whoami << ": WARNING: zlib code " << code << ", msg = " << msg << '\n'; |
| 73 | }); | 71 | }); |
| 74 | 72 | ||
| 75 | unsigned char buf[10000]; | 73 | unsigned char buf[10000]; |
| @@ -84,7 +82,7 @@ main(int argc, char* argv[]) | @@ -84,7 +82,7 @@ main(int argc, char* argv[]) | ||
| 84 | } | 82 | } |
| 85 | flate->finish(); | 83 | flate->finish(); |
| 86 | } catch (std::exception& e) { | 84 | } catch (std::exception& e) { |
| 87 | - std::cerr << whoami << ": " << e.what() << std::endl; | 85 | + std::cerr << whoami << ": " << e.what() << '\n'; |
| 88 | exit(2); | 86 | exit(2); |
| 89 | } | 87 | } |
| 90 | 88 |