2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 02:49:00 +00:00

Use nullptr instead of 0 or NULL

This commit is contained in:
m-holger 2023-05-20 12:46:50 +01:00
parent e28f4efb00
commit d0682f0f60
33 changed files with 72 additions and 72 deletions

View File

@ -11,7 +11,7 @@
// The example is a full copy of the qpdf program modified to allways remove all
// annotations from the final output.
static char const* whoami = 0;
static char const* whoami = nullptr;
static void
usageExit(std::string const& msg)

View File

@ -43,7 +43,7 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline
{
public:
QPDF_DLL
Pl_Buffer(char const* identifier, Pipeline* next = 0);
Pl_Buffer(char const* identifier, Pipeline* next = nullptr);
QPDF_DLL
virtual ~Pl_Buffer();
QPDF_DLL

View File

@ -57,7 +57,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
JDIMENSION image_height,
int components,
J_COLOR_SPACE color_space,
CompressConfig* config_callback = 0);
CompressConfig* config_callback = nullptr);
QPDF_DLL
virtual ~Pl_DCT();
@ -91,7 +91,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
JDIMENSION image_height = 0,
int components = 1,
J_COLOR_SPACE color_space = JCS_GRAYSCALE,
CompressConfig* config_callback = 0);
CompressConfig* config_callback = nullptr);
Members(Members const&) = delete;
action_e action;

View File

@ -51,7 +51,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
Pl_QPDFTokenizer(
char const* identifier,
QPDFObjectHandle::TokenFilter* filter,
Pipeline* next = 0);
Pipeline* next = nullptr);
QPDF_DLL
virtual ~Pl_QPDFTokenizer();
QPDF_DLL

View File

@ -83,7 +83,7 @@ class QPDF
// interpreted as a raw encryption key. See comments on
// setPasswordIsHexKey for more information.
QPDF_DLL
void processFile(char const* filename, char const* password = 0);
void processFile(char const* filename, char const* password = nullptr);
// Parse a PDF from a stdio FILE*. The FILE must be open in
// binary mode and must be seekable. It may be open read only.
@ -96,7 +96,7 @@ class QPDF
char const* description,
FILE* file,
bool close_file,
char const* password = 0);
char const* password = nullptr);
// Parse a PDF file loaded into a memory buffer. This works
// exactly like processFile except that the PDF file is in memory
@ -107,14 +107,14 @@ class QPDF
char const* description,
char const* buf,
size_t length,
char const* password = 0);
char const* password = nullptr);
// Parse a PDF file loaded from a custom InputSource. If you have
// your own method of retrieving a PDF file, you can subclass
// InputSource and use this method.
QPDF_DLL
void
processInputSource(std::shared_ptr<InputSource>, char const* password = 0);
processInputSource(std::shared_ptr<InputSource>, char const* password = nullptr);
// Create a PDF from an input source that contains JSON as written
// by writeJSON (or qpdf --json-output, version 2 or higher). The

View File

@ -80,7 +80,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
virtual void RC4_process(
unsigned char const* in_data,
size_t len,
unsigned char* out_data = 0) = 0;
unsigned char* out_data = nullptr) = 0;
QPDF_DLL
virtual void RC4_finalize() = 0;

View File

@ -497,7 +497,7 @@ class QPDFJob
// Helper functions
static void usage(std::string const& msg);
static JSON json_schema(int json_version, std::set<std::string>* keys = 0);
static JSON json_schema(int json_version, std::set<std::string>* keys = nullptr);
static void parse_object_id(
std::string const& objspec, bool& trailer, int& obj, int& gen);
void parseRotationParameter(std::string const&);

View File

