summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <jberkenbilt@users.noreply.github.com>2023-05-20 17:29:09 +0200
committerGitHub <noreply@github.com>2023-05-20 17:29:09 +0200
commitfd17c8e3fe38a56abf50ce0edec1cde48d4f74cb (patch)
treec1efea1b140cac94dbaf496ae6ec5e0a621daa07
parenta6d7b79e65941238871c0c3d7d06b9bf246213ba (diff)
parente6577a1323cd813a92ddbc8841e1342c05de071a (diff)
downloadqpdf-fd17c8e3fe38a56abf50ce0edec1cde48d4f74cb.tar.zst
Merge pull request #963 from m-holger/tidy
Code tidy
-rw-r--r--examples/pdf-bookmarks.cc4
-rw-r--r--examples/pdf-count-strings.cc10
-rw-r--r--examples/pdf-create.cc12
-rw-r--r--examples/pdf-custom-filter.cc20
-rw-r--r--examples/pdf-double-page-size.cc4
-rw-r--r--examples/pdf-filter-tokens.cc14
-rw-r--r--examples/pdf-invert-images.cc10
-rw-r--r--examples/pdf-mod-info.cc6
-rw-r--r--examples/pdf-name-number-tree.cc1
-rw-r--r--examples/pdf-npages.cc4
-rw-r--r--examples/pdf-overlay-page.cc3
-rw-r--r--examples/pdf-parse-content.cc11
-rw-r--r--examples/pdf-set-form-values.cc4
-rw-r--r--examples/pdf-split-pages.cc2
-rw-r--r--examples/qpdf-job.cc2
-rw-r--r--examples/qpdfjob-c-save-attachment.c1
-rw-r--r--examples/qpdfjob-remove-annotations.cc3
-rw-r--r--fuzz/qpdf_fuzzer.cc10
-rw-r--r--include/qpdf/Buffer.hh2
-rw-r--r--include/qpdf/InputSource.hh2
-rw-r--r--include/qpdf/JSON.hh28
-rw-r--r--include/qpdf/Pl_Buffer.hh8
-rw-r--r--include/qpdf/Pl_DCT.hh4
-rw-r--r--include/qpdf/Pl_QPDFTokenizer.hh2
-rw-r--r--include/qpdf/Pl_StdioFile.hh2
-rw-r--r--include/qpdf/QPDF.hh10
-rw-r--r--include/qpdf/QPDFCryptoImpl.hh2
-rw-r--r--include/qpdf/QPDFJob.hh2
-rw-r--r--include/qpdf/QPDFObjectHandle.hh4
-rw-r--r--include/qpdf/QPDFOutlineObjectHelper.hh2
-rw-r--r--include/qpdf/QPDFPageObjectHelper.hh4
-rw-r--r--include/qpdf/QPDFTokenizer.hh2
-rw-r--r--include/qpdf/QPDFWriter.hh6
-rw-r--r--include/qpdf/QUtil.hh6
-rw-r--r--include/qpdf/RandomDataProvider.hh2
-rw-r--r--libqpdf/BufferInputSource.cc4
-rw-r--r--libqpdf/FileInputSource.cc2
-rw-r--r--libqpdf/InputSource.cc2
-rw-r--r--libqpdf/InsecureRandomDataProvider.cc4
-rw-r--r--libqpdf/JSON.cc14
-rw-r--r--libqpdf/MD5.cc6
-rw-r--r--libqpdf/Pipeline.cc2
-rw-r--r--libqpdf/Pl_AES_PDF.cc1
-rw-r--r--libqpdf/Pl_ASCII85Decoder.cc2
-rw-r--r--libqpdf/Pl_ASCIIHexDecoder.cc5
-rw-r--r--libqpdf/Pl_Base64.cc1
-rw-r--r--libqpdf/Pl_Buffer.cc6
-rw-r--r--libqpdf/Pl_DCT.cc17
-rw-r--r--libqpdf/Pl_Flate.cc4
-rw-r--r--libqpdf/Pl_Function.cc2
-rw-r--r--libqpdf/Pl_LZWDecoder.cc4
-rw-r--r--libqpdf/Pl_OStream.cc2
-rw-r--r--libqpdf/Pl_PNGFilter.cc4
-rw-r--r--libqpdf/Pl_QPDFTokenizer.cc2
-rw-r--r--libqpdf/Pl_RunLength.cc4
-rw-r--r--libqpdf/Pl_SHA2.cc1
-rw-r--r--libqpdf/Pl_StdioFile.cc2
-rw-r--r--libqpdf/Pl_String.cc2
-rw-r--r--libqpdf/Pl_TIFFPredictor.cc4
-rw-r--r--libqpdf/QPDF.cc28
-rw-r--r--libqpdf/QPDFAnnotationObjectHelper.cc1
-rw-r--r--libqpdf/QPDFExc.cc2
-rw-r--r--libqpdf/QPDFFormFieldObjectHelper.cc14
-rw-r--r--libqpdf/QPDFJob.cc20
-rw-r--r--libqpdf/QPDFJob_argv.cc6
-rw-r--r--libqpdf/QPDFLogger.cc4
-rw-r--r--libqpdf/QPDFNameTreeObjectHelper.cc6
-rw-r--r--libqpdf/QPDFNumberTreeObjectHelper.cc6
-rw-r--r--libqpdf/QPDFObjectHandle.cc20
-rw-r--r--libqpdf/QPDFParser.cc1
-rw-r--r--libqpdf/QPDFSystemError.cc3
-rw-r--r--libqpdf/QPDFTokenizer.cc8
-rw-r--r--libqpdf/QPDFWriter.cc6
-rw-r--r--libqpdf/QPDFXRefEntry.cc1
-rw-r--r--libqpdf/QPDF_Array.cc2
-rw-r--r--libqpdf/QPDF_Name.cc2
-rw-r--r--libqpdf/QPDF_Stream.cc12
-rw-r--r--libqpdf/QPDF_String.cc1
-rw-r--r--libqpdf/QPDF_encryption.cc2
-rw-r--r--libqpdf/QPDF_json.cc12
-rw-r--r--libqpdf/QPDF_linearization.cc5
-rw-r--r--libqpdf/QPDF_optimization.cc2
-rw-r--r--libqpdf/QTC.cc2
-rw-r--r--libqpdf/QUtil.cc15
-rw-r--r--libqpdf/RC4.cc1
-rw-r--r--libqpdf/qpdf-c.cc3
-rw-r--r--libqpdf/qpdf/BitStream.hh2
-rw-r--r--libqpdf/qpdf/BitWriter.hh2
-rw-r--r--libqpdf/qpdf/ContentNormalizer.hh4
-rw-r--r--libqpdf/qpdf/CryptoRandomDataProvider.hh4
-rw-r--r--libqpdf/qpdf/InsecureRandomDataProvider.hh4
-rw-r--r--libqpdf/qpdf/OffsetInputSource.hh16
-rw-r--r--libqpdf/qpdf/Pl_AES_PDF.hh6
-rw-r--r--libqpdf/qpdf/Pl_ASCII85Decoder.hh6
-rw-r--r--libqpdf/qpdf/Pl_ASCIIHexDecoder.hh6
-rw-r--r--libqpdf/qpdf/Pl_Base64.hh6
-rw-r--r--libqpdf/qpdf/Pl_PNGFilter.hh6
-rw-r--r--libqpdf/qpdf/Pl_RC4.hh6
-rw-r--r--libqpdf/qpdf/Pl_SHA2.hh8
-rw-r--r--libqpdf/qpdf/Pl_TIFFPredictor.hh6
-rw-r--r--libqpdf/qpdf/QPDFArgParser.hh6
-rw-r--r--libqpdf/qpdf/QPDFCrypto_openssl.hh2
-rw-r--r--libqpdf/qpdf/ResourceFinder.hh4
-rw-r--r--libqpdf/qpdf/SF_ASCII85Decode.hh2
-rw-r--r--libqpdf/qpdf/SF_ASCIIHexDecode.hh2
-rw-r--r--libqpdf/qpdf/SF_DCTDecode.hh6
-rw-r--r--libqpdf/qpdf/SF_RunLengthDecode.hh4
-rw-r--r--libqpdf/qpdfjob-c.cc2
-rw-r--r--libqpdf/qpdflogger-c.cc1
-rw-r--r--libtests/aes.cc24
-rw-r--r--libtests/arg_parser.cc3
-rw-r--r--libtests/ascii85.cc2
-rw-r--r--libtests/bits.cc5
-rw-r--r--libtests/buffer.cc2
-rw-r--r--libtests/closed_file_input_source.cc4
-rw-r--r--libtests/cxx11.cc1
-rw-r--r--libtests/dct_compress.cc10
-rw-r--r--libtests/dct_uncompress.cc5
-rw-r--r--libtests/flate.cc6
-rw-r--r--libtests/hex.cc2
-rw-r--r--libtests/input_source.cc4
-rw-r--r--libtests/json_parse.cc13
-rw-r--r--libtests/logger_c.c1
-rw-r--r--libtests/lzw.cc4
-rw-r--r--libtests/md5.cc2
-rw-r--r--libtests/numrange.cc2
-rw-r--r--libtests/pointer_holder.cc5
-rw-r--r--libtests/predictors.cc7
-rw-r--r--libtests/qintc.cc4
-rw-r--r--libtests/qutil.cc12
-rw-r--r--libtests/random.cc3
-rw-r--r--libtests/rc4.cc14
-rw-r--r--libtests/runlength.cc6
-rw-r--r--libtests/sha2.cc3
-rw-r--r--qpdf/fix-qdf.cc6
-rw-r--r--qpdf/pdf_from_scratch.cc11
-rw-r--r--qpdf/qpdf.cc3
-rw-r--r--qpdf/qpdfjob-ctest.c1
-rw-r--r--qpdf/test_driver.cc41
-rw-r--r--qpdf/test_large_file.cc14
-rw-r--r--qpdf/test_pdf_doc_encoding.cc8
-rw-r--r--qpdf/test_pdf_unicode.cc8
-rw-r--r--qpdf/test_renumber.cc2
-rw-r--r--qpdf/test_shell_glob.cc1
-rw-r--r--qpdf/test_tokenizer.cc23
-rw-r--r--qpdf/test_unicode_filenames.cc6
-rw-r--r--qpdf/test_xref.cc3
-rw-r--r--zlib-flate/zlib-flate.cc10
148 files changed, 400 insertions, 483 deletions
diff --git a/examples/pdf-bookmarks.cc b/examples/pdf-bookmarks.cc
index b6f87e49..d507f559 100644
--- a/examples/pdf-bookmarks.cc
+++ b/examples/pdf-bookmarks.cc
@@ -5,8 +5,8 @@
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
// This program demonstrates extraction of bookmarks using the qpdf
// outlines API. Note that all the information shown by this program
diff --git a/examples/pdf-count-strings.cc b/examples/pdf-count-strings.cc
index 529f6bdc..93676375 100644
--- a/examples/pdf-count-strings.cc
+++ b/examples/pdf-count-strings.cc
@@ -5,14 +5,12 @@
//
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
#include <qpdf/Pl_StdioFile.hh>
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QPDFPageDocumentHelper.hh>
-#include <qpdf/QPDFPageObjectHelper.hh>
#include <qpdf/QUtil.hh>
static char const* whoami = nullptr;
@@ -32,9 +30,9 @@ class StringCounter: public QPDFObjectHandle::TokenFilter
count(0)
{
}
- virtual ~StringCounter() = default;
- virtual void handleToken(QPDFTokenizer::Token const&);
- virtual void handleEOF();
+ ~StringCounter() override = default;
+ void handleToken(QPDFTokenizer::Token const&) override;
+ void handleEOF() override;
int getCount() const;
private:
diff --git a/examples/pdf-create.cc b/examples/pdf-create.cc
index 527243a7..64ae5cb8 100644
--- a/examples/pdf-create.cc
+++ b/examples/pdf-create.cc
@@ -12,13 +12,11 @@
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QPDFPageDocumentHelper.hh>
-#include <qpdf/QPDFPageObjectHelper.hh>
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
#include <memory>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
static char const* whoami = nullptr;
@@ -28,8 +26,8 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider
{
public:
ImageProvider(std::string const& color_space, std::string const& filter);
- virtual ~ImageProvider() = default;
- virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
+ ~ImageProvider() override = default;
+ void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
size_t getWidth() const;
size_t getHeight() const;
@@ -168,7 +166,7 @@ add_page(
// mode. Since we are not specifying, QPDFWriter will compress
// with /FlateDecode if we don't provide any other form of
// compression.
- ImageProvider* p = new ImageProvider(color_space, filter);
+ auto* p = new ImageProvider(color_space, filter);
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
size_t width = p->getWidth();
size_t height = p->getHeight();
@@ -288,7 +286,7 @@ check(
if (!this_errors) {
// Check image data
auto actual_data = image.getStreamData(qpdf_dl_all);
- ImageProvider* p = new ImageProvider(desired_color_space, "null");
+ auto* p = new ImageProvider(desired_color_space, "null");
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
Pl_Buffer b_p("get image data");
provider->provideStreamData(QPDFObjGen(), &b_p);
diff --git a/examples/pdf-custom-filter.cc b/examples/pdf-custom-filter.cc
index 2310a687..d99c6ab2 100644
--- a/examples/pdf-custom-filter.cc
+++ b/examples/pdf-custom-filter.cc
@@ -48,9 +48,9 @@ class Pl_XOR: public Pipeline
public:
Pl_XOR(char const* identifier, Pipeline* next, unsigned char key);
- virtual ~Pl_XOR() = default;
- virtual void write(unsigned char const* data, size_t len) override;
- virtual void finish() override;
+ ~Pl_XOR() override = default;
+ void write(unsigned char const* data, size_t len) override;
+ void finish() override;
private:
unsigned char key;
@@ -91,10 +91,10 @@ class SF_XORDecode: public QPDFStreamFilter
// filter, which just means QPDF assumes that it should not
// "uncompress" the stream by default.
public:
- virtual ~SF_XORDecode() = default;
- virtual bool setDecodeParms(QPDFObjectHandle decode_parms) override;
- virtual Pipeline* getDecodePipeline(Pipeline* next) override;
- virtual bool isSpecializedCompression() override;
+ ~SF_XORDecode() override = default;
+ bool setDecodeParms(QPDFObjectHandle decode_parms) override;
+ Pipeline* getDecodePipeline(Pipeline* next) override;
+ bool isSpecializedCompression() override;
private:
unsigned char key;
@@ -199,8 +199,8 @@ class StreamReplacer: public QPDFObjectHandle::StreamDataProvider
public:
StreamReplacer(QPDF* pdf);
- virtual ~StreamReplacer() = default;
- virtual void
+ ~StreamReplacer() override = default;
+ void
provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
void registerStream(
@@ -409,7 +409,7 @@ process(
// Create a single StreamReplacer instance. The interface requires
// a std::shared_ptr in various places, so allocate a StreamReplacer
// and stash it in a std::shared_ptr.
- StreamReplacer* replacer = new StreamReplacer(&qpdf);
+ auto* replacer = new StreamReplacer(&qpdf);
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> p(replacer);
for (auto& o: qpdf.getAllObjects()) {
diff --git a/examples/pdf-double-page-size.cc b/examples/pdf-double-page-size.cc
index 1ebe71df..d1fb3344 100644
--- a/examples/pdf-double-page-size.cc
+++ b/examples/pdf-double-page-size.cc
@@ -5,8 +5,8 @@
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
static char const* whoami = nullptr;
diff --git a/examples/pdf-filter-tokens.cc b/examples/pdf-filter-tokens.cc
index a99ce70c..a897ef65 100644
--- a/examples/pdf-filter-tokens.cc
+++ b/examples/pdf-filter-tokens.cc
@@ -8,13 +8,11 @@
#include <algorithm>
#include <deque>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QPDFPageDocumentHelper.hh>
-#include <qpdf/QPDFPageObjectHelper.hh>
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
@@ -35,8 +33,8 @@ usage()
class StringReverser: public QPDFObjectHandle::TokenFilter
{
public:
- virtual ~StringReverser() = default;
- virtual void handleToken(QPDFTokenizer::Token const&);
+ ~StringReverser() override = default;
+ void handleToken(QPDFTokenizer::Token const&) override;
};
void
@@ -68,9 +66,9 @@ StringReverser::handleToken(QPDFTokenizer::Token const& token)
class ColorToGray: public QPDFObjectHandle::TokenFilter
{
public:
- virtual ~ColorToGray() = default;
- virtual void handleToken(QPDFTokenizer::Token const&);
- virtual void handleEOF();
+ ~ColorToGray() override = default;
+ void handleToken(QPDFTokenizer::Token const&) override;
+ void handleEOF() override;
private:
bool isNumeric(QPDFTokenizer::token_type_e);
diff --git a/examples/pdf-invert-images.cc b/examples/pdf-invert-images.cc
index 9ffb9c1f..fae305b1 100644
--- a/examples/pdf-invert-images.cc
+++ b/examples/pdf-invert-images.cc
@@ -6,8 +6,8 @@
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
static char const* whoami = nullptr;
@@ -33,8 +33,8 @@ usage()
class ImageInverter: public QPDFObjectHandle::StreamDataProvider
{
public:
- virtual ~ImageInverter() = default;
- virtual void
+ ~ImageInverter() override = default;
+ void
provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
void registerImage(
@@ -124,7 +124,7 @@ main(int argc, char* argv[])
QPDF qpdf;
qpdf.processFile(infilename, password);
- ImageInverter* inv = new ImageInverter;
+ auto* inv = new ImageInverter;
auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(inv);
// For each page...
diff --git a/examples/pdf-mod-info.cc b/examples/pdf-mod-info.cc
index fa49738b..196ce979 100644
--- a/examples/pdf-mod-info.cc
+++ b/examples/pdf-mod-info.cc
@@ -6,9 +6,9 @@
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
static char const* version = "1.1";
static char const* whoami = nullptr;
diff --git a/examples/pdf-name-number-tree.cc b/examples/pdf-name-number-tree.cc
index f9dcb0fc..e1dfde05 100644
--- a/examples/pdf-name-number-tree.cc
+++ b/examples/pdf-name-number-tree.cc
@@ -3,7 +3,6 @@
#include <qpdf/QPDFNumberTreeObjectHelper.hh>
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
-#include <cstring>
#include <iostream>
static char const* whoami = nullptr;
diff --git a/examples/pdf-npages.cc b/examples/pdf-npages.cc
index 3d34d489..e98d1365 100644
--- a/examples/pdf-npages.cc
+++ b/examples/pdf-npages.cc
@@ -1,6 +1,6 @@
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
#include <qpdf/QPDF.hh>
#include <qpdf/QUtil.hh>
diff --git a/examples/pdf-overlay-page.cc b/examples/pdf-overlay-page.cc
index 04a1e921..5c7bf46f 100644
--- a/examples/pdf-overlay-page.cc
+++ b/examples/pdf-overlay-page.cc
@@ -4,8 +4,7 @@
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
// This program demonstrates use of form XObjects to overlay a page
// from one file onto all pages of another file. The qpdf program's
diff --git a/examples/pdf-parse-content.cc b/examples/pdf-parse-content.cc
index 481633e6..968c980b 100644
--- a/examples/pdf-parse-content.cc
+++ b/examples/pdf-parse-content.cc
@@ -1,6 +1,5 @@
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
#include <qpdf/QIntC.hh>
#include <qpdf/QPDF.hh>
@@ -23,10 +22,10 @@ usage()
class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks
{
public:
- virtual ~ParserCallbacks() = default;
- virtual void contentSize(size_t);
- virtual void handleObject(QPDFObjectHandle, size_t offset, size_t length);
- virtual void handleEOF();
+ ~ParserCallbacks() override = default;
+ void contentSize(size_t) override;
+ void handleObject(QPDFObjectHandle, size_t offset, size_t length) override;
+ void handleEOF() override;
};
void
diff --git a/examples/pdf-set-form-values.cc b/examples/pdf-set-form-values.cc
index 1398c0dd..d13f0608 100644
--- a/examples/pdf-set-form-values.cc
+++ b/examples/pdf-set-form-values.cc
@@ -4,9 +4,7 @@
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
static char const* whoami = nullptr;
diff --git a/examples/pdf-split-pages.cc b/examples/pdf-split-pages.cc
index 5d65853e..6a4f149b 100644
--- a/examples/pdf-split-pages.cc
+++ b/examples/pdf-split-pages.cc
@@ -12,7 +12,7 @@
#include <cstring>
#include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
#include <string>
static bool static_id = false;
diff --git a/examples/qpdf-job.cc b/examples/qpdf-job.cc
index 614abbe6..c7131f77 100644
--- a/examples/qpdf-job.cc
+++ b/examples/qpdf-job.cc
@@ -1,8 +1,6 @@
-#include <qpdf/QIntC.hh>
#include <qpdf/QPDFJob.hh>
#include <qpdf/QUtil.hh>
-#include <cstring>
#include <iostream>
// This program is a simple demonstration of different ways to use the
diff --git a/examples/qpdfjob-c-save-attachment.c b/examples/qpdfjob-c-save-attachment.c
index 39d1f69a..301bf635 100644
--- a/examples/qpdfjob-c-save-attachment.c
+++ b/examples/qpdfjob-c-save-attachment.c
@@ -1,4 +1,3 @@
-#include <qpdf/Constants.h>
#include <qpdf/qpdfjob-c.h>
#include <qpdf/qpdflogger-c.h>
diff --git a/examples/qpdfjob-remove-annotations.cc b/examples/qpdfjob-remove-annotations.cc
index dfab3f7b..5334e7dc 100644
--- a/examples/qpdfjob-remove-annotations.cc
+++ b/examples/qpdfjob-remove-annotations.cc
@@ -4,7 +4,6 @@
#include <cstdio>
#include <cstdlib>
-#include <cstring>
#include <iostream>
// This example demonstrates how we can use the QPDFJob createQPDF and writeQPDF
@@ -12,7 +11,7 @@
// The example is a full copy of the qpdf program modified to allways remove all
// annotations from the final output.
-static char const* whoami = 0;
+static char const* whoami = nullptr;
static void
usageExit(std::string const& msg)
diff --git a/fuzz/qpdf_fuzzer.cc b/fuzz/qpdf_fuzzer.cc
index c402a772..8d4534bd 100644
--- a/fuzz/qpdf_fuzzer.cc
+++ b/fuzz/qpdf_fuzzer.cc
@@ -14,13 +14,13 @@
class DiscardContents: public QPDFObjectHandle::ParserCallbacks
{
public:
- virtual ~DiscardContents() = default;
- virtual void
- handleObject(QPDFObjectHandle)
+ ~DiscardContents() override = default;
+ void
+ handleObject(QPDFObjectHandle) override
{
}
- virtual void
- handleEOF()
+ void
+ handleEOF() override
{
}
};
diff --git a/include/qpdf/Buffer.hh b/include/qpdf/Buffer.hh
index c5d55da1..06615e2c 100644
--- a/include/qpdf/Buffer.hh
+++ b/include/qpdf/Buffer.hh
@@ -26,7 +26,7 @@
#include <qpdf/PointerHolder.hh> // unused -- remove in qpdf 12 (see #785)
#include <memory>
-#include <stddef.h>
+#include <cstddef>
class Buffer
{
diff --git a/include/qpdf/InputSource.hh b/include/qpdf/InputSource.hh
index 68a787c6..c66066fb 100644
--- a/include/qpdf/InputSource.hh
+++ b/include/qpdf/InputSource.hh
@@ -27,7 +27,7 @@
#include <qpdf/Types.h>
#include <memory>
-#include <stdio.h>
+#include <cstdio>
#include <string>
// Remember to use QPDF_DLL_CLASS on anything derived from InputSource
diff --git a/include/qpdf/JSON.hh b/include/qpdf/JSON.hh
index 34333e93..3ff714ae 100644
--- a/include/qpdf/JSON.hh
+++ b/include/qpdf/JSON.hh
@@ -369,8 +369,8 @@ class JSON
JSON_value(vt_dictionary)
{
}
- virtual ~JSON_dictionary() = default;
- virtual void write(Pipeline*, size_t depth) const;
+ ~JSON_dictionary() override = default;
+ void write(Pipeline*, size_t depth) const override;
std::map<std::string, JSON> members;
std::set<std::string> parsed_keys;
};
@@ -380,15 +380,15 @@ class JSON
JSON_value(vt_array)
{
}
- virtual ~JSON_array() = default;
- virtual void write(Pipeline*, size_t depth) const;
+ ~JSON_array() override = default;
+ void write(Pipeline*, size_t depth) const override;
std::vector<JSON> elements;
};
struct JSON_string: public JSON_value
{
JSON_string(std::string const& utf8);
- virtual ~JSON_string() = default;
- virtual void write(Pipeline*, size_t depth) const;
+ ~JSON_string() override = default;
+ void write(Pipeline*, size_t depth) const override;
std::string utf8;
std::string encoded;
};
@@ -397,15 +397,15 @@ class JSON
JSON_number(long long val);
JSON_number(double val);
JSON_number(std::string const& val);
- virtual ~JSON_number() = default;
- virtual void write(Pipeline*, size_t depth) const;
+ ~JSON_number() override = default;
+ void write(Pipeline*, size_t depth) const override;
std::string encoded;
};
struct JSON_bool: public JSON_value
{
JSON_bool(bool val);
- virtual ~JSON_bool() = default;
- virtual void write(Pipeline*, size_t depth) const;
+ ~JSON_bool() override = default;
+ void write(Pipeline*, size_t depth) const override;
bool value;
};
struct JSON_null: public JSON_value
@@ -414,14 +414,14 @@ class JSON
JSON_value(vt_null)
{
}
- virtual ~JSON_null() = default;
- virtual void write(Pipeline*, size_t depth) const;
+ ~JSON_null() override = default;
+ void write(Pipeline*, size_t depth) const override;
};
struct JSON_blob: public JSON_value
{
JSON_blob(std::function<void(Pipeline*)> fn);
- virtual ~JSON_blob() = default;
- virtual void write(Pipeline*, size_t depth) const;
+ ~JSON_blob() override = default;
+ void write(Pipeline*, size_t depth) const override;
std::function<void(Pipeline*)> fn;
};
diff --git a/include/qpdf/Pl_Buffer.hh b/include/qpdf/Pl_Buffer.hh
index e2f71094..ffc01d95 100644
--- a/include/qpdf/Pl_Buffer.hh
+++ b/include/qpdf/Pl_Buffer.hh
@@ -43,13 +43,13 @@ 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();
+ ~Pl_Buffer() override;
QPDF_DLL
- virtual void write(unsigned char const*, size_t);
+ void write(unsigned char const*, size_t) override;
QPDF_DLL
- virtual void finish();
+ void finish() override;
// Each call to getBuffer() resets this object -- see notes above.
// The caller is responsible for deleting the returned Buffer
diff --git a/include/qpdf/Pl_DCT.hh b/include/qpdf/Pl_DCT.hh
index 543967ec..9352091f 100644
--- a/include/qpdf/Pl_DCT.hh
+++ b/include/qpdf/Pl_DCT.hh
@@ -57,7 +57,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
JDIMENSION image_height,
int components,
J_COLOR_SPACE color_space,
- CompressConfig* config_callback = 0);
+ CompressConfig* config_callback = nullptr);
QPDF_DLL
virtual ~Pl_DCT();
@@ -91,7 +91,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
JDIMENSION image_height = 0,
int components = 1,
J_COLOR_SPACE color_space = JCS_GRAYSCALE,
- CompressConfig* config_callback = 0);
+ CompressConfig* config_callback = nullptr);
Members(Members const&) = delete;
action_e action;
diff --git a/include/qpdf/Pl_QPDFTokenizer.hh b/include/qpdf/Pl_QPDFTokenizer.hh
index ce3615ec..0b8cafc2 100644
--- a/include/qpdf/Pl_QPDFTokenizer.hh
+++ b/include/qpdf/Pl_QPDFTokenizer.hh
@@ -51,7 +51,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
Pl_QPDFTokenizer(
char const* identifier,
QPDFObjectHandle::TokenFilter* filter,
- Pipeline* next = 0);
+ Pipeline* next = nullptr);
QPDF_DLL
virtual ~Pl_QPDFTokenizer();
QPDF_DLL
diff --git a/include/qpdf/Pl_StdioFile.hh b/include/qpdf/Pl_StdioFile.hh
index 1508af2b..d175d3c3 100644
--- a/include/qpdf/Pl_StdioFile.hh
+++ b/include/qpdf/Pl_StdioFile.hh
@@ -26,7 +26,7 @@
#include <qpdf/Pipeline.hh>
-#include <stdio.h>
+#include <cstdio>
//
// This pipeline is reusable.
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh
index 4541db64..03490af7 100644
--- a/include/qpdf/QPDF.hh
+++ b/include/qpdf/QPDF.hh
@@ -30,7 +30,7 @@
#include <list>
#include <map>
#include <memory>
-#include <stdio.h>
+#include <cstdio>
#include <string>
#include <string_view>
#include <vector>
@@ -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
diff --git a/include/qpdf/QPDFCryptoImpl.hh b/include/qpdf/QPDFCryptoImpl.hh
index 5345b45b..3fd64d3a 100644
--- a/include/qpdf/QPDFCryptoImpl.hh
+++ b/include/qpdf/QPDFCryptoImpl.hh
@@ -80,7 +80,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
virtual void RC4_process(
unsigned char const* in_data,
size_t len,
- unsigned char* out_data = 0) = 0;
+ unsigned char* out_data = nullptr) = 0;
QPDF_DLL
virtual void RC4_finalize() = 0;
diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh
index 2a82d61c..7396cd6a 100644
--- a/include/qpdf/QPDFJob.hh
+++ b/include/qpdf/QPDFJob.hh
@@ -497,7 +497,7 @@ class QPDFJob
// Helper functions
static void usage(std::string const& msg);
- static JSON json_schema(int json_version, std::set<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&);
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh
index ee424e39..198ca42e 100644
--- a/include/qpdf/QPDFObjectHandle.hh
+++ b/include/qpdf/QPDFObjectHandle.hh
@@ -526,7 +526,7 @@ class QPDFObjectHandle
QPDF_DLL
void parsePageContents(ParserCallbacks* callbacks);
QPDF_DLL
- void filterPageContents(TokenFilter* filter, Pipeline* next = 0);
+ void filterPageContents(TokenFilter* filter, Pipeline* next = nullptr);
// See comments for QPDFPageObjectHelper::pipeContents.
QPDF_DLL
void pipePageContents(Pipeline* p);
@@ -538,7 +538,7 @@ class QPDFObjectHandle
// contents. This can be used to apply a TokenFilter to a form
// XObject, whose data is in the same format as a content stream.
QPDF_DLL
- void filterAsContents(TokenFilter* filter, Pipeline* next = 0);
+ void filterAsContents(TokenFilter* filter, Pipeline* next = nullptr);
// Called on a stream to parse the stream as page contents. This
// can be used to parse a form XObject.
QPDF_DLL
diff --git a/include/qpdf/QPDFOutlineObjectHelper.hh b/include/qpdf/QPDFOutlineObjectHelper.hh
index c8b82a80..507a4a51 100644
--- a/include/qpdf/QPDFOutlineObjectHelper.hh
+++ b/include/qpdf/QPDFOutlineObjectHelper.hh
@@ -42,7 +42,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
{
// This must be cleared explicitly to avoid circular references
// that prevent cleanup of pointer holders.
- this->m->parent = 0;
+ this->m->parent = nullptr;
}
// All constructors are private. You can only create one of these
diff --git a/include/qpdf/QPDFPageObjectHelper.hh b/include/qpdf/QPDFPageObjectHelper.hh
index ebb9e87e..9f647c70 100644
--- a/include/qpdf/QPDFPageObjectHelper.hh
+++ b/include/qpdf/QPDFPageObjectHelper.hh
@@ -320,12 +320,12 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
// examples/pdf-count-strings.cc for an example.
QPDF_DLL
void
- filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0);
+ filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
// Old name -- calls filterContents()
QPDF_DLL
void filterPageContents(
- QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0);
+ QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
// Pipe a page's contents through the given pipeline. This method
// works whether the contents are a single stream or an array of
diff --git a/include/qpdf/QPDFTokenizer.hh b/include/qpdf/QPDFTokenizer.hh
index 79d0d3cd..4de7a637 100644
--- a/include/qpdf/QPDFTokenizer.hh
+++ b/include/qpdf/QPDFTokenizer.hh
@@ -28,7 +28,7 @@
#include <qpdf/PointerHolder.hh> // unused -- remove in qpdf 12 (see #785)
#include <memory>
-#include <stdio.h>
+#include <cstdio>
#include <string>
class QPDFTokenizer
diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh
index c2896209..162d4f4e 100644
--- a/include/qpdf/QPDFWriter.hh
+++ b/include/qpdf/QPDFWriter.hh
@@ -34,7 +34,7 @@
#include <map>
#include <memory>
#include <set>
-#include <stdio.h>
+#include <cstdio>
#include <string>
#include <string_view>
#include <vector>
@@ -102,7 +102,7 @@ class QPDFWriter
QPDF_DLL
virtual ~FunctionProgressReporter();
QPDF_DLL
- virtual void reportProgress(int) override;
+ void reportProgress(int) override;
private:
std::function<void(int)> handler;
@@ -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)
{
diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh
index 4d46f630..2f7f15b2 100644
--- a/include/qpdf/QUtil.hh
+++ b/include/qpdf/QUtil.hh
@@ -30,9 +30,9 @@
#include <list>
#include <memory>
#include <stdexcept>
-#include <stdio.h>
+#include <cstdio>
#include <string>
-#include <time.h>
+#include <ctime>
#include <vector>
class RandomDataProvider;
@@ -245,7 +245,7 @@ namespace QUtil
// Returns true iff the variable is defined. If `value' is
// non-null, initializes it with the value of the variable.
QPDF_DLL
- bool get_env(std::string const& var, std::string* value = 0);
+ bool get_env(std::string const& var, std::string* value = nullptr);
QPDF_DLL
time_t get_current_time();
diff --git a/include/qpdf/RandomDataProvider.hh b/include/qpdf/RandomDataProvider.hh
index 5023b4d0..d40bd1f1 100644
--- a/include/qpdf/RandomDataProvider.hh
+++ b/include/qpdf/RandomDataProvider.hh
@@ -23,7 +23,7 @@
#define RANDOMDATAPROVIDER_HH
#include <qpdf/DLL.h>
-#include <string.h> // for size_t
+#include <cstring> // for size_t
class QPDF_DLL_CLASS RandomDataProvider
{
diff --git a/libqpdf/BufferInputSource.cc b/libqpdf/BufferInputSource.cc
index 6402f639..33ab44f6 100644
--- a/libqpdf/BufferInputSource.cc
+++ b/libqpdf/BufferInputSource.cc
@@ -2,10 +2,8 @@
#include <qpdf/QIntC.hh>
#include <algorithm>
-#include <limits>
#include <sstream>
-#include <stdexcept>
-#include <string.h>
+#include <cstring>
BufferInputSource::BufferInputSource(
std::string const& description, Buffer* buf, bool own_memory) :
diff --git a/libqpdf/FileInputSource.cc b/libqpdf/FileInputSource.cc
index 7c4d6d42..a5f0f4f0 100644
--- a/libqpdf/FileInputSource.cc
+++ b/libqpdf/FileInputSource.cc
@@ -3,7 +3,7 @@
#include <qpdf/QPDFExc.hh>
#include <qpdf/QUtil.hh>
#include <algorithm>
-#include <string.h>
+#include <cstring>
FileInputSource::FileInputSource() :
close_file(false),
diff --git a/libqpdf/InputSource.cc b/libqpdf/InputSource.cc
index 33ab44d1..3a4bb88a 100644
--- a/libqpdf/InputSource.cc
+++ b/libqpdf/InputSource.cc
@@ -3,7 +3,7 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QTC.hh>
#include <stdexcept>
-#include <string.h>
+#include <cstring>
void
InputSource::setLastOffset(qpdf_offset_t offset)
diff --git a/libqpdf/InsecureRandomDataProvider.cc b/libqpdf/InsecureRandomDataProvider.cc
index cb67cada..ed62d6c7 100644
--- a/libqpdf/InsecureRandomDataProvider.cc
+++ b/libqpdf/InsecureRandomDataProvider.cc
@@ -2,7 +2,7 @@
#include <qpdf/QUtil.hh>
#include <qpdf/qpdf-config.h>
-#include <stdlib.h>
+#include <cstdlib>
InsecureRandomDataProvider::InsecureRandomDataProvider() :
seeded_random(false)
@@ -24,7 +24,7 @@ InsecureRandomDataProvider::random()
// Seed the random number generator with something simple, but
// just to be interesting, don't use the unmodified current
// time. It would be better if this were a more secure seed.
- unsigned int seed =
+ auto seed =
static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc);
#ifdef HAVE_RANDOM
::srandom(seed);
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index fbf06f88..5f76f1ec 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -294,7 +294,7 @@ JSON::addDictionaryMember(std::string const& key, JSON const& val)
bool
JSON::checkDictionaryKeySeen(std::string const& key)
{
- JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
+ auto* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
if (nullptr == obj) {
throw std::logic_error(
"JSON::checkDictionaryKey called on non-dictionary");
@@ -315,7 +315,7 @@ JSON::makeArray()
JSON
JSON::addArrayElement(JSON const& val)
{
- JSON_array* arr = dynamic_cast<JSON_array*>(this->m->value.get());
+ auto* arr = dynamic_cast<JSON_array*>(this->m->value.get());
if (nullptr == arr) {
throw std::runtime_error("JSON::addArrayElement called on non-array");
}
@@ -470,13 +470,13 @@ JSON::checkSchemaInternal(
std::list<std::string>& errors,
std::string prefix)
{
- JSON_array* this_arr = dynamic_cast<JSON_array*>(this_v);
- JSON_dictionary* this_dict = dynamic_cast<JSON_dictionary*>(this_v);
+ auto* this_arr = dynamic_cast<JSON_array*>(this_v);
+ auto* this_dict = dynamic_cast<JSON_dictionary*>(this_v);
- JSON_array* sch_arr = dynamic_cast<JSON_array*>(sch_v);
- JSON_dictionary* sch_dict = dynamic_cast<JSON_dictionary*>(sch_v);
+ auto* sch_arr = dynamic_cast<JSON_array*>(sch_v);
+ auto* sch_dict = dynamic_cast<JSON_dictionary*>(sch_v);
- JSON_string* sch_str = dynamic_cast<JSON_string*>(sch_v);
+ auto* sch_str = dynamic_cast<JSON_string*>(sch_v);
std::string err_prefix;
if (prefix.empty()) {
diff --git a/libqpdf/MD5.cc b/libqpdf/MD5.cc
index 2119349c..9668c982 100644
--- a/libqpdf/MD5.cc
+++ b/libqpdf/MD5.cc
@@ -4,11 +4,7 @@
#include <qpdf/QPDFCryptoProvider.hh>
#include <qpdf/QUtil.hh>
-#include <errno.h>
-#include <memory.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstring>
MD5::MD5()
{
diff --git a/libqpdf/Pipeline.cc b/libqpdf/Pipeline.cc
index 3223ac7e..73bd1675 100644
--- a/libqpdf/Pipeline.cc
+++ b/libqpdf/Pipeline.cc
@@ -1,7 +1,5 @@
#include <qpdf/Pipeline.hh>
-#include <qpdf/QUtil.hh>
-
#include <cstring>
#include <stdexcept>
diff --git a/libqpdf/Pl_AES_PDF.cc b/libqpdf/Pl_AES_PDF.cc
index acb6b3f6..89bde7ce 100644
--- a/libqpdf/Pl_AES_PDF.cc
+++ b/libqpdf/Pl_AES_PDF.cc
@@ -5,7 +5,6 @@
#include <qpdf/QUtil.hh>
#include <cstring>
#include <stdexcept>
-#include <stdlib.h>
#include <string>
bool Pl_AES_PDF::use_static_iv = false;
diff --git a/libqpdf/Pl_ASCII85Decoder.cc b/libqpdf/Pl_ASCII85Decoder.cc
index 1e3d1b4f..e43b4a86 100644
--- a/libqpdf/Pl_ASCII85Decoder.cc
+++ b/libqpdf/Pl_ASCII85Decoder.cc
@@ -2,7 +2,7 @@
#include <qpdf/QTC.hh>
#include <stdexcept>
-#include <string.h>
+#include <cstring>
Pl_ASCII85Decoder::Pl_ASCII85Decoder(char const* identifier, Pipeline* next) :
Pipeline(identifier, next),
diff --git a/libqpdf/Pl_ASCIIHexDecoder.cc b/libqpdf/Pl_ASCIIHexDecoder.cc
index f1c4785b..3548f33e 100644
--- a/libqpdf/Pl_ASCIIHexDecoder.cc
+++ b/libqpdf/Pl_ASCIIHexDecoder.cc
@@ -1,9 +1,8 @@
#include <qpdf/Pl_ASCIIHexDecoder.hh>
#include <qpdf/QTC.hh>
-#include <ctype.h>
+#include <cctype>
#include <stdexcept>
-#include <string.h>
Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) :
Pipeline(identifier, next),
@@ -77,7 +76,7 @@ Pl_ASCIIHexDecoder::flush()
b[i] = this->inbuf[i] - '0';
}
}
- unsigned char ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
+ auto ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
QTC::TC(
"libtests",
diff --git a/libqpdf/Pl_Base64.cc b/libqpdf/Pl_Base64.cc
index 6fb422c1..af5ff0bb 100644
--- a/libqpdf/Pl_Base64.cc
+++ b/libqpdf/Pl_Base64.cc
@@ -2,7 +2,6 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QUtil.hh>
-#include <algorithm>
#include <cstring>
#include <stdexcept>
diff --git a/libqpdf/Pl_Buffer.cc b/libqpdf/Pl_Buffer.cc
index ca29ef60..ff200643 100644
--- a/libqpdf/Pl_Buffer.cc
+++ b/libqpdf/Pl_Buffer.cc
@@ -2,8 +2,8 @@
#include <algorithm>
#include <stdexcept>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) :
Pipeline(identifier, next),
@@ -45,7 +45,7 @@ Pl_Buffer::getBuffer()
}
auto size = this->m->data.length();
- Buffer* b = new Buffer(size);
+ auto* b = new Buffer(size);
if (size > 0) {
unsigned char* p = b->getBuffer();
memcpy(p, this->m->data.data(), size);
diff --git a/libqpdf/Pl_DCT.cc b/libqpdf/Pl_DCT.cc
index f7cc4b75..299b48b1 100644
--- a/libqpdf/Pl_DCT.cc
+++ b/libqpdf/Pl_DCT.cc
@@ -2,12 +2,9 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QTC.hh>
-#include <qpdf/QUtil.hh>
-#include <cstring>
-#include <setjmp.h>
+#include <csetjmp>
#include <stdexcept>
-#include <stdlib.h>
#include <string>
#if BITS_IN_JSAMPLE != 8
@@ -27,7 +24,7 @@ namespace
static void
error_handler(j_common_ptr cinfo)
{
- qpdf_jpeg_error_mgr* jerr =
+ auto* jerr =
reinterpret_cast<qpdf_jpeg_error_mgr*>(cinfo->err);
char buf[JMSG_LENGTH_MAX];
(*cinfo->err->format_message)(cinfo, buf);
@@ -170,7 +167,7 @@ static boolean
empty_pipeline_output_buffer(j_compress_ptr cinfo)
{
QTC::TC("libtests", "Pl_DCT empty_pipeline_output_buffer");
- dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
+ auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
dest->next->write(dest->buffer, dest->size);
dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = dest->size;
@@ -181,7 +178,7 @@ static void
term_pipeline_destination(j_compress_ptr cinfo)
{
QTC::TC("libtests", "Pl_DCT term_pipeline_destination");
- dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
+ auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
dest->next->write(dest->buffer, dest->size - dest->pub.free_in_buffer);
}
@@ -195,7 +192,7 @@ jpeg_pipeline_dest(
reinterpret_cast<j_common_ptr>(cinfo),
JPOOL_PERMANENT,
sizeof(dct_pipeline_dest)));
- dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
+ auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
dest->pub.init_destination = init_pipeline_destination;
dest->pub.empty_output_buffer = empty_pipeline_output_buffer;
dest->pub.term_destination = term_pipeline_destination;
@@ -264,7 +261,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, Buffer* buffer)
void
Pl_DCT::compress(void* cinfo_p, Buffer* b)
{
- struct jpeg_compress_struct* cinfo =
+ auto* cinfo =
reinterpret_cast<jpeg_compress_struct*>(cinfo_p);
#if ( \
@@ -319,7 +316,7 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
void
Pl_DCT::decompress(void* cinfo_p, Buffer* b)
{
- struct jpeg_decompress_struct* cinfo =
+ auto* cinfo =
reinterpret_cast<jpeg_decompress_struct*>(cinfo_p);
#if ( \
diff --git a/libqpdf/Pl_Flate.cc b/libqpdf/Pl_Flate.cc
index 61873ffa..6bbcd1be 100644
--- a/libqpdf/Pl_Flate.cc
+++ b/libqpdf/Pl_Flate.cc
@@ -1,7 +1,7 @@
#include <qpdf/Pl_Flate.hh>
-#include <limits.h>
-#include <string.h>
+#include <climits>
+#include <cstring>
#include <zlib.h>
#include <qpdf/QIntC.hh>
diff --git a/libqpdf/Pl_Function.cc b/libqpdf/Pl_Function.cc
index 853b4212..26551ac8 100644
--- a/libqpdf/Pl_Function.cc
+++ b/libqpdf/Pl_Function.cc
@@ -1,7 +1,5 @@
#include <qpdf/Pl_Function.hh>
-#include <qpdf/QUtil.hh>
-#include <errno.h>
#include <stdexcept>
Pl_Function::Members::Members(writer_t fn) :
diff --git a/libqpdf/Pl_LZWDecoder.cc b/libqpdf/Pl_LZWDecoder.cc
index 000fb64b..3356ea4f 100644
--- a/libqpdf/Pl_LZWDecoder.cc
+++ b/libqpdf/Pl_LZWDecoder.cc
@@ -4,7 +4,7 @@
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
#include <stdexcept>
-#include <string.h>
+#include <cstring>
Pl_LZWDecoder::Pl_LZWDecoder(
char const* identifier, Pipeline* next, bool early_code_change) :
@@ -189,7 +189,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
}
if (code < 256) {
- unsigned char ch = static_cast<unsigned char>(code);
+ auto ch = static_cast<unsigned char>(code);
getNext()->write(&ch, 1);
} else {
unsigned int idx = code - 258;
diff --git a/libqpdf/Pl_OStream.cc b/libqpdf/Pl_OStream.cc
index 137b6654..c9d4b1e6 100644
--- a/libqpdf/Pl_OStream.cc
+++ b/libqpdf/Pl_OStream.cc
@@ -1,7 +1,5 @@
#include <qpdf/Pl_OStream.hh>
-#include <qpdf/QUtil.hh>
-#include <errno.h>
#include <stdexcept>
Pl_OStream::Members::Members(std::ostream& os) :
diff --git a/libqpdf/Pl_PNGFilter.cc b/libqpdf/Pl_PNGFilter.cc
index e2a9a0db..41088e1a 100644
--- a/libqpdf/Pl_PNGFilter.cc
+++ b/libqpdf/Pl_PNGFilter.cc
@@ -3,9 +3,9 @@
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
-#include <limits.h>
+#include <climits>
#include <stdexcept>
-#include <string.h>
+#include <cstring>
static int
abs_diff(int a, int b)
diff --git a/libqpdf/Pl_QPDFTokenizer.cc b/libqpdf/Pl_QPDFTokenizer.cc
index 5e42d579..b5c3f75e 100644
--- a/libqpdf/Pl_QPDFTokenizer.cc
+++ b/libqpdf/Pl_QPDFTokenizer.cc
@@ -2,9 +2,7 @@
#include <qpdf/BufferInputSource.hh>
#include <qpdf/QTC.hh>
-#include <qpdf/QUtil.hh>
#include <stdexcept>
-#include <string.h>
Pl_QPDFTokenizer::Members::Members() :
filter(nullptr),
diff --git a/libqpdf/Pl_RunLength.cc b/libqpdf/Pl_RunLength.cc
index 786e2e86..d60da70a 100644
--- a/libqpdf/Pl_RunLength.cc
+++ b/libqpdf/Pl_RunLength.cc
@@ -127,11 +127,11 @@ Pl_RunLength::flush_encode()
throw std::logic_error(
"Pl_RunLength: invalid length in flush_encode for run");
}
- unsigned char ch = static_cast<unsigned char>(257 - this->m->length);
+ auto ch = static_cast<unsigned char>(257 - this->m->length);
this->getNext()->write(&ch, 1);
this->getNext()->write(&this->m->buf[0], 1);
} else if (this->m->length > 0) {
- unsigned char ch = static_cast<unsigned char>(this->m->length - 1);
+ auto ch = static_cast<unsigned char>(this->m->length - 1);
this->getNext()->write(&ch, 1);
this->getNext()->write(this->m->buf, this->m->length);
}
diff --git a/libqpdf/Pl_SHA2.cc b/libqpdf/Pl_SHA2.cc
index c54bd7ee..852e5db7 100644
--- a/libqpdf/Pl_SHA2.cc
+++ b/libqpdf/Pl_SHA2.cc
@@ -2,7 +2,6 @@
#include <qpdf/QPDFCryptoProvider.hh>
#include <qpdf/QUtil.hh>
-#include <cstdio>
#include <stdexcept>
Pl_SHA2::Pl_SHA2(int bits, Pipeline* next) :
diff --git a/libqpdf/Pl_StdioFile.cc b/libqpdf/Pl_StdioFile.cc
index dca16bf6..b83d0a9e 100644
--- a/libqpdf/Pl_StdioFile.cc
+++ b/libqpdf/Pl_StdioFile.cc
@@ -3,7 +3,7 @@
#include <qpdf/Pl_StdioFile.hh>
#include <qpdf/QUtil.hh>
-#include <errno.h>
+#include <cerrno>
#include <stdexcept>
Pl_StdioFile::Members::Members(FILE* f) :
diff --git a/libqpdf/Pl_String.cc b/libqpdf/Pl_String.cc
index d946a652..9b57ac2d 100644
--- a/libqpdf/Pl_String.cc
+++ b/libqpdf/Pl_String.cc
@@ -1,7 +1,5 @@
#include <qpdf/Pl_String.hh>
-#include <qpdf/QUtil.hh>
-#include <errno.h>
#include <stdexcept>
Pl_String::Members::Members(std::string& s) :
diff --git a/libqpdf/Pl_TIFFPredictor.cc b/libqpdf/Pl_TIFFPredictor.cc
index c29396db..45b6d396 100644
--- a/libqpdf/Pl_TIFFPredictor.cc
+++ b/libqpdf/Pl_TIFFPredictor.cc
@@ -5,9 +5,9 @@
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
-#include <limits.h>
+#include <climits>
#include <stdexcept>
-#include <string.h>
+#include <cstring>
#include <vector>
Pl_TIFFPredictor::Pl_TIFFPredictor(
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index c7cc1370..09221394 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -9,8 +9,8 @@
#include <memory.h>
#include <regex>
#include <sstream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
#include <vector>
#include <qpdf/BufferInputSource.hh>
@@ -60,42 +60,42 @@ namespace
class InvalidInputSource: public InputSource
{
public:
- virtual ~InvalidInputSource() = default;
- virtual qpdf_offset_t
+ ~InvalidInputSource() override = default;
+ qpdf_offset_t
findAndSkipNextEOL() override
{
throwException();
return 0;
}
- virtual std::string const&
+ std::string const&
getName() const override
{
static std::string name("closed input source");
return name;
}
- virtual qpdf_offset_t
+ qpdf_offset_t
tell() override
{
throwException();
return 0;
}
- virtual void
+ void
seek(qpdf_offset_t offset, int whence) override
{
throwException();
}
- virtual void
+ void
rewind() override
{
throwException();
}
- virtual size_t
+ size_t
read(char* buffer, size_t length) override
{
throwException();
return 0;
}
- virtual void
+ void
unreadCh(char ch) override
{
throwException();
@@ -264,7 +264,7 @@ QPDF::create()
void
QPDF::processFile(char const* filename, char const* password)
{
- FileInputSource* fi = new FileInputSource(filename);
+ auto* fi = new FileInputSource(filename);
processInputSource(std::shared_ptr<InputSource>(fi), password);
}
@@ -272,7 +272,7 @@ void
QPDF::processFile(
char const* description, FILE* filep, bool close_file, char const* password)
{
- FileInputSource* fi = new FileInputSource(description, filep, close_file);
+ auto* fi = new FileInputSource(description, filep, close_file);
processInputSource(std::shared_ptr<InputSource>(fi), password);
}
@@ -2537,7 +2537,7 @@ QPDF::getCompressibleObjGens()
if (obj.isStream()) {
QPDFObjectHandle dict = obj.getDict();
std::set<std::string> keys = dict.getKeys();
- for (std::set<std::string>::reverse_iterator iter = keys.rbegin();
+ for (auto iter = keys.rbegin();
iter != keys.rend();
++iter) {
std::string const& key = *iter;
@@ -2553,7 +2553,7 @@ QPDF::getCompressibleObjGens()
}
} else if (obj.isDictionary()) {
std::set<std::string> keys = obj.getKeys();
- for (std::set<std::string>::reverse_iterator iter = keys.rbegin();
+ for (auto iter = keys.rbegin();
iter != keys.rend();
++iter) {
queue.push_front(obj.getKey(*iter));
diff --git a/libqpdf/QPDFAnnotationObjectHelper.cc b/libqpdf/QPDFAnnotationObjectHelper.cc
index f22207de..c14d98f9 100644
--- a/libqpdf/QPDFAnnotationObjectHelper.cc
+++ b/libqpdf/QPDFAnnotationObjectHelper.cc
@@ -2,7 +2,6 @@
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFMatrix.hh>
-#include <qpdf/QPDFNameTreeObjectHelper.hh>
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
diff --git a/libqpdf/QPDFExc.cc b/libqpdf/QPDFExc.cc
index 6f1ef1a0..87fad72a 100644
--- a/libqpdf/QPDFExc.cc
+++ b/libqpdf/QPDFExc.cc
@@ -1,7 +1,5 @@
#include <qpdf/QPDFExc.hh>
-#include <qpdf/QUtil.hh>
-
QPDFExc::QPDFExc(
qpdf_error_code_e error_code,
std::string const& filename,
diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc
index e76e3121..4b95c91f 100644
--- a/libqpdf/QPDFFormFieldObjectHelper.cc
+++ b/libqpdf/QPDFFormFieldObjectHelper.cc
@@ -6,7 +6,7 @@
#include <qpdf/QPDFAnnotationObjectHelper.hh>
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
-#include <stdlib.h>
+#include <cstdlib>
QPDFFormFieldObjectHelper::QPDFFormFieldObjectHelper(QPDFObjectHandle oh) :
QPDFObjectHelper(oh),
@@ -515,9 +515,9 @@ namespace
std::vector<std::string> const& opt,
double tf,
QPDFObjectHandle::Rectangle const& bbox);
- virtual ~ValueSetter() = default;
- virtual void handleToken(QPDFTokenizer::Token const&);
- virtual void handleEOF();
+ ~ValueSetter() override = default;
+ void handleToken(QPDFTokenizer::Token const&) override;
+ void handleEOF() override;
void writeAppearance();
private:
@@ -611,7 +611,7 @@ ValueSetter::writeAppearance()
// Write one or more lines, centered vertically, possibly with
// one row highlighted.
- size_t max_rows = static_cast<size_t>((bbox.ury - bbox.lly) / tfh);
+ auto max_rows = static_cast<size_t>((bbox.ury - bbox.lly) / tfh);
bool highlight = false;
size_t highlight_idx = 0;
@@ -706,10 +706,10 @@ namespace
{
public:
TfFinder();
- virtual ~TfFinder()
+ ~TfFinder() override
{
}
- virtual void handleToken(QPDFTokenizer::Token const&);
+ void handleToken(QPDFTokenizer::Token const&) override;
double getTf();
std::string getFontName();
std::string getDA();
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc
index fbaa53e5..0e5ad3ae 100644
--- a/libqpdf/QPDFJob.cc
+++ b/libqpdf/QPDFJob.cc
@@ -3,7 +3,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <ctype.h>
+#include <cctype>
#include <fcntl.h>
#include <iostream>
#include <memory>
@@ -48,8 +48,8 @@ namespace
size_t oi_min_height,
size_t oi_min_area,
QPDFObjectHandle& image);
- virtual ~ImageOptimizer() = default;
- virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
+ ~ImageOptimizer() override = default;
+ void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
std::shared_ptr<Pipeline>
makePipeline(std::string const& description, Pipeline* next);
bool evaluate(std::string const& description);
@@ -65,13 +65,13 @@ namespace
class DiscardContents: public QPDFObjectHandle::ParserCallbacks
{
public:
- virtual ~DiscardContents() = default;
- virtual void
- handleObject(QPDFObjectHandle)
+ ~DiscardContents() override = default;
+ void
+ handleObject(QPDFObjectHandle) override
{
}
- virtual void
- handleEOF()
+ void
+ handleEOF() override
{
}
};
@@ -98,8 +98,8 @@ namespace
filename(filename)
{
}
- virtual ~ProgressReporter() = default;
- virtual void reportProgress(int);
+ ~ProgressReporter() override = default;
+ void reportProgress(int) override;
private:
Pipeline& p;
diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc
index 55696f5d..5534cd39 100644
--- a/libqpdf/QPDFJob_argv.cc
+++ b/libqpdf/QPDFJob_argv.cc
@@ -3,12 +3,12 @@
// See "HOW TO ADD A COMMAND-LINE ARGUMENT" in README-maintainer.
#include <cstdio>
-#include <ctype.h>
+#include <cctype>
#include <iostream>
#include <memory>
#include <sstream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
#include <qpdf/QIntC.hh>
#include <qpdf/QPDFArgParser.hh>
diff --git a/libqpdf/QPDFLogger.cc b/libqpdf/QPDFLogger.cc
index 7fe21c97..15d80aab 100644
--- a/libqpdf/QPDFLogger.cc
+++ b/libqpdf/QPDFLogger.cc
@@ -17,14 +17,14 @@ namespace
{
}
- virtual void
+ void
write(unsigned char const* data, size_t len) override
{
this->used = true;
getNext()->write(data, len);
}
- virtual void
+ void
finish() override
{
getNext()->finish();
diff --git a/libqpdf/QPDFNameTreeObjectHelper.cc b/libqpdf/QPDFNameTreeObjectHelper.cc
index f388dccf..574bb097 100644
--- a/libqpdf/QPDFNameTreeObjectHelper.cc
+++ b/libqpdf/QPDFNameTreeObjectHelper.cc
@@ -7,18 +7,18 @@ namespace
class NameTreeDetails: public NNTreeDetails
{
public:
- virtual std::string const&
+ std::string const&
itemsKey() const override
{
static std::string k("/Names");
return k;
}
- virtual bool
+ bool
keyValid(QPDFObjectHandle oh) const override
{
return oh.isString();
}
- virtual int
+ int
compareKeys(QPDFObjectHandle a, QPDFObjectHandle b) const override
{
if (!(keyValid(a) && keyValid(b))) {
diff --git a/libqpdf/QPDFNumberTreeObjectHelper.cc b/libqpdf/QPDFNumberTreeObjectHelper.cc
index 6443416d..08f790d4 100644
--- a/libqpdf/QPDFNumberTreeObjectHelper.cc
+++ b/libqpdf/QPDFNumberTreeObjectHelper.cc
@@ -8,18 +8,18 @@ namespace
class NumberTreeDetails: public NNTreeDetails
{
public:
- virtual std::string const&
+ std::string const&
itemsKey() const override
{
static std::string k("/Nums");
return k;
}
- virtual bool
+ bool
keyValid(QPDFObjectHandle oh) const override
{
return oh.isInteger();
}
- virtual int
+ int
compareKeys(QPDFObjectHandle a, QPDFObjectHandle b) const override
{
if (!(keyValid(a) && keyValid(b))) {
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index b3f208a5..93d269d3 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -30,10 +30,10 @@
#include <algorithm>
#include <cstring>
-#include <ctype.h>
-#include <limits.h>
+#include <cctype>
+#include <climits>
#include <stdexcept>
-#include <stdlib.h>
+#include <cstdlib>
using namespace std::literals;
@@ -111,8 +111,8 @@ namespace
old_contents(old_contents)
{
}
- virtual ~CoalesceProvider() = default;
- virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline);
+ ~CoalesceProvider() override = default;
+ void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
private:
QPDFObjectHandle containing_page;
@@ -200,9 +200,9 @@ namespace
{
public:
LastChar(Pipeline* next);
- virtual ~LastChar() = default;
- virtual void write(unsigned char const* data, size_t len);
- virtual void finish();
+ ~LastChar() override = default;
+ void write(unsigned char const* data, size_t len) override;
+ void finish() override;
unsigned char getLastChar();
private:
@@ -1446,13 +1446,13 @@ namespace
{
}
- virtual void
+ void
provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override
{
p1(pipeline);
}
- virtual bool
+ bool
provideStreamData(
QPDFObjGen const&,
Pipeline* pipeline,
diff --git a/libqpdf/QPDFParser.cc b/libqpdf/QPDFParser.cc
index 4c43e487..e56fcce3 100644
--- a/libqpdf/QPDFParser.cc
+++ b/libqpdf/QPDFParser.cc
@@ -16,7 +16,6 @@
#include <qpdf/QPDF_Reserved.hh>
#include <qpdf/QPDF_Stream.hh>
#include <qpdf/QPDF_String.hh>
-#include <qpdf/QPDF_Unresolved.hh>
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
diff --git a/libqpdf/QPDFSystemError.cc b/libqpdf/QPDFSystemError.cc
index 8d129bad..ebd0d773 100644
--- a/libqpdf/QPDFSystemError.cc
+++ b/libqpdf/QPDFSystemError.cc
@@ -1,7 +1,6 @@
#include <qpdf/QPDFSystemError.hh>
-#include <qpdf/QUtil.hh>
-#include <string.h>
+#include <cstring>
QPDFSystemError::QPDFSystemError(
std::string const& description, int system_errno) :
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc
index d8d457ab..1a14e3a9 100644
--- a/libqpdf/QPDFTokenizer.cc
+++ b/libqpdf/QPDFTokenizer.cc
@@ -11,8 +11,8 @@
#include <qpdf/QUtil.hh>
#include <stdexcept>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
static inline bool
is_delimiter(char ch)
@@ -35,8 +35,8 @@ namespace
str(str)
{
}
- virtual ~QPDFWordTokenFinder() = default;
- virtual bool check();
+ ~QPDFWordTokenFinder() override = default;
+ bool check() override;
private:
std::shared_ptr<InputSource> is;
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index de1aa45b..a5a54cc7 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -24,7 +24,7 @@
#include <algorithm>
#include <stdexcept>
-#include <stdlib.h>
+#include <cstdlib>
QPDFWriter::ProgressReporter::~ProgressReporter()
{
@@ -997,7 +997,7 @@ void
QPDFWriter::activatePipelineStack(PipelinePopper& pp)
{
std::string stack_id("stack " + std::to_string(this->m->next_stack_id));
- Pl_Count* c =
+ auto* c =
new Pl_Count(stack_id.c_str(), this->m->pipeline_stack.back());
++this->m->next_stack_id;
this->m->pipeline_stack.push_back(c);
@@ -1030,7 +1030,7 @@ QPDFWriter::PipelinePopper::~PipelinePopper()
qw->m->md5_pipeline = nullptr;
}
qw->m->pipeline_stack.pop_back();
- Pl_Buffer* buf = dynamic_cast<Pl_Buffer*>(p);
+ auto* buf = dynamic_cast<Pl_Buffer*>(p);
if (bp && buf) {
*bp = buf->getBufferSharedPointer();
}
diff --git a/libqpdf/QPDFXRefEntry.cc b/libqpdf/QPDFXRefEntry.cc
index 77f641b0..0d66028c 100644
--- a/libqpdf/QPDFXRefEntry.cc
+++ b/libqpdf/QPDFXRefEntry.cc
@@ -2,7 +2,6 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QPDFExc.hh>
-#include <qpdf/QUtil.hh>
QPDFXRefEntry::QPDFXRefEntry()
{
diff --git a/libqpdf/QPDF_Array.cc b/libqpdf/QPDF_Array.cc
index 3bd139b1..d0228361 100644
--- a/libqpdf/QPDF_Array.cc
+++ b/libqpdf/QPDF_Array.cc
@@ -83,7 +83,7 @@ QPDF_Array::copy(bool shallow)
return do_create(new QPDF_Array(*this));
} else {
if (sparse) {
- QPDF_Array* result = new QPDF_Array();
+ auto* result = new QPDF_Array();
result->sp_size = sp_size;
for (auto const& element: sp_elements) {
auto const& obj = element.second;
diff --git a/libqpdf/QPDF_Name.cc b/libqpdf/QPDF_Name.cc
index 2fa697cf..11b30086 100644
--- a/libqpdf/QPDF_Name.cc
+++ b/libqpdf/QPDF_Name.cc
@@ -1,8 +1,6 @@
#include <qpdf/QPDF_Name.hh>
#include <qpdf/QUtil.hh>
-#include <stdio.h>
-#include <string.h>
QPDF_Name::QPDF_Name(std::string const& name) :
QPDFValue(::ot_name, "name"),
diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc
index 8e2e16c5..9cfb3ac4 100644
--- a/libqpdf/QPDF_Stream.cc
+++ b/libqpdf/QPDF_Stream.cc
@@ -27,10 +27,10 @@ namespace
{
public:
SF_Crypt() = default;
- virtual ~SF_Crypt() = default;
+ ~SF_Crypt() override = default;
- virtual bool
- setDecodeParms(QPDFObjectHandle decode_parms)
+ bool
+ setDecodeParms(QPDFObjectHandle decode_parms) override
{
if (decode_parms.isNull()) {
return true;
@@ -49,8 +49,8 @@ namespace
return filterable;
}
- virtual Pipeline*
- getDecodePipeline(Pipeline*)
+ Pipeline*
+ getDecodePipeline(Pipeline*) override
{
// Not used -- handled by pipeStreamData
return nullptr;
@@ -557,7 +557,7 @@ QPDF_Stream::pipeStreamData(
if (decode_pipeline) {
pipeline = decode_pipeline;
}
- Pl_Flate* flate = dynamic_cast<Pl_Flate*>(pipeline);
+ auto* flate = dynamic_cast<Pl_Flate*>(pipeline);
if (flate != nullptr) {
flate->setWarnCallback(
[this](char const* msg, int code) { warn(msg); });
diff --git a/libqpdf/QPDF_String.cc b/libqpdf/QPDF_String.cc
index c3148fa0..51742bdd 100644
--- a/libqpdf/QPDF_String.cc
+++ b/libqpdf/QPDF_String.cc
@@ -5,7 +5,6 @@
// DO NOT USE ctype -- it is locale dependent for some things, and
// it's not worth the risk of including it in case it may accidentally
// be used.
-#include <string.h>
static bool
is_iso_latin1_printable(char ch)
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index 2e5ddefb..64ca10f1 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -17,7 +17,7 @@
#include <qpdf/RC4.hh>
#include <algorithm>
-#include <string.h>
+#include <cstring>
static unsigned char const padding_string[] = {
0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e,
diff --git a/libqpdf/QPDF_json.cc b/libqpdf/QPDF_json.cc
index 563e8e29..9e3cb3bb 100644
--- a/libqpdf/QPDF_json.cc
+++ b/libqpdf/QPDF_json.cc
@@ -242,13 +242,13 @@ class QPDF::JSONReactor: public JSON::Reactor
}
}
virtual ~JSONReactor() = default;
- virtual void dictionaryStart() override;
- virtual void arrayStart() override;
- virtual void containerEnd(JSON const& value) override;
- virtual void topLevelScalar() override;
- virtual bool
+ void dictionaryStart() override;
+ void arrayStart() override;
+ void containerEnd(JSON const& value) override;
+ void topLevelScalar() override;
+ bool
dictionaryItem(std::string const& key, JSON const& value) override;
- virtual bool arrayItem(JSON const& value) override;
+ bool arrayItem(JSON const& value) override;
bool anyErrors() const;
diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc
index 926353fa..eade317e 100644
--- a/libqpdf/QPDF_linearization.cc
+++ b/libqpdf/QPDF_linearization.cc
@@ -13,9 +13,8 @@
#include <qpdf/QUtil.hh>
#include <algorithm>
-#include <iostream>
-#include <math.h>
-#include <string.h>
+#include <cmath>
+#include <cstring>
template <class T, class int_type>
static void
diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc
index 41204fbd..9130287a 100644
--- a/libqpdf/QPDF_optimization.cc
+++ b/libqpdf/QPDF_optimization.cc
@@ -115,7 +115,7 @@ QPDF::optimize(
}
ObjUser root_ou = ObjUser(ObjUser::ou_root);
- QPDFObjGen root_og = QPDFObjGen(root.getObjGen());
+ auto root_og = QPDFObjGen(root.getObjGen());
this->m->obj_user_to_objects[root_ou].insert(root_og);
this->m->object_to_obj_users[root_og].insert(root_ou);
diff --git a/libqpdf/QTC.cc b/libqpdf/QTC.cc
index 8188846c..e537a0e1 100644
--- a/libqpdf/QTC.cc
+++ b/libqpdf/QTC.cc
@@ -3,7 +3,7 @@
#include <qpdf/QUtil.hh>
#include <map>
#include <set>
-#include <stdio.h>
+#include <cstdio>
static bool
tc_active(char const* const scope)
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc
index 03301d9d..a542736d 100644
--- a/libqpdf/QUtil.cc
+++ b/libqpdf/QUtil.cc
@@ -9,9 +9,8 @@
#include <qpdf/QPDFSystemError.hh>
#include <qpdf/QTC.hh>
-#include <cmath>
-#include <ctype.h>
-#include <errno.h>
+#include <cctype>
+#include <cerrno>
#include <fcntl.h>
#include <fstream>
#include <iomanip>
@@ -22,9 +21,9 @@
#include <set>
#include <sstream>
#include <stdexcept>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#ifndef QPDF_NO_WCHAR_T
# include <cwchar>
#endif
@@ -837,8 +836,8 @@ char*
QUtil::getWhoami(char* argv0)
{
char* whoami = nullptr;
- if (((whoami = strrchr(argv0, '/')) == NULL) &&
- ((whoami = strrchr(argv0, '\\')) == NULL)) {
+ if (((whoami = strrchr(argv0, '/')) == nullptr) &&
+ ((whoami = strrchr(argv0, '\\')) == nullptr)) {
whoami = argv0;
} else {
++whoami;
diff --git a/libqpdf/RC4.cc b/libqpdf/RC4.cc
index 6fc25a86..2d1b783d 100644
--- a/libqpdf/RC4.cc
+++ b/libqpdf/RC4.cc
@@ -2,7 +2,6 @@
#include <qpdf/QPDFCryptoProvider.hh>
-#include <string.h>
RC4::RC4(unsigned char const* key_data, int key_len) :
crypto(QPDFCryptoProvider::getImpl())
diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc
index 01987365..8f36195a 100644
--- a/libqpdf/qpdf-c.cc
+++ b/libqpdf/qpdf-c.cc
@@ -15,7 +15,6 @@
#include <qpdf/qpdf-c_impl.hh>
#include <qpdf/qpdflogger-c_impl.hh>
-#include <cstring>
#include <functional>
#include <list>
#include <stdexcept>
@@ -107,7 +106,7 @@ qpdf_data
qpdf_init()
{
QTC::TC("qpdf", "qpdf-c called qpdf_init");
- qpdf_data qpdf = new _qpdf_data();
+ auto qpdf = new _qpdf_data();
qpdf->qpdf = QPDF::create();
return qpdf;
}
diff --git a/libqpdf/qpdf/BitStream.hh b/libqpdf/qpdf/BitStream.hh
index 14555c5d..b807f56c 100644
--- a/libqpdf/qpdf/BitStream.hh
+++ b/libqpdf/qpdf/BitStream.hh
@@ -3,7 +3,7 @@
#ifndef BITSTREAM_HH
#define BITSTREAM_HH
-#include <stddef.h>
+#include <cstddef>
class BitStream
{
diff --git a/libqpdf/qpdf/BitWriter.hh b/libqpdf/qpdf/BitWriter.hh
index ca237d47..33fdd8f4 100644
--- a/libqpdf/qpdf/BitWriter.hh
+++ b/libqpdf/qpdf/BitWriter.hh
@@ -3,7 +3,7 @@
#ifndef BITWRITER_HH
#define BITWRITER_HH
-#include <stddef.h>
+#include <cstddef>
class Pipeline;
diff --git a/libqpdf/qpdf/ContentNormalizer.hh b/libqpdf/qpdf/ContentNormalizer.hh
index ba1063e0..d423aa4c 100644
--- a/libqpdf/qpdf/ContentNormalizer.hh
+++ b/libqpdf/qpdf/ContentNormalizer.hh
@@ -7,8 +7,8 @@ class ContentNormalizer: public QPDFObjectHandle::TokenFilter
{
public:
ContentNormalizer();
- virtual ~ContentNormalizer() = default;
- virtual void handleToken(QPDFTokenizer::Token const&);
+ ~ContentNormalizer() override = default;
+ void handleToken(QPDFTokenizer::Token const&) override;
bool anyBadTokens() const;
bool lastTokenWasBad() const;
diff --git a/libqpdf/qpdf/CryptoRandomDataProvider.hh b/libqpdf/qpdf/CryptoRandomDataProvider.hh
index 89859e65..e402d944 100644
--- a/libqpdf/qpdf/CryptoRandomDataProvider.hh
+++ b/libqpdf/qpdf/CryptoRandomDataProvider.hh
@@ -7,8 +7,8 @@ class CryptoRandomDataProvider: public RandomDataProvider
{
public:
CryptoRandomDataProvider() = default;
- virtual ~CryptoRandomDataProvider() = default;
- virtual void provideRandomData(unsigned char* data, size_t len);
+ ~CryptoRandomDataProvider() override = default;
+ void provideRandomData(unsigned char* data, size_t len) override;
static RandomDataProvider* getInstance();
};
diff --git a/libqpdf/qpdf/InsecureRandomDataProvider.hh b/libqpdf/qpdf/InsecureRandomDataProvider.hh
index 47a81afe..bab4e002 100644
--- a/libqpdf/qpdf/InsecureRandomDataProvider.hh
+++ b/libqpdf/qpdf/InsecureRandomDataProvider.hh
@@ -7,8 +7,8 @@ class InsecureRandomDataProvider: public RandomDataProvider
{
public:
InsecureRandomDataProvider();
- virtual ~InsecureRandomDataProvider() = default;
- virtual void provideRandomData(unsigned char* data, size_t len);
+ ~InsecureRandomDataProvider() override = default;
+ void provideRandomData(unsigned char* data, size_t len) override;
static RandomDataProvider* getInstance();
private:
diff --git a/libqpdf/qpdf/OffsetInputSource.hh b/libqpdf/qpdf/OffsetInputSource.hh
index d8b08145..fdc1a404 100644
--- a/libqpdf/qpdf/OffsetInputSource.hh
+++ b/libqpdf/qpdf/OffsetInputSource.hh
@@ -11,15 +11,15 @@ class OffsetInputSource: public InputSource
public:
OffsetInputSource(
std::shared_ptr<InputSource>, qpdf_offset_t global_offset);
- virtual ~OffsetInputSource() = default;
+ ~OffsetInputSource() override = default;
- virtual qpdf_offset_t findAndSkipNextEOL();
- virtual std::string const& getName() const;
- virtual qpdf_offset_t tell();
- virtual void seek(qpdf_offset_t offset, int whence);
- virtual void rewind();
- virtual size_t read(char* buffer, size_t length);
- virtual void unreadCh(char ch);
+ qpdf_offset_t findAndSkipNextEOL() override;
+ std::string const& getName() const override;
+ qpdf_offset_t tell() override;
+ void seek(qpdf_offset_t offset, int whence) override;
+ void rewind() override;
+ size_t read(char* buffer, size_t length) override;
+ void unreadCh(char ch) override;
private:
std::shared_ptr<InputSource> proxied;
diff --git a/libqpdf/qpdf/Pl_AES_PDF.hh b/libqpdf/qpdf/Pl_AES_PDF.hh
index 18091583..b3fde312 100644
--- a/libqpdf/qpdf/Pl_AES_PDF.hh
+++ b/libqpdf/qpdf/Pl_AES_PDF.hh
@@ -18,10 +18,10 @@ class Pl_AES_PDF: public Pipeline
bool encrypt,
unsigned char const* key,
size_t key_bytes);
- virtual ~Pl_AES_PDF() = default;
+ ~Pl_AES_PDF() override = default;
- virtual void write(unsigned char const* data, size_t len);
- virtual void finish();
+ void write(unsigned char const* data, size_t len) override;
+ void finish() override;
// Use zero initialization vector; needed for AESV3
void useZeroIV();
diff --git a/libqpdf/qpdf/Pl_ASCII85Decoder.hh b/libqpdf/qpdf/Pl_ASCII85Decoder.hh
index 667b56e9..dd5efd06 100644
--- a/libqpdf/qpdf/Pl_ASCII85Decoder.hh
+++ b/libqpdf/qpdf/Pl_ASCII85Decoder.hh
@@ -7,9 +7,9 @@ class Pl_ASCII85Decoder: public Pipeline
{
public:
Pl_ASCII85Decoder(char const* identifier, Pipeline* next);
- virtual ~Pl_ASCII85Decoder() = default;
- virtual void write(unsigned char const* buf, size_t len);
- virtual void finish();
+ ~Pl_ASCII85Decoder() override = default;
+ void write(unsigned char const* buf, size_t len) override;
+ void finish() override;
private:
void flush();
diff --git a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh
index c71dcf00..5edf74f0 100644
--- a/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh
+++ b/libqpdf/qpdf/Pl_ASCIIHexDecoder.hh
@@ -7,9 +7,9 @@ class Pl_ASCIIHexDecoder: public Pipeline
{
public:
Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next);
- virtual ~Pl_ASCIIHexDecoder() = default;
- virtual void write(unsigned char const* buf, size_t len);
- virtual void finish();
+ ~Pl_ASCIIHexDecoder() override = default;
+ void write(unsigned char const* buf, size_t len) override;
+ void finish() override;
private:
void flush();
diff --git a/libqpdf/qpdf/Pl_Base64.hh b/libqpdf/qpdf/Pl_Base64.hh
index 788bfd6d..a084a17f 100644
--- a/libqpdf/qpdf/Pl_Base64.hh
+++ b/libqpdf/qpdf/Pl_Base64.hh
@@ -8,9 +8,9 @@ class Pl_Base64: public Pipeline
public:
enum action_e { a_encode, a_decode };
Pl_Base64(char const* identifier, Pipeline* next, action_e);
- virtual ~Pl_Base64() = default;
- virtual void write(unsigned char const* buf, size_t len) override;
- virtual void finish() override;
+ ~Pl_Base64() override = default;
+ void write(unsigned char const* buf, size_t len) override;
+ void finish() override;
private:
void decode(unsigned char const* buf, size_t len);
diff --git a/libqpdf/qpdf/Pl_PNGFilter.hh b/libqpdf/qpdf/Pl_PNGFilter.hh
index 6cc34a9c..7ab7bf0d 100644
--- a/libqpdf/qpdf/Pl_PNGFilter.hh
+++ b/libqpdf/qpdf/Pl_PNGFilter.hh
@@ -22,10 +22,10 @@ class Pl_PNGFilter: public Pipeline
unsigned int columns,
unsigned int samples_per_pixel = 1,
unsigned int bits_per_sample = 8);
- virtual ~Pl_PNGFilter() = default;
+ ~Pl_PNGFilter() override = default;
- virtual void write(unsigned char const* data, size_t len);
- virtual void finish();
+ void write(unsigned char const* data, size_t len) override;
+ void finish() override;
private:
void decodeSub();
diff --git a/libqpdf/qpdf/Pl_RC4.hh b/libqpdf/qpdf/Pl_RC4.hh
index 07b8a1c4..49c943b9 100644
--- a/libqpdf/qpdf/Pl_RC4.hh
+++ b/libqpdf/qpdf/Pl_RC4.hh
@@ -17,10 +17,10 @@ class Pl_RC4: public Pipeline
unsigned char const* key_data,
int key_len = -1,
size_t out_bufsize = def_bufsize);
- virtual ~Pl_RC4() = default;
+ ~Pl_RC4() override = default;
- virtual void write(unsigned char const* data, size_t len);
- virtual void finish();
+ void write(unsigned char const* data, size_t len) override;
+ void finish() override;
private:
std::shared_ptr<unsigned char> outbuf;
diff --git a/libqpdf/qpdf/Pl_SHA2.hh b/libqpdf/qpdf/Pl_SHA2.hh
index d5b2e547..571271eb 100644
--- a/libqpdf/qpdf/Pl_SHA2.hh
+++ b/libqpdf/qpdf/Pl_SHA2.hh
@@ -20,10 +20,10 @@
class Pl_SHA2: public Pipeline
{
public:
- Pl_SHA2(int bits = 0, Pipeline* next = 0);
- virtual ~Pl_SHA2() = default;
- virtual void write(unsigned char const*, size_t);
- virtual void finish();
+ Pl_SHA2(int bits = 0, Pipeline* next = nullptr);
+ ~Pl_SHA2() override = default;
+ void write(unsigned char const*, size_t) override;
+ void finish() override;
void resetBits(int bits);
std::string getHexDigest();
std::string getRawDigest();
diff --git a/libqpdf/qpdf/Pl_TIFFPredictor.hh b/libqpdf/qpdf/Pl_TIFFPredictor.hh
index 2b3bdb10..6bc48e72 100644
--- a/libqpdf/qpdf/Pl_TIFFPredictor.hh
+++ b/libqpdf/qpdf/Pl_TIFFPredictor.hh
@@ -18,10 +18,10 @@ class Pl_TIFFPredictor: public Pipeline
unsigned int columns,
unsigned int samples_per_pixel = 1,
unsigned int bits_per_sample = 8);
- virtual ~Pl_TIFFPredictor() = default;
+ ~Pl_TIFFPredictor() override = default;
- virtual void write(unsigned char const* data, size_t len);
- virtual void finish();
+ void write(unsigned char const* data, size_t len) override;
+ void finish() override;
private:
void processRow();
diff --git a/libqpdf/qpdf/QPDFArgParser.hh b/libqpdf/qpdf/QPDFArgParser.hh
index 89c7acc0..759ad148 100644
--- a/libqpdf/qpdf/QPDFArgParser.hh
+++ b/libqpdf/qpdf/QPDFArgParser.hh
@@ -177,9 +177,9 @@ class QPDFArgParser
{
OptionEntry() :
parameter_needed(false),
- bare_arg_handler(0),
- param_arg_handler(0),
- invalid_choice_handler(0)
+ bare_arg_handler(nullptr),
+ param_arg_handler(nullptr),
+ invalid_choice_handler(nullptr)
{
}
bool parameter_needed;
diff --git a/libqpdf/qpdf/QPDFCrypto_openssl.hh b/libqpdf/qpdf/QPDFCrypto_openssl.hh
index eae69ab1..0d07b99b 100644
--- a/libqpdf/qpdf/QPDFCrypto_openssl.hh
+++ b/libqpdf/qpdf/QPDFCrypto_openssl.hh
@@ -39,7 +39,7 @@ class QPDFCrypto_openssl: public QPDFCryptoImpl
void RC4_process(
unsigned char const* in_data,
size_t len,
- unsigned char* out_data = 0) override;
+ unsigned char* out_data = nullptr) override;
void RC4_finalize() override;
void SHA2_init(int bits) override;
diff --git a/libqpdf/qpdf/ResourceFinder.hh b/libqpdf/qpdf/ResourceFinder.hh
index d037e600..c4f5673b 100644
--- a/libqpdf/qpdf/ResourceFinder.hh
+++ b/libqpdf/qpdf/ResourceFinder.hh
@@ -8,8 +8,8 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
public:
ResourceFinder();
virtual ~ResourceFinder() = default;
- virtual void handleObject(QPDFObjectHandle, size_t, size_t) override;
- virtual void handleEOF() override;
+ void handleObject(QPDFObjectHandle, size_t, size_t) override;
+ void handleEOF() override;
std::set<std::string> const& getNames() const;
std::map<std::string, std::map<std::string, std::set<size_t>>> const&
getNamesByResourceType() const;
diff --git a/libqpdf/qpdf/SF_ASCII85Decode.hh b/libqpdf/qpdf/SF_ASCII85Decode.hh
index 0b77d2e4..f383364a 100644
--- a/libqpdf/qpdf/SF_ASCII85Decode.hh
+++ b/libqpdf/qpdf/SF_ASCII85Decode.hh
@@ -11,7 +11,7 @@ class SF_ASCII85Decode: public QPDFStreamFilter
SF_ASCII85Decode() = default;
virtual ~SF_ASCII85Decode() = default;
- virtual Pipeline*
+ Pipeline*
getDecodePipeline(Pipeline* next) override
{
this->pipeline =
diff --git a/libqpdf/qpdf/SF_ASCIIHexDecode.hh b/libqpdf/qpdf/SF_ASCIIHexDecode.hh
index 6454ce44..911f7370 100644
--- a/libqpdf/qpdf/SF_ASCIIHexDecode.hh
+++ b/libqpdf/qpdf/SF_ASCIIHexDecode.hh
@@ -11,7 +11,7 @@ class SF_ASCIIHexDecode: public QPDFStreamFilter
SF_ASCIIHexDecode() = default;
virtual ~SF_ASCIIHexDecode() = default;
- virtual Pipeline*
+ Pipeline*
getDecodePipeline(Pipeline* next) override
{
this->pipeline =
diff --git a/libqpdf/qpdf/SF_DCTDecode.hh b/libqpdf/qpdf/SF_DCTDecode.hh
index f9b1af3a..997ba89a 100644
--- a/libqpdf/qpdf/SF_DCTDecode.hh
+++ b/libqpdf/qpdf/SF_DCTDecode.hh
@@ -11,7 +11,7 @@ class SF_DCTDecode: public QPDFStreamFilter
SF_DCTDecode() = default;
virtual ~SF_DCTDecode() = default;
- virtual Pipeline*
+ Pipeline*
getDecodePipeline(Pipeline* next) override
{
this->pipeline = std::make_shared<Pl_DCT>("DCT decode", next);
@@ -24,13 +24,13 @@ class SF_DCTDecode: public QPDFStreamFilter
return std::make_shared<SF_DCTDecode>();
}
- virtual bool
+ bool
isSpecializedCompression() override
{
return true;
}
- virtual bool
+ bool
isLossyCompression() override
{
return true;
diff --git a/libqpdf/qpdf/SF_RunLengthDecode.hh b/libqpdf/qpdf/SF_RunLengthDecode.hh
index a1c8c80a..9dec379d 100644
--- a/libqpdf/qpdf/SF_RunLengthDecode.hh
+++ b/libqpdf/qpdf/SF_RunLengthDecode.hh
@@ -11,7 +11,7 @@ class SF_RunLengthDecode: public QPDFStreamFilter
SF_RunLengthDecode() = default;
virtual ~SF_RunLengthDecode() = default;
- virtual Pipeline*
+ Pipeline*
getDecodePipeline(Pipeline* next) override
{
this->pipeline = std::make_shared<Pl_RunLength>(
@@ -25,7 +25,7 @@ class SF_RunLengthDecode: public QPDFStreamFilter
return std::make_shared<SF_RunLengthDecode>();
}
- virtual bool
+ bool
isSpecializedCompression() override
{
return true;
diff --git a/libqpdf/qpdfjob-c.cc b/libqpdf/qpdfjob-c.cc
index ddb33349..2e78672f 100644
--- a/libqpdf/qpdfjob-c.cc
+++ b/libqpdf/qpdfjob-c.cc
@@ -1,14 +1,12 @@
#include <qpdf/qpdfjob-c.h>
#include <qpdf/QPDFJob.hh>
-#include <qpdf/QPDFLogger.hh>
#include <qpdf/QPDFUsage.hh>
#include <qpdf/QUtil.hh>
#include <qpdf/qpdf-c_impl.hh>
#include <qpdf/qpdflogger-c_impl.hh>
#include <cstdio>
-#include <cstring>
struct _qpdfjob_handle
{
diff --git a/libqpdf/qpdflogger-c.cc b/libqpdf/qpdflogger-c.cc
index 2a6d1052..c713dfb4 100644
--- a/libqpdf/qpdflogger-c.cc
+++ b/libqpdf/qpdflogger-c.cc
@@ -4,7 +4,6 @@
#include <qpdf/Pipeline.hh>
#include <qpdf/Pl_Function.hh>
-#include <qpdf/QIntC.hh>
#include <qpdf/QPDFLogger.hh>
#include <functional>
#include <memory>
diff --git a/libtests/aes.cc b/libtests/aes.cc
index 3ad491cc..a981fc22 100644
--- a/libtests/aes.cc
+++ b/libtests/aes.cc
@@ -4,9 +4,9 @@
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
static void
usage()
@@ -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();
}
@@ -74,21 +74,21 @@ main(int argc, char* argv[])
FILE* infile = QUtil::safe_fopen(infilename, "rb");
FILE* outfile = QUtil::safe_fopen(outfilename, "wb");
- unsigned char* key = new unsigned char[keylen];
+ auto* key = new unsigned char[keylen];
for (unsigned int i = 0; i < strlen(hexkey); i += 2) {
char t[3];
t[0] = hexkey[i];
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);
+ auto* out = new Pl_StdioFile("stdout", outfile);
+ auto* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen);
delete[] key;
- key = 0;
+ key = nullptr;
if (!cbc_mode) {
aes->disableCBC();
}
diff --git a/libtests/arg_parser.cc b/libtests/arg_parser.cc
index 9e3e8da5..c9474d55 100644
--- a/libtests/arg_parser.cc
+++ b/libtests/arg_parser.cc
@@ -2,7 +2,6 @@
#include <qpdf/QPDFArgParser.hh>
#include <qpdf/QPDFUsage.hh>
-#include <qpdf/QUtil.hh>
#include <cstring>
#include <iostream>
@@ -52,7 +51,7 @@ ArgParser::initOptions()
ap.addBare("potato", b(&ArgParser::handlePotato));
ap.addRequiredParameter("salad", p(&ArgParser::handleSalad), "tossed");
ap.addOptionalParameter("moo", p(&ArgParser::handleMoo));
- char const* choices[] = {"pig", "boar", "sow", 0};
+ char const* choices[] = {"pig", "boar", "sow", nullptr};
ap.addChoices("oink", p(&ArgParser::handleOink), true, choices);
ap.selectHelpOptionTable();
ap.addBare("version", [this]() { output("3.14159"); });
diff --git a/libtests/ascii85.cc b/libtests/ascii85.cc
index 2acc56ba..8d926898 100644
--- a/libtests/ascii85.cc
+++ b/libtests/ascii85.cc
@@ -2,7 +2,7 @@
#include <qpdf/Pl_StdioFile.hh>
#include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
int
main()
diff --git a/libtests/bits.cc b/libtests/bits.cc
index 07870eb7..af715da8 100644
--- a/libtests/bits.cc
+++ b/libtests/bits.cc
@@ -4,8 +4,7 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdlib>
// See comments in bits_functions.hh
#define BITS_TESTING 1
@@ -142,7 +141,7 @@ test()
unsigned char ch = 0;
bit_offset = 7;
- Pl_Buffer* bp = new Pl_Buffer("buffer");
+ auto* bp = new Pl_Buffer("buffer");
test_write_bits(ch, bit_offset, 30UL, 5, bp);
test_write_bits(ch, bit_offset, 10UL, 4, bp);
diff --git a/libtests/buffer.cc b/libtests/buffer.cc
index f372e7b4..66eaa71c 100644
--- a/libtests/buffer.cc
+++ b/libtests/buffer.cc
@@ -7,7 +7,7 @@
#include <cstring>
#include <iostream>
#include <stdexcept>
-#include <stdlib.h>
+#include <cstdlib>
static unsigned char*
uc(char const* s)
diff --git a/libtests/closed_file_input_source.cc b/libtests/closed_file_input_source.cc
index e4c8ed36..183658a9 100644
--- a/libtests/closed_file_input_source.cc
+++ b/libtests/closed_file_input_source.cc
@@ -2,9 +2,7 @@
#include <qpdf/FileInputSource.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
void
check(std::string const& what, bool result)
diff --git a/libtests/cxx11.cc b/libtests/cxx11.cc
index ac18e13e..5f0dcc9a 100644
--- a/libtests/cxx11.cc
+++ b/libtests/cxx11.cc
@@ -1,6 +1,5 @@
#include <qpdf/assert_test.h>
-#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <functional>
diff --git a/libtests/dct_compress.cc b/libtests/dct_compress.cc
index ad8710b1..1f969982 100644
--- a/libtests/dct_compress.cc
+++ b/libtests/dct_compress.cc
@@ -3,9 +3,9 @@
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
static void
usage()
@@ -22,8 +22,8 @@ class Callback: public Pl_DCT::CompressConfig
called(false)
{
}
- virtual ~Callback() = default;
- virtual void apply(jpeg_compress_struct*);
+ ~Callback() override = default;
+ void apply(jpeg_compress_struct*) override;
bool called;
};
diff --git a/libtests/dct_uncompress.cc b/libtests/dct_uncompress.cc
index 1ab22e97..6606e4a5 100644
--- a/libtests/dct_uncompress.cc
+++ b/libtests/dct_uncompress.cc
@@ -3,9 +3,8 @@
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
int
main(int argc, char* argv[])
diff --git a/libtests/flate.cc b/libtests/flate.cc
index 77fb440e..9b64ca67 100644
--- a/libtests/flate.cc
+++ b/libtests/flate.cc
@@ -4,10 +4,8 @@
#include <qpdf/Pl_StdioFile.hh>
#include <qpdf/QUtil.hh>
-#include <errno.h>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
void
run(char const* filename)
@@ -30,7 +28,7 @@ run(char const* filename)
Pipeline* inf2 = new Pl_Flate("inf2", out2, Pl_Flate::a_inflate);
// Count bytes written to o3
- Pl_Count* count3 = new Pl_Count("count3", out3);
+ auto* count3 = new Pl_Count("count3", out3);
// Do both simultaneously
Pipeline* inf3 = new Pl_Flate("inf3", count3, Pl_Flate::a_inflate);
diff --git a/libtests/hex.cc b/libtests/hex.cc
index 9e708204..d239d202 100644
--- a/libtests/hex.cc
+++ b/libtests/hex.cc
@@ -2,7 +2,7 @@
#include <qpdf/Pl_StdioFile.hh>
#include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
int
main()
diff --git a/libtests/input_source.cc b/libtests/input_source.cc
index 83744250..9ab41b5d 100644
--- a/libtests/input_source.cc
+++ b/libtests/input_source.cc
@@ -24,8 +24,8 @@ class Finder: public InputSource::Finder
after(after)
{
}
- virtual ~Finder() = default;
- virtual bool check();
+ ~Finder() override = default;
+ bool check() override;
private:
std::shared_ptr<InputSource> is;
diff --git a/libtests/json_parse.cc b/libtests/json_parse.cc
index 721b17de..31381ebf 100644
--- a/libtests/json_parse.cc
+++ b/libtests/json_parse.cc
@@ -1,6 +1,5 @@
#include <qpdf/FileInputSource.hh>
#include <qpdf/JSON.hh>
-#include <qpdf/QUtil.hh>
#include <cstdlib>
#include <cstring>
#include <iostream>
@@ -12,13 +11,13 @@ namespace
{
public:
virtual ~Reactor() = default;
- virtual void dictionaryStart() override;
- virtual void arrayStart() override;
- virtual void containerEnd(JSON const& value) override;
- virtual void topLevelScalar() override;
- virtual bool
+ void dictionaryStart() override;
+ void arrayStart() override;
+ void containerEnd(JSON const& value) override;
+ void topLevelScalar() override;
+ bool
dictionaryItem(std::string const& key, JSON const& value) override;
- virtual bool arrayItem(JSON const& value) override;
+ bool arrayItem(JSON const& value) override;
private:
void printItem(JSON const&);
diff --git a/libtests/logger_c.c b/libtests/logger_c.c
index 5c4c519a..c3fa0d8c 100644
--- a/libtests/logger_c.c
+++ b/libtests/logger_c.c
@@ -2,7 +2,6 @@
#include <qpdf/qpdflogger-c.h>
-#include <qpdf/Constants.h>
#include <qpdf/qpdfjob-c.h>
#include <stdio.h>
diff --git a/libtests/lzw.cc b/libtests/lzw.cc
index 788d3dfc..412ce4c5 100644
--- a/libtests/lzw.cc
+++ b/libtests/lzw.cc
@@ -3,8 +3,8 @@
#include <qpdf/Pl_StdioFile.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
int
main(int argc, char* argv[])
diff --git a/libtests/md5.cc b/libtests/md5.cc
index 0fe4205e..27aaad51 100644
--- a/libtests/md5.cc
+++ b/libtests/md5.cc
@@ -3,7 +3,7 @@
#include <qpdf/Pl_MD5.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
+#include <cstdio>
static void
test_string(char const* str)
diff --git a/libtests/numrange.cc b/libtests/numrange.cc
index c0bf5bd7..ded03324 100644
--- a/libtests/numrange.cc
+++ b/libtests/numrange.cc
@@ -4,7 +4,7 @@
static void
test_numrange(char const* range)
{
- if (range == 0) {
+ if (range == nullptr) {
std::cout << "null" << std::endl;
} else {
std::vector<int> result = QUtil::parse_numrange(range, 15);
diff --git a/libtests/pointer_holder.cc b/libtests/pointer_holder.cc
index f03c4257..4b9d43cb 100644
--- a/libtests/pointer_holder.cc
+++ b/libtests/pointer_holder.cc
@@ -7,7 +7,6 @@
#include <iostream>
#include <list>
-#include <stdlib.h>
class Object
{
@@ -73,7 +72,7 @@ test_ph()
ObjectHolder oh0;
{
std::cout << "hello" << std::endl;
- Object* o1 = new Object;
+ auto* o1 = new Object;
ObjectHolder oh1(o1);
std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl;
ObjectHolder oh2(oh1);
@@ -96,7 +95,7 @@ test_ph()
}
ol1.push_back(oh3);
ol1.push_back(oh3);
- Object* o3 = new Object;
+ auto* o3 = new Object;
oh0 = o3;
PointerHolder<Object const> oh6(new Object());
oh6->hello();
diff --git a/libtests/predictors.cc b/libtests/predictors.cc
index a8f6c5d9..d7825bc6 100644
--- a/libtests/predictors.cc
+++ b/libtests/predictors.cc
@@ -6,10 +6,9 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QUtil.hh>
-#include <errno.h>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
void
run(char const* filename,
@@ -22,7 +21,7 @@ run(char const* filename,
FILE* in = QUtil::safe_fopen(filename, "rb");
FILE* o1 = QUtil::safe_fopen("out", "wb");
Pipeline* out = new Pl_StdioFile("out", o1);
- Pipeline* pl = 0;
+ Pipeline* pl = nullptr;
if (strcmp(filter, "png") == 0) {
pl = new Pl_PNGFilter(
"png",
diff --git a/libtests/qintc.cc b/libtests/qintc.cc
index f6c15f00..5b985644 100644
--- a/libtests/qintc.cc
+++ b/libtests/qintc.cc
@@ -1,7 +1,7 @@
#include <qpdf/assert_test.h>
#include <qpdf/QIntC.hh>
-#include <stdint.h>
+#include <cstdint>
#define try_convert(exp_pass, fn, i) \
try_convert_real(#fn "(" #i ")", exp_pass, fn, i)
@@ -74,7 +74,7 @@ main()
uint64_t ul1 = 1099511627776LL; // Too big for 32-bit
uint64_t ul2 = 12345; // Fits into 32-bit
int32_t i2 = 81; // Fits in char and uchar
- signed char c1 = static_cast<signed char>('\xf7'); // Signed value when char
+ auto c1 = static_cast<signed char>('\xf7'); // Signed value when char
char c2 = 'W'; // char; may be signed or unsigned
// Verify i1 and u1 have same bit pattern
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index 66264d19..be5b6b1b 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -3,15 +3,11 @@
#include <qpdf/Pl_Buffer.hh>
#include <qpdf/QPDFSystemError.hh>
#include <qpdf/QUtil.hh>
-#include <fcntl.h>
#include <fstream>
#include <iostream>
-#include <limits.h>
-#include <locale>
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include <climits>
+#include <cstdio>
+#include <cstring>
#ifdef _WIN32
# include <io.h>
@@ -493,7 +489,7 @@ same_file_test()
assert_same_file("qutil.out", "qutil.out", true);
assert_same_file("qutil.out", "other-file", false);
assert_same_file("qutil.out", "", false);
- assert_same_file("qutil.out", 0, false);
+ assert_same_file("qutil.out", nullptr, false);
assert_same_file("", "qutil.out", false);
}
diff --git a/libtests/random.cc b/libtests/random.cc
index ad7d105d..899c264c 100644
--- a/libtests/random.cc
+++ b/libtests/random.cc
@@ -1,7 +1,6 @@
#include <qpdf/InsecureRandomDataProvider.hh>
#include <qpdf/QUtil.hh>
#include <qpdf/SecureRandomDataProvider.hh>
-#include <qpdf/qpdf-config.h>
#include <iostream>
class BogusRandomDataProvider: public RandomDataProvider
@@ -57,7 +56,7 @@ main()
if (!((buf[0] == 0) && (buf[1] == 1) && (buf[2] == 2) && (buf[3] == 3))) {
std::cout << "fail: bogus random didn't provide correct bytes\n";
}
- QUtil::setRandomDataProvider(0);
+ QUtil::setRandomDataProvider(nullptr);
if (QUtil::getRandomDataProvider() != orig_rdp) {
std::cout << "fail: passing null to setRandomDataProvider "
"didn't reset the random data provider\n";
diff --git a/libtests/rc4.cc b/libtests/rc4.cc
index a6a1328e..300c6201 100644
--- a/libtests/rc4.cc
+++ b/libtests/rc4.cc
@@ -6,9 +6,9 @@
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
static void
other_tests()
@@ -41,7 +41,7 @@ main(int argc, char* argv[])
char* outfilename = argv[3];
unsigned int hexkeylen = QIntC::to_uint(strlen(hexkey));
unsigned int keylen = hexkeylen / 2;
- unsigned char* key = new unsigned char[keylen + 1];
+ auto* key = new unsigned char[keylen + 1];
key[keylen] = '\0';
FILE* infile = QUtil::safe_fopen(infilename, "rb");
@@ -51,14 +51,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);
}
FILE* outfile = QUtil::safe_fopen(outfilename, "wb");
- Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile);
+ auto* out = new Pl_StdioFile("stdout", outfile);
// Use a small buffer size (64) for testing
- Pl_RC4* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U);
+ auto* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U);
delete[] key;
// 64 < buffer size < 512, buffer_size is not a power of 2 for testing
diff --git a/libtests/runlength.cc b/libtests/runlength.cc
index 456e33a2..260ce5cb 100644
--- a/libtests/runlength.cc
+++ b/libtests/runlength.cc
@@ -3,9 +3,9 @@
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
int
main(int argc, char* argv[])
diff --git a/libtests/sha2.cc b/libtests/sha2.cc
index 65b70c39..4be8956a 100644
--- a/libtests/sha2.cc
+++ b/libtests/sha2.cc
@@ -1,8 +1,7 @@
#include <qpdf/Pl_SHA2.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstring>
static void
test(
diff --git a/qpdf/fix-qdf.cc b/qpdf/fix-qdf.cc
index 34b3d3dc..1d46971c 100644
--- a/qpdf/fix-qdf.cc
+++ b/qpdf/fix-qdf.cc
@@ -8,7 +8,7 @@
#include <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);
diff --git a/qpdf/pdf_from_scratch.cc b/qpdf/pdf_from_scratch.cc
index bdcdaae1..41e52f9c 100644
--- a/qpdf/pdf_from_scratch.cc
+++ b/qpdf/pdf_from_scratch.cc
@@ -3,14 +3,13 @@
#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QPDFPageDocumentHelper.hh>
#include <qpdf/QPDFWriter.hh>
-#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
-static char const* whoami = 0;
+static char const* whoami = nullptr;
void
usage()
@@ -87,7 +86,7 @@ int
main(int argc, char* argv[])
{
QUtil::setLineBuf(stdout);
- if ((whoami = strrchr(argv[0], '/')) == NULL) {
+ if ((whoami = strrchr(argv[0], '/')) == nullptr) {
whoami = argv[0];
} else {
++whoami;
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index ea7f338a..08e94d38 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -4,10 +4,9 @@
#include <cstdio>
#include <cstdlib>
-#include <cstring>
#include <iostream>
-static char const* whoami = 0;
+static char const* whoami = nullptr;
static void
usageExit(std::string const& msg)
diff --git a/qpdf/qpdfjob-ctest.c b/qpdf/qpdfjob-ctest.c
index 31f22d28..62da7fe5 100644
--- a/qpdf/qpdfjob-ctest.c
+++ b/qpdf/qpdfjob-ctest.c
@@ -2,7 +2,6 @@
#include <qpdf/qpdfjob-c.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#ifndef QPDF_NO_WCHAR_T
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 4a5d0ae8..da1be6c0 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -26,19 +26,18 @@
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
-#include <algorithm>
#include <iostream>
-#include <limits.h>
+#include <climits>
#include <map>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#define QPDF_OBJECT_NOWARN
#include <qpdf/QPDFObject.hh>
-static char const* whoami = 0;
+static char const* whoami = nullptr;
void
usage()
@@ -287,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);
@@ -388,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();
@@ -500,7 +499,7 @@ test_8(QPDF& pdf, char const* arg2)
auto b = p1.getBufferSharedPointer();
// This is a bogus way to use StreamDataProvider, but it does
// adequately test its functionality.
- Provider* provider = new Provider(b);
+ auto* provider = new Provider(b);
auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(provider);
qstream.replaceStreamData(
p,
@@ -600,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
@@ -1010,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;
@@ -1036,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");
@@ -1069,7 +1068,7 @@ test_27(QPDF& pdf, char const* arg2)
pl.writeCStr("new data for stream\n");
pl.finish();
auto b = pl.getBufferSharedPointer();
- Provider* provider = new Provider(b);
+ auto* provider = new Provider(b);
p1 = decltype(p1)(provider);
}
// Create a stream that uses a provider in empty1 and copy it
@@ -1096,7 +1095,7 @@ test_27(QPDF& pdf, char const* arg2)
pl.writeCStr("more data for stream\n");
pl.finish();
auto b = pl.getBufferSharedPointer();
- Provider* provider = new Provider(b);
+ auto* provider = new Provider(b);
p2 = decltype(p2)(provider);
}
QPDF empty3;
@@ -1105,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");
@@ -1152,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
@@ -1202,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");
@@ -1434,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);
@@ -3559,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) {
@@ -3653,7 +3652,7 @@ int
main(int argc, char* argv[])
{
QUtil::setLineBuf(stdout);
- if ((whoami = strrchr(argv[0], '/')) == NULL) {
+ if ((whoami = strrchr(argv[0], '/')) == nullptr) {
whoami = argv[0];
} else {
++whoami;
diff --git a/qpdf/test_large_file.cc b/qpdf/test_large_file.cc
index e8bea103..cfd1c5db 100644
--- a/qpdf/test_large_file.cc
+++ b/qpdf/test_large_file.cc
@@ -13,8 +13,8 @@
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
// Run "test_large_file write small a.pdf" to get a PDF file that you
// can look at in a reader.
@@ -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;
@@ -218,7 +218,7 @@ create_pdf(char const* filename)
image_dict.replaceKey("/BitsPerComponent", newInteger(8));
image_dict.replaceKey("/Width", newInteger(width));
image_dict.replaceKey("/Height", newInteger(height));
- ImageProvider* p = new ImageProvider(pageno);
+ auto* p = new ImageProvider(pageno);
std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
image.replaceStreamData(
provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
diff --git a/qpdf/test_pdf_doc_encoding.cc b/qpdf/test_pdf_doc_encoding.cc
index 5c67f59a..e7aba030 100644
--- a/qpdf/test_pdf_doc_encoding.cc
+++ b/qpdf/test_pdf_doc_encoding.cc
@@ -1,10 +1,10 @@
#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#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;
diff --git a/qpdf/test_pdf_unicode.cc b/qpdf/test_pdf_unicode.cc
index 38df6daa..325fcad8 100644
--- a/qpdf/test_pdf_unicode.cc
+++ b/qpdf/test_pdf_unicode.cc
@@ -1,10 +1,10 @@
#include <qpdf/QPDFObjectHandle.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
+#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;
diff --git a/qpdf/test_renumber.cc b/qpdf/test_renumber.cc
index 7edec21b..1b828128 100644
--- a/qpdf/test_renumber.cc
+++ b/qpdf/test_renumber.cc
@@ -1,4 +1,3 @@
-#include <qpdf/Buffer.hh>
#include <qpdf/Constants.h>
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFObjGen.hh>
@@ -6,7 +5,6 @@
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QPDFXRefEntry.hh>
-#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <set>
diff --git a/qpdf/test_shell_glob.cc b/qpdf/test_shell_glob.cc
index c2cfb422..492e117d 100644
--- a/qpdf/test_shell_glob.cc
+++ b/qpdf/test_shell_glob.cc
@@ -1,5 +1,4 @@
#include <qpdf/QUtil.hh>
-#include <cstring>
#include <iostream>
int
diff --git a/qpdf/test_tokenizer.cc b/qpdf/test_tokenizer.cc
index f465cd46..507de459 100644
--- a/qpdf/test_tokenizer.cc
+++ b/qpdf/test_tokenizer.cc
@@ -4,15 +4,14 @@
#include <qpdf/QIntC.hh>
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFPageDocumentHelper.hh>
-#include <qpdf/QPDFPageObjectHelper.hh>
#include <qpdf/QPDFTokenizer.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
-static char const* whoami = 0;
+static char const* whoami = nullptr;
void
usage()
@@ -92,7 +91,7 @@ tokenTypeName(QPDFTokenizer::token_type_e ttype)
case QPDFTokenizer::tt_inline_image:
return "inline-image";
}
- return 0;
+ return nullptr;
}
static std::string
@@ -191,7 +190,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
std::shared_ptr<InputSource> is;
// Tokenize file, skipping streams
- FileInputSource* fis = new FileInputSource(filename);
+ auto* fis = new FileInputSource(filename);
is = std::shared_ptr<InputSource>(fis);
dump_tokens(is, "FILE", max_len, include_ignorable, true, false);
@@ -204,7 +203,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
Pl_Buffer plb("buffer");
page.pipeContents(&plb);
auto content_data = plb.getBufferSharedPointer();
- BufferInputSource* bis =
+ auto* bis =
new BufferInputSource("content data", content_data.get());
is = std::shared_ptr<InputSource>(bis);
dump_tokens(
@@ -221,7 +220,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
if (obj.isStream() && obj.getDict().getKey("/Type").isName() &&
obj.getDict().getKey("/Type").getName() == "/ObjStm") {
std::shared_ptr<Buffer> b = obj.getStreamData(qpdf_dl_specialized);
- BufferInputSource* bis =
+ auto* bis =
new BufferInputSource("object stream data", b.get());
is = std::shared_ptr<InputSource>(bis);
dump_tokens(
@@ -239,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) {
@@ -266,7 +265,7 @@ main(int argc, char* argv[])
filename = argv[i];
}
}
- if (filename == 0) {
+ if (filename == nullptr) {
usage();
}
diff --git a/qpdf/test_unicode_filenames.cc b/qpdf/test_unicode_filenames.cc
index 3d9e8038..16478161 100644
--- a/qpdf/test_unicode_filenames.cc
+++ b/qpdf/test_unicode_filenames.cc
@@ -6,13 +6,13 @@
#endif
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
static void
do_copy(FILE* in, FILE* out)
{
- if ((in == 0) || (out == 0)) {
+ if ((in == nullptr) || (out == nullptr)) {
std::cerr << "errors opening files" << std::endl;
exit(2);
}
diff --git a/qpdf/test_xref.cc b/qpdf/test_xref.cc
index d01ac046..6ecb9a00 100644
--- a/qpdf/test_xref.cc
+++ b/qpdf/test_xref.cc
@@ -1,11 +1,8 @@
#include <qpdf/QPDF.hh>
-#include <qpdf/QPDFObjGen.hh>
-#include <qpdf/QPDFXRefEntry.hh>
#include <cstdlib>
#include <iostream>
#include <map>
-#include <string>
int
main(int argc, char* argv[])
diff --git a/zlib-flate/zlib-flate.cc b/zlib-flate/zlib-flate.cc
index f7d0c807..d1311c84 100644
--- a/zlib-flate/zlib-flate.cc
+++ b/zlib-flate/zlib-flate.cc
@@ -5,11 +5,11 @@
#include <fcntl.h>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#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;