Commit 4feb10fdaf51bf3f88b853cdb32a1e9b1692ba52

Authored by Jay Berkenbilt
Committed by GitHub
2 parents c9cc8cfd 073808aa

Merge pull request #734 from m-holger/nullptr

Code tidy : replace 0 with nullptr or true
examples/pdf-attach-file.cc
... ... @@ -15,7 +15,7 @@
15 15 // the use of the qpdf literal syntax introduced in qpdf 10.6.
16 16 //
17 17  
18   -static char const* whoami = 0;
  18 +static char const* whoami = nullptr;
19 19  
20 20 static void
21 21 usage(std::string const& msg)
... ... @@ -167,11 +167,11 @@ main(int argc, char* argv[])
167 167 {
168 168 whoami = QUtil::getWhoami(argv[0]);
169 169  
170   - char const* infilename = 0;
171   - char const* password = 0;
172   - char const* attachment = 0;
173   - char const* outfilename = 0;
174   - char const* mimetype = 0;
  170 + char const* infilename = nullptr;
  171 + char const* password = nullptr;
  172 + char const* attachment = nullptr;
  173 + char const* outfilename = nullptr;
  174 + char const* mimetype = nullptr;
175 175  
176 176 auto check_arg = [](char const* arg, std::string const& msg) {
177 177 if (arg == nullptr) {
... ...
examples/pdf-bookmarks.cc
... ... @@ -14,7 +14,7 @@
14 14 //
15 15 // Ignore calls to QTC::TC - they are for qpdf CI testing only.
16 16  
17   -static char const* whoami = 0;
  17 +static char const* whoami = nullptr;
18 18 static enum { st_none, st_numbers, st_lines } style = st_none;
19 19 static bool show_open = false;
20 20 static bool show_targets = false;
... ...
examples/pdf-count-strings.cc
... ... @@ -15,7 +15,7 @@
15 15 #include <qpdf/QPDFPageObjectHelper.hh>
16 16 #include <qpdf/QUtil.hh>
17 17  
18   -static char const* whoami = 0;
  18 +static char const* whoami = nullptr;
19 19  
20 20 void
21 21 usage()
... ...
examples/pdf-create.cc
... ... @@ -20,7 +20,7 @@
20 20 #include <stdlib.h>
21 21 #include <string.h>
22 22  
23   -static char const* whoami = 0;
  23 +static char const* whoami = nullptr;
24 24  
25 25 // This is a simple StreamDataProvider that writes image data for an
26 26 // orange square of the given width and height.
... ...
examples/pdf-custom-filter.cc
... ... @@ -37,7 +37,7 @@
37 37 // of running this example on test files that are specifically crafted
38 38 // for it.
39 39  
40   -static char const* whoami = 0;
  40 +static char const* whoami = nullptr;
41 41  
42 42 class Pl_XOR: public Pipeline
43 43 {
... ... @@ -447,8 +447,8 @@ main(int argc, char* argv[])
447 447 {
448 448 whoami = QUtil::getWhoami(argv[0]);
449 449  
450   - char const* infilename = 0;
451   - char const* outfilename = 0;
  450 + char const* infilename = nullptr;
  451 + char const* outfilename = nullptr;
452 452 bool decode_specialized = false;
453 453 for (int i = 1; i < argc; ++i) {
454 454 if (strcmp(argv[i], "--decode-specialized") == 0) {
... ...
examples/pdf-double-page-size.cc
... ... @@ -8,7 +8,7 @@
8 8 #include <stdlib.h>
9 9 #include <string.h>
10 10  
11   -static char const* whoami = 0;
  11 +static char const* whoami = nullptr;
12 12  
13 13 void
14 14 usage()
... ...
examples/pdf-filter-tokens.cc
... ... @@ -18,7 +18,7 @@
18 18 #include <qpdf/QPDFWriter.hh>
19 19 #include <qpdf/QUtil.hh>
20 20  
21   -static char const* whoami = 0;
  21 +static char const* whoami = nullptr;
22 22  
23 23 void
24 24 usage()
... ...
examples/pdf-invert-images.cc
... ... @@ -9,7 +9,7 @@
9 9 #include <stdlib.h>
10 10 #include <string.h>
11 11  
12   -static char const* whoami = 0;
  12 +static char const* whoami = nullptr;
13 13  
14 14 void
15 15 usage()
... ... @@ -142,7 +142,8 @@ main(int argc, char* argv[])
142 142 // pipeStreamData with a null pipeline to determine
143 143 // whether the image is filterable. Directly inspect
144 144 // keys to determine the image type.
145   - if (image.pipeStreamData(0, qpdf_ef_compress, qpdf_dl_all) &&
  145 + if (image.pipeStreamData(
  146 + nullptr, qpdf_ef_compress, qpdf_dl_all) &&
146 147 color_space.isNameAndEquals("/DeviceGray") &&
147 148 bits_per_component.isInteger() &&
148 149 (bits_per_component.getIntValue() == 8)) {
... ...
examples/pdf-mod-info.cc
... ... @@ -11,7 +11,7 @@
11 11 #include <string.h>
12 12  
13 13 static char const* version = "1.1";
14   -static char const* whoami = 0;
  14 +static char const* whoami = nullptr;
15 15  
16 16 void
17 17 usage()
... ... @@ -77,8 +77,8 @@ main(int argc, char* argv[])
77 77 exit(0);
78 78 }
79 79  
80   - char* fl_in = 0;
81   - char* fl_out = 0;
  80 + char* fl_in = nullptr;
  81 + char* fl_out = nullptr;
82 82 std::string cur_key;
83 83  
84 84 for (int i = 1; i < argc; ++i) {
... ...
examples/pdf-name-number-tree.cc
... ... @@ -6,7 +6,7 @@
6 6 #include <cstring>
7 7 #include <iostream>
8 8  
9   -static char const* whoami = 0;
  9 +static char const* whoami = nullptr;
10 10  
11 11 void
12 12 usage()
... ...
examples/pdf-npages.cc
... ... @@ -5,7 +5,7 @@
5 5 #include <qpdf/QPDF.hh>
6 6 #include <qpdf/QUtil.hh>
7 7  
8   -static char const* whoami = 0;
  8 +static char const* whoami = nullptr;
9 9  
10 10 void
11 11 usage()
... ...
examples/pdf-overlay-page.cc
... ... @@ -12,7 +12,7 @@
12 12 // --overlay and --underlay options provide a more general version of
13 13 // this capability.
14 14  
15   -static char const* whoami = 0;
  15 +static char const* whoami = nullptr;
16 16  
17 17 void
18 18 usage()
... ...
examples/pdf-parse-content.cc
... ... @@ -8,7 +8,7 @@
8 8 #include <qpdf/QPDFPageObjectHelper.hh>
9 9 #include <qpdf/QUtil.hh>
10 10  
11   -static char const* whoami = 0;
  11 +static char const* whoami = nullptr;
12 12  
13 13 void
14 14 usage()
... ...
examples/pdf-set-form-values.cc
... ... @@ -8,7 +8,7 @@
8 8 #include <stdlib.h>
9 9 #include <string.h>
10 10  
11   -static char const* whoami = 0;
  11 +static char const* whoami = nullptr;
12 12  
13 13 void
14 14 usage()
... ...
examples/qpdf-job.cc
... ... @@ -8,7 +8,7 @@
8 8 // This program is a simple demonstration of different ways to use the
9 9 // QPDFJob API.
10 10  
11   -static char const* whoami = 0;
  11 +static char const* whoami = nullptr;
12 12  
13 13 static void
14 14 usage()
... ...
libqpdf/Buffer.cc
... ... @@ -5,10 +5,10 @@
5 5 Buffer::Members::Members(size_t size, unsigned char* buf, bool own_memory) :
6 6 own_memory(own_memory),
7 7 size(size),
8   - buf(0)
  8 + buf(nullptr)
9 9 {
10 10 if (own_memory) {
11   - this->buf = (size ? new unsigned char[size] : 0);
  11 + this->buf = (size ? new unsigned char[size] : nullptr);
12 12 } else {
13 13 this->buf = buf;
14 14 }
... ... @@ -22,12 +22,12 @@ Buffer::Members::~Members()
22 22 }
23 23  
24 24 Buffer::Buffer() :
25   - m(new Members(0, 0, true))
  25 + m(new Members(0, nullptr, true))
26 26 {
27 27 }
28 28  
29 29 Buffer::Buffer(size_t size) :
30   - m(new Members(size, 0, true))
  30 + m(new Members(size, nullptr, true))
31 31 {
32 32 }
33 33  
... ... @@ -52,7 +52,8 @@ void
52 52 Buffer::copy(Buffer const& rhs)
53 53 {
54 54 if (this != &rhs) {
55   - this->m = std::shared_ptr<Members>(new Members(rhs.m->size, 0, true));
  55 + this->m =
  56 + std::shared_ptr<Members>(new Members(rhs.m->size, nullptr, true));
56 57 if (this->m->size) {
57 58 memcpy(this->m->buf, rhs.m->buf, this->m->size);
58 59 }
... ...
libqpdf/BufferInputSource.cc
... ... @@ -25,7 +25,7 @@ BufferInputSource::BufferInputSource(
25 25  
26 26 BufferInputSource::BufferInputSource(
27 27 std::string const& description, std::string const& contents) :
28   - m(new Members(true, description, 0))
  28 + m(new Members(true, description, nullptr))
29 29 {
30 30 this->m->buf = new Buffer(contents.length());
31 31 this->m->max_offset = QIntC::to_offset(this->m->buf->getSize());
... ...
libqpdf/ClosedFileInputSource.cc
... ... @@ -23,7 +23,7 @@ ClosedFileInputSource::~ClosedFileInputSource()
23 23 void
24 24 ClosedFileInputSource::before()
25 25 {
26   - if (0 == this->m->fis.get()) {
  26 + if (nullptr == this->m->fis.get()) {
27 27 this->m->fis =
28 28 std::make_shared<FileInputSource>(this->m->filename.c_str());
29 29 this->m->fis->seek(this->m->offset, SEEK_SET);
... ... @@ -39,7 +39,7 @@ ClosedFileInputSource::after()
39 39 if (this->m->stay_open) {
40 40 return;
41 41 }
42   - this->m->fis = 0;
  42 + this->m->fis = nullptr;
43 43 }
44 44  
45 45 qpdf_offset_t
... ...
libqpdf/FileInputSource.cc
... ... @@ -7,7 +7,7 @@
7 7  
8 8 FileInputSource::Members::Members(bool close_file) :
9 9 close_file(close_file),
10   - file(0)
  10 + file(nullptr)
11 11 {
12 12 }
13 13  
... ...
libqpdf/InputSource.cc
... ... @@ -69,7 +69,7 @@ InputSource::findFirst(
69 69 " too small or too large of a character sequence");
70 70 }
71 71  
72   - char* p = 0;
  72 + char* p = nullptr;
73 73 qpdf_offset_t buf_offset = offset;
74 74 size_t bytes_read = 0;
75 75  
... ... @@ -86,7 +86,8 @@ InputSource::findFirst(
86 86 // If p points to buf[size], since strlen(start_chars) is
87 87 // always >= 1, this overflow test will be correct for that
88 88 // case regardless of start_chars.
89   - if ((p == 0) || ((p + strlen(start_chars)) > (buf + bytes_read))) {
  89 + if ((p == nullptr) ||
  90 + ((p + strlen(start_chars)) > (buf + bytes_read))) {
90 91 if (p) {
91 92 QTC::TC(
92 93 "libtests",
... ... @@ -117,7 +118,7 @@ InputSource::findFirst(
117 118 memchr(
118 119 p,
119 120 start_chars[0],
120   - bytes_read - QIntC::to_size(p - buf)))) != 0) {
  121 + bytes_read - QIntC::to_size(p - buf)))) != nullptr) {
121 122 if (p == buf) {
122 123 QTC::TC("libtests", "InputSource found match at buf[0]");
123 124 }
... ...
libqpdf/JSON.cc
... ... @@ -204,7 +204,7 @@ JSON::JSON_blob::write(Pipeline* p, size_t) const
204 204 void
205 205 JSON::write(Pipeline* p, size_t depth) const
206 206 {
207   - if (0 == this->m->value.get()) {
  207 + if (nullptr == this->m->value.get()) {
208 208 *p << "null";
209 209 } else {
210 210 this->m->value->write(p, depth);
... ... @@ -270,7 +270,7 @@ JSON
270 270 JSON::addDictionaryMember(std::string const& key, JSON const& val)
271 271 {
272 272 JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
273   - if (0 == obj) {
  273 + if (nullptr == obj) {
274 274 throw std::runtime_error(
275 275 "JSON::addDictionaryMember called on non-dictionary");
276 276 }
... ... @@ -286,7 +286,7 @@ bool
286 286 JSON::checkDictionaryKeySeen(std::string const& key)
287 287 {
288 288 JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
289   - if (0 == obj) {
  289 + if (nullptr == obj) {
290 290 throw std::logic_error(
291 291 "JSON::checkDictionaryKey called on non-dictionary");
292 292 }
... ... @@ -307,7 +307,7 @@ JSON
307 307 JSON::addArrayElement(JSON const& val)
308 308 {
309 309 JSON_array* arr = dynamic_cast<JSON_array*>(this->m->value.get());
310   - if (0 == arr) {
  310 + if (nullptr == arr) {
311 311 throw std::runtime_error("JSON::addArrayElement called on non-array");
312 312 }
313 313 if (val.m->value.get()) {
... ...
libqpdf/Pipeline.cc
... ... @@ -14,7 +14,7 @@ Pipeline::Pipeline(char const* identifier, Pipeline* next) :
14 14 Pipeline*
15 15 Pipeline::getNext(bool allow_null)
16 16 {
17   - if ((this->next == 0) && (!allow_null)) {
  17 + if ((this->next == nullptr) && (!allow_null)) {
18 18 throw std::logic_error(
19 19 this->identifier +
20 20 ": Pipeline::getNext() called on pipeline with no next");
... ...
libqpdf/Pl_Buffer.cc
... ... @@ -26,7 +26,7 @@ Pl_Buffer::~Pl_Buffer()
26 26 void
27 27 Pl_Buffer::write(unsigned char const* buf, size_t len)
28 28 {
29   - if (this->m->data.get() == 0) {
  29 + if (this->m->data.get() == nullptr) {
30 30 this->m->data = std::make_shared<Buffer>(len);
31 31 }
32 32 size_t cur_size = this->m->data->getSize();
... ...
libqpdf/Pl_Discard.cc
... ... @@ -3,7 +3,7 @@
3 3 // Exercised in md5 test suite
4 4  
5 5 Pl_Discard::Pl_Discard() :
6   - Pipeline("discard", 0)
  6 + Pipeline("discard", nullptr)
7 7 {
8 8 }
9 9  
... ...
libqpdf/Pl_Flate.cc
... ... @@ -13,7 +13,7 @@ Pl_Flate::Members::Members(size_t out_bufsize, action_e action) :
13 13 out_bufsize(out_bufsize),
14 14 action(action),
15 15 initialized(false),
16   - zdata(0)
  16 + zdata(nullptr)
17 17 {
18 18 this->outbuf = QUtil::make_shared_array<unsigned char>(out_bufsize);
19 19 // Indirect through zdata to reach the z_stream so we don't have
... ... @@ -29,10 +29,10 @@ Pl_Flate::Members::Members(size_t out_bufsize, action_e action) :
29 29 }
30 30  
31 31 z_stream& zstream = *(static_cast<z_stream*>(this->zdata));
32   - zstream.zalloc = 0;
33   - zstream.zfree = 0;
34   - zstream.opaque = 0;
35   - zstream.next_in = 0;
  32 + zstream.zalloc = nullptr;
  33 + zstream.zfree = nullptr;
  34 + zstream.opaque = nullptr;
  35 + zstream.next_in = nullptr;
36 36 zstream.avail_in = 0;
37 37 zstream.next_out = this->outbuf.get();
38 38 zstream.avail_out = QIntC::to_uint(out_bufsize);
... ... @@ -50,7 +50,7 @@ Pl_Flate::Members::~Members()
50 50 }
51 51  
52 52 delete static_cast<z_stream*>(this->zdata);
53   - this->zdata = 0;
  53 + this->zdata = nullptr;
54 54 }
55 55  
56 56 Pl_Flate::Pl_Flate(
... ... @@ -86,7 +86,7 @@ Pl_Flate::warn(char const* msg, int code)
86 86 void
87 87 Pl_Flate::write(unsigned char const* data, size_t len)
88 88 {
89   - if (this->m->outbuf.get() == 0) {
  89 + if (this->m->outbuf.get() == nullptr) {
90 90 throw std::logic_error(
91 91 this->identifier +
92 92 ": Pl_Flate: write() called after finish() called");
... ... @@ -227,7 +227,7 @@ Pl_Flate::finish()
227 227 checkError("End", err);
228 228 }
229 229  
230   - this->m->outbuf = 0;
  230 + this->m->outbuf = nullptr;
231 231 }
232 232 } catch (std::exception& e) {
233 233 try {
... ...
libqpdf/Pl_LZWDecoder.cc
... ... @@ -14,7 +14,7 @@ Pl_LZWDecoder::Pl_LZWDecoder(
14 14 byte_pos(0),
15 15 bit_pos(0),
16 16 bits_available(0),
17   - code_change_delta(early_code_change ? 1 : 0),
  17 + code_change_delta(early_code_change),
18 18 eod(false),
19 19 last_code(256)
20 20 {
... ... @@ -107,7 +107,7 @@ void
107 107 Pl_LZWDecoder::addToTable(unsigned char next)
108 108 {
109 109 unsigned int last_size = 0;
110   - unsigned char const* last_data = 0;
  110 + unsigned char const* last_data = nullptr;
111 111 unsigned char tmp[1];
112 112  
113 113 if (this->last_code < 256) {
... ...
libqpdf/Pl_OStream.cc
... ... @@ -10,7 +10,7 @@ Pl_OStream::Members::Members(std::ostream&amp; os) :
10 10 }
11 11  
12 12 Pl_OStream::Pl_OStream(char const* identifier, std::ostream& os) :
13   - Pipeline(identifier, 0),
  13 + Pipeline(identifier, nullptr),
14 14 m(new Members(os))
15 15 {
16 16 }
... ...
libqpdf/Pl_PNGFilter.cc
... ... @@ -22,10 +22,10 @@ Pl_PNGFilter::Pl_PNGFilter(
22 22 unsigned int bits_per_sample) :
23 23 Pipeline(identifier, next),
24 24 action(action),
25   - cur_row(0),
26   - prev_row(0),
27   - buf1(0),
28   - buf2(0),
  25 + cur_row(nullptr),
  26 + prev_row(nullptr),
  27 + buf1(nullptr),
  28 + buf2(nullptr),
29 29 pos(0)
30 30 {
31 31 if (samples_per_pixel < 1) {
... ... @@ -243,7 +243,7 @@ Pl_PNGFilter::finish()
243 243 // write partial row
244 244 processRow();
245 245 }
246   - this->prev_row = 0;
  246 + this->prev_row = nullptr;
247 247 this->cur_row = buf1.get();
248 248 this->pos = 0;
249 249 memset(this->cur_row, 0, this->bytes_per_row + 1);
... ...
libqpdf/Pl_QPDFTokenizer.cc
... ... @@ -7,7 +7,7 @@
7 7 #include <string.h>
8 8  
9 9 Pl_QPDFTokenizer::Members::Members() :
10   - filter(0),
  10 + filter(nullptr),
11 11 buf("tokenizer buffer")
12 12 {
13 13 }
... ... @@ -68,7 +68,8 @@ Pl_QPDFTokenizer::finish()
68 68 }
69 69 }
70 70 this->m->filter->handleEOF();
71   - QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, 0);
  71 + QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(
  72 + m->filter, nullptr);
72 73 Pipeline* next = this->getNext(true);
73 74 if (next) {
74 75 next->finish();
... ...
libqpdf/Pl_RC4.cc
... ... @@ -18,7 +18,7 @@ Pl_RC4::Pl_RC4(
18 18 void
19 19 Pl_RC4::write(unsigned char const* data, size_t len)
20 20 {
21   - if (this->outbuf.get() == 0) {
  21 + if (this->outbuf.get() == nullptr) {
22 22 throw std::logic_error(
23 23 this->identifier +
24 24 ": Pl_RC4: write() called after finish() called");
... ... @@ -41,6 +41,6 @@ Pl_RC4::write(unsigned char const* data, size_t len)
41 41 void
42 42 Pl_RC4::finish()
43 43 {
44   - this->outbuf = 0;
  44 + this->outbuf = nullptr;
45 45 this->getNext()->finish();
46 46 }
... ...
libqpdf/Pl_StdioFile.cc
... ... @@ -12,7 +12,7 @@ Pl_StdioFile::Members::Members(FILE* f) :
12 12 }
13 13  
14 14 Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) :
15   - Pipeline(identifier, 0),
  15 + Pipeline(identifier, nullptr),
16 16 m(new Members(f))
17 17 {
18 18 }
... ...
libqpdf/QPDF.cc
... ... @@ -216,7 +216,7 @@ QPDF::Members::Members() :
216 216 pushed_inherited_attributes_to_pages(false),
217 217 ever_pushed_inherited_attributes_to_pages(false),
218 218 ever_called_get_all_pages(false),
219   - copied_stream_data_provider(0),
  219 + copied_stream_data_provider(nullptr),
220 220 reconstructed_xref(false),
221 221 fixed_dangling_refs(false),
222 222 immediate_copy_from(false),
... ... @@ -1496,7 +1496,7 @@ QPDF::readObject(
1496 1496  
1497 1497 bool empty = false;
1498 1498 std::shared_ptr<StringDecrypter> decrypter_ph;
1499   - StringDecrypter* decrypter = 0;
  1499 + StringDecrypter* decrypter = nullptr;
1500 1500 if (this->m->encp->encrypted && (!in_object_stream)) {
1501 1501 decrypter_ph = std::make_shared<StringDecrypter>(this, og);
1502 1502 decrypter = decrypter_ph.get();
... ... @@ -2434,7 +2434,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2434 2434  
2435 2435 QPDFObjectHandle dict = result.getDict();
2436 2436 QPDFObjectHandle old_dict = foreign.getDict();
2437   - if (this->m->copied_stream_data_provider == 0) {
  2437 + if (this->m->copied_stream_data_provider == nullptr) {
2438 2438 this->m->copied_stream_data_provider =
2439 2439 new CopiedStreamDataProvider(*this);
2440 2440 this->m->copied_streams =
... ... @@ -2457,7 +2457,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2457 2457 }
2458 2458 std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer();
2459 2459 if ((foreign_stream_qpdf->m->immediate_copy_from) &&
2460   - (stream_buffer.get() == 0)) {
  2460 + (stream_buffer.get() == nullptr)) {
2461 2461 // Pull the stream data into a buffer before attempting
2462 2462 // the copy operation. Do it on the source stream so that
2463 2463 // if the source stream is copied multiple times, we don't
... ...
libqpdf/QPDFArgParser.cc
... ... @@ -30,7 +30,7 @@ QPDFArgParser::QPDFArgParser(
30 30 m(new Members(argc, argv, progname_env))
31 31 {
32 32 selectHelpOptionTable();
33   - char const* help_choices[] = {"all", 0};
  33 + char const* help_choices[] = {"all", nullptr};
34 34 // More help choices are added dynamically.
35 35 addChoices(
36 36 "help", bindParam(&QPDFArgParser::argHelp, this), false, help_choices);
... ... @@ -254,7 +254,7 @@ QPDFArgParser::handleArgFileArguments()
254 254 // deleted by using shared pointers to back the pointers in argv.
255 255 this->m->new_argv.push_back(QUtil::make_shared_cstr(this->m->argv[0]));
256 256 for (int i = 1; i < this->m->argc; ++i) {
257   - char const* argfile = 0;
  257 + char const* argfile = nullptr;
258 258 if ((strlen(this->m->argv[i]) > 1) && (this->m->argv[i][0] == '@')) {
259 259 argfile = 1 + this->m->argv[i];
260 260 if (strcmp(argfile, "-") != 0) {
... ...
libqpdf/QPDFCrypto_native.cc
... ... @@ -14,7 +14,7 @@ getRandomProvider()
14 14 static RandomDataProvider* insecure_random_data_provider =
15 15 InsecureRandomDataProvider::getInstance();
16 16 #else
17   - static RandomDataProvider* insecure_random_data_provider = 0;
  17 + static RandomDataProvider* insecure_random_data_provider = nullptr;
18 18 #endif
19 19 static RandomDataProvider* secure_random_data_provider =
20 20 SecureRandomDataProvider::getInstance();
... ... @@ -22,9 +22,9 @@ getRandomProvider()
22 22 static RandomDataProvider* provider =
23 23 (secure_random_data_provider ? secure_random_data_provider
24 24 : insecure_random_data_provider ? insecure_random_data_provider
25   - : 0);
  25 + : nullptr);
26 26  
27   - if (provider == 0) {
  27 + if (provider == nullptr) {
28 28 throw std::logic_error("QPDFCrypto_native has no random data provider");
29 29 }
30 30  
... ...
libqpdf/QPDFFormFieldObjectHelper.cc
... ... @@ -746,7 +746,7 @@ TfFinder::handleToken(QPDFTokenizer::Token const&amp; token)
746 746 switch (ttype) {
747 747 case QPDFTokenizer::tt_integer:
748 748 case QPDFTokenizer::tt_real:
749   - last_num = strtod(value.c_str(), 0);
  749 + last_num = strtod(value.c_str(), nullptr);
750 750 last_num_idx = QIntC::to_int(DA.size() - 1);
751 751 break;
752 752  
... ... @@ -785,7 +785,7 @@ TfFinder::getDA()
785 785 for (size_t i = 0; i < n; ++i) {
786 786 std::string cur = this->DA.at(i);
787 787 if (QIntC::to_int(i) == tf_idx) {
788   - double delta = strtod(cur.c_str(), 0) - this->tf;
  788 + double delta = strtod(cur.c_str(), nullptr) - this->tf;
789 789 if ((delta > 0.001) || (delta < -0.001)) {
790 790 // tf doesn't match the font size passed to Tf, so
791 791 // substitute.
... ...
libqpdf/QPDFJob.cc
... ... @@ -211,7 +211,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
211 211 bool
212 212 ImageOptimizer::evaluate(std::string const& description)
213 213 {
214   - if (!image.pipeStreamData(0, 0, qpdf_dl_specialized, true)) {
  214 + if (!image.pipeStreamData(nullptr, 0, qpdf_dl_specialized, true)) {
215 215 QTC::TC("qpdf", "QPDFJob image optimize no pipeline");
216 216 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
217 217 v << prefix << ": " << description
... ... @@ -317,7 +317,7 @@ QPDFJob::Members::Members() :
317 317 warnings(false),
318 318 encryption_status(0),
319 319 verbose(false),
320   - password(0),
  320 + password(nullptr),
321 321 linearize(false),
322 322 decrypt(false),
323 323 split_pages(0),
... ... @@ -326,7 +326,7 @@ QPDFJob::Members::Members() :
326 326 suppress_warnings(false),
327 327 warnings_exit_zero(false),
328 328 copy_encryption(false),
329   - encryption_file_password(0),
  329 + encryption_file_password(nullptr),
330 330 encrypt(false),
331 331 password_is_hex_key(false),
332 332 suppress_password_recovery(false),
... ... @@ -411,7 +411,7 @@ QPDFJob::Members::Members() :
411 411 ii_min_bytes(DEFAULT_II_MIN_BYTES),
412 412 underlay("underlay"),
413 413 overlay("overlay"),
414   - under_overlay(0),
  414 + under_overlay(nullptr),
415 415 require_outfile(true),
416 416 replace_input(false),
417 417 check_is_encrypted(false),
... ... @@ -673,13 +673,15 @@ QPDFJob::checkConfiguration()
673 673 usage("--split-pages may not be used with --replace-input");
674 674 }
675 675 }
676   - if (m->infilename == 0) {
  676 + if (m->infilename == nullptr) {
677 677 usage("an input file name is required");
678 678 } else if (
679   - m->require_outfile && (m->outfilename == 0) && (!m->replace_input)) {
  679 + m->require_outfile && (m->outfilename == nullptr) &&
  680 + (!m->replace_input)) {
680 681 usage("an output file name is required; use - for standard output");
681 682 } else if (
682   - (!m->require_outfile) && ((m->outfilename != 0) || m->replace_input)) {
  683 + (!m->require_outfile) &&
  684 + ((m->outfilename != nullptr) || m->replace_input)) {
683 685 usage("no output file may be given for this option");
684 686 }
685 687 if (m->check_requires_password && m->check_is_encrypted) {
... ... @@ -924,7 +926,7 @@ QPDFJob::doShowObj(QPDF&amp; pdf)
924 926 if (obj.isStream()) {
925 927 if (m->show_raw_stream_data || m->show_filtered_stream_data) {
926 928 bool filter = m->show_filtered_stream_data;
927   - if (filter && (!obj.pipeStreamData(0, 0, qpdf_dl_all))) {
  929 + if (filter && (!obj.pipeStreamData(nullptr, 0, qpdf_dl_all))) {
928 930 QTC::TC("qpdf", "QPDFJob unable to filter");
929 931 obj.warnIfPossible("unable to filter stream data");
930 932 error = true;
... ... @@ -1204,7 +1206,7 @@ QPDFJob::doJSONPages(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1204 1206 j_image.addDictionaryMember(
1205 1207 "filterable",
1206 1208 JSON::makeBool(
1207   - image.pipeStreamData(0, 0, m->decode_level, true)));
  1209 + image.pipeStreamData(nullptr, 0, m->decode_level, true)));
1208 1210 }
1209 1211 j_page.addDictionaryMember("images", j_images);
1210 1212 JSON j_contents =
... ... @@ -1561,7 +1563,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys)
1561 1563 "decodelevel": "decode level used to determine stream filterability"
1562 1564 })"));
1563 1565  
1564   - bool all_keys = ((keys == 0) || keys->empty());
  1566 + bool all_keys = ((keys == nullptr) || keys->empty());
1565 1567  
1566 1568 // The list of selectable top-level keys id duplicated in the
1567 1569 // following places: job.yml, QPDFJob::json_schema, and
... ... @@ -1943,7 +1945,7 @@ QPDFJob::doProcess(
1943 1945 password = ptemp.c_str();
1944 1946 }
1945 1947 }
1946   - if ((password == 0) || empty || m->password_is_hex_key ||
  1948 + if ((password == nullptr) || empty || m->password_is_hex_key ||
1947 1949 m->suppress_password_recovery) {
1948 1950 // There is no password, or we're not doing recovery, so just
1949 1951 // do the normal processing with the supplied password.
... ... @@ -2591,7 +2593,7 @@ QPDFJob::handlePageSpecs(
2591 2593 // to the same underlying file with the same path to
2592 2594 // achieve the same affect.
2593 2595 char const* password = page_spec.password.get();
2594   - if ((!m->encryption_file.empty()) && (password == 0) &&
  2596 + if ((!m->encryption_file.empty()) && (password == nullptr) &&
2595 2597 (page_spec.filename == m->encryption_file)) {
2596 2598 QTC::TC("qpdf", "QPDFJob pages encryption password");
2597 2599 password = m->encryption_file_password.get();
... ... @@ -2600,7 +2602,7 @@ QPDFJob::handlePageSpecs(
2600 2602 v << prefix << ": processing " << page_spec.filename << "\n";
2601 2603 });
2602 2604 std::shared_ptr<InputSource> is;
2603   - ClosedFileInputSource* cis = 0;
  2605 + ClosedFileInputSource* cis = nullptr;
2604 2606 if (!m->keep_files_open) {
2605 2607 QTC::TC("qpdf", "QPDFJob keep files open n");
2606 2608 cis = new ClosedFileInputSource(page_spec.filename.c_str());
... ... @@ -2636,7 +2638,7 @@ QPDFJob::handlePageSpecs(
2636 2638 if (m->remove_unreferenced_page_resources != QPDFJob::re_no) {
2637 2639 for (auto const& iter: page_spec_qpdfs) {
2638 2640 std::string const& filename = iter.first;
2639   - ClosedFileInputSource* cis = 0;
  2641 + ClosedFileInputSource* cis = nullptr;
2640 2642 if (page_spec_cfis.count(filename)) {
2641 2643 cis = page_spec_cfis[filename];
2642 2644 cis->stayOpen(true);
... ... @@ -2707,7 +2709,7 @@ QPDFJob::handlePageSpecs(
2707 2709 auto this_afdh = get_afdh_for_qpdf(afdh_map, &pdf);
2708 2710 std::set<QPDFObjGen> referenced_fields;
2709 2711 for (auto& page_data: parsed_specs) {
2710   - ClosedFileInputSource* cis = 0;
  2712 + ClosedFileInputSource* cis = nullptr;
2711 2713 if (page_spec_cfis.count(page_data.filename)) {
2712 2714 cis = page_spec_cfis[page_data.filename];
2713 2715 cis->stayOpen(true);
... ... @@ -3061,7 +3063,7 @@ parse_version(
3061 3063 auto vp = QUtil::make_unique_cstr(full_version_string);
3062 3064 char* v = vp.get();
3063 3065 char* p1 = strchr(v, '.');
3064   - char* p2 = (p1 ? strchr(1 + p1, '.') : 0);
  3066 + char* p2 = (p1 ? strchr(1 + p1, '.') : nullptr);
3065 3067 if (p2 && *(p2 + 1)) {
3066 3068 *p2++ = '\0';
3067 3069 extension_level = QUtil::string_to_int(p2);
... ... @@ -3176,7 +3178,7 @@ QPDFJob::doSplitPages(QPDF&amp; pdf, bool&amp; warnings)
3176 3178 std::string after;
3177 3179 size_t len = strlen(m->outfilename.get());
3178 3180 char* num_spot = strstr(const_cast<char*>(m->outfilename.get()), "%d");
3179   - if (num_spot != 0) {
  3181 + if (num_spot != nullptr) {
3180 3182 QTC::TC("qpdf", "QPDFJob split-pages %d");
3181 3183 before = std::string(
3182 3184 m->outfilename.get(),
... ... @@ -3310,7 +3312,7 @@ QPDFJob::writeOutfile(QPDF&amp; pdf)
3310 3312 });
3311 3313 }
3312 3314 if (m->replace_input) {
3313   - m->outfilename = 0;
  3315 + m->outfilename = nullptr;
3314 3316 }
3315 3317 if (m->replace_input) {
3316 3318 // We must close the input before we can rename files
... ...
libqpdf/QPDFJob_config.cc
... ... @@ -13,7 +13,7 @@ QPDFJob::Config::checkConfiguration()
13 13 QPDFJob::Config*
14 14 QPDFJob::Config::inputFile(std::string const& filename)
15 15 {
16   - if (o.m->infilename == 0) {
  16 + if (o.m->infilename == nullptr) {
17 17 o.m->infilename = QUtil::make_shared_cstr(filename);
18 18 } else {
19 19 usage("input file has already been given");
... ... @@ -24,7 +24,7 @@ QPDFJob::Config::inputFile(std::string const&amp; filename)
24 24 QPDFJob::Config*
25 25 QPDFJob::Config::emptyInput()
26 26 {
27   - if (o.m->infilename == 0) {
  27 + if (o.m->infilename == nullptr) {
28 28 // Various places in QPDFJob.cc know that the empty string for
29 29 // infile means empty. We set it to something other than a
30 30 // null pointer as an indication that some input source has
... ... @@ -44,7 +44,7 @@ QPDFJob::Config::emptyInput()
44 44 QPDFJob::Config*
45 45 QPDFJob::Config::outputFile(std::string const& filename)
46 46 {
47   - if ((o.m->outfilename == 0) && (!o.m->replace_input)) {
  47 + if ((o.m->outfilename == nullptr) && (!o.m->replace_input)) {
48 48 o.m->outfilename = QUtil::make_shared_cstr(filename);
49 49 } else {
50 50 usage("output file has already been given");
... ... @@ -55,7 +55,7 @@ QPDFJob::Config::outputFile(std::string const&amp; filename)
55 55 QPDFJob::Config*
56 56 QPDFJob::Config::replaceInput()
57 57 {
58   - if ((o.m->outfilename == 0) && (!o.m->replace_input)) {
  58 + if ((o.m->outfilename == nullptr) && (!o.m->replace_input)) {
59 59 o.m->replace_input = true;
60 60 } else {
61 61 usage("replace-input can't be used"
... ... @@ -977,7 +977,7 @@ QPDFJob::UOConfig::endUnderlayOverlay()
977 977 if (config->o.m->under_overlay->filename.empty()) {
978 978 usage(config->o.m->under_overlay->which + " file not specified");
979 979 }
980   - config->o.m->under_overlay = 0;
  980 + config->o.m->under_overlay = nullptr;
981 981 return this->config;
982 982 }
983 983  
... ...
libqpdf/QPDFObject.cc
1 1 #include <qpdf/QPDFObject.hh>
2 2  
3 3 QPDFObject::QPDFObject() :
4   - owning_qpdf(0),
  4 + owning_qpdf(nullptr),
5 5 parsed_offset(-1)
6 6 {
7 7 }
... ... @@ -25,13 +25,13 @@ QPDFObject::getDescription(QPDF*&amp; qpdf, std::string&amp; description)
25 25 {
26 26 qpdf = this->owning_qpdf;
27 27 description = this->object_description;
28   - return this->owning_qpdf != 0;
  28 + return this->owning_qpdf != nullptr;
29 29 }
30 30  
31 31 bool
32 32 QPDFObject::hasDescription()
33 33 {
34   - return this->owning_qpdf != 0;
  34 + return this->owning_qpdf != nullptr;
35 35 }
36 36  
37 37 void
... ...
libqpdf/QPDFObjectHandle.cc
... ... @@ -265,7 +265,7 @@ QPDFObjectHandle::releaseResolved()
265 265 // destruction. See comments in QPDF::~QPDF().
266 266 if (isIndirect()) {
267 267 if (this->obj.get()) {
268   - this->obj = 0;
  268 + this->obj = nullptr;
269 269 }
270 270 } else {
271 271 QPDFObject::ObjAccessor::releaseResolved(this->obj.get());
... ... @@ -780,7 +780,7 @@ QPDFObjectHandle::getArrayItem(int n)
780 780 typeWarning("array", "returning null");
781 781 QTC::TC("qpdf", "QPDFObjectHandle array null for non-array");
782 782 }
783   - QPDF* context = 0;
  783 + QPDF* context = nullptr;
784 784 std::string description;
785 785 if (this->obj->getDescription(context, description)) {
786 786 result.setObjectDescription(
... ... @@ -998,7 +998,7 @@ QPDFObjectHandle::getKey(std::string const&amp; key)
998 998 typeWarning("dictionary", "returning null for attempted key retrieval");
999 999 QTC::TC("qpdf", "QPDFObjectHandle dictionary null for getKey");
1000 1000 result = newNull();
1001   - QPDF* qpdf = 0;
  1001 + QPDF* qpdf = nullptr;
1002 1002 std::string description;
1003 1003 if (this->obj->getDescription(qpdf, description)) {
1004 1004 result.setObjectDescription(
... ... @@ -1665,7 +1665,7 @@ QPDFObjectHandle::coalesceContentStreams()
1665 1665 return;
1666 1666 }
1667 1667 QPDF* qpdf = getOwningQPDF();
1668   - if (qpdf == 0) {
  1668 + if (qpdf == nullptr) {
1669 1669 // Should not be possible for a page object to not have an
1670 1670 // owning PDF unless it was manually constructed in some
1671 1671 // incorrect way. However, it can happen in a PDF file whose
... ... @@ -1782,7 +1782,7 @@ QPDFObjectHandle::parse(
1782 1782 QPDFTokenizer tokenizer;
1783 1783 bool empty = false;
1784 1784 QPDFObjectHandle result =
1785   - parse(input, object_description, tokenizer, empty, 0, context);
  1785 + parse(input, object_description, tokenizer, empty, nullptr, context);
1786 1786 size_t offset = QIntC::to_size(input->tell());
1787 1787 while (offset < object_str.length()) {
1788 1788 if (!isspace(object_str.at(offset))) {
... ... @@ -1918,8 +1918,8 @@ QPDFObjectHandle::parseContentStream_data(
1918 1918 tokenizer.readToken(input, "content", true);
1919 1919 qpdf_offset_t offset = input->getLastOffset();
1920 1920 input->seek(offset, SEEK_SET);
1921   - QPDFObjectHandle obj =
1922   - parseInternal(input, "content", tokenizer, empty, 0, context, true);
  1921 + QPDFObjectHandle obj = parseInternal(
  1922 + input, "content", tokenizer, empty, nullptr, context, true);
1923 1923 if (!obj.isInitialized()) {
1924 1924 // EOF
1925 1925 break;
... ... @@ -2195,7 +2195,7 @@ QPDFObjectHandle::parseInternal(
2195 2195 (olist.at(olist.size() - 1).isInteger()) &&
2196 2196 (!olist.at(olist.size() - 2).isIndirect()) &&
2197 2197 (olist.at(olist.size() - 2).isInteger())) {
2198   - if (context == 0) {
  2198 + if (context == nullptr) {
2199 2199 QTC::TC(
2200 2200 "qpdf",
2201 2201 "QPDFObjectHandle indirect without context");
... ... @@ -2671,7 +2671,7 @@ QPDFObjectHandle::newStream(
2671 2671 QPDFObjectHandle
2672 2672 QPDFObjectHandle::newStream(QPDF* qpdf)
2673 2673 {
2674   - if (qpdf == 0) {
  2674 + if (qpdf == nullptr) {
2675 2675 throw std::runtime_error(
2676 2676 "attempt to create stream in null qpdf object");
2677 2677 }
... ... @@ -2915,7 +2915,7 @@ QPDFObjectHandle::typeWarning(
2915 2915 void
2916 2916 QPDFObjectHandle::warnIfPossible(std::string const& warning)
2917 2917 {
2918   - QPDF* context = 0;
  2918 + QPDF* context = nullptr;
2919 2919 std::string description;
2920 2920 if (dereference() && obj->getDescription(context, description)) {
2921 2921 warn(context, QPDFExc(qpdf_e_damaged_pdf, "", description, 0, warning));
... ... @@ -3122,10 +3122,10 @@ QPDFObjectHandle::dereference()
3122 3122 QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj)) {
3123 3123 this->obj = nullptr;
3124 3124 }
3125   - if (this->obj.get() == 0) {
  3125 + if (this->obj.get() == nullptr) {
3126 3126 std::shared_ptr<QPDFObject> obj =
3127 3127 QPDF::Resolver::resolve(this->qpdf, getObjGen());
3128   - if (obj.get() == 0) {
  3128 + if (obj.get() == nullptr) {
3129 3129 // QPDF::resolve never returns an uninitialized object, but
3130 3130 // check just in case.
3131 3131 this->obj = QPDF_Null::create();
... ...
libqpdf/QPDFOutlineDocumentHelper.cc
... ... @@ -82,7 +82,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name)
82 82 result = this->m->dest_dict.getKey(name.getName());
83 83 }
84 84 } else if (name.isString()) {
85   - if (0 == this->m->names_dest.get()) {
  85 + if (nullptr == this->m->names_dest.get()) {
86 86 QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names");
87 87 if (names.isDictionary()) {
88 88 QPDFObjectHandle dests = names.getKey("/Dests");
... ...
libqpdf/QPDFPageLabelDocumentHelper.cc
... ... @@ -16,7 +16,7 @@ QPDFPageLabelDocumentHelper::QPDFPageLabelDocumentHelper(QPDF&amp; qpdf) :
16 16 bool
17 17 QPDFPageLabelDocumentHelper::hasPageLabels()
18 18 {
19   - return 0 != this->m->labels.get();
  19 + return nullptr != this->m->labels.get();
20 20 }
21 21  
22 22 QPDFObjectHandle
... ...
libqpdf/QPDFTokenizer.cc
... ... @@ -17,7 +17,7 @@
17 17 static bool
18 18 is_delimiter(char ch)
19 19 {
20   - return (strchr(" \t\n\v\f\r()<>[]{}/%", ch) != 0);
  20 + return (strchr(" \t\n\v\f\r()<>[]{}/%", ch) != nullptr);
21 21 }
22 22  
23 23 namespace
... ... @@ -158,7 +158,7 @@ QPDFTokenizer::resolveLiteral()
158 158 num[0] = this->m->val.at(i + 1);
159 159 num[1] = this->m->val.at(i + 2);
160 160 num[2] = '\0';
161   - char ch2 = static_cast<char>(strtol(num, 0, 16));
  161 + char ch2 = static_cast<char>(strtol(num, nullptr, 16));
162 162 if (ch2 == '\0') {
163 163 this->m->type = tt_bad;
164 164 QTC::TC("qpdf", "QPDFTokenizer null in name");
... ... @@ -323,7 +323,7 @@ QPDFTokenizer::presentCharacter(char ch)
323 323 // We've accumulated \ddd. PDF Spec says to ignore
324 324 // high-order overflow.
325 325 this->m->val +=
326   - static_cast<char>(strtol(this->m->bs_num_register, 0, 8));
  326 + static_cast<char>(strtol(this->m->bs_num_register, nullptr, 8));
327 327 memset(
328 328 this->m->bs_num_register,
329 329 '\0',
... ... @@ -447,7 +447,7 @@ QPDFTokenizer::presentCharacter(char ch)
447 447 for (unsigned int i = 0; i < this->m->val.length(); i += 2) {
448 448 num[0] = this->m->val.at(i);
449 449 num[1] = this->m->val.at(i + 1);
450   - char nch = static_cast<char>(strtol(num, 0, 16));
  450 + char nch = static_cast<char>(strtol(num, nullptr, 16));
451 451 nval += nch;
452 452 }
453 453 this->m->val = nval;
... ...
libqpdf/QPDFWriter.cc
... ... @@ -52,10 +52,10 @@ QPDFWriter::FunctionProgressReporter::reportProgress(int progress)
52 52 QPDFWriter::Members::Members(QPDF& pdf) :
53 53 pdf(pdf),
54 54 filename("unspecified"),
55   - file(0),
  55 + file(nullptr),
56 56 close_file(false),
57   - buffer_pipeline(0),
58   - output_buffer(0),
  57 + buffer_pipeline(nullptr),
  58 + output_buffer(nullptr),
59 59 normalize_content_set(false),
60 60 normalize_content(false),
61 61 compress_streams(true),
... ... @@ -82,7 +82,7 @@ QPDFWriter::Members::Members(QPDF&amp; pdf) :
82 82 min_extension_level(0),
83 83 forced_extension_level(0),
84 84 encryption_dict_objid(0),
85   - pipeline(0),
  85 + pipeline(nullptr),
86 86 next_objid(1),
87 87 cur_stream_length_id(0),
88 88 cur_stream_length(0),
... ... @@ -90,7 +90,7 @@ QPDFWriter::Members::Members(QPDF&amp; pdf) :
90 90 max_ostream_index(0),
91 91 next_stack_id(0),
92 92 deterministic_id(false),
93   - md5_pipeline(0),
  93 + md5_pipeline(nullptr),
94 94 did_write_setup(false),
95 95 events_expected(0),
96 96 events_seen(0),
... ... @@ -128,9 +128,9 @@ void
128 128 QPDFWriter::setOutputFilename(char const* filename)
129 129 {
130 130 char const* description = filename;
131   - FILE* f = 0;
  131 + FILE* f = nullptr;
132 132 bool close_file = false;
133   - if (filename == 0) {
  133 + if (filename == nullptr) {
134 134 description = "standard output";
135 135 QTC::TC("qpdf", "QPDFWriter write to stdout");
136 136 f = stdout;
... ... @@ -169,7 +169,7 @@ Buffer*
169 169 QPDFWriter::getBuffer()
170 170 {
171 171 Buffer* result = this->m->output_buffer;
172   - this->m->output_buffer = 0;
  172 + this->m->output_buffer = nullptr;
173 173 return result;
174 174 }
175 175  
... ... @@ -1021,7 +1021,7 @@ QPDFWriter::writePad(int nspaces)
1021 1021 Pipeline*
1022 1022 QPDFWriter::pushPipeline(Pipeline* p)
1023 1023 {
1024   - qpdf_assert_debug(dynamic_cast<Pl_Count*>(p) == 0);
  1024 + qpdf_assert_debug(dynamic_cast<Pl_Count*>(p) == nullptr);
1025 1025 this->m->pipeline_stack.push_back(p);
1026 1026 return p;
1027 1027 }
... ... @@ -1066,10 +1066,10 @@ QPDFWriter::PipelinePopper::~PipelinePopper()
1066 1066 qpdf_assert_debug(qw->m->pipeline->getIdentifier() == stack_id);
1067 1067 delete qw->m->pipeline_stack.back();
1068 1068 qw->m->pipeline_stack.pop_back();
1069   - while (dynamic_cast<Pl_Count*>(qw->m->pipeline_stack.back()) == 0) {
  1069 + while (dynamic_cast<Pl_Count*>(qw->m->pipeline_stack.back()) == nullptr) {
1070 1070 Pipeline* p = qw->m->pipeline_stack.back();
1071 1071 if (dynamic_cast<Pl_MD5*>(p) == qw->m->md5_pipeline) {
1072   - qw->m->md5_pipeline = 0;
  1072 + qw->m->md5_pipeline = nullptr;
1073 1073 }
1074 1074 qw->m->pipeline_stack.pop_back();
1075 1075 Pl_Buffer* buf = dynamic_cast<Pl_Buffer*>(p);
... ... @@ -1097,7 +1097,7 @@ void
1097 1097 QPDFWriter::pushEncryptionFilter(PipelinePopper& pp)
1098 1098 {
1099 1099 if (this->m->encrypted && (!this->m->cur_data_key.empty())) {
1100   - Pipeline* p = 0;
  1100 + Pipeline* p = nullptr;
1101 1101 if (this->m->encrypt_use_aes) {
1102 1102 p = new Pl_AES_PDF(
1103 1103 "aes stream encryption",
... ... @@ -1135,7 +1135,7 @@ QPDFWriter::pushMD5Pipeline(PipelinePopper&amp; pp)
1135 1135 " generation has already occurred.");
1136 1136 }
1137 1137 qpdf_assert_debug(this->m->deterministic_id);
1138   - qpdf_assert_debug(this->m->md5_pipeline == 0);
  1138 + qpdf_assert_debug(this->m->md5_pipeline == nullptr);
1139 1139 qpdf_assert_debug(this->m->pipeline->getCount() == 0);
1140 1140 this->m->md5_pipeline = new Pl_MD5("qpdf md5", this->m->pipeline);
1141 1141 this->m->md5_pipeline->persistAcrossFinish(true);
... ... @@ -1148,7 +1148,7 @@ QPDFWriter::pushMD5Pipeline(PipelinePopper&amp; pp)
1148 1148 void
1149 1149 QPDFWriter::computeDeterministicIDData()
1150 1150 {
1151   - qpdf_assert_debug(this->m->md5_pipeline != 0);
  1151 + qpdf_assert_debug(this->m->md5_pipeline != nullptr);
1152 1152 qpdf_assert_debug(this->m->deterministic_id_data.empty());
1153 1153 this->m->deterministic_id_data = this->m->md5_pipeline->getHexDigest();
1154 1154 this->m->md5_pipeline->enable(false);
... ... @@ -2455,10 +2455,10 @@ QPDFWriter::write()
2455 2455 if (this->m->close_file) {
2456 2456 fclose(this->m->file);
2457 2457 }
2458   - this->m->file = 0;
  2458 + this->m->file = nullptr;
2459 2459 if (this->m->buffer_pipeline) {
2460 2460 this->m->output_buffer = this->m->buffer_pipeline->getBuffer();
2461   - this->m->buffer_pipeline = 0;
  2461 + this->m->buffer_pipeline = nullptr;
2462 2462 }
2463 2463 indicateProgress(false, true);
2464 2464 }
... ... @@ -2967,7 +2967,7 @@ QPDFWriter::writeLinearized()
2967 2967  
2968 2968 // Write file in two passes. Part numbers refer to PDF spec 1.4.
2969 2969  
2970   - FILE* lin_pass1_file = 0;
  2970 + FILE* lin_pass1_file = nullptr;
2971 2971 auto pp_pass1 = std::make_shared<PipelinePopper>(this);
2972 2972 auto pp_md5 = std::make_shared<PipelinePopper>(this);
2973 2973 for (int pass = 1; pass <= 2; ++pass) {
... ... @@ -3203,13 +3203,13 @@ QPDFWriter::writeLinearized()
3203 3203 "QPDFWriter linearized deterministic ID",
3204 3204 need_xref_stream ? 0 : 1);
3205 3205 computeDeterministicIDData();
3206   - pp_md5 = 0;
3207   - qpdf_assert_debug(this->m->md5_pipeline == 0);
  3206 + pp_md5 = nullptr;
  3207 + qpdf_assert_debug(this->m->md5_pipeline == nullptr);
3208 3208 }
3209 3209  
3210 3210 // Close first pass pipeline
3211 3211 file_size = this->m->pipeline->getCount();
3212   - pp_pass1 = 0;
  3212 + pp_pass1 = nullptr;
3213 3213  
3214 3214 // Save hint offset since it will be set to zero by
3215 3215 // calling openObject.
... ... @@ -3245,7 +3245,7 @@ QPDFWriter::writeLinearized()
3245 3245 "%% second_xref_end=%s\n",
3246 3246 QUtil::int_to_string(second_xref_end).c_str());
3247 3247 fclose(lin_pass1_file);
3248   - lin_pass1_file = 0;
  3248 + lin_pass1_file = nullptr;
3249 3249 }
3250 3250 }
3251 3251 }
... ... @@ -3401,7 +3401,7 @@ QPDFWriter::writeStandard()
3401 3401 "qpdf",
3402 3402 "QPDFWriter standard deterministic ID",
3403 3403 this->m->object_stream_to_objects.empty() ? 0 : 1);
3404   - pp_md5 = 0;
3405   - qpdf_assert_debug(this->m->md5_pipeline == 0);
  3404 + pp_md5 = nullptr;
  3405 + qpdf_assert_debug(this->m->md5_pipeline == nullptr);
3406 3406 }
3407 3407 }
... ...
libqpdf/QPDF_Dictionary.cc
... ... @@ -87,7 +87,7 @@ QPDF_Dictionary::getKey(std::string const&amp; key)
87 87 return item->second;
88 88 } else {
89 89 QPDFObjectHandle null = QPDFObjectHandle::newNull();
90   - QPDF* qpdf = 0;
  90 + QPDF* qpdf = nullptr;
91 91 std::string description;
92 92 if (getDescription(qpdf, description)) {
93 93 null.setObjectDescription(
... ...
libqpdf/QPDF_Stream.cc
... ... @@ -169,7 +169,7 @@ QPDF_Stream::getFilterOnWrite() const
169 169 void
170 170 QPDF_Stream::releaseResolved()
171 171 {
172   - this->stream_provider = 0;
  172 + this->stream_provider = nullptr;
173 173 QPDFObjectHandle::ReleaseResolver::releaseResolved(this->stream_dict);
174 174 }
175 175  
... ... @@ -313,7 +313,7 @@ QPDF_Stream::setDescription(QPDF* qpdf, std::string const&amp; description)
313 313 void
314 314 QPDF_Stream::setDictDescription()
315 315 {
316   - QPDF* qpdf = 0;
  316 + QPDF* qpdf = nullptr;
317 317 std::string description;
318 318 if ((!this->stream_dict.hasObjectDescription()) &&
319 319 getDescription(qpdf, description)) {
... ... @@ -547,7 +547,7 @@ QPDF_Stream::pipeStreamData(
547 547 : 3);
548 548 }
549 549  
550   - if (pipeline == 0) {
  550 + if (pipeline == nullptr) {
551 551 QTC::TC("qpdf", "QPDF_Stream pipeStreamData with null pipeline");
552 552 // Return value is whether we can filter in this case.
553 553 return filter;
... ... @@ -693,7 +693,7 @@ QPDF_Stream::replaceStreamData(
693 693 QPDFObjectHandle const& decode_parms)
694 694 {
695 695 this->stream_data = data;
696   - this->stream_provider = 0;
  696 + this->stream_provider = nullptr;
697 697 replaceFilterData(filter, decode_parms, data->getSize());
698 698 }
699 699  
... ... @@ -704,7 +704,7 @@ QPDF_Stream::replaceStreamData(
704 704 QPDFObjectHandle const& decode_parms)
705 705 {
706 706 this->stream_provider = provider;
707   - this->stream_data = 0;
  707 + this->stream_data = nullptr;
708 708 replaceFilterData(filter, decode_parms, 0);
709 709 }
710 710  
... ...
libqpdf/QPDF_encryption.cc
... ... @@ -149,8 +149,8 @@ QPDF::trim_user_password(std::string&amp; user_password)
149 149 }
150 150  
151 151 char const* p1 = cstr;
152   - char const* p2 = 0;
153   - while ((p2 = strchr(p1, '\x28')) != 0) {
  152 + char const* p2 = nullptr;
  153 + while ((p2 = strchr(p1, '\x28')) != nullptr) {
154 154 size_t idx = toS(p2 - cstr);
155 155 if (memcmp(p2, padding_string, len - idx) == 0) {
156 156 user_password = user_password.substr(0, idx);
... ... @@ -218,7 +218,7 @@ process_with_aes(
218 218 std::string const& data,
219 219 size_t outlength = 0,
220 220 unsigned int repetitions = 1,
221   - unsigned char const* iv = 0,
  221 + unsigned char const* iv = nullptr,
222 222 size_t iv_length = 0)
223 223 {
224 224 Pl_Buffer buffer("buffer");
... ...
libqpdf/QPDF_linearization.cc
... ... @@ -542,7 +542,7 @@ QPDF::checkLinearizationInternal()
542 542  
543 543 // T: offset of whitespace character preceding xref entry for object 0
544 544 this->m->file->seek(p.xref_zero_offset, SEEK_SET);
545   - while (1) {
  545 + while (true) {
546 546 char ch;
547 547 this->m->file->read(&ch, 1);
548 548 if (!((ch == ' ') || (ch == '\r') || (ch == '\n'))) {
... ...
libqpdf/QUtil.cc
... ... @@ -396,7 +396,7 @@ QUtil::string_to_ll(char const* str)
396 396 #ifdef _MSC_VER
397 397 long long result = _strtoi64(str, 0, 10);
398 398 #else
399   - long long result = strtoll(str, 0, 10);
  399 + long long result = strtoll(str, nullptr, 10);
400 400 #endif
401 401 if (errno == ERANGE) {
402 402 throw std::range_error(
... ... @@ -430,7 +430,7 @@ QUtil::string_to_ull(char const* str)
430 430 #ifdef _MSC_VER
431 431 unsigned long long result = _strtoui64(str, 0, 10);
432 432 #else
433   - unsigned long long result = strtoull(str, 0, 10);
  433 + unsigned long long result = strtoull(str, nullptr, 10);
434 434 #endif
435 435 if (errno == ERANGE) {
436 436 throw std::runtime_error(
... ... @@ -512,7 +512,7 @@ win_convert_filename(char const* filename)
512 512 FILE*
513 513 QUtil::safe_fopen(char const* filename, char const* mode)
514 514 {
515   - FILE* f = 0;
  515 + FILE* f = nullptr;
516 516 #ifdef _WIN32
517 517 std::shared_ptr<wchar_t> wfilenamep = win_convert_filename(filename);
518 518 wchar_t* wfilename = wfilenamep.get();
... ... @@ -543,7 +543,7 @@ QUtil::safe_fopen(char const* filename, char const* mode)
543 543 FILE*
544 544 QUtil::fopen_wrapper(std::string const& description, FILE* f)
545 545 {
546   - if (f == 0) {
  546 + if (f == nullptr) {
547 547 throw_system_error(description);
548 548 }
549 549 return f;
... ... @@ -599,7 +599,7 @@ QUtil::tell(FILE* stream)
599 599 bool
600 600 QUtil::same_file(char const* name1, char const* name2)
601 601 {
602   - if ((name1 == 0) || (strlen(name1) == 0) || (name2 == 0) ||
  602 + if ((name1 == nullptr) || (strlen(name1) == 0) || (name2 == nullptr) ||
603 603 (strlen(name2) == 0)) {
604 604 return false;
605 605 }
... ... @@ -834,7 +834,7 @@ QUtil::setLineBuf(FILE* f)
834 834 char*
835 835 QUtil::getWhoami(char* argv0)
836 836 {
837   - char* whoami = 0;
  837 + char* whoami = nullptr;
838 838 if (((whoami = strrchr(argv0, '/')) == NULL) &&
839 839 ((whoami = strrchr(argv0, '\\')) == NULL)) {
840 840 whoami = argv0;
... ... @@ -875,7 +875,7 @@ QUtil::get_env(std::string const&amp; var, std::string* value)
875 875 # endif
876 876 #else
877 877 char* p = getenv(var.c_str());
878   - if (p == 0) {
  878 + if (p == nullptr) {
879 879 return false;
880 880 }
881 881 if (value) {
... ... @@ -908,7 +908,7 @@ QUtil::get_current_time()
908 908 ULONGLONG now = uinow.QuadPart;
909 909 return static_cast<time_t>((now / 10000000ULL) - 11644473600ULL);
910 910 #else
911   - return time(0);
  911 + return time(nullptr);
912 912 #endif
913 913 }
914 914  
... ... @@ -931,7 +931,7 @@ QUtil::get_current_qpdf_time()
931 931 static_cast<int>(tzinfo.Bias));
932 932 #else
933 933 struct tm ltime;
934   - time_t now = time(0);
  934 + time_t now = time(nullptr);
935 935 tzset();
936 936 # ifdef HAVE_LOCALTIME_R
937 937 localtime_r(&now, &ltime);
... ... @@ -1155,7 +1155,7 @@ namespace
1155 1155  
1156 1156 RandomDataProviderProvider::RandomDataProviderProvider() :
1157 1157 default_provider(CryptoRandomDataProvider::getInstance()),
1158   - current_provider(0)
  1158 + current_provider(nullptr)
1159 1159 {
1160 1160 this->current_provider = default_provider;
1161 1161 }
... ... @@ -1210,13 +1210,13 @@ QUtil::random()
1210 1210 bool
1211 1211 QUtil::is_hex_digit(char ch)
1212 1212 {
1213   - return (ch && (strchr("0123456789abcdefABCDEF", ch) != 0));
  1213 + return (ch && (strchr("0123456789abcdefABCDEF", ch) != nullptr));
1214 1214 }
1215 1215  
1216 1216 bool
1217 1217 QUtil::is_space(char ch)
1218 1218 {
1219   - return (ch && (strchr(" \f\n\r\t\v", ch) != 0));
  1219 + return (ch && (strchr(" \f\n\r\t\v", ch) != nullptr));
1220 1220 }
1221 1221  
1222 1222 bool
... ... @@ -1332,10 +1332,10 @@ QUtil::read_lines_from_file(
1332 1332 std::list<std::string>& lines,
1333 1333 bool preserve_eol)
1334 1334 {
1335   - std::string* buf = 0;
  1335 + std::string* buf = nullptr;
1336 1336 char c;
1337 1337 while (next_char(c)) {
1338   - if (buf == 0) {
  1338 + if (buf == nullptr) {
1339 1339 lines.push_back("");
1340 1340 buf = &(lines.back());
1341 1341 buf->reserve(80);
... ... @@ -1354,7 +1354,7 @@ QUtil::read_lines_from_file(
1354 1354 buf->erase(buf->length() - 1);
1355 1355 }
1356 1356 }
1357   - buf = 0;
  1357 + buf = nullptr;
1358 1358 } else {
1359 1359 buf->append(1, c);
1360 1360 }
... ... @@ -1471,7 +1471,7 @@ QUtil::parse_numrange(char const* range, int max)
1471 1471 }
1472 1472 }
1473 1473  
1474   - p = 0;
  1474 + p = nullptr;
1475 1475 for (size_t i = 0; i < work.size(); i += 2) {
1476 1476 int num = work.at(i);
1477 1477 // max == 0 means we don't know the max and are just
... ... @@ -1990,7 +1990,7 @@ call_main_from_wmain(
1990 1990 new_argv[i] = utf8_argv.at(i).get();
1991 1991 }
1992 1992 argc = QIntC::to_int(utf8_argv.size());
1993   - new_argv[argc] = 0;
  1993 + new_argv[argc] = nullptr;
1994 1994 return realmain(argc, new_argv);
1995 1995 }
1996 1996  
... ...
libqpdf/qpdf-c.cc
... ... @@ -164,7 +164,7 @@ qpdf_cleanup(qpdf_data* qpdf)
164 164 << (*qpdf)->error->what() << "\n";
165 165 }
166 166 delete *qpdf;
167   - *qpdf = 0;
  167 + *qpdf = nullptr;
168 168 }
169 169  
170 170 size_t
... ... @@ -203,11 +203,11 @@ qpdf_get_error(qpdf_data qpdf)
203 203 {
204 204 if (qpdf->error.get()) {
205 205 qpdf->tmp_error.exc = qpdf->error;
206   - qpdf->error = 0;
  206 + qpdf->error = nullptr;
207 207 QTC::TC("qpdf", "qpdf-c qpdf_get_error returned error");
208 208 return &qpdf->tmp_error;
209 209 } else {
210   - return 0;
  210 + return nullptr;
211 211 }
212 212 }
213 213  
... ... @@ -220,14 +220,14 @@ qpdf_next_warning(qpdf_data qpdf)
220 220 QTC::TC("qpdf", "qpdf-c qpdf_next_warning returned warning");
221 221 return &qpdf->tmp_error;
222 222 } else {
223   - return 0;
  223 + return nullptr;
224 224 }
225 225 }
226 226  
227 227 char const*
228 228 qpdf_get_error_full_text(qpdf_data qpdf, qpdf_error e)
229 229 {
230   - if (e == 0) {
  230 + if (e == nullptr) {
231 231 return "";
232 232 }
233 233 return e->exc->what();
... ... @@ -236,7 +236,7 @@ qpdf_get_error_full_text(qpdf_data qpdf, qpdf_error e)
236 236 enum qpdf_error_code_e
237 237 qpdf_get_error_code(qpdf_data qpdf, qpdf_error e)
238 238 {
239   - if (e == 0) {
  239 + if (e == nullptr) {
240 240 return qpdf_e_success;
241 241 }
242 242 return e->exc->getErrorCode();
... ... @@ -245,7 +245,7 @@ qpdf_get_error_code(qpdf_data qpdf, qpdf_error e)
245 245 char const*
246 246 qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e)
247 247 {
248   - if (e == 0) {
  248 + if (e == nullptr) {
249 249 return "";
250 250 }
251 251 return e->exc->getFilename().c_str();
... ... @@ -254,7 +254,7 @@ qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e)
254 254 unsigned long long
255 255 qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e)
256 256 {
257   - if (e == 0) {
  257 + if (e == nullptr) {
258 258 return 0;
259 259 }
260 260 return QIntC::to_ulonglong(e->exc->getFilePosition());
... ... @@ -263,7 +263,7 @@ qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e)
263 263 char const*
264 264 qpdf_get_error_message_detail(qpdf_data qpdf, qpdf_error e)
265 265 {
266   - if (e == 0) {
  266 + if (e == nullptr) {
267 267 return "";
268 268 }
269 269 return e->exc->getMessageDetail().c_str();
... ... @@ -371,7 +371,7 @@ qpdf_get_user_password(qpdf_data qpdf)
371 371 char const*
372 372 qpdf_get_info_key(qpdf_data qpdf, char const* key)
373 373 {
374   - char const* result = 0;
  374 + char const* result = nullptr;
375 375 QPDFObjectHandle trailer = qpdf->qpdf->getTrailer();
376 376 if (trailer.hasKey("/Info")) {
377 377 QPDFObjectHandle info = trailer.getKey("/Info");
... ... @@ -383,14 +383,14 @@ qpdf_get_info_key(qpdf_data qpdf, char const* key)
383 383 }
384 384 }
385 385 }
386   - QTC::TC("qpdf", "qpdf-c get_info_key", (result == 0 ? 0 : 1));
  386 + QTC::TC("qpdf", "qpdf-c get_info_key", (result == nullptr ? 0 : 1));
387 387 return result;
388 388 }
389 389  
390 390 void
391 391 qpdf_set_info_key(qpdf_data qpdf, char const* key, char const* value)
392 392 {
393   - if ((key == 0) || (std::strlen(key) == 0) || (key[0] != '/')) {
  393 + if ((key == nullptr) || (std::strlen(key) == 0) || (key[0] != '/')) {
394 394 return;
395 395 }
396 396 QPDFObjectHandle value_object;
... ... @@ -498,11 +498,11 @@ qpdf_init_write_internal(qpdf_data qpdf)
498 498 {
499 499 if (qpdf->qpdf_writer.get()) {
500 500 QTC::TC("qpdf", "qpdf-c called qpdf_init_write multiple times");
501   - qpdf->qpdf_writer = 0;
  501 + qpdf->qpdf_writer = nullptr;
502 502 if (qpdf->output_buffer.get()) {
503   - qpdf->output_buffer = 0;
  503 + qpdf->output_buffer = nullptr;
504 504 qpdf->write_memory = false;
505   - qpdf->filename = 0;
  505 + qpdf->filename = nullptr;
506 506 }
507 507 }
508 508 }
... ... @@ -530,7 +530,7 @@ qpdf_init_write_memory(qpdf_data qpdf)
530 530 static void
531 531 qpdf_get_buffer_internal(qpdf_data qpdf)
532 532 {
533   - if (qpdf->write_memory && (qpdf->output_buffer == 0)) {
  533 + if (qpdf->write_memory && (qpdf->output_buffer == nullptr)) {
534 534 qpdf->output_buffer = qpdf->qpdf_writer->getBufferSharedPointer();
535 535 }
536 536 }
... ... @@ -549,7 +549,7 @@ qpdf_get_buffer_length(qpdf_data qpdf)
549 549 unsigned char const*
550 550 qpdf_get_buffer(qpdf_data qpdf)
551 551 {
552   - unsigned char const* result = 0;
  552 + unsigned char const* result = nullptr;
553 553 qpdf_get_buffer_internal(qpdf);
554 554 if (qpdf->output_buffer.get()) {
555 555 result = qpdf->output_buffer->getBuffer();
... ...