@ -526,7 +526,7 @@ class QPDFObjectHandle
QPDF_DLL
void parsePageContents(ParserCallbacks* callbacks);
QPDF_DLL
void filterPageContents(TokenFilter* filter, Pipeline* next = 0);
void filterPageContents(TokenFilter* filter, Pipeline* next = nullptr);
// See comments for QPDFPageObjectHelper::pipeContents.
QPDF_DLL
void pipePageContents(Pipeline* p);
@ -538,7 +538,7 @@ class QPDFObjectHandle
// contents. This can be used to apply a TokenFilter to a form
// XObject, whose data is in the same format as a content stream.
QPDF_DLL
void filterAsContents(TokenFilter* filter, Pipeline* next = 0);
void filterAsContents(TokenFilter* filter, Pipeline* next = nullptr);
// Called on a stream to parse the stream as page contents. This
// can be used to parse a form XObject.
QPDF_DLL

View File

@ -42,7 +42,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
{
// This must be cleared explicitly to avoid circular references
// that prevent cleanup of pointer holders.
this->m->parent = 0;
this->m->parent = nullptr;
}
// All constructors are private. You can only create one of these

View File

@ -320,12 +320,12 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// examples/pdf-count-strings.cc for an example.
QPDF_DLL
void
filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0);
filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
// Old name -- calls filterContents()
QPDF_DLL
void filterPageContents(
QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0);
QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
// Pipe a page's contents through the given pipeline. This method
// works whether the contents are a single stream or an array of

View File

