From e28f4efb00d5040fa71532d76e63aa7ade105c99 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 20 May 2023 12:22:32 +0100 Subject: Replace deprecated C++ includes --- libtests/rc4.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libtests/rc4.cc') diff --git a/libtests/rc4.cc b/libtests/rc4.cc index a6a1328e..874c11ff 100644 --- a/libtests/rc4.cc +++ b/libtests/rc4.cc @@ -6,9 +6,9 @@ #include #include -#include -#include -#include +#include +#include +#include static void other_tests() -- cgit v1.2.3-54-g00ecf From d0682f0f609e979ba085d93a1a0d8e0559f739bb Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 20 May 2023 12:46:50 +0100 Subject: Use nullptr instead of 0 or NULL --- examples/qpdfjob-remove-annotations.cc | 2 +- include/qpdf/Pl_Buffer.hh | 2 +- include/qpdf/Pl_DCT.hh | 4 ++-- include/qpdf/Pl_QPDFTokenizer.hh | 2 +- include/qpdf/QPDF.hh | 8 ++++---- include/qpdf/QPDFCryptoImpl.hh | 2 +- include/qpdf/QPDFJob.hh | 2 +- include/qpdf/QPDFObjectHandle.hh | 4 ++-- include/qpdf/QPDFOutlineObjectHelper.hh | 2 +- include/qpdf/QPDFPageObjectHelper.hh | 4 ++-- include/qpdf/QPDFWriter.hh | 2 +- include/qpdf/QUtil.hh | 2 +- libqpdf/QUtil.cc | 4 ++-- libqpdf/qpdf/Pl_SHA2.hh | 2 +- libqpdf/qpdf/QPDFArgParser.hh | 6 +++--- libqpdf/qpdf/QPDFCrypto_openssl.hh | 2 +- libtests/aes.cc | 12 ++++++------ libtests/arg_parser.cc | 2 +- libtests/numrange.cc | 2 +- libtests/predictors.cc | 2 +- libtests/qutil.cc | 2 +- libtests/random.cc | 2 +- libtests/rc4.cc | 2 +- qpdf/fix-qdf.cc | 6 +++--- qpdf/pdf_from_scratch.cc | 4 ++-- qpdf/qpdf.cc | 2 +- qpdf/test_driver.cc | 26 +++++++++++++------------- qpdf/test_large_file.cc | 8 ++++---- qpdf/test_pdf_doc_encoding.cc | 4 ++-- qpdf/test_pdf_unicode.cc | 4 ++-- qpdf/test_tokenizer.cc | 10 +++++----- qpdf/test_unicode_filenames.cc | 2 +- zlib-flate/zlib-flate.cc | 4 ++-- 33 files changed, 72 insertions(+), 72 deletions(-) (limited to 'libtests/rc4.cc') diff --git a/examples/qpdfjob-remove-annotations.cc b/examples/qpdfjob-remove-annotations.cc index fd8754d5..5334e7dc 100644 --- a/examples/qpdfjob-remove-annotations.cc +++ b/examples/qpdfjob-remove-annotations.cc @@ -11,7 +11,7 @@ // The example is a full copy of the qpdf program modified to allways remove all // annotations from the final output. -static char const* whoami = 0; +static char const* whoami = nullptr; static void usageExit(std::string const& msg) diff --git a/include/qpdf/Pl_Buffer.hh b/include/qpdf/Pl_Buffer.hh index e2f71094..fcef0c56 100644 --- a/include/qpdf/Pl_Buffer.hh +++ b/include/qpdf/Pl_Buffer.hh @@ -43,7 +43,7 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline { public: QPDF_DLL - Pl_Buffer(char const* identifier, Pipeline* next = 0); + Pl_Buffer(char const* identifier, Pipeline* next = nullptr); QPDF_DLL virtual ~Pl_Buffer(); QPDF_DLL diff --git a/include/qpdf/Pl_DCT.hh b/include/qpdf/Pl_DCT.hh index 543967ec..9352091f 100644 --- a/include/qpdf/Pl_DCT.hh +++ b/include/qpdf/Pl_DCT.hh @@ -57,7 +57,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline JDIMENSION image_height, int components, J_COLOR_SPACE color_space, - CompressConfig* config_callback = 0); + CompressConfig* config_callback = nullptr); QPDF_DLL virtual ~Pl_DCT(); @@ -91,7 +91,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline JDIMENSION image_height = 0, int components = 1, J_COLOR_SPACE color_space = JCS_GRAYSCALE, - CompressConfig* config_callback = 0); + CompressConfig* config_callback = nullptr); Members(Members const&) = delete; action_e action; diff --git a/include/qpdf/Pl_QPDFTokenizer.hh b/include/qpdf/Pl_QPDFTokenizer.hh index ce3615ec..0b8cafc2 100644 --- a/include/qpdf/Pl_QPDFTokenizer.hh +++ b/include/qpdf/Pl_QPDFTokenizer.hh @@ -51,7 +51,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline Pl_QPDFTokenizer( char const* identifier, QPDFObjectHandle::TokenFilter* filter, - Pipeline* next = 0); + Pipeline* next = nullptr); QPDF_DLL virtual ~Pl_QPDFTokenizer(); QPDF_DLL diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 5567a686..03490af7 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -83,7 +83,7 @@ class QPDF // interpreted as a raw encryption key. See comments on // setPasswordIsHexKey for more information. QPDF_DLL - void processFile(char const* filename, char const* password = 0); + void processFile(char const* filename, char const* password = nullptr); // Parse a PDF from a stdio FILE*. The FILE must be open in // binary mode and must be seekable. It may be open read only. @@ -96,7 +96,7 @@ class QPDF char const* description, FILE* file, bool close_file, - char const* password = 0); + char const* password = nullptr); // Parse a PDF file loaded into a memory buffer. This works // exactly like processFile except that the PDF file is in memory @@ -107,14 +107,14 @@ class QPDF char const* description, char const* buf, size_t length, - char const* password = 0); + char const* password = nullptr); // Parse a PDF file loaded from a custom InputSource. If you have // your own method of retrieving a PDF file, you can subclass // InputSource and use this method. QPDF_DLL void - processInputSource(std::shared_ptr, char const* password = 0); + processInputSource(std::shared_ptr, char const* password = nullptr); // Create a PDF from an input source that contains JSON as written // by writeJSON (or qpdf --json-output, version 2 or higher). The diff --git a/include/qpdf/QPDFCryptoImpl.hh b/include/qpdf/QPDFCryptoImpl.hh index 5345b45b..3fd64d3a 100644 --- a/include/qpdf/QPDFCryptoImpl.hh +++ b/include/qpdf/QPDFCryptoImpl.hh @@ -80,7 +80,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl virtual void RC4_process( unsigned char const* in_data, size_t len, - unsigned char* out_data = 0) = 0; + unsigned char* out_data = nullptr) = 0; QPDF_DLL virtual void RC4_finalize() = 0; diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index 2a82d61c..7396cd6a 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -497,7 +497,7 @@ class QPDFJob // Helper functions static void usage(std::string const& msg); - static JSON json_schema(int json_version, std::set* keys = 0); + static JSON json_schema(int json_version, std::set* keys = nullptr); static void parse_object_id( std::string const& objspec, bool& trailer, int& obj, int& gen); void parseRotationParameter(std::string const&); diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index ee424e39..198ca42e 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -526,7 +526,7 @@ class QPDFObjectHandle QPDF_DLL void parsePageContents(ParserCallbacks* callbacks); QPDF_DLL - void filterPageContents(TokenFilter* filter, Pipeline* next = 0); + void filterPageContents(TokenFilter* filter, Pipeline* next = nullptr); // See comments for QPDFPageObjectHelper::pipeContents. QPDF_DLL void pipePageContents(Pipeline* p); @@ -538,7 +538,7 @@ class QPDFObjectHandle // contents. This can be used to apply a TokenFilter to a form // XObject, whose data is in the same format as a content stream. QPDF_DLL - void filterAsContents(TokenFilter* filter, Pipeline* next = 0); + void filterAsContents(TokenFilter* filter, Pipeline* next = nullptr); // Called on a stream to parse the stream as page contents. This // can be used to parse a form XObject. QPDF_DLL diff --git a/include/qpdf/QPDFOutlineObjectHelper.hh b/include/qpdf/QPDFOutlineObjectHelper.hh index c8b82a80..507a4a51 100644 --- a/include/qpdf/QPDFOutlineObjectHelper.hh +++ b/include/qpdf/QPDFOutlineObjectHelper.hh @@ -42,7 +42,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper { // This must be cleared explicitly to avoid circular references // that prevent cleanup of pointer holders. - this->m->parent = 0; + this->m->parent = nullptr; } // All constructors are private. You can only create one of these diff --git a/include/qpdf/QPDFPageObjectHelper.hh b/include/qpdf/QPDFPageObjectHelper.hh index ebb9e87e..9f647c70 100644 --- a/include/qpdf/QPDFPageObjectHelper.hh +++ b/include/qpdf/QPDFPageObjectHelper.hh @@ -320,12 +320,12 @@ class QPDFPageObjectHelper: public QPDFObjectHelper // examples/pdf-count-strings.cc for an example. QPDF_DLL void - filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0); + filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr); // Old name -- calls filterContents() QPDF_DLL void filterPageContents( - QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0); + QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr); // Pipe a page's contents through the given pipeline. This method // works whether the contents are a single stream or an array of diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh index 15b5579f..8305974c 100644 --- a/include/qpdf/QPDFWriter.hh +++ b/include/qpdf/QPDFWriter.hh @@ -539,7 +539,7 @@ class QPDFWriter friend class QPDFWriter; public: - PipelinePopper(QPDFWriter* qw, std::shared_ptr* bp = 0) : + PipelinePopper(QPDFWriter* qw, std::shared_ptr* bp = nullptr) : qw(qw), bp(bp) { diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index 5291fe09..2f7f15b2 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -245,7 +245,7 @@ namespace QUtil // Returns true iff the variable is defined. If `value' is // non-null, initializes it with the value of the variable. QPDF_DLL - bool get_env(std::string const& var, std::string* value = 0); + bool get_env(std::string const& var, std::string* value = nullptr); QPDF_DLL time_t get_current_time(); diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 4f9c1021..a542736d 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -836,8 +836,8 @@ char* QUtil::getWhoami(char* argv0) { char* whoami = nullptr; - if (((whoami = strrchr(argv0, '/')) == NULL) && - ((whoami = strrchr(argv0, '\\')) == NULL)) { + if (((whoami = strrchr(argv0, '/')) == nullptr) && + ((whoami = strrchr(argv0, '\\')) == nullptr)) { whoami = argv0; } else { ++whoami; diff --git a/libqpdf/qpdf/Pl_SHA2.hh b/libqpdf/qpdf/Pl_SHA2.hh index d5b2e547..99a19a37 100644 --- a/libqpdf/qpdf/Pl_SHA2.hh +++ b/libqpdf/qpdf/Pl_SHA2.hh @@ -20,7 +20,7 @@ class Pl_SHA2: public Pipeline { public: - Pl_SHA2(int bits = 0, Pipeline* next = 0); + Pl_SHA2(int bits = 0, Pipeline* next = nullptr); virtual ~Pl_SHA2() = default; virtual void write(unsigned char const*, size_t); virtual void finish(); diff --git a/libqpdf/qpdf/QPDFArgParser.hh b/libqpdf/qpdf/QPDFArgParser.hh index 89c7acc0..759ad148 100644 --- a/libqpdf/qpdf/QPDFArgParser.hh +++ b/libqpdf/qpdf/QPDFArgParser.hh @@ -177,9 +177,9 @@ class QPDFArgParser { OptionEntry() : parameter_needed(false), - bare_arg_handler(0), - param_arg_handler(0), - invalid_choice_handler(0) + bare_arg_handler(nullptr), + param_arg_handler(nullptr), + invalid_choice_handler(nullptr) { } bool parameter_needed; diff --git a/libqpdf/qpdf/QPDFCrypto_openssl.hh b/libqpdf/qpdf/QPDFCrypto_openssl.hh index eae69ab1..0d07b99b 100644 --- a/libqpdf/qpdf/QPDFCrypto_openssl.hh +++ b/libqpdf/qpdf/QPDFCrypto_openssl.hh @@ -39,7 +39,7 @@ class QPDFCrypto_openssl: public QPDFCryptoImpl void RC4_process( unsigned char const* in_data, size_t len, - unsigned char* out_data = 0) override; + unsigned char* out_data = nullptr) override; void RC4_finalize() override; void SHA2_init(int bits) override; diff --git a/libtests/aes.cc b/libtests/aes.cc index 4541fffe..5ae8152a 100644 --- a/libtests/aes.cc +++ b/libtests/aes.cc @@ -29,9 +29,9 @@ main(int argc, char* argv[]) { bool encrypt = true; bool cbc_mode = true; - char* hexkey = 0; - char* infilename = 0; - char* outfilename = 0; + char* hexkey = nullptr; + char* infilename = nullptr; + char* outfilename = nullptr; bool zero_iv = false; bool static_iv = false; bool disable_padding = false; @@ -65,7 +65,7 @@ main(int argc, char* argv[]) usage(); } } - if (outfilename == 0) { + if (outfilename == nullptr) { usage(); } @@ -81,14 +81,14 @@ main(int argc, char* argv[]) t[1] = hexkey[i + 1]; t[2] = '\0'; - long val = strtol(t, 0, 16); + long val = strtol(t, nullptr, 16); key[i / 2] = static_cast(val); } Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); Pl_AES_PDF* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen); delete[] key; - key = 0; + key = nullptr; if (!cbc_mode) { aes->disableCBC(); } diff --git a/libtests/arg_parser.cc b/libtests/arg_parser.cc index 6b4c829f..c9474d55 100644 --- a/libtests/arg_parser.cc +++ b/libtests/arg_parser.cc @@ -51,7 +51,7 @@ ArgParser::initOptions() ap.addBare("potato", b(&ArgParser::handlePotato)); ap.addRequiredParameter("salad", p(&ArgParser::handleSalad), "tossed"); ap.addOptionalParameter("moo", p(&ArgParser::handleMoo)); - char const* choices[] = {"pig", "boar", "sow", 0}; + char const* choices[] = {"pig", "boar", "sow", nullptr}; ap.addChoices("oink", p(&ArgParser::handleOink), true, choices); ap.selectHelpOptionTable(); ap.addBare("version", [this]() { output("3.14159"); }); diff --git a/libtests/numrange.cc b/libtests/numrange.cc index c0bf5bd7..ded03324 100644 --- a/libtests/numrange.cc +++ b/libtests/numrange.cc @@ -4,7 +4,7 @@ static void test_numrange(char const* range) { - if (range == 0) { + if (range == nullptr) { std::cout << "null" << std::endl; } else { std::vector result = QUtil::parse_numrange(range, 15); diff --git a/libtests/predictors.cc b/libtests/predictors.cc index fd1cc2ad..d7825bc6 100644 --- a/libtests/predictors.cc +++ b/libtests/predictors.cc @@ -21,7 +21,7 @@ run(char const* filename, FILE* in = QUtil::safe_fopen(filename, "rb"); FILE* o1 = QUtil::safe_fopen("out", "wb"); Pipeline* out = new Pl_StdioFile("out", o1); - Pipeline* pl = 0; + Pipeline* pl = nullptr; if (strcmp(filter, "png") == 0) { pl = new Pl_PNGFilter( "png", diff --git a/libtests/qutil.cc b/libtests/qutil.cc index a6f1282a..be5b6b1b 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -489,7 +489,7 @@ same_file_test() assert_same_file("qutil.out", "qutil.out", true); assert_same_file("qutil.out", "other-file", false); assert_same_file("qutil.out", "", false); - assert_same_file("qutil.out", 0, false); + assert_same_file("qutil.out", nullptr, false); assert_same_file("", "qutil.out", false); } diff --git a/libtests/random.cc b/libtests/random.cc index 40ef7d47..899c264c 100644 --- a/libtests/random.cc +++ b/libtests/random.cc @@ -56,7 +56,7 @@ main() if (!((buf[0] == 0) && (buf[1] == 1) && (buf[2] == 2) && (buf[3] == 3))) { std::cout << "fail: bogus random didn't provide correct bytes\n"; } - QUtil::setRandomDataProvider(0); + QUtil::setRandomDataProvider(nullptr); if (QUtil::getRandomDataProvider() != orig_rdp) { std::cout << "fail: passing null to setRandomDataProvider " "didn't reset the random data provider\n"; diff --git a/libtests/rc4.cc b/libtests/rc4.cc index 874c11ff..ca4af91d 100644 --- a/libtests/rc4.cc +++ b/libtests/rc4.cc @@ -51,7 +51,7 @@ main(int argc, char* argv[]) t[1] = hexkey[i + 1]; t[2] = '\0'; - long val = strtol(t, 0, 16); + long val = strtol(t, nullptr, 16); key[i / 2] = static_cast(val); } 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 #include -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 1b172964..41e52f9c 100644 --- a/qpdf/pdf_from_scratch.cc +++ b/qpdf/pdf_from_scratch.cc @@ -9,7 +9,7 @@ #include #include -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -86,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 815a86b4..08e94d38 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -6,7 +6,7 @@ #include #include -static char const* whoami = 0; +static char const* whoami = nullptr; static void usageExit(std::string const& msg) diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 673c6b58..e9e7754c 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -37,7 +37,7 @@ #define QPDF_OBJECT_NOWARN #include -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -286,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("filtered", stdout); @@ -387,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(); @@ -599,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 @@ -1009,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; @@ -1035,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"); @@ -1104,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"); @@ -1151,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 @@ -1201,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"); @@ -1433,7 +1433,7 @@ test_40(QPDF& pdf, char const* arg2) // feature was implemented by Sahil Arora // 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); @@ -3558,11 +3558,11 @@ runtest(int n, char const* filename1, char const* arg2) QPDF pdf; std::shared_ptr 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) { @@ -3652,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 b30967c7..aea7c0c5 100644 --- a/qpdf/test_large_file.cc +++ b/qpdf/test_large_file.cc @@ -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; diff --git a/qpdf/test_pdf_doc_encoding.cc b/qpdf/test_pdf_doc_encoding.cc index cd2e9b42..e7aba030 100644 --- a/qpdf/test_pdf_doc_encoding.cc +++ b/qpdf/test_pdf_doc_encoding.cc @@ -4,7 +4,7 @@ #include #include -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 b28edeaf..325fcad8 100644 --- a/qpdf/test_pdf_unicode.cc +++ b/qpdf/test_pdf_unicode.cc @@ -4,7 +4,7 @@ #include #include -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_tokenizer.cc b/qpdf/test_tokenizer.cc index 8a58fc8e..d9c09c0b 100644 --- a/qpdf/test_tokenizer.cc +++ b/qpdf/test_tokenizer.cc @@ -11,7 +11,7 @@ #include #include -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -91,7 +91,7 @@ tokenTypeName(QPDFTokenizer::token_type_e ttype) case QPDFTokenizer::tt_inline_image: return "inline-image"; } - return 0; + return nullptr; } static std::string @@ -238,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) { @@ -265,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 b2fd50f3..16478161 100644 --- a/qpdf/test_unicode_filenames.cc +++ b/qpdf/test_unicode_filenames.cc @@ -12,7 +12,7 @@ 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/zlib-flate/zlib-flate.cc b/zlib-flate/zlib-flate.cc index 8f0f087a..d1311c84 100644 --- a/zlib-flate/zlib-flate.cc +++ b/zlib-flate/zlib-flate.cc @@ -9,7 +9,7 @@ #include #include -static char const* whoami = 0; +static char const* whoami = nullptr; void usage() @@ -27,7 +27,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; -- cgit v1.2.3-54-g00ecf From 41ec7eda54e2263eeb1aee4c3a0616c9c2777fb7 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 20 May 2023 13:24:10 +0100 Subject: Use auto when initialializing with new --- examples/pdf-create.cc | 4 ++-- examples/pdf-custom-filter.cc | 2 +- examples/pdf-invert-images.cc | 2 +- libqpdf/Pl_Buffer.cc | 2 +- libqpdf/QPDF.cc | 4 ++-- libqpdf/QPDFWriter.cc | 4 ++-- libqpdf/QPDF_Array.cc | 2 +- libqpdf/qpdf-c.cc | 2 +- libtests/aes.cc | 6 +++--- libtests/bits.cc | 2 +- libtests/flate.cc | 2 +- libtests/pointer_holder.cc | 4 ++-- libtests/rc4.cc | 6 +++--- qpdf/test_driver.cc | 6 +++--- qpdf/test_large_file.cc | 2 +- qpdf/test_tokenizer.cc | 6 +++--- 16 files changed, 28 insertions(+), 28 deletions(-) (limited to 'libtests/rc4.cc') diff --git a/examples/pdf-create.cc b/examples/pdf-create.cc index 7898479a..af7ec6b7 100644 --- a/examples/pdf-create.cc +++ b/examples/pdf-create.cc @@ -166,7 +166,7 @@ add_page( // mode. Since we are not specifying, QPDFWriter will compress // with /FlateDecode if we don't provide any other form of // compression. - ImageProvider* p = new ImageProvider(color_space, filter); + auto* p = new ImageProvider(color_space, filter); std::shared_ptr provider(p); size_t width = p->getWidth(); size_t height = p->getHeight(); @@ -286,7 +286,7 @@ check( if (!this_errors) { // Check image data auto actual_data = image.getStreamData(qpdf_dl_all); - ImageProvider* p = new ImageProvider(desired_color_space, "null"); + auto* p = new ImageProvider(desired_color_space, "null"); std::shared_ptr provider(p); Pl_Buffer b_p("get image data"); provider->provideStreamData(QPDFObjGen(), &b_p); diff --git a/examples/pdf-custom-filter.cc b/examples/pdf-custom-filter.cc index 2310a687..f6977a21 100644 --- a/examples/pdf-custom-filter.cc +++ b/examples/pdf-custom-filter.cc @@ -409,7 +409,7 @@ process( // Create a single StreamReplacer instance. The interface requires // a std::shared_ptr in various places, so allocate a StreamReplacer // and stash it in a std::shared_ptr. - StreamReplacer* replacer = new StreamReplacer(&qpdf); + auto* replacer = new StreamReplacer(&qpdf); std::shared_ptr p(replacer); for (auto& o: qpdf.getAllObjects()) { diff --git a/examples/pdf-invert-images.cc b/examples/pdf-invert-images.cc index 06d74198..89989885 100644 --- a/examples/pdf-invert-images.cc +++ b/examples/pdf-invert-images.cc @@ -124,7 +124,7 @@ main(int argc, char* argv[]) QPDF qpdf; qpdf.processFile(infilename, password); - ImageInverter* inv = new ImageInverter; + auto* inv = new ImageInverter; auto p = std::shared_ptr(inv); // For each page... diff --git a/libqpdf/Pl_Buffer.cc b/libqpdf/Pl_Buffer.cc index d942465d..ff200643 100644 --- a/libqpdf/Pl_Buffer.cc +++ b/libqpdf/Pl_Buffer.cc @@ -45,7 +45,7 @@ Pl_Buffer::getBuffer() } auto size = this->m->data.length(); - Buffer* b = new Buffer(size); + auto* b = new Buffer(size); if (size > 0) { unsigned char* p = b->getBuffer(); memcpy(p, this->m->data.data(), size); diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index bc88b5d6..3a4712e0 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -264,7 +264,7 @@ QPDF::create() void QPDF::processFile(char const* filename, char const* password) { - FileInputSource* fi = new FileInputSource(filename); + auto* fi = new FileInputSource(filename); processInputSource(std::shared_ptr(fi), password); } @@ -272,7 +272,7 @@ void QPDF::processFile( char const* description, FILE* filep, bool close_file, char const* password) { - FileInputSource* fi = new FileInputSource(description, filep, close_file); + auto* fi = new FileInputSource(description, filep, close_file); processInputSource(std::shared_ptr(fi), password); } diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 56b4e1ef..a5a54cc7 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -997,7 +997,7 @@ void QPDFWriter::activatePipelineStack(PipelinePopper& pp) { std::string stack_id("stack " + std::to_string(this->m->next_stack_id)); - Pl_Count* c = + auto* c = new Pl_Count(stack_id.c_str(), this->m->pipeline_stack.back()); ++this->m->next_stack_id; this->m->pipeline_stack.push_back(c); @@ -1030,7 +1030,7 @@ QPDFWriter::PipelinePopper::~PipelinePopper() qw->m->md5_pipeline = nullptr; } qw->m->pipeline_stack.pop_back(); - Pl_Buffer* buf = dynamic_cast(p); + auto* buf = dynamic_cast(p); if (bp && buf) { *bp = buf->getBufferSharedPointer(); } diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc index 3bd139b1..d0228361 100644 --- a/libqpdf/QPDF_Array.cc +++ b/libqpdf/QPDF_Array.cc @@ -83,7 +83,7 @@ QPDF_Array::copy(bool shallow) return do_create(new QPDF_Array(*this)); } else { if (sparse) { - QPDF_Array* result = new QPDF_Array(); + auto* result = new QPDF_Array(); result->sp_size = sp_size; for (auto const& element: sp_elements) { auto const& obj = element.second; diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc index e7df8ac3..8f36195a 100644 --- a/libqpdf/qpdf-c.cc +++ b/libqpdf/qpdf-c.cc @@ -106,7 +106,7 @@ qpdf_data qpdf_init() { QTC::TC("qpdf", "qpdf-c called qpdf_init"); - qpdf_data qpdf = new _qpdf_data(); + auto qpdf = new _qpdf_data(); qpdf->qpdf = QPDF::create(); return qpdf; } diff --git a/libtests/aes.cc b/libtests/aes.cc index 5ae8152a..a981fc22 100644 --- a/libtests/aes.cc +++ b/libtests/aes.cc @@ -74,7 +74,7 @@ main(int argc, char* argv[]) FILE* infile = QUtil::safe_fopen(infilename, "rb"); FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); - unsigned char* key = new unsigned char[keylen]; + auto* key = new unsigned char[keylen]; for (unsigned int i = 0; i < strlen(hexkey); i += 2) { char t[3]; t[0] = hexkey[i]; @@ -85,8 +85,8 @@ main(int argc, char* argv[]) key[i / 2] = static_cast(val); } - Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); - Pl_AES_PDF* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen); + auto* out = new Pl_StdioFile("stdout", outfile); + auto* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen); delete[] key; key = nullptr; if (!cbc_mode) { diff --git a/libtests/bits.cc b/libtests/bits.cc index e63ebdd3..af715da8 100644 --- a/libtests/bits.cc +++ b/libtests/bits.cc @@ -141,7 +141,7 @@ test() unsigned char ch = 0; bit_offset = 7; - Pl_Buffer* bp = new Pl_Buffer("buffer"); + auto* bp = new Pl_Buffer("buffer"); test_write_bits(ch, bit_offset, 30UL, 5, bp); test_write_bits(ch, bit_offset, 10UL, 4, bp); diff --git a/libtests/flate.cc b/libtests/flate.cc index 93c41f85..9b64ca67 100644 --- a/libtests/flate.cc +++ b/libtests/flate.cc @@ -28,7 +28,7 @@ run(char const* filename) Pipeline* inf2 = new Pl_Flate("inf2", out2, Pl_Flate::a_inflate); // Count bytes written to o3 - Pl_Count* count3 = new Pl_Count("count3", out3); + auto* count3 = new Pl_Count("count3", out3); // Do both simultaneously Pipeline* inf3 = new Pl_Flate("inf3", count3, Pl_Flate::a_inflate); diff --git a/libtests/pointer_holder.cc b/libtests/pointer_holder.cc index e5a58d17..4b9d43cb 100644 --- a/libtests/pointer_holder.cc +++ b/libtests/pointer_holder.cc @@ -72,7 +72,7 @@ test_ph() ObjectHolder oh0; { std::cout << "hello" << std::endl; - Object* o1 = new Object; + auto* o1 = new Object; ObjectHolder oh1(o1); std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl; ObjectHolder oh2(oh1); @@ -95,7 +95,7 @@ test_ph() } ol1.push_back(oh3); ol1.push_back(oh3); - Object* o3 = new Object; + auto* o3 = new Object; oh0 = o3; PointerHolder oh6(new Object()); oh6->hello(); diff --git a/libtests/rc4.cc b/libtests/rc4.cc index ca4af91d..300c6201 100644 --- a/libtests/rc4.cc +++ b/libtests/rc4.cc @@ -41,7 +41,7 @@ main(int argc, char* argv[]) char* outfilename = argv[3]; unsigned int hexkeylen = QIntC::to_uint(strlen(hexkey)); unsigned int keylen = hexkeylen / 2; - unsigned char* key = new unsigned char[keylen + 1]; + auto* key = new unsigned char[keylen + 1]; key[keylen] = '\0'; FILE* infile = QUtil::safe_fopen(infilename, "rb"); @@ -56,9 +56,9 @@ main(int argc, char* argv[]) } FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); - Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); + auto* out = new Pl_StdioFile("stdout", outfile); // Use a small buffer size (64) for testing - Pl_RC4* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U); + auto* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U); delete[] key; // 64 < buffer size < 512, buffer_size is not a power of 2 for testing diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index e9e7754c..da1be6c0 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -499,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(provider); qstream.replaceStreamData( p, @@ -1068,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 @@ -1095,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; diff --git a/qpdf/test_large_file.cc b/qpdf/test_large_file.cc index aea7c0c5..cfd1c5db 100644 --- a/qpdf/test_large_file.cc +++ b/qpdf/test_large_file.cc @@ -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 provider(p); image.replaceStreamData( provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); diff --git a/qpdf/test_tokenizer.cc b/qpdf/test_tokenizer.cc index d9c09c0b..507de459 100644 --- a/qpdf/test_tokenizer.cc +++ b/qpdf/test_tokenizer.cc @@ -190,7 +190,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) std::shared_ptr is; // Tokenize file, skipping streams - FileInputSource* fis = new FileInputSource(filename); + auto* fis = new FileInputSource(filename); is = std::shared_ptr(fis); dump_tokens(is, "FILE", max_len, include_ignorable, true, false); @@ -203,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(bis); dump_tokens( @@ -220,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 b = obj.getStreamData(qpdf_dl_specialized); - BufferInputSource* bis = + auto* bis = new BufferInputSource("object stream data", b.get()); is = std::shared_ptr(bis); dump_tokens( -- cgit v1.2.3-54-g00ecf