Merge pull request #734 from m-holger/nullptr

Code tidy : replace 0 with nullptr or true
This commit is contained in:
Jay Berkenbilt 2022-07-31 08:33:45 -04:00 committed by GitHub
commit 4feb10fdaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 193 additions and 187 deletions

View File

@ -15,7 +15,7 @@
// the use of the qpdf literal syntax introduced in qpdf 10.6. // the use of the qpdf literal syntax introduced in qpdf 10.6.
// //
static char const* whoami = 0; static char const* whoami = nullptr;
static void static void
usage(std::string const& msg) usage(std::string const& msg)
@ -167,11 +167,11 @@ main(int argc, char* argv[])
{ {
whoami = QUtil::getWhoami(argv[0]); whoami = QUtil::getWhoami(argv[0]);
char const* infilename = 0; char const* infilename = nullptr;
char const* password = 0; char const* password = nullptr;
char const* attachment = 0; char const* attachment = nullptr;
char const* outfilename = 0; char const* outfilename = nullptr;
char const* mimetype = 0; char const* mimetype = nullptr;
auto check_arg = [](char const* arg, std::string const& msg) { auto check_arg = [](char const* arg, std::string const& msg) {
if (arg == nullptr) { if (arg == nullptr) {

View File

@ -14,7 +14,7 @@
// //
// Ignore calls to QTC::TC - they are for qpdf CI testing only. // Ignore calls to QTC::TC - they are for qpdf CI testing only.
static char const* whoami = 0; static char const* whoami = nullptr;
static enum { st_none, st_numbers, st_lines } style = st_none; static enum { st_none, st_numbers, st_lines } style = st_none;
static bool show_open = false; static bool show_open = false;
static bool show_targets = false; static bool show_targets = false;

View File

@ -15,7 +15,7 @@
#include <qpdf/QPDFPageObjectHelper.hh> #include <qpdf/QPDFPageObjectHelper.hh>
#include <qpdf/QUtil.hh> #include <qpdf/QUtil.hh>
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()

View File

@ -20,7 +20,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static char const* whoami = 0; static char const* whoami = nullptr;
// This is a simple StreamDataProvider that writes image data for an // This is a simple StreamDataProvider that writes image data for an
// orange square of the given width and height. // orange square of the given width and height.

View File

@ -37,7 +37,7 @@
// of running this example on test files that are specifically crafted // of running this example on test files that are specifically crafted
// for it. // for it.
static char const* whoami = 0; static char const* whoami = nullptr;
class Pl_XOR: public Pipeline class Pl_XOR: public Pipeline
{ {
@ -447,8 +447,8 @@ main(int argc, char* argv[])
{ {
whoami = QUtil::getWhoami(argv[0]); whoami = QUtil::getWhoami(argv[0]);
char const* infilename = 0; char const* infilename = nullptr;
char const* outfilename = 0; char const* outfilename = nullptr;
bool decode_specialized = false; bool decode_specialized = false;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--decode-specialized") == 0) { if (strcmp(argv[i], "--decode-specialized") == 0) {

View File

@ -8,7 +8,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()

View File

@ -18,7 +18,7 @@
#include <qpdf/QPDFWriter.hh> #include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh> #include <qpdf/QUtil.hh>
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()

View File

@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()
@ -142,7 +142,8 @@ main(int argc, char* argv[])
// pipeStreamData with a null pipeline to determine // pipeStreamData with a null pipeline to determine
// whether the image is filterable. Directly inspect // whether the image is filterable. Directly inspect
// keys to determine the image type. // keys to determine the image type.
if (image.pipeStreamData(0, qpdf_ef_compress, qpdf_dl_all) && if (image.pipeStreamData(
nullptr, qpdf_ef_compress, qpdf_dl_all) &&
color_space.isNameAndEquals("/DeviceGray") && color_space.isNameAndEquals("/DeviceGray") &&
bits_per_component.isInteger() && bits_per_component.isInteger() &&
(bits_per_component.getIntValue() == 8)) { (bits_per_component.getIntValue() == 8)) {

View File

@ -11,7 +11,7 @@
#include <string.h> #include <string.h>
static char const* version = "1.1"; static char const* version = "1.1";
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()
@ -77,8 +77,8 @@ main(int argc, char* argv[])
exit(0); exit(0);
} }
char* fl_in = 0; char* fl_in = nullptr;
char* fl_out = 0; char* fl_out = nullptr;
std::string cur_key; std::string cur_key;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {

View File

@ -6,7 +6,7 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()

View File

@ -5,7 +5,7 @@
#include <qpdf/QPDF.hh> #include <qpdf/QPDF.hh>
#include <qpdf/QUtil.hh> #include <qpdf/QUtil.hh>
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()

View File

@ -12,7 +12,7 @@
// --overlay and --underlay options provide a more general version of // --overlay and --underlay options provide a more general version of
// this capability. // this capability.
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()

View File

@ -8,7 +8,7 @@
#include <qpdf/QPDFPageObjectHelper.hh> #include <qpdf/QPDFPageObjectHelper.hh>
#include <qpdf/QUtil.hh> #include <qpdf/QUtil.hh>
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()

View File

@ -8,7 +8,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
static char const* whoami = 0; static char const* whoami = nullptr;
void void
usage() usage()

View File

@ -8,7 +8,7 @@
// This program is a simple demonstration of different ways to use the // This program is a simple demonstration of different ways to use the
// QPDFJob API. // QPDFJob API.
static char const* whoami = 0; static char const* whoami = nullptr;
static void static void
usage() usage()

View File

@ -5,10 +5,10 @@
Buffer::Members::Members(size_t size, unsigned char* buf, bool own_memory) : Buffer::Members::Members(size_t size, unsigned char* buf, bool own_memory) :
own_memory(own_memory), own_memory(own_memory),
size(size), size(size),
buf(0) buf(nullptr)
{ {
if (own_memory) { if (own_memory) {
this->buf = (size ? new unsigned char[size] : 0); this->buf = (size ? new unsigned char[size] : nullptr);
} else { } else {
this->buf = buf; this->buf = buf;
} }
@ -22,12 +22,12 @@ Buffer::Members::~Members()
} }
Buffer::Buffer() : Buffer::Buffer() :
m(new Members(0, 0, true)) m(new Members(0, nullptr, true))
{ {
} }
Buffer::Buffer(size_t size) : Buffer::Buffer(size_t size) :
m(new Members(size, 0, true)) m(new Members(size, nullptr, true))
{ {
} }
@ -52,7 +52,8 @@ void
Buffer::copy(Buffer const& rhs) Buffer::copy(Buffer const& rhs)
{ {
if (this != &rhs) { if (this != &rhs) {
this->m = std::shared_ptr<Members>(new Members(rhs.m->size, 0, true)); this->m =
std::shared_ptr<Members>(new Members(rhs.m->size, nullptr, true));
if (this->m->size) { if (this->m->size) {
memcpy(this->m->buf, rhs.m->buf, this->m->size); memcpy(this->m->buf, rhs.m->buf, this->m->size);
} }

View File

@ -25,7 +25,7 @@ BufferInputSource::BufferInputSource(
BufferInputSource::BufferInputSource( BufferInputSource::BufferInputSource(
std::string const& description, std::string const& contents) : std::string const& description, std::string const& contents) :
m(new Members(true, description, 0)) m(new Members(true, description, nullptr))
{ {
this->m->buf = new Buffer(contents.length()); this->m->buf = new Buffer(contents.length());
this->m->max_offset = QIntC::to_offset(this->m->buf->getSize()); this->m->max_offset = QIntC::to_offset(this->m->buf->getSize());

View File

@ -23,7 +23,7 @@ ClosedFileInputSource::~ClosedFileInputSource()
void void
ClosedFileInputSource::before() ClosedFileInputSource::before()
{ {
if (0 == this->m->fis.get()) { if (nullptr == this->m->fis.get()) {
this->m->fis = this->m->fis =
std::make_shared<FileInputSource>(this->m->filename.c_str()); std::make_shared<FileInputSource>(this->m->filename.c_str());
this->m->fis->seek(this->m->offset, SEEK_SET); this->m->fis->seek(this->m->offset, SEEK_SET);
@ -39,7 +39,7 @@ ClosedFileInputSource::after()
if (this->m->stay_open) { if (this->m->stay_open) {
return; return;
} }
this->m->fis = 0; this->m->fis = nullptr;
} }
qpdf_offset_t qpdf_offset_t

View File

@ -7,7 +7,7 @@
FileInputSource::Members::Members(bool close_file) : FileInputSource::Members::Members(bool close_file) :
close_file(close_file), close_file(close_file),
file(0) file(nullptr)
{ {
} }

View File

@ -69,7 +69,7 @@ InputSource::findFirst(
" too small or too large of a character sequence"); " too small or too large of a character sequence");
} }
char* p = 0; char* p = nullptr;
qpdf_offset_t buf_offset = offset; qpdf_offset_t buf_offset = offset;
size_t bytes_read = 0; size_t bytes_read = 0;
@ -86,7 +86,8 @@ InputSource::findFirst(
// If p points to buf[size], since strlen(start_chars) is // If p points to buf[size], since strlen(start_chars) is
// always >= 1, this overflow test will be correct for that // always >= 1, this overflow test will be correct for that
// case regardless of start_chars. // case regardless of start_chars.
if ((p == 0) || ((p + strlen(start_chars)) > (buf + bytes_read))) { if ((p == nullptr) ||
((p + strlen(start_chars)) > (buf + bytes_read))) {
if (p) { if (p) {
QTC::TC( QTC::TC(
"libtests", "libtests",
@ -117,7 +118,7 @@ InputSource::findFirst(
memchr( memchr(
p, p,
start_chars[0], start_chars[0],
bytes_read - QIntC::to_size(p - buf)))) != 0) { bytes_read - QIntC::to_size(p - buf)))) != nullptr) {
if (p == buf) { if (p == buf) {
QTC::TC("libtests", "InputSource found match at buf[0]"); QTC::TC("libtests", "InputSource found match at buf[0]");
} }

View File

@ -204,7 +204,7 @@ JSON::JSON_blob::write(Pipeline* p, size_t) const
void void
JSON::write(Pipeline* p, size_t depth) const JSON::write(Pipeline* p, size_t depth) const
{ {
if (0 == this->m->value.get()) { if (nullptr == this->m->value.get()) {
*p << "null"; *p << "null";
} else { } else {
this->m->value->write(p, depth); this->m->value->write(p, depth);
@ -270,7 +270,7 @@ JSON
JSON::addDictionaryMember(std::string const& key, JSON const& val) JSON::addDictionaryMember(std::string const& key, JSON const& val)
{ {
JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get()); JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
if (0 == obj) { if (nullptr == obj) {
throw std::runtime_error( throw std::runtime_error(
"JSON::addDictionaryMember called on non-dictionary"); "JSON::addDictionaryMember called on non-dictionary");
} }
@ -286,7 +286,7 @@ bool
JSON::checkDictionaryKeySeen(std::string const& key) JSON::checkDictionaryKeySeen(std::string const& key)
{ {
JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get()); JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
if (0 == obj) { if (nullptr == obj) {
throw std::logic_error( throw std::logic_error(
"JSON::checkDictionaryKey called on non-dictionary"); "JSON::checkDictionaryKey called on non-dictionary");
} }
@ -307,7 +307,7 @@ JSON
JSON::addArrayElement(JSON const& val) JSON::addArrayElement(JSON const& val)
{ {
JSON_array* arr = dynamic_cast<JSON_array*>(this->m->value.get()); JSON_array* arr = dynamic_cast<JSON_array*>(this->m->value.get());
if (0 == arr) { if (nullptr == arr) {
throw std::runtime_error("JSON::addArrayElement called on non-array"); throw std::runtime_error("JSON::addArrayElement called on non-array");
} }
if (val.m->value.get()) { if (val.m->value.get()) {

View File

@ -14,7 +14,7 @@ Pipeline::Pipeline(char const* identifier, Pipeline* next) :
Pipeline* Pipeline*
Pipeline::getNext(bool allow_null) Pipeline::getNext(bool allow_null)
{ {
if ((this->next == 0) && (!allow_null)) { if ((this->next == nullptr) && (!allow_null)) {
throw std::logic_error( throw std::logic_error(
this->identifier + this->identifier +
": Pipeline::getNext() called on pipeline with no next"); ": Pipeline::getNext() called on pipeline with no next");

View File

@ -26,7 +26,7 @@ Pl_Buffer::~Pl_Buffer()
void void
Pl_Buffer::write(unsigned char const* buf, size_t len) Pl_Buffer::write(unsigned char const* buf, size_t len)
{ {
if (this->m->data.get() == 0) { if (this->m->data.get() == nullptr) {
this->m->data = std::make_shared<Buffer>(len); this->m->data = std::make_shared<Buffer>(len);
} }
size_t cur_size = this->m->data->getSize(); size_t cur_size = this->m->data->getSize();

View File

@ -3,7 +3,7 @@
// Exercised in md5 test suite // Exercised in md5 test suite
Pl_Discard::Pl_Discard() : Pl_Discard::Pl_Discard() :
Pipeline("discard", 0) Pipeline("discard", nullptr)
{ {
} }

View File

@ -13,7 +13,7 @@ Pl_Flate::Members::Members(size_t out_bufsize, action_e action) :
out_bufsize(out_bufsize), out_bufsize(out_bufsize),
action(action), action(action),
initialized(false), initialized(false),
zdata(0) zdata(nullptr)
{ {
this->outbuf = QUtil::make_shared_array<unsigned char>(out_bufsize); this->outbuf = QUtil::make_shared_array<unsigned char>(out_bufsize);
// Indirect through zdata to reach the z_stream so we don't have // 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) :
} }
z_stream& zstream = *(static_cast<z_stream*>(this->zdata)); z_stream& zstream = *(static_cast<z_stream*>(this->zdata));
zstream.zalloc = 0; zstream.zalloc = nullptr;
zstream.zfree = 0; zstream.zfree = nullptr;
zstream.opaque = 0; zstream.opaque = nullptr;
zstream.next_in = 0; zstream.next_in = nullptr;
zstream.avail_in = 0; zstream.avail_in = 0;
zstream.next_out = this->outbuf.get(); zstream.next_out = this->outbuf.get();
zstream.avail_out = QIntC::to_uint(out_bufsize); zstream.avail_out = QIntC::to_uint(out_bufsize);
@ -50,7 +50,7 @@ Pl_Flate::Members::~Members()
} }
delete static_cast<z_stream*>(this->zdata); delete static_cast<z_stream*>(this->zdata);
this->zdata = 0; this->zdata = nullptr;
} }
Pl_Flate::Pl_Flate( Pl_Flate::Pl_Flate(
@ -86,7 +86,7 @@ Pl_Flate::warn(char const* msg, int code)
void void
Pl_Flate::write(unsigned char const* data, size_t len) Pl_Flate::write(unsigned char const* data, size_t len)
{ {
if (this->m->outbuf.get() == 0) { if (this->m->outbuf.get() == nullptr) {
throw std::logic_error( throw std::logic_error(
this->identifier + this->identifier +
": Pl_Flate: write() called after finish() called"); ": Pl_Flate: write() called after finish() called");
@ -227,7 +227,7 @@ Pl_Flate::finish()
checkError("End", err); checkError("End", err);
} }
this->m->outbuf = 0; this->m->outbuf = nullptr;
} }
} catch (std::exception& e) { } catch (std::exception& e) {
try { try {

View File

@ -14,7 +14,7 @@ Pl_LZWDecoder::Pl_LZWDecoder(
byte_pos(0), byte_pos(0),
bit_pos(0), bit_pos(0),
bits_available(0), bits_available(0),
code_change_delta(early_code_change ? 1 : 0), code_change_delta(early_code_change),
eod(false), eod(false),
last_code(256) last_code(256)
{ {
@ -107,7 +107,7 @@ void
Pl_LZWDecoder::addToTable(unsigned char next) Pl_LZWDecoder::addToTable(unsigned char next)
{ {
unsigned int last_size = 0; unsigned int last_size = 0;
unsigned char const* last_data = 0; unsigned char const* last_data = nullptr;
unsigned char tmp[1]; unsigned char tmp[1];
if (this->last_code < 256) { if (this->last_code < 256) {

View File

@ -10,7 +10,7 @@ Pl_OStream::Members::Members(std::ostream& os) :
} }
Pl_OStream::Pl_OStream(char const* identifier, std::ostream& os) : Pl_OStream::Pl_OStream(char const* identifier, std::ostream& os) :
Pipeline(identifier, 0), Pipeline(identifier, nullptr),
m(new Members(os)) m(new Members(os))
{ {
} }

View File

@ -22,10 +22,10 @@ Pl_PNGFilter::Pl_PNGFilter(
unsigned int bits_per_sample) : unsigned int bits_per_sample) :
Pipeline(identifier, next), Pipeline(identifier, next),
action(action), action(action),
cur_row(0), cur_row(nullptr),
prev_row(0), prev_row(nullptr),
buf1(0), buf1(nullptr),
buf2(0), buf2(nullptr),
pos(0) pos(0)
{ {
if (samples_per_pixel < 1) { if (samples_per_pixel < 1) {
@ -243,7 +243,7 @@ Pl_PNGFilter::finish()
// write partial row // write partial row
processRow(); processRow();
} }
this->prev_row = 0; this->prev_row = nullptr;
this->cur_row = buf1.get(); this->cur_row = buf1.get();
this->pos = 0; this->pos = 0;
memset(this->cur_row, 0, this->bytes_per_row + 1); memset(this->cur_row, 0, this->bytes_per_row + 1);

View File

@ -7,7 +7,7 @@
#include <string.h> #include <string.h>
Pl_QPDFTokenizer::Members::Members() : Pl_QPDFTokenizer::Members::Members() :
filter(0), filter(nullptr),
buf("tokenizer buffer") buf("tokenizer buffer")
{ {
} }
@ -68,7 +68,8 @@ Pl_QPDFTokenizer::finish()
} }
} }
this->m->filter->handleEOF(); this->m->filter->handleEOF();
QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, 0); QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(
m->filter, nullptr);
Pipeline* next = this->getNext(true); Pipeline* next = this->getNext(true);
if (next) { if (next) {
next->finish(); next->finish();

View File

@ -18,7 +18,7 @@ Pl_RC4::Pl_RC4(
void void
Pl_RC4::write(unsigned char const* data, size_t len) Pl_RC4::write(unsigned char const* data, size_t len)
{ {
if (this->outbuf.get() == 0) { if (this->outbuf.get() == nullptr) {
throw std::logic_error( throw std::logic_error(
this->identifier + this->identifier +
": Pl_RC4: write() called after finish() called"); ": Pl_RC4: write() called after finish() called");
@ -41,6 +41,6 @@ Pl_RC4::write(unsigned char const* data, size_t len)
void void
Pl_RC4::finish() Pl_RC4::finish()
{ {
this->outbuf = 0; this->outbuf = nullptr;
this->getNext()->finish(); this->getNext()->finish();
} }

View File

@ -12,7 +12,7 @@ Pl_StdioFile::Members::Members(FILE* f) :
} }
Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) : Pl_StdioFile::Pl_StdioFile(char const* identifier, FILE* f) :
Pipeline(identifier, 0), Pipeline(identifier, nullptr),
m(new Members(f)) m(new Members(f))
{ {
} }

View File

@ -216,7 +216,7 @@ QPDF::Members::Members() :
pushed_inherited_attributes_to_pages(false), pushed_inherited_attributes_to_pages(false),
ever_pushed_inherited_attributes_to_pages(false), ever_pushed_inherited_attributes_to_pages(false),
ever_called_get_all_pages(false), ever_called_get_all_pages(false),
copied_stream_data_provider(0), copied_stream_data_provider(nullptr),
reconstructed_xref(false), reconstructed_xref(false),
fixed_dangling_refs(false), fixed_dangling_refs(false),
immediate_copy_from(false), immediate_copy_from(false),
@ -1496,7 +1496,7 @@ QPDF::readObject(
bool empty = false; bool empty = false;
std::shared_ptr<StringDecrypter> decrypter_ph; std::shared_ptr<StringDecrypter> decrypter_ph;
StringDecrypter* decrypter = 0; StringDecrypter* decrypter = nullptr;
if (this->m->encp->encrypted && (!in_object_stream)) { if (this->m->encp->encrypted && (!in_object_stream)) {
decrypter_ph = std::make_shared<StringDecrypter>(this, og); decrypter_ph = std::make_shared<StringDecrypter>(this, og);
decrypter = decrypter_ph.get(); decrypter = decrypter_ph.get();
@ -2434,7 +2434,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
QPDFObjectHandle dict = result.getDict(); QPDFObjectHandle dict = result.getDict();
QPDFObjectHandle old_dict = foreign.getDict(); QPDFObjectHandle old_dict = foreign.getDict();
if (this->m->copied_stream_data_provider == 0) { if (this->m->copied_stream_data_provider == nullptr) {
this->m->copied_stream_data_provider = this->m->copied_stream_data_provider =
new CopiedStreamDataProvider(*this); new CopiedStreamDataProvider(*this);
this->m->copied_streams = this->m->copied_streams =
@ -2457,7 +2457,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
} }
std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer(); std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer();
if ((foreign_stream_qpdf->m->immediate_copy_from) && if ((foreign_stream_qpdf->m->immediate_copy_from) &&
(stream_buffer.get() == 0)) { (stream_buffer.get() == nullptr)) {
// Pull the stream data into a buffer before attempting // Pull the stream data into a buffer before attempting
// the copy operation. Do it on the source stream so that // the copy operation. Do it on the source stream so that
// if the source stream is copied multiple times, we don't // if the source stream is copied multiple times, we don't

View File

@ -30,7 +30,7 @@ QPDFArgParser::QPDFArgParser(
m(new Members(argc, argv, progname_env)) m(new Members(argc, argv, progname_env))
{ {
selectHelpOptionTable(); selectHelpOptionTable();
char const* help_choices[] = {"all", 0}; char const* help_choices[] = {"all", nullptr};
// More help choices are added dynamically. // More help choices are added dynamically.
addChoices( addChoices(
"help", bindParam(&QPDFArgParser::argHelp, this), false, help_choices); "help", bindParam(&QPDFArgParser::argHelp, this), false, help_choices);
@ -254,7 +254,7 @@ QPDFArgParser::handleArgFileArguments()
// deleted by using shared pointers to back the pointers in argv. // deleted by using shared pointers to back the pointers in argv.
this->m->new_argv.push_back(QUtil::make_shared_cstr(this->m->argv[0])); this->m->new_argv.push_back(QUtil::make_shared_cstr(this->m->argv[0]));
for (int i = 1; i < this->m->argc; ++i) { for (int i = 1; i < this->m->argc; ++i) {
char const* argfile = 0; char const* argfile = nullptr;
if ((strlen(this->m->argv[i]) > 1) && (this->m->argv[i][0] == '@')) { if ((strlen(this->m->argv[i]) > 1) && (this->m->argv[i][0] == '@')) {
argfile = 1 + this->m->argv[i]; argfile = 1 + this->m->argv[i];
if (strcmp(argfile, "-") != 0) { if (strcmp(argfile, "-") != 0) {

View File

@ -14,7 +14,7 @@ getRandomProvider()
static RandomDataProvider* insecure_random_data_provider = static RandomDataProvider* insecure_random_data_provider =
InsecureRandomDataProvider::getInstance(); InsecureRandomDataProvider::getInstance();
#else #else
static RandomDataProvider* insecure_random_data_provider = 0; static RandomDataProvider* insecure_random_data_provider = nullptr;
#endif #endif
static RandomDataProvider* secure_random_data_provider = static RandomDataProvider* secure_random_data_provider =
SecureRandomDataProvider::getInstance(); SecureRandomDataProvider::getInstance();
@ -22,9 +22,9 @@ getRandomProvider()
static RandomDataProvider* provider = static RandomDataProvider* provider =
(secure_random_data_provider ? secure_random_data_provider (secure_random_data_provider ? secure_random_data_provider
: insecure_random_data_provider ? insecure_random_data_provider : insecure_random_data_provider ? insecure_random_data_provider
: 0); : nullptr);
if (provider == 0) { if (provider == nullptr) {
throw std::logic_error("QPDFCrypto_native has no random data provider"); throw std::logic_error("QPDFCrypto_native has no random data provider");
} }

View File

@ -746,7 +746,7 @@ TfFinder::handleToken(QPDFTokenizer::Token const& token)
switch (ttype) { switch (ttype) {
case QPDFTokenizer::tt_integer: case QPDFTokenizer::tt_integer:
case QPDFTokenizer::tt_real: case QPDFTokenizer::tt_real:
last_num = strtod(value.c_str(), 0); last_num = strtod(value.c_str(), nullptr);
last_num_idx = QIntC::to_int(DA.size() - 1); last_num_idx = QIntC::to_int(DA.size() - 1);
break; break;
@ -785,7 +785,7 @@ TfFinder::getDA()
for (size_t i = 0; i < n; ++i) { for (size_t i = 0; i < n; ++i) {
std::string cur = this->DA.at(i); std::string cur = this->DA.at(i);
if (QIntC::to_int(i) == tf_idx) { if (QIntC::to_int(i) == tf_idx) {
double delta = strtod(cur.c_str(), 0) - this->tf; double delta = strtod(cur.c_str(), nullptr) - this->tf;
if ((delta > 0.001) || (delta < -0.001)) { if ((delta > 0.001) || (delta < -0.001)) {
// tf doesn't match the font size passed to Tf, so // tf doesn't match the font size passed to Tf, so
// substitute. // substitute.

View File

@ -211,7 +211,7 @@ ImageOptimizer::makePipeline(std::string const& description, Pipeline* next)
bool bool
ImageOptimizer::evaluate(std::string const& description) ImageOptimizer::evaluate(std::string const& description)
{ {
if (!image.pipeStreamData(0, 0, qpdf_dl_specialized, true)) { if (!image.pipeStreamData(nullptr, 0, qpdf_dl_specialized, true)) {
QTC::TC("qpdf", "QPDFJob image optimize no pipeline"); QTC::TC("qpdf", "QPDFJob image optimize no pipeline");
o.doIfVerbose([&](Pipeline& v, std::string const& prefix) { o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
v << prefix << ": " << description v << prefix << ": " << description
@ -317,7 +317,7 @@ QPDFJob::Members::Members() :
warnings(false), warnings(false),
encryption_status(0), encryption_status(0),
verbose(false), verbose(false),
password(0), password(nullptr),
linearize(false), linearize(false),
decrypt(false), decrypt(false),
split_pages(0), split_pages(0),
@ -326,7 +326,7 @@ QPDFJob::Members::Members() :
suppress_warnings(false), suppress_warnings(false),
warnings_exit_zero(false), warnings_exit_zero(false),
copy_encryption(false), copy_encryption(false),
encryption_file_password(0), encryption_file_password(nullptr),
encrypt(false), encrypt(false),
password_is_hex_key(false), password_is_hex_key(false),
suppress_password_recovery(false), suppress_password_recovery(false),
@ -411,7 +411,7 @@ QPDFJob::Members::Members() :
ii_min_bytes(DEFAULT_II_MIN_BYTES), ii_min_bytes(DEFAULT_II_MIN_BYTES),
underlay("underlay"), underlay("underlay"),
overlay("overlay"), overlay("overlay"),
under_overlay(0), under_overlay(nullptr),
require_outfile(true), require_outfile(true),
replace_input(false), replace_input(false),
check_is_encrypted(false), check_is_encrypted(false),
@ -673,13 +673,15 @@ QPDFJob::checkConfiguration()
usage("--split-pages may not be used with --replace-input"); usage("--split-pages may not be used with --replace-input");
} }
} }
if (m->infilename == 0) { if (m->infilename == nullptr) {
usage("an input file name is required"); usage("an input file name is required");
} else if ( } else if (
m->require_outfile && (m->outfilename == 0) && (!m->replace_input)) { m->require_outfile && (m->outfilename == nullptr) &&
(!m->replace_input)) {
usage("an output file name is required; use - for standard output"); usage("an output file name is required; use - for standard output");
} else if ( } else if (
(!m->require_outfile) && ((m->outfilename != 0) || m->replace_input)) { (!m->require_outfile) &&
((m->outfilename != nullptr) || m->replace_input)) {
usage("no output file may be given for this option"); usage("no output file may be given for this option");
} }
if (m->check_requires_password && m->check_is_encrypted) { if (m->check_requires_password && m->check_is_encrypted) {
@ -924,7 +926,7 @@ QPDFJob::doShowObj(QPDF& pdf)
if (obj.isStream()) { if (obj.isStream()) {
if (m->show_raw_stream_data || m->show_filtered_stream_data) { if (m->show_raw_stream_data || m->show_filtered_stream_data) {
bool filter = m->show_filtered_stream_data; bool filter = m->show_filtered_stream_data;
if (filter && (!obj.pipeStreamData(0, 0, qpdf_dl_all))) { if (filter && (!obj.pipeStreamData(nullptr, 0, qpdf_dl_all))) {
QTC::TC("qpdf", "QPDFJob unable to filter"); QTC::TC("qpdf", "QPDFJob unable to filter");
obj.warnIfPossible("unable to filter stream data"); obj.warnIfPossible("unable to filter stream data");
error = true; error = true;
@ -1204,7 +1206,7 @@ QPDFJob::doJSONPages(Pipeline* p, bool& first, QPDF& pdf)
j_image.addDictionaryMember( j_image.addDictionaryMember(
"filterable", "filterable",
JSON::makeBool( JSON::makeBool(
image.pipeStreamData(0, 0, m->decode_level, true))); image.pipeStreamData(nullptr, 0, m->decode_level, true)));
} }
j_page.addDictionaryMember("images", j_images); j_page.addDictionaryMember("images", j_images);
JSON j_contents = JSON j_contents =
@ -1561,7 +1563,7 @@ QPDFJob::json_schema(int json_version, std::set<std::string>* keys)
"decodelevel": "decode level used to determine stream filterability" "decodelevel": "decode level used to determine stream filterability"
})")); })"));
bool all_keys = ((keys == 0) || keys->empty()); bool all_keys = ((keys == nullptr) || keys->empty());
// The list of selectable top-level keys id duplicated in the // The list of selectable top-level keys id duplicated in the
// following places: job.yml, QPDFJob::json_schema, and // following places: job.yml, QPDFJob::json_schema, and
@ -1943,7 +1945,7 @@ QPDFJob::doProcess(
password = ptemp.c_str(); password = ptemp.c_str();
} }
} }
if ((password == 0) || empty || m->password_is_hex_key || if ((password == nullptr) || empty || m->password_is_hex_key ||
m->suppress_password_recovery) { m->suppress_password_recovery) {
// There is no password, or we're not doing recovery, so just // There is no password, or we're not doing recovery, so just
// do the normal processing with the supplied password. // do the normal processing with the supplied password.
@ -2591,7 +2593,7 @@ QPDFJob::handlePageSpecs(
// to the same underlying file with the same path to // to the same underlying file with the same path to
// achieve the same affect. // achieve the same affect.
char const* password = page_spec.password.get(); char const* password = page_spec.password.get();
if ((!m->encryption_file.empty()) && (password == 0) && if ((!m->encryption_file.empty()) && (password == nullptr) &&
(page_spec.filename == m->encryption_file)) { (page_spec.filename == m->encryption_file)) {
QTC::TC("qpdf", "QPDFJob pages encryption password"); QTC::TC("qpdf", "QPDFJob pages encryption password");
password = m->encryption_file_password.get(); password = m->encryption_file_password.get();
@ -2600,7 +2602,7 @@ QPDFJob::handlePageSpecs(
v << prefix << ": processing " << page_spec.filename << "\n"; v << prefix << ": processing " << page_spec.filename << "\n";
}); });
std::shared_ptr<InputSource> is; std::shared_ptr<InputSource> is;
ClosedFileInputSource* cis = 0; ClosedFileInputSource* cis = nullptr;
if (!m->keep_files_open) { if (!m->keep_files_open) {
QTC::TC("qpdf", "QPDFJob keep files open n"); QTC::TC("qpdf", "QPDFJob keep files open n");
cis = new ClosedFileInputSource(page_spec.filename.c_str()); cis = new ClosedFileInputSource(page_spec.filename.c_str());
@ -2636,7 +2638,7 @@ QPDFJob::handlePageSpecs(
if (m->remove_unreferenced_page_resources != QPDFJob::re_no) { if (m->remove_unreferenced_page_resources != QPDFJob::re_no) {
for (auto const& iter: page_spec_qpdfs) { for (auto const& iter: page_spec_qpdfs) {
std::string const& filename = iter.first; std::string const& filename = iter.first;
ClosedFileInputSource* cis = 0; ClosedFileInputSource* cis = nullptr;
if (page_spec_cfis.count(filename)) { if (page_spec_cfis.count(filename)) {
cis = page_spec_cfis[filename]; cis = page_spec_cfis[filename];
cis->stayOpen(true); cis->stayOpen(true);
@ -2707,7 +2709,7 @@ QPDFJob::handlePageSpecs(
auto this_afdh = get_afdh_for_qpdf(afdh_map, &pdf); auto this_afdh = get_afdh_for_qpdf(afdh_map, &pdf);
std::set<QPDFObjGen> referenced_fields; std::set<QPDFObjGen> referenced_fields;
for (auto& page_data: parsed_specs) { for (auto& page_data: parsed_specs) {
ClosedFileInputSource* cis = 0; ClosedFileInputSource* cis = nullptr;
if (page_spec_cfis.count(page_data.filename)) { if (page_spec_cfis.count(page_data.filename)) {
cis = page_spec_cfis[page_data.filename]; cis = page_spec_cfis[page_data.filename];
cis->stayOpen(true); cis->stayOpen(true);
@ -3061,7 +3063,7 @@ parse_version(
auto vp = QUtil::make_unique_cstr(full_version_string); auto vp = QUtil::make_unique_cstr(full_version_string);
char* v = vp.get(); char* v = vp.get();
char* p1 = strchr(v, '.'); char* p1 = strchr(v, '.');
char* p2 = (p1 ? strchr(1 + p1, '.') : 0); char* p2 = (p1 ? strchr(1 + p1, '.') : nullptr);
if (p2 && *(p2 + 1)) { if (p2 && *(p2 + 1)) {
*p2++ = '\0'; *p2++ = '\0';
extension_level = QUtil::string_to_int(p2); extension_level = QUtil::string_to_int(p2);
@ -3176,7 +3178,7 @@ QPDFJob::doSplitPages(QPDF& pdf, bool& warnings)
std::string after; std::string after;
size_t len = strlen(m->outfilename.get()); size_t len = strlen(m->outfilename.get());
char* num_spot = strstr(const_cast<char*>(m->outfilename.get()), "%d"); char* num_spot = strstr(const_cast<char*>(m->outfilename.get()), "%d");
if (num_spot != 0) { if (num_spot != nullptr) {
QTC::TC("qpdf", "QPDFJob split-pages %d"); QTC::TC("qpdf", "QPDFJob split-pages %d");
before = std::string( before = std::string(
m->outfilename.get(), m->outfilename.get(),
@ -3310,7 +3312,7 @@ QPDFJob::writeOutfile(QPDF& pdf)
}); });
} }
if (m->replace_input) { if (m->replace_input) {
m->outfilename = 0; m->outfilename = nullptr;
} }
if (m->replace_input) { if (m->replace_input) {
// We must close the input before we can rename files // We must close the input before we can rename files

View File

@ -13,7 +13,7 @@ QPDFJob::Config::checkConfiguration()
QPDFJob::Config* QPDFJob::Config*
QPDFJob::Config::inputFile(std::string const& filename) QPDFJob::Config::inputFile(std::string const& filename)
{ {
if (o.m->infilename == 0) { if (o.m->infilename == nullptr) {
o.m->infilename = QUtil::make_shared_cstr(filename); o.m->infilename = QUtil::make_shared_cstr(filename);
} else { } else {
usage("input file has already been given"); usage("input file has already been given");
@ -24,7 +24,7 @@ QPDFJob::Config::inputFile(std::string const& filename)
QPDFJob::Config* QPDFJob::Config*
QPDFJob::Config::emptyInput() QPDFJob::Config::emptyInput()
{ {
if (o.m->infilename == 0) { if (o.m->infilename == nullptr) {
// Various places in QPDFJob.cc know that the empty string for // Various places in QPDFJob.cc know that the empty string for
// infile means empty. We set it to something other than a // infile means empty. We set it to something other than a
// null pointer as an indication that some input source has // null pointer as an indication that some input source has
@ -44,7 +44,7 @@ QPDFJob::Config::emptyInput()
QPDFJob::Config* QPDFJob::Config*
QPDFJob::Config::outputFile(std::string const& filename) QPDFJob::Config::outputFile(std::string const& filename)
{ {
if ((o.m->outfilename == 0) && (!o.m->replace_input)) { if ((o.m->outfilename == nullptr) && (!o.m->replace_input)) {
o.m->outfilename = QUtil::make_shared_cstr(filename); o.m->outfilename = QUtil::make_shared_cstr(filename);
} else { } else {
usage("output file has already been given"); usage("output file has already been given");
@ -55,7 +55,7 @@ QPDFJob::Config::outputFile(std::string const& filename)
QPDFJob::Config* QPDFJob::Config*
QPDFJob::Config::replaceInput() QPDFJob::Config::replaceInput()
{ {
if ((o.m->outfilename == 0) && (!o.m->replace_input)) { if ((o.m->outfilename == nullptr) && (!o.m->replace_input)) {
o.m->replace_input = true; o.m->replace_input = true;
} else { } else {
usage("replace-input can't be used" usage("replace-input can't be used"
@ -977,7 +977,7 @@ QPDFJob::UOConfig::endUnderlayOverlay()
if (config->o.m->under_overlay->filename.empty()) { if (config->o.m->under_overlay->filename.empty()) {
usage(config->o.m->under_overlay->which + " file not specified"); usage(config->o.m->under_overlay->which + " file not specified");
} }
config->o.m->under_overlay = 0; config->o.m->under_overlay = nullptr;
return this->config; return this->config;
} }

View File

@ -1,7 +1,7 @@
#include <qpdf/QPDFObject.hh> #include <qpdf/QPDFObject.hh>
QPDFObject::QPDFObject() : QPDFObject::QPDFObject() :
owning_qpdf(0), owning_qpdf(nullptr),
parsed_offset(-1) parsed_offset(-1)
{ {
} }
@ -25,13 +25,13 @@ QPDFObject::getDescription(QPDF*& qpdf, std::string& description)
{ {
qpdf = this->owning_qpdf; qpdf = this->owning_qpdf;
description = this->object_description; description = this->object_description;
return this->owning_qpdf != 0; return this->owning_qpdf != nullptr;
} }
bool bool
QPDFObject::hasDescription() QPDFObject::hasDescription()
{ {
return this->owning_qpdf != 0; return this->owning_qpdf != nullptr;
} }
void void

View File

@ -265,7 +265,7 @@ QPDFObjectHandle::releaseResolved()
// destruction. See comments in QPDF::~QPDF(). // destruction. See comments in QPDF::~QPDF().
if (isIndirect()) { if (isIndirect()) {
if (this->obj.get()) { if (this->obj.get()) {
this->obj = 0; this->obj = nullptr;
} }
} else { } else {
QPDFObject::ObjAccessor::releaseResolved(this->obj.get()); QPDFObject::ObjAccessor::releaseResolved(this->obj.get());
@ -780,7 +780,7 @@ QPDFObjectHandle::getArrayItem(int n)
typeWarning("array", "returning null"); typeWarning("array", "returning null");
QTC::TC("qpdf", "QPDFObjectHandle array null for non-array"); QTC::TC("qpdf", "QPDFObjectHandle array null for non-array");
} }
QPDF* context = 0; QPDF* context = nullptr;
std::string description; std::string description;
if (this->obj->getDescription(context, description)) { if (this->obj->getDescription(context, description)) {
result.setObjectDescription( result.setObjectDescription(
@ -998,7 +998,7 @@ QPDFObjectHandle::getKey(std::string const& key)
typeWarning("dictionary", "returning null for attempted key retrieval"); typeWarning("dictionary", "returning null for attempted key retrieval");
QTC::TC("qpdf", "QPDFObjectHandle dictionary null for getKey"); QTC::TC("qpdf", "QPDFObjectHandle dictionary null for getKey");
result = newNull(); result = newNull();
QPDF* qpdf = 0; QPDF* qpdf = nullptr;
std::string description; std::string description;
if (this->obj->getDescription(qpdf, description)) { if (this->obj->getDescription(qpdf, description)) {
result.setObjectDescription( result.setObjectDescription(
@ -1665,7 +1665,7 @@ QPDFObjectHandle::coalesceContentStreams()
return; return;
} }
QPDF* qpdf = getOwningQPDF(); QPDF* qpdf = getOwningQPDF();
if (qpdf == 0) { if (qpdf == nullptr) {
// Should not be possible for a page object to not have an // Should not be possible for a page object to not have an
// owning PDF unless it was manually constructed in some // owning PDF unless it was manually constructed in some
// incorrect way. However, it can happen in a PDF file whose // incorrect way. However, it can happen in a PDF file whose
@ -1782,7 +1782,7 @@ QPDFObjectHandle::parse(
QPDFTokenizer tokenizer; QPDFTokenizer tokenizer;
bool empty = false; bool empty = false;
QPDFObjectHandle result = QPDFObjectHandle result =
parse(input, object_description, tokenizer, empty, 0, context); parse(input, object_description, tokenizer, empty, nullptr, context);
size_t offset = QIntC::to_size(input->tell()); size_t offset = QIntC::to_size(input->tell());
while (offset < object_str.length()) { while (offset < object_str.length()) {
if (!isspace(object_str.at(offset))) { if (!isspace(object_str.at(offset))) {
@ -1918,8 +1918,8 @@ QPDFObjectHandle::parseContentStream_data(
tokenizer.readToken(input, "content", true); tokenizer.readToken(input, "content", true);
qpdf_offset_t offset = input->getLastOffset(); qpdf_offset_t offset = input->getLastOffset();
input->seek(offset, SEEK_SET); input->seek(offset, SEEK_SET);
QPDFObjectHandle obj = QPDFObjectHandle obj = parseInternal(
parseInternal(input, "content", tokenizer, empty, 0, context, true); input, "content", tokenizer, empty, nullptr, context, true);
if (!obj.isInitialized()) { if (!obj.isInitialized()) {
// EOF // EOF
break; break;
@ -2195,7 +2195,7 @@ QPDFObjectHandle::parseInternal(
(olist.at(olist.size() - 1).isInteger()) && (olist.at(olist.size() - 1).isInteger()) &&
(!olist.at(olist.size() - 2).isIndirect()) && (!olist.at(olist.size() - 2).isIndirect()) &&
(olist.at(olist.size() - 2).isInteger())) { (olist.at(olist.size() - 2).isInteger())) {
if (context == 0) { if (context == nullptr) {
QTC::TC( QTC::TC(
"qpdf", "qpdf",
"QPDFObjectHandle indirect without context"); "QPDFObjectHandle indirect without context");
@ -2671,7 +2671,7 @@ QPDFObjectHandle::newStream(
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newStream(QPDF* qpdf) QPDFObjectHandle::newStream(QPDF* qpdf)
{ {
if (qpdf == 0) { if (qpdf == nullptr) {
throw std::runtime_error( throw std::runtime_error(
"attempt to create stream in null qpdf object"); "attempt to create stream in null qpdf object");
} }
@ -2915,7 +2915,7 @@ QPDFObjectHandle::typeWarning(
void void
QPDFObjectHandle::warnIfPossible(std::string const& warning) QPDFObjectHandle::warnIfPossible(std::string const& warning)
{ {
QPDF* context = 0; QPDF* context = nullptr;
std::string description; std::string description;
if (dereference() && obj->getDescription(context, description)) { if (dereference() && obj->getDescription(context, description)) {
warn(context, QPDFExc(qpdf_e_damaged_pdf, "", description, 0, warning)); warn(context, QPDFExc(qpdf_e_damaged_pdf, "", description, 0, warning));
@ -3122,10 +3122,10 @@ QPDFObjectHandle::dereference()
QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj)) { QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj)) {
this->obj = nullptr; this->obj = nullptr;
} }
if (this->obj.get() == 0) { if (this->obj.get() == nullptr) {
std::shared_ptr<QPDFObject> obj = std::shared_ptr<QPDFObject> obj =
QPDF::Resolver::resolve(this->qpdf, getObjGen()); QPDF::Resolver::resolve(this->qpdf, getObjGen());
if (obj.get() == 0) { if (obj.get() == nullptr) {
// QPDF::resolve never returns an uninitialized object, but // QPDF::resolve never returns an uninitialized object, but
// check just in case. // check just in case.
this->obj = QPDF_Null::create(); this->obj = QPDF_Null::create();

View File

@ -82,7 +82,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name)
result = this->m->dest_dict.getKey(name.getName()); result = this->m->dest_dict.getKey(name.getName());
} }
} else if (name.isString()) { } else if (name.isString()) {
if (0 == this->m->names_dest.get()) { if (nullptr == this->m->names_dest.get()) {
QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names"); QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names");
if (names.isDictionary()) { if (names.isDictionary()) {
QPDFObjectHandle dests = names.getKey("/Dests"); QPDFObjectHandle dests = names.getKey("/Dests");

View File

@ -16,7 +16,7 @@ QPDFPageLabelDocumentHelper::QPDFPageLabelDocumentHelper(QPDF& qpdf) :
bool bool
QPDFPageLabelDocumentHelper::hasPageLabels() QPDFPageLabelDocumentHelper::hasPageLabels()
{ {
return 0 != this->m->labels.get(); return nullptr != this->m->labels.get();
} }
QPDFObjectHandle QPDFObjectHandle

View File

@ -17,7 +17,7 @@
static bool static bool
is_delimiter(char ch) is_delimiter(char ch)
{ {
return (strchr(" \t\n\v\f\r()<>[]{}/%", ch) != 0); return (strchr(" \t\n\v\f\r()<>[]{}/%", ch) != nullptr);
} }
namespace namespace
@ -158,7 +158,7 @@ QPDFTokenizer::resolveLiteral()
num[0] = this->m->val.at(i + 1); num[0] = this->m->val.at(i + 1);
num[1] = this->m->val.at(i + 2); num[1] = this->m->val.at(i + 2);
num[2] = '\0'; num[2] = '\0';
char ch2 = static_cast<char>(strtol(num, 0, 16)); char ch2 = static_cast<char>(strtol(num, nullptr, 16));
if (ch2 == '\0') { if (ch2 == '\0') {
this->m->type = tt_bad; this->m->type = tt_bad;
QTC::TC("qpdf", "QPDFTokenizer null in name"); QTC::TC("qpdf", "QPDFTokenizer null in name");
@ -323,7 +323,7 @@ QPDFTokenizer::presentCharacter(char ch)
// We've accumulated \ddd. PDF Spec says to ignore // We've accumulated \ddd. PDF Spec says to ignore
// high-order overflow. // high-order overflow.
this->m->val += this->m->val +=
static_cast<char>(strtol(this->m->bs_num_register, 0, 8)); static_cast<char>(strtol(this->m->bs_num_register, nullptr, 8));
memset( memset(
this->m->bs_num_register, this->m->bs_num_register,
'\0', '\0',
@ -447,7 +447,7 @@ QPDFTokenizer::presentCharacter(char ch)
for (unsigned int i = 0; i < this->m->val.length(); i += 2) { for (unsigned int i = 0; i < this->m->val.length(); i += 2) {
num[0] = this->m->val.at(i); num[0] = this->m->val.at(i);
num[1] = this->m->val.at(i + 1); num[1] = this->m->val.at(i + 1);
char nch = static_cast<char>(strtol(num, 0, 16)); char nch = static_cast<char>(strtol(num, nullptr, 16));
nval += nch; nval += nch;
} }
this->m->val = nval; this->m->val = nval;

View File

@ -52,10 +52,10 @@ QPDFWriter::FunctionProgressReporter::reportProgress(int progress)
QPDFWriter::Members::Members(QPDF& pdf) : QPDFWriter::Members::Members(QPDF& pdf) :
pdf(pdf), pdf(pdf),
filename("unspecified"), filename("unspecified"),
file(0), file(nullptr),
close_file(false), close_file(false),
buffer_pipeline(0), buffer_pipeline(nullptr),
output_buffer(0), output_buffer(nullptr),
normalize_content_set(false), normalize_content_set(false),
normalize_content(false), normalize_content(false),
compress_streams(true), compress_streams(true),
@ -82,7 +82,7 @@ QPDFWriter::Members::Members(QPDF& pdf) :
min_extension_level(0), min_extension_level(0),
forced_extension_level(0), forced_extension_level(0),
encryption_dict_objid(0), encryption_dict_objid(0),
pipeline(0), pipeline(nullptr),
next_objid(1), next_objid(1),
cur_stream_length_id(0), cur_stream_length_id(0),
cur_stream_length(0), cur_stream_length(0),
@ -90,7 +90,7 @@ QPDFWriter::Members::Members(QPDF& pdf) :
max_ostream_index(0), max_ostream_index(0),
next_stack_id(0), next_stack_id(0),
deterministic_id(false), deterministic_id(false),
md5_pipeline(0), md5_pipeline(nullptr),
did_write_setup(false), did_write_setup(false),
events_expected(0), events_expected(0),
events_seen(0), events_seen(0),
@ -128,9 +128,9 @@ void
QPDFWriter::setOutputFilename(char const* filename) QPDFWriter::setOutputFilename(char const* filename)
{ {
char const* description = filename; char const* description = filename;
FILE* f = 0; FILE* f = nullptr;
bool close_file = false; bool close_file = false;
if (filename == 0) { if (filename == nullptr) {
description = "standard output"; description = "standard output";
QTC::TC("qpdf", "QPDFWriter write to stdout"); QTC::TC("qpdf", "QPDFWriter write to stdout");
f = stdout; f = stdout;
@ -169,7 +169,7 @@ Buffer*
QPDFWriter::getBuffer() QPDFWriter::getBuffer()
{ {
Buffer* result = this->m->output_buffer; Buffer* result = this->m->output_buffer;
this->m->output_buffer = 0; this->m->output_buffer = nullptr;
return result; return result;
} }
@ -1021,7 +1021,7 @@ QPDFWriter::writePad(int nspaces)
Pipeline* Pipeline*
QPDFWriter::pushPipeline(Pipeline* p) QPDFWriter::pushPipeline(Pipeline* p)
{ {
qpdf_assert_debug(dynamic_cast<Pl_Count*>(p) == 0); qpdf_assert_debug(dynamic_cast<Pl_Count*>(p) == nullptr);
this->m->pipeline_stack.push_back(p); this->m->pipeline_stack.push_back(p);
return p; return p;
} }
@ -1066,10 +1066,10 @@ QPDFWriter::PipelinePopper::~PipelinePopper()
qpdf_assert_debug(qw->m->pipeline->getIdentifier() == stack_id); qpdf_assert_debug(qw->m->pipeline->getIdentifier() == stack_id);
delete qw->m->pipeline_stack.back(); delete qw->m->pipeline_stack.back();
qw->m->pipeline_stack.pop_back(); qw->m->pipeline_stack.pop_back();
while (dynamic_cast<Pl_Count*>(qw->m->pipeline_stack.back()) == 0) { while (dynamic_cast<Pl_Count*>(qw->m->pipeline_stack.back()) == nullptr) {
Pipeline* p = qw->m->pipeline_stack.back(); Pipeline* p = qw->m->pipeline_stack.back();
if (dynamic_cast<Pl_MD5*>(p) == qw->m->md5_pipeline) { if (dynamic_cast<Pl_MD5*>(p) == qw->m->md5_pipeline) {
qw->m->md5_pipeline = 0; qw->m->md5_pipeline = nullptr;
} }
qw->m->pipeline_stack.pop_back(); qw->m->pipeline_stack.pop_back();
Pl_Buffer* buf = dynamic_cast<Pl_Buffer*>(p); Pl_Buffer* buf = dynamic_cast<Pl_Buffer*>(p);
@ -1097,7 +1097,7 @@ void
QPDFWriter::pushEncryptionFilter(PipelinePopper& pp) QPDFWriter::pushEncryptionFilter(PipelinePopper& pp)
{ {
if (this->m->encrypted && (!this->m->cur_data_key.empty())) { if (this->m->encrypted && (!this->m->cur_data_key.empty())) {
Pipeline* p = 0; Pipeline* p = nullptr;
if (this->m->encrypt_use_aes) { if (this->m->encrypt_use_aes) {
p = new Pl_AES_PDF( p = new Pl_AES_PDF(
"aes stream encryption", "aes stream encryption",
@ -1135,7 +1135,7 @@ QPDFWriter::pushMD5Pipeline(PipelinePopper& pp)
" generation has already occurred."); " generation has already occurred.");
} }
qpdf_assert_debug(this->m->deterministic_id); qpdf_assert_debug(this->m->deterministic_id);
qpdf_assert_debug(this->m->md5_pipeline == 0); qpdf_assert_debug(this->m->md5_pipeline == nullptr);
qpdf_assert_debug(this->m->pipeline->getCount() == 0); qpdf_assert_debug(this->m->pipeline->getCount() == 0);
this->m->md5_pipeline = new Pl_MD5("qpdf md5", this->m->pipeline); this->m->md5_pipeline = new Pl_MD5("qpdf md5", this->m->pipeline);
this->m->md5_pipeline->persistAcrossFinish(true); this->m->md5_pipeline->persistAcrossFinish(true);
@ -1148,7 +1148,7 @@ QPDFWriter::pushMD5Pipeline(PipelinePopper& pp)
void void
QPDFWriter::computeDeterministicIDData() QPDFWriter::computeDeterministicIDData()
{ {
qpdf_assert_debug(this->m->md5_pipeline != 0); qpdf_assert_debug(this->m->md5_pipeline != nullptr);
qpdf_assert_debug(this->m->deterministic_id_data.empty()); qpdf_assert_debug(this->m->deterministic_id_data.empty());
this->m->deterministic_id_data = this->m->md5_pipeline->getHexDigest(); this->m->deterministic_id_data = this->m->md5_pipeline->getHexDigest();
this->m->md5_pipeline->enable(false); this->m->md5_pipeline->enable(false);
@ -2455,10 +2455,10 @@ QPDFWriter::write()
if (this->m->close_file) { if (this->m->close_file) {
fclose(this->m->file); fclose(this->m->file);
} }
this->m->file = 0; this->m->file = nullptr;
if (this->m->buffer_pipeline) { if (this->m->buffer_pipeline) {
this->m->output_buffer = this->m->buffer_pipeline->getBuffer(); this->m->output_buffer = this->m->buffer_pipeline->getBuffer();
this->m->buffer_pipeline = 0; this->m->buffer_pipeline = nullptr;
} }
indicateProgress(false, true); indicateProgress(false, true);
} }
@ -2967,7 +2967,7 @@ QPDFWriter::writeLinearized()
// Write file in two passes. Part numbers refer to PDF spec 1.4. // Write file in two passes. Part numbers refer to PDF spec 1.4.
FILE* lin_pass1_file = 0; FILE* lin_pass1_file = nullptr;
auto pp_pass1 = std::make_shared<PipelinePopper>(this); auto pp_pass1 = std::make_shared<PipelinePopper>(this);
auto pp_md5 = std::make_shared<PipelinePopper>(this); auto pp_md5 = std::make_shared<PipelinePopper>(this);
for (int pass = 1; pass <= 2; ++pass) { for (int pass = 1; pass <= 2; ++pass) {
@ -3203,13 +3203,13 @@ QPDFWriter::writeLinearized()
"QPDFWriter linearized deterministic ID", "QPDFWriter linearized deterministic ID",
need_xref_stream ? 0 : 1); need_xref_stream ? 0 : 1);
computeDeterministicIDData(); computeDeterministicIDData();
pp_md5 = 0; pp_md5 = nullptr;
qpdf_assert_debug(this->m->md5_pipeline == 0); qpdf_assert_debug(this->m->md5_pipeline == nullptr);
} }
// Close first pass pipeline // Close first pass pipeline
file_size = this->m->pipeline->getCount(); file_size = this->m->pipeline->getCount();
pp_pass1 = 0; pp_pass1 = nullptr;
// Save hint offset since it will be set to zero by // Save hint offset since it will be set to zero by
// calling openObject. // calling openObject.
@ -3245,7 +3245,7 @@ QPDFWriter::writeLinearized()
"%% second_xref_end=%s\n", "%% second_xref_end=%s\n",
QUtil::int_to_string(second_xref_end).c_str()); QUtil::int_to_string(second_xref_end).c_str());
fclose(lin_pass1_file); fclose(lin_pass1_file);
lin_pass1_file = 0; lin_pass1_file = nullptr;
} }
} }
} }
@ -3401,7 +3401,7 @@ QPDFWriter::writeStandard()
"qpdf", "qpdf",
"QPDFWriter standard deterministic ID", "QPDFWriter standard deterministic ID",
this->m->object_stream_to_objects.empty() ? 0 : 1); this->m->object_stream_to_objects.empty() ? 0 : 1);
pp_md5 = 0; pp_md5 = nullptr;
qpdf_assert_debug(this->m->md5_pipeline == 0); qpdf_assert_debug(this->m->md5_pipeline == nullptr);
} }
} }

View File

@ -87,7 +87,7 @@ QPDF_Dictionary::getKey(std::string const& key)
return item->second; return item->second;
} else { } else {
QPDFObjectHandle null = QPDFObjectHandle::newNull(); QPDFObjectHandle null = QPDFObjectHandle::newNull();
QPDF* qpdf = 0; QPDF* qpdf = nullptr;
std::string description; std::string description;
if (getDescription(qpdf, description)) { if (getDescription(qpdf, description)) {
null.setObjectDescription( null.setObjectDescription(

View File

@ -169,7 +169,7 @@ QPDF_Stream::getFilterOnWrite() const
void void
QPDF_Stream::releaseResolved() QPDF_Stream::releaseResolved()
{ {
this->stream_provider = 0; this->stream_provider = nullptr;
QPDFObjectHandle::ReleaseResolver::releaseResolved(this->stream_dict); QPDFObjectHandle::ReleaseResolver::releaseResolved(this->stream_dict);
} }
@ -313,7 +313,7 @@ QPDF_Stream::setDescription(QPDF* qpdf, std::string const& description)
void void
QPDF_Stream::setDictDescription() QPDF_Stream::setDictDescription()
{ {
QPDF* qpdf = 0; QPDF* qpdf = nullptr;
std::string description; std::string description;
if ((!this->stream_dict.hasObjectDescription()) && if ((!this->stream_dict.hasObjectDescription()) &&
getDescription(qpdf, description)) { getDescription(qpdf, description)) {
@ -547,7 +547,7 @@ QPDF_Stream::pipeStreamData(
: 3); : 3);
} }
if (pipeline == 0) { if (pipeline == nullptr) {
QTC::TC("qpdf", "QPDF_Stream pipeStreamData with null pipeline"); QTC::TC("qpdf", "QPDF_Stream pipeStreamData with null pipeline");
// Return value is whether we can filter in this case. // Return value is whether we can filter in this case.
return filter; return filter;
@ -693,7 +693,7 @@ QPDF_Stream::replaceStreamData(
QPDFObjectHandle const& decode_parms) QPDFObjectHandle const& decode_parms)
{ {
this->stream_data = data; this->stream_data = data;
this->stream_provider = 0; this->stream_provider = nullptr;
replaceFilterData(filter, decode_parms, data->getSize()); replaceFilterData(filter, decode_parms, data->getSize());
} }
@ -704,7 +704,7 @@ QPDF_Stream::replaceStreamData(
QPDFObjectHandle const& decode_parms) QPDFObjectHandle const& decode_parms)
{ {
this->stream_provider = provider; this->stream_provider = provider;
this->stream_data = 0; this->stream_data = nullptr;
replaceFilterData(filter, decode_parms, 0); replaceFilterData(filter, decode_parms, 0);
} }

View File

@ -149,8 +149,8 @@ QPDF::trim_user_password(std::string& user_password)
} }
char const* p1 = cstr; char const* p1 = cstr;
char const* p2 = 0; char const* p2 = nullptr;
while ((p2 = strchr(p1, '\x28')) != 0) { while ((p2 = strchr(p1, '\x28')) != nullptr) {
size_t idx = toS(p2 - cstr); size_t idx = toS(p2 - cstr);
if (memcmp(p2, padding_string, len - idx) == 0) { if (memcmp(p2, padding_string, len - idx) == 0) {
user_password = user_password.substr(0, idx); user_password = user_password.substr(0, idx);
@ -218,7 +218,7 @@ process_with_aes(
std::string const& data, std::string const& data,
size_t outlength = 0, size_t outlength = 0,
unsigned int repetitions = 1, unsigned int repetitions = 1,
unsigned char const* iv = 0, unsigned char const* iv = nullptr,
size_t iv_length = 0) size_t iv_length = 0)
{ {
Pl_Buffer buffer("buffer"); Pl_Buffer buffer("buffer");

View File

@ -542,7 +542,7 @@ QPDF::checkLinearizationInternal()
// T: offset of whitespace character preceding xref entry for object 0 // T: offset of whitespace character preceding xref entry for object 0
this->m->file->seek(p.xref_zero_offset, SEEK_SET); this->m->file->seek(p.xref_zero_offset, SEEK_SET);
while (1) { while (true) {
char ch; char ch;
this->m->file->read(&ch, 1); this->m->file->read(&ch, 1);
if (!((ch == ' ') || (ch == '\r') || (ch == '\n'))) { if (!((ch == ' ') || (ch == '\r') || (ch == '\n'))) {

View File

@ -396,7 +396,7 @@ QUtil::string_to_ll(char const* str)
#ifdef _MSC_VER #ifdef _MSC_VER
long long result = _strtoi64(str, 0, 10); long long result = _strtoi64(str, 0, 10);
#else #else
long long result = strtoll(str, 0, 10); long long result = strtoll(str, nullptr, 10);
#endif #endif
if (errno == ERANGE) { if (errno == ERANGE) {
throw std::range_error( throw std::range_error(
@ -430,7 +430,7 @@ QUtil::string_to_ull(char const* str)
#ifdef _MSC_VER #ifdef _MSC_VER
unsigned long long result = _strtoui64(str, 0, 10); unsigned long long result = _strtoui64(str, 0, 10);
#else #else
unsigned long long result = strtoull(str, 0, 10); unsigned long long result = strtoull(str, nullptr, 10);
#endif #endif
if (errno == ERANGE) { if (errno == ERANGE) {
throw std::runtime_error( throw std::runtime_error(
@ -512,7 +512,7 @@ win_convert_filename(char const* filename)
FILE* FILE*
QUtil::safe_fopen(char const* filename, char const* mode) QUtil::safe_fopen(char const* filename, char const* mode)
{ {
FILE* f = 0; FILE* f = nullptr;
#ifdef _WIN32 #ifdef _WIN32
std::shared_ptr<wchar_t> wfilenamep = win_convert_filename(filename); std::shared_ptr<wchar_t> wfilenamep = win_convert_filename(filename);
wchar_t* wfilename = wfilenamep.get(); wchar_t* wfilename = wfilenamep.get();
@ -543,7 +543,7 @@ QUtil::safe_fopen(char const* filename, char const* mode)
FILE* FILE*
QUtil::fopen_wrapper(std::string const& description, FILE* f) QUtil::fopen_wrapper(std::string const& description, FILE* f)
{ {
if (f == 0) { if (f == nullptr) {
throw_system_error(description); throw_system_error(description);
} }
return f; return f;
@ -599,7 +599,7 @@ QUtil::tell(FILE* stream)
bool bool
QUtil::same_file(char const* name1, char const* name2) QUtil::same_file(char const* name1, char const* name2)
{ {
if ((name1 == 0) || (strlen(name1) == 0) || (name2 == 0) || if ((name1 == nullptr) || (strlen(name1) == 0) || (name2 == nullptr) ||
(strlen(name2) == 0)) { (strlen(name2) == 0)) {
return false; return false;
} }
@ -834,7 +834,7 @@ QUtil::setLineBuf(FILE* f)
char* char*
QUtil::getWhoami(char* argv0) QUtil::getWhoami(char* argv0)
{ {
char* whoami = 0; char* whoami = nullptr;
if (((whoami = strrchr(argv0, '/')) == NULL) && if (((whoami = strrchr(argv0, '/')) == NULL) &&
((whoami = strrchr(argv0, '\\')) == NULL)) { ((whoami = strrchr(argv0, '\\')) == NULL)) {
whoami = argv0; whoami = argv0;
@ -875,7 +875,7 @@ QUtil::get_env(std::string const& var, std::string* value)
# endif # endif
#else #else
char* p = getenv(var.c_str()); char* p = getenv(var.c_str());
if (p == 0) { if (p == nullptr) {
return false; return false;
} }
if (value) { if (value) {
@ -908,7 +908,7 @@ QUtil::get_current_time()
ULONGLONG now = uinow.QuadPart; ULONGLONG now = uinow.QuadPart;
return static_cast<time_t>((now / 10000000ULL) - 11644473600ULL); return static_cast<time_t>((now / 10000000ULL) - 11644473600ULL);
#else #else
return time(0); return time(nullptr);
#endif #endif
} }
@ -931,7 +931,7 @@ QUtil::get_current_qpdf_time()
static_cast<int>(tzinfo.Bias)); static_cast<int>(tzinfo.Bias));
#else #else
struct tm ltime; struct tm ltime;
time_t now = time(0); time_t now = time(nullptr);
tzset(); tzset();
# ifdef HAVE_LOCALTIME_R # ifdef HAVE_LOCALTIME_R
localtime_r(&now, &ltime); localtime_r(&now, &ltime);
@ -1155,7 +1155,7 @@ namespace
RandomDataProviderProvider::RandomDataProviderProvider() : RandomDataProviderProvider::RandomDataProviderProvider() :
default_provider(CryptoRandomDataProvider::getInstance()), default_provider(CryptoRandomDataProvider::getInstance()),
current_provider(0) current_provider(nullptr)
{ {
this->current_provider = default_provider; this->current_provider = default_provider;
} }
@ -1210,13 +1210,13 @@ QUtil::random()
bool bool
QUtil::is_hex_digit(char ch) QUtil::is_hex_digit(char ch)
{ {
return (ch && (strchr("0123456789abcdefABCDEF", ch) != 0)); return (ch && (strchr("0123456789abcdefABCDEF", ch) != nullptr));
} }
bool bool
QUtil::is_space(char ch) QUtil::is_space(char ch)
{ {
return (ch && (strchr(" \f\n\r\t\v", ch) != 0)); return (ch && (strchr(" \f\n\r\t\v", ch) != nullptr));
} }
bool bool
@ -1332,10 +1332,10 @@ QUtil::read_lines_from_file(
std::list<std::string>& lines, std::list<std::string>& lines,
bool preserve_eol) bool preserve_eol)
{ {
std::string* buf = 0; std::string* buf = nullptr;
char c; char c;
while (next_char(c)) { while (next_char(c)) {
if (buf == 0) { if (buf == nullptr) {
lines.push_back(""); lines.push_back("");
buf = &(lines.back()); buf = &(lines.back());
buf->reserve(80); buf->reserve(80);
@ -1354,7 +1354,7 @@ QUtil::read_lines_from_file(
buf->erase(buf->length() - 1); buf->erase(buf->length() - 1);
} }
} }
buf = 0; buf = nullptr;
} else { } else {
buf->append(1, c); buf->append(1, c);
} }
@ -1471,7 +1471,7 @@ QUtil::parse_numrange(char const* range, int max)
} }
} }
p = 0; p = nullptr;
for (size_t i = 0; i < work.size(); i += 2) { for (size_t i = 0; i < work.size(); i += 2) {
int num = work.at(i); int num = work.at(i);
// max == 0 means we don't know the max and are just // max == 0 means we don't know the max and are just
@ -1990,7 +1990,7 @@ call_main_from_wmain(
new_argv[i] = utf8_argv.at(i).get(); new_argv[i] = utf8_argv.at(i).get();
} }
argc = QIntC::to_int(utf8_argv.size()); argc = QIntC::to_int(utf8_argv.size());
new_argv[argc] = 0; new_argv[argc] = nullptr;
return realmain(argc, new_argv); return realmain(argc, new_argv);
} }

View File

@ -164,7 +164,7 @@ qpdf_cleanup(qpdf_data* qpdf)
<< (*qpdf)->error->what() << "\n"; << (*qpdf)->error->what() << "\n";
} }
delete *qpdf; delete *qpdf;
*qpdf = 0; *qpdf = nullptr;
} }
size_t size_t
@ -203,11 +203,11 @@ qpdf_get_error(qpdf_data qpdf)
{ {
if (qpdf->error.get()) { if (qpdf->error.get()) {
qpdf->tmp_error.exc = qpdf->error; qpdf->tmp_error.exc = qpdf->error;
qpdf->error = 0; qpdf->error = nullptr;
QTC::TC("qpdf", "qpdf-c qpdf_get_error returned error"); QTC::TC("qpdf", "qpdf-c qpdf_get_error returned error");
return &qpdf->tmp_error; return &qpdf->tmp_error;
} else { } else {
return 0; return nullptr;
} }
} }
@ -220,14 +220,14 @@ qpdf_next_warning(qpdf_data qpdf)
QTC::TC("qpdf", "qpdf-c qpdf_next_warning returned warning"); QTC::TC("qpdf", "qpdf-c qpdf_next_warning returned warning");
return &qpdf->tmp_error; return &qpdf->tmp_error;
} else { } else {
return 0; return nullptr;
} }
} }
char const* char const*
qpdf_get_error_full_text(qpdf_data qpdf, qpdf_error e) qpdf_get_error_full_text(qpdf_data qpdf, qpdf_error e)
{ {
if (e == 0) { if (e == nullptr) {
return ""; return "";
} }
return e->exc->what(); return e->exc->what();
@ -236,7 +236,7 @@ qpdf_get_error_full_text(qpdf_data qpdf, qpdf_error e)
enum qpdf_error_code_e enum qpdf_error_code_e
qpdf_get_error_code(qpdf_data qpdf, qpdf_error e) qpdf_get_error_code(qpdf_data qpdf, qpdf_error e)
{ {
if (e == 0) { if (e == nullptr) {
return qpdf_e_success; return qpdf_e_success;
} }
return e->exc->getErrorCode(); return e->exc->getErrorCode();
@ -245,7 +245,7 @@ qpdf_get_error_code(qpdf_data qpdf, qpdf_error e)
char const* char const*
qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e) qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e)
{ {
if (e == 0) { if (e == nullptr) {
return ""; return "";
} }
return e->exc->getFilename().c_str(); return e->exc->getFilename().c_str();
@ -254,7 +254,7 @@ qpdf_get_error_filename(qpdf_data qpdf, qpdf_error e)
unsigned long long unsigned long long
qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e) qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e)
{ {
if (e == 0) { if (e == nullptr) {
return 0; return 0;
} }
return QIntC::to_ulonglong(e->exc->getFilePosition()); return QIntC::to_ulonglong(e->exc->getFilePosition());
@ -263,7 +263,7 @@ qpdf_get_error_file_position(qpdf_data qpdf, qpdf_error e)
char const* char const*
qpdf_get_error_message_detail(qpdf_data qpdf, qpdf_error e) qpdf_get_error_message_detail(qpdf_data qpdf, qpdf_error e)
{ {
if (e == 0) { if (e == nullptr) {
return ""; return "";
} }
return e->exc->getMessageDetail().c_str(); return e->exc->getMessageDetail().c_str();
@ -371,7 +371,7 @@ qpdf_get_user_password(qpdf_data qpdf)
char const* char const*
qpdf_get_info_key(qpdf_data qpdf, char const* key) qpdf_get_info_key(qpdf_data qpdf, char const* key)
{ {
char const* result = 0; char const* result = nullptr;
QPDFObjectHandle trailer = qpdf->qpdf->getTrailer(); QPDFObjectHandle trailer = qpdf->qpdf->getTrailer();
if (trailer.hasKey("/Info")) { if (trailer.hasKey("/Info")) {
QPDFObjectHandle info = trailer.getKey("/Info"); QPDFObjectHandle info = trailer.getKey("/Info");
@ -383,14 +383,14 @@ qpdf_get_info_key(qpdf_data qpdf, char const* key)
} }
} }
} }
QTC::TC("qpdf", "qpdf-c get_info_key", (result == 0 ? 0 : 1)); QTC::TC("qpdf", "qpdf-c get_info_key", (result == nullptr ? 0 : 1));
return result; return result;
} }
void void
qpdf_set_info_key(qpdf_data qpdf, char const* key, char const* value) qpdf_set_info_key(qpdf_data qpdf, char const* key, char const* value)
{ {
if ((key == 0) || (std::strlen(key) == 0) || (key[0] != '/')) { if ((key == nullptr) || (std::strlen(key) == 0) || (key[0] != '/')) {
return; return;
} }
QPDFObjectHandle value_object; QPDFObjectHandle value_object;
@ -498,11 +498,11 @@ qpdf_init_write_internal(qpdf_data qpdf)
{ {
if (qpdf->qpdf_writer.get()) { if (qpdf->qpdf_writer.get()) {
QTC::TC("qpdf", "qpdf-c called qpdf_init_write multiple times"); QTC::TC("qpdf", "qpdf-c called qpdf_init_write multiple times");
qpdf->qpdf_writer = 0; qpdf->qpdf_writer = nullptr;
if (qpdf->output_buffer.get()) { if (qpdf->output_buffer.get()) {
qpdf->output_buffer = 0; qpdf->output_buffer = nullptr;
qpdf->write_memory = false; qpdf->write_memory = false;
qpdf->filename = 0; qpdf->filename = nullptr;
} }
} }
} }
@ -530,7 +530,7 @@ qpdf_init_write_memory(qpdf_data qpdf)
static void static void
qpdf_get_buffer_internal(qpdf_data qpdf) qpdf_get_buffer_internal(qpdf_data qpdf)
{ {
if (qpdf->write_memory && (qpdf->output_buffer == 0)) { if (qpdf->write_memory && (qpdf->output_buffer == nullptr)) {
qpdf->output_buffer = qpdf->qpdf_writer->getBufferSharedPointer(); qpdf->output_buffer = qpdf->qpdf_writer->getBufferSharedPointer();
} }
} }
@ -549,7 +549,7 @@ qpdf_get_buffer_length(qpdf_data qpdf)
unsigned char const* unsigned char const*
qpdf_get_buffer(qpdf_data qpdf) qpdf_get_buffer(qpdf_data qpdf)
{ {
unsigned char const* result = 0; unsigned char const* result = nullptr;
qpdf_get_buffer_internal(qpdf); qpdf_get_buffer_internal(qpdf);
if (qpdf->output_buffer.get()) { if (qpdf->output_buffer.get()) {
result = qpdf->output_buffer->getBuffer(); result = qpdf->output_buffer->getBuffer();