@ -539,7 +539,7 @@ class QPDFWriter
friend class QPDFWriter;
public:
PipelinePopper(QPDFWriter* qw, std::shared_ptr<Buffer>* bp = 0) :
PipelinePopper(QPDFWriter* qw, std::shared_ptr<Buffer>* bp = nullptr) :
qw(qw),
bp(bp)
{

View File

@ -245,7 +245,7 @@ namespace QUtil
// Returns true iff the variable is defined. If `value' is
// non-null, initializes it with the value of the variable.
QPDF_DLL
bool get_env(std::string const& var, std::string* value = 0);
bool get_env(std::string const& var, std::string* value = nullptr);
QPDF_DLL
time_t get_current_time();

View File

@ -836,8 +836,8 @@ char*
QUtil::getWhoami(char* argv0)
{
char* whoami = nullptr;
if (((whoami = strrchr(argv0, '/')) == NULL) &&
((whoami = strrchr(argv0, '\\')) == NULL)) {
if (((whoami = strrchr(argv0, '/')) == nullptr) &&
((whoami = strrchr(argv0, '\\')) == nullptr)) {
whoami = argv0;
} else {
++whoami;

View File

@ -20,7 +20,7 @@
class Pl_SHA2: public Pipeline
{
public:
Pl_SHA2(int bits = 0, Pipeline* next = 0);
Pl_SHA2(int bits = 0, Pipeline* next = nullptr);
virtual ~Pl_SHA2() = default;
virtual void write(unsigned char const*, size_t);
virtual void finish();

View File

@ -177,9 +177,9 @@ class QPDFArgParser
{
OptionEntry() :
parameter_needed(false),
bare_arg_handler(0),
param_arg_handler(0),
invalid_choice_handler(0)
bare_arg_handler(nullptr),
param_arg_handler(nullptr),
invalid_choice_handler(nullptr)
{
}
bool parameter_needed;

View File

@ -39,7 +39,7 @@ class QPDFCrypto_openssl: public QPDFCryptoImpl
void RC4_process(
unsigned char const* in_data,
size_t len,
unsigned char* out_data = 0) override;
unsigned char* out_data = nullptr) override;
void RC4_finalize() override;
void SHA2_init(int bits) override;

View File

@ -29,9 +29,9 @@ main(int argc, char* argv[])
{
bool encrypt = true;
bool cbc_mode = true;
char* hexkey = 0;
char* infilename = 0;
char* outfilename = 0;
char* hexkey = nullptr;
char* infilename = nullptr;
char* outfilename = nullptr;
bool zero_iv = false;
bool static_iv = false;
bool disable_padding = false;
@ -65,7 +65,7 @@ main(int argc, char* argv[])
usage();
}
}
if (outfilename == 0) {
if (outfilename == nullptr) {
usage();
}
@ -81,14 +81,14 @@ main(int argc, char* argv[])
t[1] = hexkey[i + 1];
t[2] = '\0';
long val = strtol(t, 0, 16);
long val = strtol(t, nullptr, 16);
key[i / 2] = static_cast<unsigned char>(val);
}
Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile);
Pl_AES_PDF* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen);
delete[] key;
key = 0;
key = nullptr;
if (!cbc_mode) {
aes->disableCBC();
}

View File

@ -51,7 +51,7 @@ ArgParser::initOptions()
ap.addBare("potato", b(&ArgParser::handlePotato));
ap.addRequiredParameter("salad", p(&ArgParser::handleSalad), "tossed");
ap.addOptionalParameter("moo", p(&ArgParser::handleMoo));
char const* choices[] = {"pig", "boar", "sow", 0};
char const* choices[] = {"pig", "boar", "sow", nullptr};
ap.addChoices("oink", p(&ArgParser::handleOink), true, choices);
ap.selectHelpOptionTable();
ap.addBare("version", [this]() { output("3.14159"); });

View File

@ -4,7 +4,7 @@
static void
test_numrange(char const* range)
{
if (range == 0) {
if (range == nullptr) {
std::cout << "null" << std::endl;
} else {
std::vector<int> result = QUtil::parse_numrange(range, 15);

View File

@ -21,7 +21,7 @@ run(char const* filename,
FILE* in = QUtil::safe_fopen(filename, "rb");
FILE* o1 = QUtil::safe_fopen("out", "wb");
Pipeline* out = new Pl_StdioFile("out", o1);
Pipeline* pl = 0;
Pipeline* pl = nullptr;
if (strcmp(filter, "png") == 0) {
pl = new Pl_PNGFilter(
"png",

View File

@ -489,7 +489,7 @@ same_file_test()
assert_same_file("qutil.out", "qutil.out", true);
assert_same_file("qutil.out", "other-file", false);
assert_same_file("qutil.out", "", false);
assert_same_file("qutil.out", 0, false);
assert_same_file("qutil.out", nullptr, false);
assert_same_file("", "qutil.out", false);
}

View File

@ -56,7 +56,7 @@ main()
if (!((buf[0] == 0) && (buf[1] == 1) && (buf[2] == 2) && (buf[3] == 3))) {
std::cout << "fail: bogus random didn't provide correct bytes\n";
}
QUtil::setRandomDataProvider(0);
QUtil::setRandomDataProvider(nullptr);
if (QUtil::getRandomDataProvider() != orig_rdp) {
std::cout << "fail: passing null to setRandomDataProvider "
"didn't reset the random data provider\n";

View File

@ -51,7 +51,7 @@ main(int argc, char* argv[])
t[1] = hexkey[i + 1];
t[2] = '\0';
long val = strtol(t, 0, 16);
long val = strtol(t, nullptr, 16);
key[i / 2] = static_cast<unsigned char>(val);
}

View File

@ -8,7 +8,7 @@
#include <regex>
#include <string_view>
static char const* whoami = 0;
static char const* whoami = nullptr;
static void
usage()
@ -392,7 +392,7 @@ realmain(int argc, char* argv[])
{
whoami = QUtil::getWhoami(argv[0]);
QUtil::setLineBuf(stdout);
char const* filename = 0;
char const* filename = nullptr;
if (argc > 2) {
usage();
} else if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) {
@ -405,7 +405,7 @@ realmain(int argc, char* argv[])
filename = argv[1];
}
std::string input;
if (filename == 0) {
if (filename == nullptr) {
filename = "standard input";
QUtil::binary_stdin();
input = QUtil::read_file_into_string(stdin);

View File

@ -9,7 +9,7 @@
#include <cstdlib>
#include <cstring>
static char const* whoami = 0;
static char const* whoami = nullptr;
void
usage()
@ -86,7 +86,7 @@ int
main(int argc, char* argv[])
{
QUtil::setLineBuf(stdout);
if ((whoami = strrchr(argv[0], '/')) == NULL) {
if ((whoami = strrchr(argv[0], '/')) == nullptr) {
whoami = argv[0];
} else {
++whoami;

View File

@ -6,7 +6,7 @@
#include <cstdlib>
#include <iostream>
static char const* whoami = 0;
static char const* whoami = nullptr;
static void
usageExit(std::string const& msg)

View File

@ -37,7 +37,7 @@
#define QPDF_OBJECT_NOWARN
#include <qpdf/QPDFObject.hh>
static char const* whoami = 0;
static char const* whoami = nullptr;
void
usage()
@ -286,7 +286,7 @@ test_0_1(QPDF& pdf, char const* arg2)
qtest.pipeStreamData(out.get(), 0, qpdf_dl_none);
std::cout << std::endl << "Uncompressed stream data:" << std::endl;
if (qtest.pipeStreamData(0, 0, qpdf_dl_all)) {
if (qtest.pipeStreamData(nullptr, 0, qpdf_dl_all)) {
std::cout.flush();
QUtil::binary_stdout();
out = std::make_shared<Pl_StdioFile>("filtered", stdout);
@ -387,7 +387,7 @@ test_4(QPDF& pdf, char const* arg2)
}
trailer.replaceKey("/Info", pdf.makeIndirectObject(qtest));
QPDFWriter w(pdf, 0);
QPDFWriter w(pdf, nullptr);
w.setQDFMode(true);
w.setStaticID(true);
w.write();
@ -599,7 +599,7 @@ test_12(QPDF& pdf, char const* arg2)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
pdf.setOutputStreams(0, 0);
pdf.setOutputStreams(nullptr, nullptr);
#if (defined(__GNUC__) || defined(__clang__))
# pragma GCC diagnostic pop
#endif
@ -1009,7 +1009,7 @@ test_25(QPDF& pdf, char const* arg2)
// Copy qtest without crossing page boundaries. Should get O1
// and O2 and their streams but not O3 or any other pages.
assert(arg2 != 0);
assert(arg2 != nullptr);
{
// Make sure original PDF is out of scope when we write.
QPDF oldpdf;
@ -1035,7 +1035,7 @@ test_26(QPDF& pdf, char const* arg2)
{
// Make sure original PDF is out of scope when we write.
assert(arg2 != 0);
assert(arg2 != nullptr);
QPDF oldpdf;
oldpdf.processFile(arg2);
QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest");
@ -1104,7 +1104,7 @@ test_27(QPDF& pdf, char const* arg2)
QPDFObjectHandle s3 = QPDFObjectHandle::newStream(&empty3);
s3.replaceStreamData(
p2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
assert(arg2 != 0);
assert(arg2 != nullptr);
QPDF oldpdf;
oldpdf.processFile(arg2);
QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest");
@ -1151,7 +1151,7 @@ static void
test_29(QPDF& pdf, char const* arg2)
{
// Detect mixed objects in QPDFWriter
assert(arg2 != 0);
assert(arg2 != nullptr);
auto other = QPDF::create();
other->processFile(arg2);
// We need to create a QPDF with mixed ownership to exercise
@ -1201,7 +1201,7 @@ test_29(QPDF& pdf, char const* arg2)
static void
test_30(QPDF& pdf, char const* arg2)
{
assert(arg2 != 0);
assert(arg2 != nullptr);
QPDF encrypted;
encrypted.processFile(arg2, "user");
QPDFWriter w(pdf, "b.pdf");
@ -1433,7 +1433,7 @@ test_40(QPDF& pdf, char const* arg2)
// feature was implemented by Sahil Arora
// <sahilarora.535@gmail.com> as part of a Google Summer of
// Code project in 2017.
assert(arg2 != 0);
assert(arg2 != nullptr);
QPDFWriter w(pdf, arg2);
w.setPCLm(true);
w.setStaticID(true);
@ -3558,11 +3558,11 @@ runtest(int n, char const* filename1, char const* arg2)
QPDF pdf;
std::shared_ptr<char> file_buf;
FILE* filep = 0;
FILE* filep = nullptr;
if (n == 0) {
pdf.setAttemptRecovery(false);
}
if (((n == 35) || (n == 36)) && (arg2 != 0)) {
if (((n == 35) || (n == 36)) && (arg2 != nullptr)) {
// arg2 is password
pdf.processFile(filename1, arg2);
} else if (n == 45) {
@ -3652,7 +3652,7 @@ int
main(int argc, char* argv[])
{
QUtil::setLineBuf(stdout);
if ((whoami = strrchr(argv[0], '/')) == NULL) {
if ((whoami = strrchr(argv[0], '/')) == nullptr) {
whoami = argv[0];
} else {
++whoami;

View File

@ -35,7 +35,7 @@
// reading the large file then allows us to verify large file support
// with confidence.
static char const* whoami = 0;
static char const* whoami = nullptr;
// Height should be a multiple of 10
static size_t const nstripes = 10;
@ -47,7 +47,7 @@ static size_t const npages = 200;
size_t stripesize = 0;
size_t width = 0;
size_t height = 0;
static unsigned char* buf = 0;
static unsigned char* buf = nullptr;
static inline unsigned char
get_pixel_color(size_t n, size_t row)
@ -73,7 +73,7 @@ class ImageChecker: public Pipeline
};
ImageChecker::ImageChecker(size_t n) :
Pipeline("image checker", 0),
Pipeline("image checker", nullptr),
n(n),
offset(0),
okay(true)
@ -122,7 +122,7 @@ ImageProvider::ImageProvider(size_t n) :
void
ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline)
{
if (buf == 0) {
if (buf == nullptr) {
buf = new unsigned char[width * stripesize];
}
std::cout << "page " << n << " of " << npages << std::endl;

View File

@ -4,7 +4,7 @@
#include <cstdlib>
#include <cstring>
static char const* whoami = 0;
static char const* whoami = nullptr;
void
usage()
@ -16,7 +16,7 @@ usage()
int
main(int argc, char* argv[])
{
if ((whoami = strrchr(argv[0], '/')) == NULL) {
if ((whoami = strrchr(argv[0], '/')) == nullptr) {
whoami = argv[0];
} else {
++whoami;

View File

@ -4,7 +4,7 @@
#include <cstdlib>
#include <cstring>
static char const* whoami = 0;
static char const* whoami = nullptr;
void
usage()
@ -16,7 +16,7 @@ usage()
int
main(int argc, char* argv[])
{
if ((whoami = strrchr(argv[0], '/')) == NULL) {
if ((whoami = strrchr(argv[0], '/')) == nullptr) {
whoami = argv[0];
} else {
++whoami;

View File

@ -11,7 +11,7 @@
#include <cstdlib>
#include <cstring>
static char const* whoami = 0;
static char const* whoami = nullptr;
void
usage()
@ -91,7 +91,7 @@ tokenTypeName(QPDFTokenizer::token_type_e ttype)
case QPDFTokenizer::tt_inline_image:
return "inline-image";
}
return 0;
return nullptr;
}
static std::string
@ -238,13 +238,13 @@ int
main(int argc, char* argv[])
{
QUtil::setLineBuf(stdout);
if ((whoami = strrchr(argv[0], '/')) == NULL) {
if ((whoami = strrchr(argv[0], '/')) == nullptr) {
whoami = argv[0];
} else {
++whoami;
}
char const* filename = 0;
char const* filename = nullptr;
size_t max_len = 0;
bool include_ignorable = true;
for (int i = 1; i < argc; ++i) {
@ -265,7 +265,7 @@ main(int argc, char* argv[])
filename = argv[i];
}
}
if (filename == 0) {
if (filename == nullptr) {
usage();
}

View File

@ -12,7 +12,7 @@
static void
do_copy(FILE* in, FILE* out)
{
if ((in == 0) || (out == 0)) {
if ((in == nullptr) || (out == nullptr)) {
std::cerr << "errors opening files" << std::endl;
exit(2);
}

View File

@ -9,7 +9,7 @@
#include <cstdlib>
#include <cstring>
static char const* whoami = 0;
static char const* whoami = nullptr;
void
usage()
@ -27,7 +27,7 @@ usage()
int
main(int argc, char* argv[])
{
if ((whoami = strrchr(argv[0], '/')) == NULL) {
if ((whoami = strrchr(argv[0], '/')) == nullptr) {
whoami = argv[0];
} else {
++whoami;