diff options
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/fix-qdf.cc | 6 | ||||
-rw-r--r-- | qpdf/pdf_from_scratch.cc | 11 | ||||
-rw-r--r-- | qpdf/qpdf.cc | 3 | ||||
-rw-r--r-- | qpdf/qpdfjob-ctest.c | 1 | ||||
-rw-r--r-- | qpdf/test_driver.cc | 41 | ||||
-rw-r--r-- | qpdf/test_large_file.cc | 14 | ||||
-rw-r--r-- | qpdf/test_pdf_doc_encoding.cc | 8 | ||||
-rw-r--r-- | qpdf/test_pdf_unicode.cc | 8 | ||||
-rw-r--r-- | qpdf/test_renumber.cc | 2 | ||||
-rw-r--r-- | qpdf/test_shell_glob.cc | 1 | ||||
-rw-r--r-- | qpdf/test_tokenizer.cc | 23 | ||||
-rw-r--r-- | qpdf/test_unicode_filenames.cc | 6 | ||||
-rw-r--r-- | qpdf/test_xref.cc | 3 |
13 files changed, 58 insertions, 69 deletions
diff --git a/qpdf/fix-qdf.cc b/qpdf/fix-qdf.cc index 34b3d3dc..1d46971c 100644 --- a/qpdf/fix-qdf.cc +++ b/qpdf/fix-qdf.cc @@ -8,7 +8,7 @@ #include <regex> #include <string_view> -static char const* whoami = 0; +static char const* whoami = nullptr; static void usage() @@ -392,7 +392,7 @@ realmain(int argc, char* argv[]) { whoami = QUtil::getWhoami(argv[0]); QUtil::setLineBuf(stdout); - char const* filename = 0; + char const* filename = nullptr; if (argc > 2) { usage(); } else if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) { @@ -405,7 +405,7 @@ realmain(int argc, char* argv[]) filename = argv[1]; } std::string input; - if (filename == 0) { + if (filename == nullptr) { filename = "standard input"; QUtil::binary_stdin(); input = QUtil::read_file_into_string(stdin); diff --git a/qpdf/pdf_from_scratch.cc b/qpdf/pdf_from_scratch.cc index bdcdaae1..41e52f9c 100644 --- a/qpdf/pdf_from_scratch.cc +++ b/qpdf/pdf_from_scratch.cc @@ -3,14 +3,13 @@ #include <qpdf/QPDFObjectHandle.hh> #include <qpdf/QPDFPageDocumentHelper.hh> #include <qpdf/QPDFWriter.hh> -#include <qpdf/QTC.hh> #include <qpdf/QUtil.hh> #include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include <cstdio> +#include <cstdlib> +#include <cstring> -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -87,7 +86,7 @@ int main(int argc, char* argv[]) { QUtil::setLineBuf(stdout); - if ((whoami = strrchr(argv[0], '/')) == NULL) { + if ((whoami = strrchr(argv[0], '/')) == nullptr) { whoami = argv[0]; } else { ++whoami; diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index ea7f338a..08e94d38 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -4,10 +4,9 @@ #include <cstdio> #include <cstdlib> -#include <cstring> #include <iostream> -static char const* whoami = 0; +static char const* whoami = nullptr; static void usageExit(std::string const& msg) diff --git a/qpdf/qpdfjob-ctest.c b/qpdf/qpdfjob-ctest.c index 31f22d28..62da7fe5 100644 --- a/qpdf/qpdfjob-ctest.c +++ b/qpdf/qpdfjob-ctest.c @@ -2,7 +2,6 @@ #include <qpdf/qpdfjob-c.h> #include <stdio.h> -#include <stdlib.h> #include <string.h> #ifndef QPDF_NO_WCHAR_T diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 4a5d0ae8..da1be6c0 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -26,19 +26,18 @@ #include <qpdf/QPDFWriter.hh> #include <qpdf/QTC.hh> #include <qpdf/QUtil.hh> -#include <algorithm> #include <iostream> -#include <limits.h> +#include <climits> #include <map> #include <sstream> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include <cstdio> +#include <cstdlib> +#include <cstring> #define QPDF_OBJECT_NOWARN #include <qpdf/QPDFObject.hh> -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -287,7 +286,7 @@ test_0_1(QPDF& pdf, char const* arg2) qtest.pipeStreamData(out.get(), 0, qpdf_dl_none); std::cout << std::endl << "Uncompressed stream data:" << std::endl; - if (qtest.pipeStreamData(0, 0, qpdf_dl_all)) { + if (qtest.pipeStreamData(nullptr, 0, qpdf_dl_all)) { std::cout.flush(); QUtil::binary_stdout(); out = std::make_shared<Pl_StdioFile>("filtered", stdout); @@ -388,7 +387,7 @@ test_4(QPDF& pdf, char const* arg2) } trailer.replaceKey("/Info", pdf.makeIndirectObject(qtest)); - QPDFWriter w(pdf, 0); + QPDFWriter w(pdf, nullptr); w.setQDFMode(true); w.setStaticID(true); w.write(); @@ -500,7 +499,7 @@ test_8(QPDF& pdf, char const* arg2) auto b = p1.getBufferSharedPointer(); // This is a bogus way to use StreamDataProvider, but it does // adequately test its functionality. - Provider* provider = new Provider(b); + auto* provider = new Provider(b); auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(provider); qstream.replaceStreamData( p, @@ -600,7 +599,7 @@ test_12(QPDF& pdf, char const* arg2) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif - pdf.setOutputStreams(0, 0); + pdf.setOutputStreams(nullptr, nullptr); #if (defined(__GNUC__) || defined(__clang__)) # pragma GCC diagnostic pop #endif @@ -1010,7 +1009,7 @@ test_25(QPDF& pdf, char const* arg2) // Copy qtest without crossing page boundaries. Should get O1 // and O2 and their streams but not O3 or any other pages. - assert(arg2 != 0); + assert(arg2 != nullptr); { // Make sure original PDF is out of scope when we write. QPDF oldpdf; @@ -1036,7 +1035,7 @@ test_26(QPDF& pdf, char const* arg2) { // Make sure original PDF is out of scope when we write. - assert(arg2 != 0); + assert(arg2 != nullptr); QPDF oldpdf; oldpdf.processFile(arg2); QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest"); @@ -1069,7 +1068,7 @@ test_27(QPDF& pdf, char const* arg2) pl.writeCStr("new data for stream\n"); pl.finish(); auto b = pl.getBufferSharedPointer(); - Provider* provider = new Provider(b); + auto* provider = new Provider(b); p1 = decltype(p1)(provider); } // Create a stream that uses a provider in empty1 and copy it @@ -1096,7 +1095,7 @@ test_27(QPDF& pdf, char const* arg2) pl.writeCStr("more data for stream\n"); pl.finish(); auto b = pl.getBufferSharedPointer(); - Provider* provider = new Provider(b); + auto* provider = new Provider(b); p2 = decltype(p2)(provider); } QPDF empty3; @@ -1105,7 +1104,7 @@ test_27(QPDF& pdf, char const* arg2) QPDFObjectHandle s3 = QPDFObjectHandle::newStream(&empty3); s3.replaceStreamData( p2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); - assert(arg2 != 0); + assert(arg2 != nullptr); QPDF oldpdf; oldpdf.processFile(arg2); QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest"); @@ -1152,7 +1151,7 @@ static void test_29(QPDF& pdf, char const* arg2) { // Detect mixed objects in QPDFWriter - assert(arg2 != 0); + assert(arg2 != nullptr); auto other = QPDF::create(); other->processFile(arg2); // We need to create a QPDF with mixed ownership to exercise @@ -1202,7 +1201,7 @@ test_29(QPDF& pdf, char const* arg2) static void test_30(QPDF& pdf, char const* arg2) { - assert(arg2 != 0); + assert(arg2 != nullptr); QPDF encrypted; encrypted.processFile(arg2, "user"); QPDFWriter w(pdf, "b.pdf"); @@ -1434,7 +1433,7 @@ test_40(QPDF& pdf, char const* arg2) // feature was implemented by Sahil Arora // <sahilarora.535@gmail.com> as part of a Google Summer of // Code project in 2017. - assert(arg2 != 0); + assert(arg2 != nullptr); QPDFWriter w(pdf, arg2); w.setPCLm(true); w.setStaticID(true); @@ -3559,11 +3558,11 @@ runtest(int n, char const* filename1, char const* arg2) QPDF pdf; std::shared_ptr<char> file_buf; - FILE* filep = 0; + FILE* filep = nullptr; if (n == 0) { pdf.setAttemptRecovery(false); } - if (((n == 35) || (n == 36)) && (arg2 != 0)) { + if (((n == 35) || (n == 36)) && (arg2 != nullptr)) { // arg2 is password pdf.processFile(filename1, arg2); } else if (n == 45) { @@ -3653,7 +3652,7 @@ int main(int argc, char* argv[]) { QUtil::setLineBuf(stdout); - if ((whoami = strrchr(argv[0], '/')) == NULL) { + if ((whoami = strrchr(argv[0], '/')) == nullptr) { whoami = argv[0]; } else { ++whoami; diff --git a/qpdf/test_large_file.cc b/qpdf/test_large_file.cc index e8bea103..cfd1c5db 100644 --- a/qpdf/test_large_file.cc +++ b/qpdf/test_large_file.cc @@ -13,8 +13,8 @@ #include <qpdf/QPDFWriter.hh> #include <qpdf/QUtil.hh> #include <iostream> -#include <stdlib.h> -#include <string.h> +#include <cstdlib> +#include <cstring> // Run "test_large_file write small a.pdf" to get a PDF file that you // can look at in a reader. @@ -35,7 +35,7 @@ // reading the large file then allows us to verify large file support // with confidence. -static char const* whoami = 0; +static char const* whoami = nullptr; // Height should be a multiple of 10 static size_t const nstripes = 10; @@ -47,7 +47,7 @@ static size_t const npages = 200; size_t stripesize = 0; size_t width = 0; size_t height = 0; -static unsigned char* buf = 0; +static unsigned char* buf = nullptr; static inline unsigned char get_pixel_color(size_t n, size_t row) @@ -73,7 +73,7 @@ class ImageChecker: public Pipeline }; ImageChecker::ImageChecker(size_t n) : - Pipeline("image checker", 0), + Pipeline("image checker", nullptr), n(n), offset(0), okay(true) @@ -122,7 +122,7 @@ ImageProvider::ImageProvider(size_t n) : void ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline) { - if (buf == 0) { + if (buf == nullptr) { buf = new unsigned char[width * stripesize]; } std::cout << "page " << n << " of " << npages << std::endl; @@ -218,7 +218,7 @@ create_pdf(char const* filename) image_dict.replaceKey("/BitsPerComponent", newInteger(8)); image_dict.replaceKey("/Width", newInteger(width)); image_dict.replaceKey("/Height", newInteger(height)); - ImageProvider* p = new ImageProvider(pageno); + auto* p = new ImageProvider(pageno); std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); image.replaceStreamData( provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); diff --git a/qpdf/test_pdf_doc_encoding.cc b/qpdf/test_pdf_doc_encoding.cc index 5c67f59a..e7aba030 100644 --- a/qpdf/test_pdf_doc_encoding.cc +++ b/qpdf/test_pdf_doc_encoding.cc @@ -1,10 +1,10 @@ #include <qpdf/QPDFObjectHandle.hh> #include <qpdf/QUtil.hh> #include <iostream> -#include <stdlib.h> -#include <string.h> +#include <cstdlib> +#include <cstring> -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -16,7 +16,7 @@ usage() int main(int argc, char* argv[]) { - if ((whoami = strrchr(argv[0], '/')) == NULL) { + if ((whoami = strrchr(argv[0], '/')) == nullptr) { whoami = argv[0]; } else { ++whoami; diff --git a/qpdf/test_pdf_unicode.cc b/qpdf/test_pdf_unicode.cc index 38df6daa..325fcad8 100644 --- a/qpdf/test_pdf_unicode.cc +++ b/qpdf/test_pdf_unicode.cc @@ -1,10 +1,10 @@ #include <qpdf/QPDFObjectHandle.hh> #include <qpdf/QUtil.hh> #include <iostream> -#include <stdlib.h> -#include <string.h> +#include <cstdlib> +#include <cstring> -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -16,7 +16,7 @@ usage() int main(int argc, char* argv[]) { - if ((whoami = strrchr(argv[0], '/')) == NULL) { + if ((whoami = strrchr(argv[0], '/')) == nullptr) { whoami = argv[0]; } else { ++whoami; diff --git a/qpdf/test_renumber.cc b/qpdf/test_renumber.cc index 7edec21b..1b828128 100644 --- a/qpdf/test_renumber.cc +++ b/qpdf/test_renumber.cc @@ -1,4 +1,3 @@ -#include <qpdf/Buffer.hh> #include <qpdf/Constants.h> #include <qpdf/QPDF.hh> #include <qpdf/QPDFObjGen.hh> @@ -6,7 +5,6 @@ #include <qpdf/QPDFWriter.hh> #include <qpdf/QPDFXRefEntry.hh> -#include <algorithm> #include <cstdlib> #include <iostream> #include <set> diff --git a/qpdf/test_shell_glob.cc b/qpdf/test_shell_glob.cc index c2cfb422..492e117d 100644 --- a/qpdf/test_shell_glob.cc +++ b/qpdf/test_shell_glob.cc @@ -1,5 +1,4 @@ #include <qpdf/QUtil.hh> -#include <cstring> #include <iostream> int diff --git a/qpdf/test_tokenizer.cc b/qpdf/test_tokenizer.cc index f465cd46..507de459 100644 --- a/qpdf/test_tokenizer.cc +++ b/qpdf/test_tokenizer.cc @@ -4,15 +4,14 @@ #include <qpdf/QIntC.hh> #include <qpdf/QPDF.hh> #include <qpdf/QPDFPageDocumentHelper.hh> -#include <qpdf/QPDFPageObjectHelper.hh> #include <qpdf/QPDFTokenizer.hh> #include <qpdf/QUtil.hh> #include <iostream> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include <cstdio> +#include <cstdlib> +#include <cstring> -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -92,7 +91,7 @@ tokenTypeName(QPDFTokenizer::token_type_e ttype) case QPDFTokenizer::tt_inline_image: return "inline-image"; } - return 0; + return nullptr; } static std::string @@ -191,7 +190,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) std::shared_ptr<InputSource> is; // Tokenize file, skipping streams - FileInputSource* fis = new FileInputSource(filename); + auto* fis = new FileInputSource(filename); is = std::shared_ptr<InputSource>(fis); dump_tokens(is, "FILE", max_len, include_ignorable, true, false); @@ -204,7 +203,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) Pl_Buffer plb("buffer"); page.pipeContents(&plb); auto content_data = plb.getBufferSharedPointer(); - BufferInputSource* bis = + auto* bis = new BufferInputSource("content data", content_data.get()); is = std::shared_ptr<InputSource>(bis); dump_tokens( @@ -221,7 +220,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) if (obj.isStream() && obj.getDict().getKey("/Type").isName() && obj.getDict().getKey("/Type").getName() == "/ObjStm") { std::shared_ptr<Buffer> b = obj.getStreamData(qpdf_dl_specialized); - BufferInputSource* bis = + auto* bis = new BufferInputSource("object stream data", b.get()); is = std::shared_ptr<InputSource>(bis); dump_tokens( @@ -239,13 +238,13 @@ int main(int argc, char* argv[]) { QUtil::setLineBuf(stdout); - if ((whoami = strrchr(argv[0], '/')) == NULL) { + if ((whoami = strrchr(argv[0], '/')) == nullptr) { whoami = argv[0]; } else { ++whoami; } - char const* filename = 0; + char const* filename = nullptr; size_t max_len = 0; bool include_ignorable = true; for (int i = 1; i < argc; ++i) { @@ -266,7 +265,7 @@ main(int argc, char* argv[]) filename = argv[i]; } } - if (filename == 0) { + if (filename == nullptr) { usage(); } diff --git a/qpdf/test_unicode_filenames.cc b/qpdf/test_unicode_filenames.cc index 3d9e8038..16478161 100644 --- a/qpdf/test_unicode_filenames.cc +++ b/qpdf/test_unicode_filenames.cc @@ -6,13 +6,13 @@ #endif #include <iostream> -#include <stdio.h> -#include <stdlib.h> +#include <cstdio> +#include <cstdlib> static void do_copy(FILE* in, FILE* out) { - if ((in == 0) || (out == 0)) { + if ((in == nullptr) || (out == nullptr)) { std::cerr << "errors opening files" << std::endl; exit(2); } diff --git a/qpdf/test_xref.cc b/qpdf/test_xref.cc index d01ac046..6ecb9a00 100644 --- a/qpdf/test_xref.cc +++ b/qpdf/test_xref.cc @@ -1,11 +1,8 @@ #include <qpdf/QPDF.hh> -#include <qpdf/QPDFObjGen.hh> -#include <qpdf/QPDFXRefEntry.hh> #include <cstdlib> #include <iostream> #include <map> -#include <string> int main(int argc, char* argv[]) |