Commit d0682f0f609e979ba085d93a1a0d8e0559f739bb

Authored by m-holger
1 parent e28f4efb

Use nullptr instead of 0 or NULL

examples/qpdfjob-remove-annotations.cc
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 // The example is a full copy of the qpdf program modified to allways remove all 11 // The example is a full copy of the qpdf program modified to allways remove all
12 // annotations from the final output. 12 // annotations from the final output.
13 13
14 -static char const* whoami = 0; 14 +static char const* whoami = nullptr;
15 15
16 static void 16 static void
17 usageExit(std::string const& msg) 17 usageExit(std::string const& msg)
include/qpdf/Pl_Buffer.hh
@@ -43,7 +43,7 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline @@ -43,7 +43,7 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline
43 { 43 {
44 public: 44 public:
45 QPDF_DLL 45 QPDF_DLL
46 - Pl_Buffer(char const* identifier, Pipeline* next = 0); 46 + Pl_Buffer(char const* identifier, Pipeline* next = nullptr);
47 QPDF_DLL 47 QPDF_DLL
48 virtual ~Pl_Buffer(); 48 virtual ~Pl_Buffer();
49 QPDF_DLL 49 QPDF_DLL
include/qpdf/Pl_DCT.hh
@@ -57,7 +57,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline @@ -57,7 +57,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
57 JDIMENSION image_height, 57 JDIMENSION image_height,
58 int components, 58 int components,
59 J_COLOR_SPACE color_space, 59 J_COLOR_SPACE color_space,
60 - CompressConfig* config_callback = 0); 60 + CompressConfig* config_callback = nullptr);
61 61
62 QPDF_DLL 62 QPDF_DLL
63 virtual ~Pl_DCT(); 63 virtual ~Pl_DCT();
@@ -91,7 +91,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline @@ -91,7 +91,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
91 JDIMENSION image_height = 0, 91 JDIMENSION image_height = 0,
92 int components = 1, 92 int components = 1,
93 J_COLOR_SPACE color_space = JCS_GRAYSCALE, 93 J_COLOR_SPACE color_space = JCS_GRAYSCALE,
94 - CompressConfig* config_callback = 0); 94 + CompressConfig* config_callback = nullptr);
95 Members(Members const&) = delete; 95 Members(Members const&) = delete;
96 96
97 action_e action; 97 action_e action;
include/qpdf/Pl_QPDFTokenizer.hh
@@ -51,7 +51,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline @@ -51,7 +51,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
51 Pl_QPDFTokenizer( 51 Pl_QPDFTokenizer(
52 char const* identifier, 52 char const* identifier,
53 QPDFObjectHandle::TokenFilter* filter, 53 QPDFObjectHandle::TokenFilter* filter,
54 - Pipeline* next = 0); 54 + Pipeline* next = nullptr);
55 QPDF_DLL 55 QPDF_DLL
56 virtual ~Pl_QPDFTokenizer(); 56 virtual ~Pl_QPDFTokenizer();
57 QPDF_DLL 57 QPDF_DLL
include/qpdf/QPDF.hh
@@ -83,7 +83,7 @@ class QPDF @@ -83,7 +83,7 @@ class QPDF
83 // interpreted as a raw encryption key. See comments on 83 // interpreted as a raw encryption key. See comments on
84 // setPasswordIsHexKey for more information. 84 // setPasswordIsHexKey for more information.
85 QPDF_DLL 85 QPDF_DLL
86 - void processFile(char const* filename, char const* password = 0); 86 + void processFile(char const* filename, char const* password = nullptr);
87 87
88 // Parse a PDF from a stdio FILE*. The FILE must be open in 88 // Parse a PDF from a stdio FILE*. The FILE must be open in
89 // binary mode and must be seekable. It may be open read only. 89 // binary mode and must be seekable. It may be open read only.
@@ -96,7 +96,7 @@ class QPDF @@ -96,7 +96,7 @@ class QPDF
96 char const* description, 96 char const* description,
97 FILE* file, 97 FILE* file,
98 bool close_file, 98 bool close_file,
99 - char const* password = 0); 99 + char const* password = nullptr);
100 100
101 // Parse a PDF file loaded into a memory buffer. This works 101 // Parse a PDF file loaded into a memory buffer. This works
102 // exactly like processFile except that the PDF file is in memory 102 // exactly like processFile except that the PDF file is in memory
@@ -107,14 +107,14 @@ class QPDF @@ -107,14 +107,14 @@ class QPDF
107 char const* description, 107 char const* description,
108 char const* buf, 108 char const* buf,
109 size_t length, 109 size_t length,
110 - char const* password = 0); 110 + char const* password = nullptr);
111 111
112 // Parse a PDF file loaded from a custom InputSource. If you have 112 // Parse a PDF file loaded from a custom InputSource. If you have
113 // your own method of retrieving a PDF file, you can subclass 113 // your own method of retrieving a PDF file, you can subclass
114 // InputSource and use this method. 114 // InputSource and use this method.
115 QPDF_DLL 115 QPDF_DLL
116 void 116 void
117 - processInputSource(std::shared_ptr<InputSource>, char const* password = 0); 117 + processInputSource(std::shared_ptr<InputSource>, char const* password = nullptr);
118 118
119 // Create a PDF from an input source that contains JSON as written 119 // Create a PDF from an input source that contains JSON as written
120 // by writeJSON (or qpdf --json-output, version 2 or higher). The 120 // by writeJSON (or qpdf --json-output, version 2 or higher). The
include/qpdf/QPDFCryptoImpl.hh
@@ -80,7 +80,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl @@ -80,7 +80,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
80 virtual void RC4_process( 80 virtual void RC4_process(
81 unsigned char const* in_data, 81 unsigned char const* in_data,
82 size_t len, 82 size_t len,
83 - unsigned char* out_data = 0) = 0; 83 + unsigned char* out_data = nullptr) = 0;
84 QPDF_DLL 84 QPDF_DLL
85 virtual void RC4_finalize() = 0; 85 virtual void RC4_finalize() = 0;
86 86
include/qpdf/QPDFJob.hh
@@ -497,7 +497,7 @@ class QPDFJob @@ -497,7 +497,7 @@ class QPDFJob
497 497
498 // Helper functions 498 // Helper functions
499 static void usage(std::string const& msg); 499 static void usage(std::string const& msg);
500 - static JSON json_schema(int json_version, std::set<std::string>* keys = 0); 500 + static JSON json_schema(int json_version, std::set<std::string>* keys = nullptr);
501 static void parse_object_id( 501 static void parse_object_id(
502 std::string const& objspec, bool& trailer, int& obj, int& gen); 502 std::string const& objspec, bool& trailer, int& obj, int& gen);
503 void parseRotationParameter(std::string const&); 503 void parseRotationParameter(std::string const&);
include/qpdf/QPDFObjectHandle.hh
@@ -526,7 +526,7 @@ class QPDFObjectHandle @@ -526,7 +526,7 @@ class QPDFObjectHandle
526 QPDF_DLL 526 QPDF_DLL
527 void parsePageContents(ParserCallbacks* callbacks); 527 void parsePageContents(ParserCallbacks* callbacks);
528 QPDF_DLL 528 QPDF_DLL
529 - void filterPageContents(TokenFilter* filter, Pipeline* next = 0); 529 + void filterPageContents(TokenFilter* filter, Pipeline* next = nullptr);
530 // See comments for QPDFPageObjectHelper::pipeContents. 530 // See comments for QPDFPageObjectHelper::pipeContents.
531 QPDF_DLL 531 QPDF_DLL
532 void pipePageContents(Pipeline* p); 532 void pipePageContents(Pipeline* p);
@@ -538,7 +538,7 @@ class QPDFObjectHandle @@ -538,7 +538,7 @@ class QPDFObjectHandle
538 // contents. This can be used to apply a TokenFilter to a form 538 // contents. This can be used to apply a TokenFilter to a form
539 // XObject, whose data is in the same format as a content stream. 539 // XObject, whose data is in the same format as a content stream.
540 QPDF_DLL 540 QPDF_DLL
541 - void filterAsContents(TokenFilter* filter, Pipeline* next = 0); 541 + void filterAsContents(TokenFilter* filter, Pipeline* next = nullptr);
542 // Called on a stream to parse the stream as page contents. This 542 // Called on a stream to parse the stream as page contents. This
543 // can be used to parse a form XObject. 543 // can be used to parse a form XObject.
544 QPDF_DLL 544 QPDF_DLL
include/qpdf/QPDFOutlineObjectHelper.hh
@@ -42,7 +42,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper @@ -42,7 +42,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
42 { 42 {
43 // This must be cleared explicitly to avoid circular references 43 // This must be cleared explicitly to avoid circular references
44 // that prevent cleanup of pointer holders. 44 // that prevent cleanup of pointer holders.
45 - this->m->parent = 0; 45 + this->m->parent = nullptr;
46 } 46 }
47 47
48 // All constructors are private. You can only create one of these 48 // All constructors are private. You can only create one of these
include/qpdf/QPDFPageObjectHelper.hh
@@ -320,12 +320,12 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -320,12 +320,12 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
320 // examples/pdf-count-strings.cc for an example. 320 // examples/pdf-count-strings.cc for an example.
321 QPDF_DLL 321 QPDF_DLL
322 void 322 void
323 - filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0); 323 + filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
324 324
325 // Old name -- calls filterContents() 325 // Old name -- calls filterContents()
326 QPDF_DLL 326 QPDF_DLL
327 void filterPageContents( 327 void filterPageContents(
328 - QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0); 328 + QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
329 329
330 // Pipe a page's contents through the given pipeline. This method 330 // Pipe a page's contents through the given pipeline. This method
331 // works whether the contents are a single stream or an array of 331 // works whether the contents are a single stream or an array of
include/qpdf/QPDFWriter.hh
@@ -539,7 +539,7 @@ class QPDFWriter @@ -539,7 +539,7 @@ class QPDFWriter
539 friend class QPDFWriter; 539 friend class QPDFWriter;
540 540
541 public: 541 public:
542 - PipelinePopper(QPDFWriter* qw, std::shared_ptr<Buffer>* bp = 0) : 542 + PipelinePopper(QPDFWriter* qw, std::shared_ptr<Buffer>* bp = nullptr) :
543 qw(qw), 543 qw(qw),
544 bp(bp) 544 bp(bp)
545 { 545 {
include/qpdf/QUtil.hh
@@ -245,7 +245,7 @@ namespace QUtil @@ -245,7 +245,7 @@ namespace QUtil
245 // Returns true iff the variable is defined. If `value' is 245 // Returns true iff the variable is defined. If `value' is
246 // non-null, initializes it with the value of the variable. 246 // non-null, initializes it with the value of the variable.
247 QPDF_DLL 247 QPDF_DLL
248 - bool get_env(std::string const& var, std::string* value = 0); 248 + bool get_env(std::string const& var, std::string* value = nullptr);
249 249
250 QPDF_DLL 250 QPDF_DLL
251 time_t get_current_time(); 251 time_t get_current_time();
libqpdf/QUtil.cc
@@ -836,8 +836,8 @@ char* @@ -836,8 +836,8 @@ char*
836 QUtil::getWhoami(char* argv0) 836 QUtil::getWhoami(char* argv0)
837 { 837 {
838 char* whoami = nullptr; 838 char* whoami = nullptr;
839 - if (((whoami = strrchr(argv0, '/')) == NULL) &&  
840 - ((whoami = strrchr(argv0, '\\')) == NULL)) { 839 + if (((whoami = strrchr(argv0, '/')) == nullptr) &&
  840 + ((whoami = strrchr(argv0, '\\')) == nullptr)) {
841 whoami = argv0; 841 whoami = argv0;
842 } else { 842 } else {
843 ++whoami; 843 ++whoami;
libqpdf/qpdf/Pl_SHA2.hh
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 class Pl_SHA2: public Pipeline 20 class Pl_SHA2: public Pipeline
21 { 21 {
22 public: 22 public:
23 - Pl_SHA2(int bits = 0, Pipeline* next = 0); 23 + Pl_SHA2(int bits = 0, Pipeline* next = nullptr);
24 virtual ~Pl_SHA2() = default; 24 virtual ~Pl_SHA2() = default;
25 virtual void write(unsigned char const*, size_t); 25 virtual void write(unsigned char const*, size_t);
26 virtual void finish(); 26 virtual void finish();
libqpdf/qpdf/QPDFArgParser.hh
@@ -177,9 +177,9 @@ class QPDFArgParser @@ -177,9 +177,9 @@ class QPDFArgParser
177 { 177 {
178 OptionEntry() : 178 OptionEntry() :
179 parameter_needed(false), 179 parameter_needed(false),
180 - bare_arg_handler(0),  
181 - param_arg_handler(0),  
182 - invalid_choice_handler(0) 180 + bare_arg_handler(nullptr),
  181 + param_arg_handler(nullptr),
  182 + invalid_choice_handler(nullptr)
183 { 183 {
184 } 184 }
185 bool parameter_needed; 185 bool parameter_needed;
libqpdf/qpdf/QPDFCrypto_openssl.hh
@@ -39,7 +39,7 @@ class QPDFCrypto_openssl: public QPDFCryptoImpl @@ -39,7 +39,7 @@ class QPDFCrypto_openssl: public QPDFCryptoImpl
39 void RC4_process( 39 void RC4_process(
40 unsigned char const* in_data, 40 unsigned char const* in_data,
41 size_t len, 41 size_t len,
42 - unsigned char* out_data = 0) override; 42 + unsigned char* out_data = nullptr) override;
43 void RC4_finalize() override; 43 void RC4_finalize() override;
44 44
45 void SHA2_init(int bits) override; 45 void SHA2_init(int bits) override;
libtests/aes.cc
@@ -29,9 +29,9 @@ main(int argc, char* argv[]) @@ -29,9 +29,9 @@ main(int argc, char* argv[])
29 { 29 {
30 bool encrypt = true; 30 bool encrypt = true;
31 bool cbc_mode = true; 31 bool cbc_mode = true;
32 - char* hexkey = 0;  
33 - char* infilename = 0;  
34 - char* outfilename = 0; 32 + char* hexkey = nullptr;
  33 + char* infilename = nullptr;
  34 + char* outfilename = nullptr;
35 bool zero_iv = false; 35 bool zero_iv = false;
36 bool static_iv = false; 36 bool static_iv = false;
37 bool disable_padding = false; 37 bool disable_padding = false;
@@ -65,7 +65,7 @@ main(int argc, char* argv[]) @@ -65,7 +65,7 @@ main(int argc, char* argv[])
65 usage(); 65 usage();
66 } 66 }
67 } 67 }
68 - if (outfilename == 0) { 68 + if (outfilename == nullptr) {
69 usage(); 69 usage();
70 } 70 }
71 71
@@ -81,14 +81,14 @@ main(int argc, char* argv[]) @@ -81,14 +81,14 @@ main(int argc, char* argv[])
81 t[1] = hexkey[i + 1]; 81 t[1] = hexkey[i + 1];
82 t[2] = '\0'; 82 t[2] = '\0';
83 83
84 - long val = strtol(t, 0, 16); 84 + long val = strtol(t, nullptr, 16);
85 key[i / 2] = static_cast<unsigned char>(val); 85 key[i / 2] = static_cast<unsigned char>(val);
86 } 86 }
87 87
88 Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); 88 Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile);
89 Pl_AES_PDF* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen); 89 Pl_AES_PDF* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen);
90 delete[] key; 90 delete[] key;
91 - key = 0; 91 + key = nullptr;
92 if (!cbc_mode) { 92 if (!cbc_mode) {
93 aes->disableCBC(); 93 aes->disableCBC();
94 } 94 }
libtests/arg_parser.cc
@@ -51,7 +51,7 @@ ArgParser::initOptions() @@ -51,7 +51,7 @@ ArgParser::initOptions()
51 ap.addBare("potato", b(&ArgParser::handlePotato)); 51 ap.addBare("potato", b(&ArgParser::handlePotato));
52 ap.addRequiredParameter("salad", p(&ArgParser::handleSalad), "tossed"); 52 ap.addRequiredParameter("salad", p(&ArgParser::handleSalad), "tossed");
53 ap.addOptionalParameter("moo", p(&ArgParser::handleMoo)); 53 ap.addOptionalParameter("moo", p(&ArgParser::handleMoo));
54 - char const* choices[] = {"pig", "boar", "sow", 0}; 54 + char const* choices[] = {"pig", "boar", "sow", nullptr};
55 ap.addChoices("oink", p(&ArgParser::handleOink), true, choices); 55 ap.addChoices("oink", p(&ArgParser::handleOink), true, choices);
56 ap.selectHelpOptionTable(); 56 ap.selectHelpOptionTable();
57 ap.addBare("version", [this]() { output("3.14159"); }); 57 ap.addBare("version", [this]() { output("3.14159"); });
libtests/numrange.cc
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 static void 4 static void
5 test_numrange(char const* range) 5 test_numrange(char const* range)
6 { 6 {
7 - if (range == 0) { 7 + if (range == nullptr) {
8 std::cout << "null" << std::endl; 8 std::cout << "null" << std::endl;
9 } else { 9 } else {
10 std::vector<int> result = QUtil::parse_numrange(range, 15); 10 std::vector<int> result = QUtil::parse_numrange(range, 15);
libtests/predictors.cc
@@ -21,7 +21,7 @@ run(char const* filename, @@ -21,7 +21,7 @@ run(char const* filename,
21 FILE* in = QUtil::safe_fopen(filename, "rb"); 21 FILE* in = QUtil::safe_fopen(filename, "rb");
22 FILE* o1 = QUtil::safe_fopen("out", "wb"); 22 FILE* o1 = QUtil::safe_fopen("out", "wb");
23 Pipeline* out = new Pl_StdioFile("out", o1); 23 Pipeline* out = new Pl_StdioFile("out", o1);
24 - Pipeline* pl = 0; 24 + Pipeline* pl = nullptr;
25 if (strcmp(filter, "png") == 0) { 25 if (strcmp(filter, "png") == 0) {
26 pl = new Pl_PNGFilter( 26 pl = new Pl_PNGFilter(
27 "png", 27 "png",
libtests/qutil.cc
@@ -489,7 +489,7 @@ same_file_test() @@ -489,7 +489,7 @@ same_file_test()
489 assert_same_file("qutil.out", "qutil.out", true); 489 assert_same_file("qutil.out", "qutil.out", true);
490 assert_same_file("qutil.out", "other-file", false); 490 assert_same_file("qutil.out", "other-file", false);
491 assert_same_file("qutil.out", "", false); 491 assert_same_file("qutil.out", "", false);
492 - assert_same_file("qutil.out", 0, false); 492 + assert_same_file("qutil.out", nullptr, false);
493 assert_same_file("", "qutil.out", false); 493 assert_same_file("", "qutil.out", false);
494 } 494 }
495 495
libtests/random.cc
@@ -56,7 +56,7 @@ main() @@ -56,7 +56,7 @@ main()
56 if (!((buf[0] == 0) && (buf[1] == 1) && (buf[2] == 2) && (buf[3] == 3))) { 56 if (!((buf[0] == 0) && (buf[1] == 1) && (buf[2] == 2) && (buf[3] == 3))) {
57 std::cout << "fail: bogus random didn't provide correct bytes\n"; 57 std::cout << "fail: bogus random didn't provide correct bytes\n";
58 } 58 }
59 - QUtil::setRandomDataProvider(0); 59 + QUtil::setRandomDataProvider(nullptr);
60 if (QUtil::getRandomDataProvider() != orig_rdp) { 60 if (QUtil::getRandomDataProvider() != orig_rdp) {
61 std::cout << "fail: passing null to setRandomDataProvider " 61 std::cout << "fail: passing null to setRandomDataProvider "
62 "didn't reset the random data provider\n"; 62 "didn't reset the random data provider\n";
libtests/rc4.cc
@@ -51,7 +51,7 @@ main(int argc, char* argv[]) @@ -51,7 +51,7 @@ main(int argc, char* argv[])
51 t[1] = hexkey[i + 1]; 51 t[1] = hexkey[i + 1];
52 t[2] = '\0'; 52 t[2] = '\0';
53 53
54 - long val = strtol(t, 0, 16); 54 + long val = strtol(t, nullptr, 16);
55 key[i / 2] = static_cast<unsigned char>(val); 55 key[i / 2] = static_cast<unsigned char>(val);
56 } 56 }
57 57
qpdf/fix-qdf.cc
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 #include <regex> 8 #include <regex>
9 #include <string_view> 9 #include <string_view>
10 10
11 -static char const* whoami = 0; 11 +static char const* whoami = nullptr;
12 12
13 static void 13 static void
14 usage() 14 usage()
@@ -392,7 +392,7 @@ realmain(int argc, char* argv[]) @@ -392,7 +392,7 @@ realmain(int argc, char* argv[])
392 { 392 {
393 whoami = QUtil::getWhoami(argv[0]); 393 whoami = QUtil::getWhoami(argv[0]);
394 QUtil::setLineBuf(stdout); 394 QUtil::setLineBuf(stdout);
395 - char const* filename = 0; 395 + char const* filename = nullptr;
396 if (argc > 2) { 396 if (argc > 2) {
397 usage(); 397 usage();
398 } else if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) { 398 } else if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) {
@@ -405,7 +405,7 @@ realmain(int argc, char* argv[]) @@ -405,7 +405,7 @@ realmain(int argc, char* argv[])
405 filename = argv[1]; 405 filename = argv[1];
406 } 406 }
407 std::string input; 407 std::string input;
408 - if (filename == 0) { 408 + if (filename == nullptr) {
409 filename = "standard input"; 409 filename = "standard input";
410 QUtil::binary_stdin(); 410 QUtil::binary_stdin();
411 input = QUtil::read_file_into_string(stdin); 411 input = QUtil::read_file_into_string(stdin);
qpdf/pdf_from_scratch.cc
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <cstring> 10 #include <cstring>
11 11
12 -static char const* whoami = 0; 12 +static char const* whoami = nullptr;
13 13
14 void 14 void
15 usage() 15 usage()
@@ -86,7 +86,7 @@ int @@ -86,7 +86,7 @@ int
86 main(int argc, char* argv[]) 86 main(int argc, char* argv[])
87 { 87 {
88 QUtil::setLineBuf(stdout); 88 QUtil::setLineBuf(stdout);
89 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 89 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
90 whoami = argv[0]; 90 whoami = argv[0];
91 } else { 91 } else {
92 ++whoami; 92 ++whoami;
qpdf/qpdf.cc
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 #include <cstdlib> 6 #include <cstdlib>
7 #include <iostream> 7 #include <iostream>
8 8
9 -static char const* whoami = 0; 9 +static char const* whoami = nullptr;
10 10
11 static void 11 static void
12 usageExit(std::string const& msg) 12 usageExit(std::string const& msg)
qpdf/test_driver.cc
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 #define QPDF_OBJECT_NOWARN 37 #define QPDF_OBJECT_NOWARN
38 #include <qpdf/QPDFObject.hh> 38 #include <qpdf/QPDFObject.hh>
39 39
40 -static char const* whoami = 0; 40 +static char const* whoami = nullptr;
41 41
42 void 42 void
43 usage() 43 usage()
@@ -286,7 +286,7 @@ test_0_1(QPDF&amp; pdf, char const* arg2) @@ -286,7 +286,7 @@ test_0_1(QPDF&amp; pdf, char const* arg2)
286 qtest.pipeStreamData(out.get(), 0, qpdf_dl_none); 286 qtest.pipeStreamData(out.get(), 0, qpdf_dl_none);
287 287
288 std::cout << std::endl << "Uncompressed stream data:" << std::endl; 288 std::cout << std::endl << "Uncompressed stream data:" << std::endl;
289 - if (qtest.pipeStreamData(0, 0, qpdf_dl_all)) { 289 + if (qtest.pipeStreamData(nullptr, 0, qpdf_dl_all)) {
290 std::cout.flush(); 290 std::cout.flush();
291 QUtil::binary_stdout(); 291 QUtil::binary_stdout();
292 out = std::make_shared<Pl_StdioFile>("filtered", stdout); 292 out = std::make_shared<Pl_StdioFile>("filtered", stdout);
@@ -387,7 +387,7 @@ test_4(QPDF&amp; pdf, char const* arg2) @@ -387,7 +387,7 @@ test_4(QPDF&amp; pdf, char const* arg2)
387 } 387 }
388 388
389 trailer.replaceKey("/Info", pdf.makeIndirectObject(qtest)); 389 trailer.replaceKey("/Info", pdf.makeIndirectObject(qtest));
390 - QPDFWriter w(pdf, 0); 390 + QPDFWriter w(pdf, nullptr);
391 w.setQDFMode(true); 391 w.setQDFMode(true);
392 w.setStaticID(true); 392 w.setStaticID(true);
393 w.write(); 393 w.write();
@@ -599,7 +599,7 @@ test_12(QPDF&amp; pdf, char const* arg2) @@ -599,7 +599,7 @@ test_12(QPDF&amp; pdf, char const* arg2)
599 # pragma GCC diagnostic push 599 # pragma GCC diagnostic push
600 # pragma GCC diagnostic ignored "-Wdeprecated-declarations" 600 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
601 #endif 601 #endif
602 - pdf.setOutputStreams(0, 0); 602 + pdf.setOutputStreams(nullptr, nullptr);
603 #if (defined(__GNUC__) || defined(__clang__)) 603 #if (defined(__GNUC__) || defined(__clang__))
604 # pragma GCC diagnostic pop 604 # pragma GCC diagnostic pop
605 #endif 605 #endif
@@ -1009,7 +1009,7 @@ test_25(QPDF&amp; pdf, char const* arg2) @@ -1009,7 +1009,7 @@ test_25(QPDF&amp; pdf, char const* arg2)
1009 // Copy qtest without crossing page boundaries. Should get O1 1009 // Copy qtest without crossing page boundaries. Should get O1
1010 // and O2 and their streams but not O3 or any other pages. 1010 // and O2 and their streams but not O3 or any other pages.
1011 1011
1012 - assert(arg2 != 0); 1012 + assert(arg2 != nullptr);
1013 { 1013 {
1014 // Make sure original PDF is out of scope when we write. 1014 // Make sure original PDF is out of scope when we write.
1015 QPDF oldpdf; 1015 QPDF oldpdf;
@@ -1035,7 +1035,7 @@ test_26(QPDF&amp; pdf, char const* arg2) @@ -1035,7 +1035,7 @@ test_26(QPDF&amp; pdf, char const* arg2)
1035 1035
1036 { 1036 {
1037 // Make sure original PDF is out of scope when we write. 1037 // Make sure original PDF is out of scope when we write.
1038 - assert(arg2 != 0); 1038 + assert(arg2 != nullptr);
1039 QPDF oldpdf; 1039 QPDF oldpdf;
1040 oldpdf.processFile(arg2); 1040 oldpdf.processFile(arg2);
1041 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest"); 1041 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest");
@@ -1104,7 +1104,7 @@ test_27(QPDF&amp; pdf, char const* arg2) @@ -1104,7 +1104,7 @@ test_27(QPDF&amp; pdf, char const* arg2)
1104 QPDFObjectHandle s3 = QPDFObjectHandle::newStream(&empty3); 1104 QPDFObjectHandle s3 = QPDFObjectHandle::newStream(&empty3);
1105 s3.replaceStreamData( 1105 s3.replaceStreamData(
1106 p2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); 1106 p2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
1107 - assert(arg2 != 0); 1107 + assert(arg2 != nullptr);
1108 QPDF oldpdf; 1108 QPDF oldpdf;
1109 oldpdf.processFile(arg2); 1109 oldpdf.processFile(arg2);
1110 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest"); 1110 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest");
@@ -1151,7 +1151,7 @@ static void @@ -1151,7 +1151,7 @@ static void
1151 test_29(QPDF& pdf, char const* arg2) 1151 test_29(QPDF& pdf, char const* arg2)
1152 { 1152 {
1153 // Detect mixed objects in QPDFWriter 1153 // Detect mixed objects in QPDFWriter
1154 - assert(arg2 != 0); 1154 + assert(arg2 != nullptr);
1155 auto other = QPDF::create(); 1155 auto other = QPDF::create();
1156 other->processFile(arg2); 1156 other->processFile(arg2);
1157 // We need to create a QPDF with mixed ownership to exercise 1157 // We need to create a QPDF with mixed ownership to exercise
@@ -1201,7 +1201,7 @@ test_29(QPDF&amp; pdf, char const* arg2) @@ -1201,7 +1201,7 @@ test_29(QPDF&amp; pdf, char const* arg2)
1201 static void 1201 static void
1202 test_30(QPDF& pdf, char const* arg2) 1202 test_30(QPDF& pdf, char const* arg2)
1203 { 1203 {
1204 - assert(arg2 != 0); 1204 + assert(arg2 != nullptr);
1205 QPDF encrypted; 1205 QPDF encrypted;
1206 encrypted.processFile(arg2, "user"); 1206 encrypted.processFile(arg2, "user");
1207 QPDFWriter w(pdf, "b.pdf"); 1207 QPDFWriter w(pdf, "b.pdf");
@@ -1433,7 +1433,7 @@ test_40(QPDF&amp; pdf, char const* arg2) @@ -1433,7 +1433,7 @@ test_40(QPDF&amp; pdf, char const* arg2)
1433 // feature was implemented by Sahil Arora 1433 // feature was implemented by Sahil Arora
1434 // <sahilarora.535@gmail.com> as part of a Google Summer of 1434 // <sahilarora.535@gmail.com> as part of a Google Summer of
1435 // Code project in 2017. 1435 // Code project in 2017.
1436 - assert(arg2 != 0); 1436 + assert(arg2 != nullptr);
1437 QPDFWriter w(pdf, arg2); 1437 QPDFWriter w(pdf, arg2);
1438 w.setPCLm(true); 1438 w.setPCLm(true);
1439 w.setStaticID(true); 1439 w.setStaticID(true);
@@ -3558,11 +3558,11 @@ runtest(int n, char const* filename1, char const* arg2) @@ -3558,11 +3558,11 @@ runtest(int n, char const* filename1, char const* arg2)
3558 3558
3559 QPDF pdf; 3559 QPDF pdf;
3560 std::shared_ptr<char> file_buf; 3560 std::shared_ptr<char> file_buf;
3561 - FILE* filep = 0; 3561 + FILE* filep = nullptr;
3562 if (n == 0) { 3562 if (n == 0) {
3563 pdf.setAttemptRecovery(false); 3563 pdf.setAttemptRecovery(false);
3564 } 3564 }
3565 - if (((n == 35) || (n == 36)) && (arg2 != 0)) { 3565 + if (((n == 35) || (n == 36)) && (arg2 != nullptr)) {
3566 // arg2 is password 3566 // arg2 is password
3567 pdf.processFile(filename1, arg2); 3567 pdf.processFile(filename1, arg2);
3568 } else if (n == 45) { 3568 } else if (n == 45) {
@@ -3652,7 +3652,7 @@ int @@ -3652,7 +3652,7 @@ int
3652 main(int argc, char* argv[]) 3652 main(int argc, char* argv[])
3653 { 3653 {
3654 QUtil::setLineBuf(stdout); 3654 QUtil::setLineBuf(stdout);
3655 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 3655 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
3656 whoami = argv[0]; 3656 whoami = argv[0];
3657 } else { 3657 } else {
3658 ++whoami; 3658 ++whoami;
qpdf/test_large_file.cc
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 // reading the large file then allows us to verify large file support 35 // reading the large file then allows us to verify large file support
36 // with confidence. 36 // with confidence.
37 37
38 -static char const* whoami = 0; 38 +static char const* whoami = nullptr;
39 39
40 // Height should be a multiple of 10 40 // Height should be a multiple of 10
41 static size_t const nstripes = 10; 41 static size_t const nstripes = 10;
@@ -47,7 +47,7 @@ static size_t const npages = 200; @@ -47,7 +47,7 @@ static size_t const npages = 200;
47 size_t stripesize = 0; 47 size_t stripesize = 0;
48 size_t width = 0; 48 size_t width = 0;
49 size_t height = 0; 49 size_t height = 0;
50 -static unsigned char* buf = 0; 50 +static unsigned char* buf = nullptr;
51 51
52 static inline unsigned char 52 static inline unsigned char
53 get_pixel_color(size_t n, size_t row) 53 get_pixel_color(size_t n, size_t row)
@@ -73,7 +73,7 @@ class ImageChecker: public Pipeline @@ -73,7 +73,7 @@ class ImageChecker: public Pipeline
73 }; 73 };
74 74
75 ImageChecker::ImageChecker(size_t n) : 75 ImageChecker::ImageChecker(size_t n) :
76 - Pipeline("image checker", 0), 76 + Pipeline("image checker", nullptr),
77 n(n), 77 n(n),
78 offset(0), 78 offset(0),
79 okay(true) 79 okay(true)
@@ -122,7 +122,7 @@ ImageProvider::ImageProvider(size_t n) : @@ -122,7 +122,7 @@ ImageProvider::ImageProvider(size_t n) :
122 void 122 void
123 ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline) 123 ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline)
124 { 124 {
125 - if (buf == 0) { 125 + if (buf == nullptr) {
126 buf = new unsigned char[width * stripesize]; 126 buf = new unsigned char[width * stripesize];
127 } 127 }
128 std::cout << "page " << n << " of " << npages << std::endl; 128 std::cout << "page " << n << " of " << npages << std::endl;
qpdf/test_pdf_doc_encoding.cc
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 #include <cstdlib> 4 #include <cstdlib>
5 #include <cstring> 5 #include <cstring>
6 6
7 -static char const* whoami = 0; 7 +static char const* whoami = nullptr;
8 8
9 void 9 void
10 usage() 10 usage()
@@ -16,7 +16,7 @@ usage() @@ -16,7 +16,7 @@ usage()
16 int 16 int
17 main(int argc, char* argv[]) 17 main(int argc, char* argv[])
18 { 18 {
19 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 19 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
20 whoami = argv[0]; 20 whoami = argv[0];
21 } else { 21 } else {
22 ++whoami; 22 ++whoami;
qpdf/test_pdf_unicode.cc
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 #include <cstdlib> 4 #include <cstdlib>
5 #include <cstring> 5 #include <cstring>
6 6
7 -static char const* whoami = 0; 7 +static char const* whoami = nullptr;
8 8
9 void 9 void
10 usage() 10 usage()
@@ -16,7 +16,7 @@ usage() @@ -16,7 +16,7 @@ usage()
16 int 16 int
17 main(int argc, char* argv[]) 17 main(int argc, char* argv[])
18 { 18 {
19 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 19 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
20 whoami = argv[0]; 20 whoami = argv[0];
21 } else { 21 } else {
22 ++whoami; 22 ++whoami;
qpdf/test_tokenizer.cc
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 #include <cstdlib> 11 #include <cstdlib>
12 #include <cstring> 12 #include <cstring>
13 13
14 -static char const* whoami = 0; 14 +static char const* whoami = nullptr;
15 15
16 void 16 void
17 usage() 17 usage()
@@ -91,7 +91,7 @@ tokenTypeName(QPDFTokenizer::token_type_e ttype) @@ -91,7 +91,7 @@ tokenTypeName(QPDFTokenizer::token_type_e ttype)
91 case QPDFTokenizer::tt_inline_image: 91 case QPDFTokenizer::tt_inline_image:
92 return "inline-image"; 92 return "inline-image";
93 } 93 }
94 - return 0; 94 + return nullptr;
95 } 95 }
96 96
97 static std::string 97 static std::string
@@ -238,13 +238,13 @@ int @@ -238,13 +238,13 @@ int
238 main(int argc, char* argv[]) 238 main(int argc, char* argv[])
239 { 239 {
240 QUtil::setLineBuf(stdout); 240 QUtil::setLineBuf(stdout);
241 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 241 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
242 whoami = argv[0]; 242 whoami = argv[0];
243 } else { 243 } else {
244 ++whoami; 244 ++whoami;
245 } 245 }
246 246
247 - char const* filename = 0; 247 + char const* filename = nullptr;
248 size_t max_len = 0; 248 size_t max_len = 0;
249 bool include_ignorable = true; 249 bool include_ignorable = true;
250 for (int i = 1; i < argc; ++i) { 250 for (int i = 1; i < argc; ++i) {
@@ -265,7 +265,7 @@ main(int argc, char* argv[]) @@ -265,7 +265,7 @@ main(int argc, char* argv[])
265 filename = argv[i]; 265 filename = argv[i];
266 } 266 }
267 } 267 }
268 - if (filename == 0) { 268 + if (filename == nullptr) {
269 usage(); 269 usage();
270 } 270 }
271 271
qpdf/test_unicode_filenames.cc
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 static void 12 static void
13 do_copy(FILE* in, FILE* out) 13 do_copy(FILE* in, FILE* out)
14 { 14 {
15 - if ((in == 0) || (out == 0)) { 15 + if ((in == nullptr) || (out == nullptr)) {
16 std::cerr << "errors opening files" << std::endl; 16 std::cerr << "errors opening files" << std::endl;
17 exit(2); 17 exit(2);
18 } 18 }
zlib-flate/zlib-flate.cc
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <cstring> 10 #include <cstring>
11 11
12 -static char const* whoami = 0; 12 +static char const* whoami = nullptr;
13 13
14 void 14 void
15 usage() 15 usage()
@@ -27,7 +27,7 @@ usage() @@ -27,7 +27,7 @@ usage()
27 int 27 int
28 main(int argc, char* argv[]) 28 main(int argc, char* argv[])
29 { 29 {
30 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 30 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
31 whoami = argv[0]; 31 whoami = argv[0];
32 } else { 32 } else {
33 ++whoami; 33 ++whoami;