Commit fd17c8e3fe38a56abf50ce0edec1cde48d4f74cb

Authored by Jay Berkenbilt
Committed by GitHub
2 parents a6d7b79e e6577a13

Merge pull request #963 from m-holger/tidy

Code tidy
Showing 148 changed files with 400 additions and 483 deletions
examples/pdf-bookmarks.cc
@@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
5 #include <qpdf/QTC.hh> 5 #include <qpdf/QTC.hh>
6 #include <qpdf/QUtil.hh> 6 #include <qpdf/QUtil.hh>
7 #include <iostream> 7 #include <iostream>
8 -#include <stdlib.h>  
9 -#include <string.h> 8 +#include <cstdlib>
  9 +#include <cstring>
10 10
11 // This program demonstrates extraction of bookmarks using the qpdf 11 // This program demonstrates extraction of bookmarks using the qpdf
12 // outlines API. Note that all the information shown by this program 12 // outlines API. Note that all the information shown by this program
examples/pdf-count-strings.cc
@@ -5,14 +5,12 @@ @@ -5,14 +5,12 @@
5 // 5 //
6 6
7 #include <iostream> 7 #include <iostream>
8 -#include <stdlib.h>  
9 -#include <string.h> 8 +#include <cstdlib>
10 9
11 #include <qpdf/Pl_StdioFile.hh> 10 #include <qpdf/Pl_StdioFile.hh>
12 #include <qpdf/QPDF.hh> 11 #include <qpdf/QPDF.hh>
13 #include <qpdf/QPDFObjectHandle.hh> 12 #include <qpdf/QPDFObjectHandle.hh>
14 #include <qpdf/QPDFPageDocumentHelper.hh> 13 #include <qpdf/QPDFPageDocumentHelper.hh>
15 -#include <qpdf/QPDFPageObjectHelper.hh>  
16 #include <qpdf/QUtil.hh> 14 #include <qpdf/QUtil.hh>
17 15
18 static char const* whoami = nullptr; 16 static char const* whoami = nullptr;
@@ -32,9 +30,9 @@ class StringCounter: public QPDFObjectHandle::TokenFilter @@ -32,9 +30,9 @@ class StringCounter: public QPDFObjectHandle::TokenFilter
32 count(0) 30 count(0)
33 { 31 {
34 } 32 }
35 - virtual ~StringCounter() = default;  
36 - virtual void handleToken(QPDFTokenizer::Token const&);  
37 - virtual void handleEOF(); 33 + ~StringCounter() override = default;
  34 + void handleToken(QPDFTokenizer::Token const&) override;
  35 + void handleEOF() override;
38 int getCount() const; 36 int getCount() const;
39 37
40 private: 38 private:
examples/pdf-create.cc
@@ -12,13 +12,11 @@ @@ -12,13 +12,11 @@
12 #include <qpdf/QPDF.hh> 12 #include <qpdf/QPDF.hh>
13 #include <qpdf/QPDFObjectHandle.hh> 13 #include <qpdf/QPDFObjectHandle.hh>
14 #include <qpdf/QPDFPageDocumentHelper.hh> 14 #include <qpdf/QPDFPageDocumentHelper.hh>
15 -#include <qpdf/QPDFPageObjectHelper.hh>  
16 #include <qpdf/QPDFWriter.hh> 15 #include <qpdf/QPDFWriter.hh>
17 #include <qpdf/QUtil.hh> 16 #include <qpdf/QUtil.hh>
18 #include <iostream> 17 #include <iostream>
19 #include <memory> 18 #include <memory>
20 -#include <stdlib.h>  
21 -#include <string.h> 19 +#include <cstdlib>
22 20
23 static char const* whoami = nullptr; 21 static char const* whoami = nullptr;
24 22
@@ -28,8 +26,8 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider @@ -28,8 +26,8 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider
28 { 26 {
29 public: 27 public:
30 ImageProvider(std::string const& color_space, std::string const& filter); 28 ImageProvider(std::string const& color_space, std::string const& filter);
31 - virtual ~ImageProvider() = default;  
32 - virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline); 29 + ~ImageProvider() override = default;
  30 + void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
33 size_t getWidth() const; 31 size_t getWidth() const;
34 size_t getHeight() const; 32 size_t getHeight() const;
35 33
@@ -168,7 +166,7 @@ add_page( @@ -168,7 +166,7 @@ add_page(
168 // mode. Since we are not specifying, QPDFWriter will compress 166 // mode. Since we are not specifying, QPDFWriter will compress
169 // with /FlateDecode if we don't provide any other form of 167 // with /FlateDecode if we don't provide any other form of
170 // compression. 168 // compression.
171 - ImageProvider* p = new ImageProvider(color_space, filter); 169 + auto* p = new ImageProvider(color_space, filter);
172 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); 170 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
173 size_t width = p->getWidth(); 171 size_t width = p->getWidth();
174 size_t height = p->getHeight(); 172 size_t height = p->getHeight();
@@ -288,7 +286,7 @@ check( @@ -288,7 +286,7 @@ check(
288 if (!this_errors) { 286 if (!this_errors) {
289 // Check image data 287 // Check image data
290 auto actual_data = image.getStreamData(qpdf_dl_all); 288 auto actual_data = image.getStreamData(qpdf_dl_all);
291 - ImageProvider* p = new ImageProvider(desired_color_space, "null"); 289 + auto* p = new ImageProvider(desired_color_space, "null");
292 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); 290 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
293 Pl_Buffer b_p("get image data"); 291 Pl_Buffer b_p("get image data");
294 provider->provideStreamData(QPDFObjGen(), &b_p); 292 provider->provideStreamData(QPDFObjGen(), &b_p);
examples/pdf-custom-filter.cc
@@ -48,9 +48,9 @@ class Pl_XOR: public Pipeline @@ -48,9 +48,9 @@ class Pl_XOR: public Pipeline
48 48
49 public: 49 public:
50 Pl_XOR(char const* identifier, Pipeline* next, unsigned char key); 50 Pl_XOR(char const* identifier, Pipeline* next, unsigned char key);
51 - virtual ~Pl_XOR() = default;  
52 - virtual void write(unsigned char const* data, size_t len) override;  
53 - virtual void finish() override; 51 + ~Pl_XOR() override = default;
  52 + void write(unsigned char const* data, size_t len) override;
  53 + void finish() override;
54 54
55 private: 55 private:
56 unsigned char key; 56 unsigned char key;
@@ -91,10 +91,10 @@ class SF_XORDecode: public QPDFStreamFilter @@ -91,10 +91,10 @@ class SF_XORDecode: public QPDFStreamFilter
91 // filter, which just means QPDF assumes that it should not 91 // filter, which just means QPDF assumes that it should not
92 // "uncompress" the stream by default. 92 // "uncompress" the stream by default.
93 public: 93 public:
94 - virtual ~SF_XORDecode() = default;  
95 - virtual bool setDecodeParms(QPDFObjectHandle decode_parms) override;  
96 - virtual Pipeline* getDecodePipeline(Pipeline* next) override;  
97 - virtual bool isSpecializedCompression() override; 94 + ~SF_XORDecode() override = default;
  95 + bool setDecodeParms(QPDFObjectHandle decode_parms) override;
  96 + Pipeline* getDecodePipeline(Pipeline* next) override;
  97 + bool isSpecializedCompression() override;
98 98
99 private: 99 private:
100 unsigned char key; 100 unsigned char key;
@@ -199,8 +199,8 @@ class StreamReplacer: public QPDFObjectHandle::StreamDataProvider @@ -199,8 +199,8 @@ class StreamReplacer: public QPDFObjectHandle::StreamDataProvider
199 199
200 public: 200 public:
201 StreamReplacer(QPDF* pdf); 201 StreamReplacer(QPDF* pdf);
202 - virtual ~StreamReplacer() = default;  
203 - virtual void 202 + ~StreamReplacer() override = default;
  203 + void
204 provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override; 204 provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
205 205
206 void registerStream( 206 void registerStream(
@@ -409,7 +409,7 @@ process( @@ -409,7 +409,7 @@ process(
409 // Create a single StreamReplacer instance. The interface requires 409 // Create a single StreamReplacer instance. The interface requires
410 // a std::shared_ptr in various places, so allocate a StreamReplacer 410 // a std::shared_ptr in various places, so allocate a StreamReplacer
411 // and stash it in a std::shared_ptr. 411 // and stash it in a std::shared_ptr.
412 - StreamReplacer* replacer = new StreamReplacer(&qpdf); 412 + auto* replacer = new StreamReplacer(&qpdf);
413 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> p(replacer); 413 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> p(replacer);
414 414
415 for (auto& o: qpdf.getAllObjects()) { 415 for (auto& o: qpdf.getAllObjects()) {
examples/pdf-double-page-size.cc
@@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
5 #include <qpdf/QPDFWriter.hh> 5 #include <qpdf/QPDFWriter.hh>
6 #include <qpdf/QUtil.hh> 6 #include <qpdf/QUtil.hh>
7 #include <iostream> 7 #include <iostream>
8 -#include <stdlib.h>  
9 -#include <string.h> 8 +#include <cstdlib>
  9 +#include <cstring>
10 10
11 static char const* whoami = nullptr; 11 static char const* whoami = nullptr;
12 12
examples/pdf-filter-tokens.cc
@@ -8,13 +8,11 @@ @@ -8,13 +8,11 @@
8 #include <algorithm> 8 #include <algorithm>
9 #include <deque> 9 #include <deque>
10 #include <iostream> 10 #include <iostream>
11 -#include <stdlib.h>  
12 -#include <string.h> 11 +#include <cstdlib>
13 12
14 #include <qpdf/QPDF.hh> 13 #include <qpdf/QPDF.hh>
15 #include <qpdf/QPDFObjectHandle.hh> 14 #include <qpdf/QPDFObjectHandle.hh>
16 #include <qpdf/QPDFPageDocumentHelper.hh> 15 #include <qpdf/QPDFPageDocumentHelper.hh>
17 -#include <qpdf/QPDFPageObjectHelper.hh>  
18 #include <qpdf/QPDFWriter.hh> 16 #include <qpdf/QPDFWriter.hh>
19 #include <qpdf/QUtil.hh> 17 #include <qpdf/QUtil.hh>
20 18
@@ -35,8 +33,8 @@ usage() @@ -35,8 +33,8 @@ usage()
35 class StringReverser: public QPDFObjectHandle::TokenFilter 33 class StringReverser: public QPDFObjectHandle::TokenFilter
36 { 34 {
37 public: 35 public:
38 - virtual ~StringReverser() = default;  
39 - virtual void handleToken(QPDFTokenizer::Token const&); 36 + ~StringReverser() override = default;
  37 + void handleToken(QPDFTokenizer::Token const&) override;
40 }; 38 };
41 39
42 void 40 void
@@ -68,9 +66,9 @@ StringReverser::handleToken(QPDFTokenizer::Token const&amp; token) @@ -68,9 +66,9 @@ StringReverser::handleToken(QPDFTokenizer::Token const&amp; token)
68 class ColorToGray: public QPDFObjectHandle::TokenFilter 66 class ColorToGray: public QPDFObjectHandle::TokenFilter
69 { 67 {
70 public: 68 public:
71 - virtual ~ColorToGray() = default;  
72 - virtual void handleToken(QPDFTokenizer::Token const&);  
73 - virtual void handleEOF(); 69 + ~ColorToGray() override = default;
  70 + void handleToken(QPDFTokenizer::Token const&) override;
  71 + void handleEOF() override;
74 72
75 private: 73 private:
76 bool isNumeric(QPDFTokenizer::token_type_e); 74 bool isNumeric(QPDFTokenizer::token_type_e);
examples/pdf-invert-images.cc
@@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
6 #include <qpdf/QPDFWriter.hh> 6 #include <qpdf/QPDFWriter.hh>
7 #include <qpdf/QUtil.hh> 7 #include <qpdf/QUtil.hh>
8 #include <iostream> 8 #include <iostream>
9 -#include <stdlib.h>  
10 -#include <string.h> 9 +#include <cstdlib>
  10 +#include <cstring>
11 11
12 static char const* whoami = nullptr; 12 static char const* whoami = nullptr;
13 13
@@ -33,8 +33,8 @@ usage() @@ -33,8 +33,8 @@ usage()
33 class ImageInverter: public QPDFObjectHandle::StreamDataProvider 33 class ImageInverter: public QPDFObjectHandle::StreamDataProvider
34 { 34 {
35 public: 35 public:
36 - virtual ~ImageInverter() = default;  
37 - virtual void 36 + ~ImageInverter() override = default;
  37 + void
38 provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override; 38 provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
39 39
40 void registerImage( 40 void registerImage(
@@ -124,7 +124,7 @@ main(int argc, char* argv[]) @@ -124,7 +124,7 @@ main(int argc, char* argv[])
124 QPDF qpdf; 124 QPDF qpdf;
125 qpdf.processFile(infilename, password); 125 qpdf.processFile(infilename, password);
126 126
127 - ImageInverter* inv = new ImageInverter; 127 + auto* inv = new ImageInverter;
128 auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(inv); 128 auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(inv);
129 129
130 // For each page... 130 // For each page...
examples/pdf-mod-info.cc
@@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
6 #include <qpdf/QTC.hh> 6 #include <qpdf/QTC.hh>
7 #include <qpdf/QUtil.hh> 7 #include <qpdf/QUtil.hh>
8 #include <iostream> 8 #include <iostream>
9 -#include <stdio.h>  
10 -#include <stdlib.h>  
11 -#include <string.h> 9 +#include <cstdio>
  10 +#include <cstdlib>
  11 +#include <cstring>
12 12
13 static char const* version = "1.1"; 13 static char const* version = "1.1";
14 static char const* whoami = nullptr; 14 static char const* whoami = nullptr;
examples/pdf-name-number-tree.cc
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 #include <qpdf/QPDFNumberTreeObjectHelper.hh> 3 #include <qpdf/QPDFNumberTreeObjectHelper.hh>
4 #include <qpdf/QPDFWriter.hh> 4 #include <qpdf/QPDFWriter.hh>
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 -#include <cstring>  
7 #include <iostream> 6 #include <iostream>
8 7
9 static char const* whoami = nullptr; 8 static char const* whoami = nullptr;
examples/pdf-npages.cc
1 #include <iostream> 1 #include <iostream>
2 -#include <stdlib.h>  
3 -#include <string.h> 2 +#include <cstdlib>
  3 +#include <cstring>
4 4
5 #include <qpdf/QPDF.hh> 5 #include <qpdf/QPDF.hh>
6 #include <qpdf/QUtil.hh> 6 #include <qpdf/QUtil.hh>
examples/pdf-overlay-page.cc
@@ -4,8 +4,7 @@ @@ -4,8 +4,7 @@
4 #include <qpdf/QPDFWriter.hh> 4 #include <qpdf/QPDFWriter.hh>
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 #include <iostream> 6 #include <iostream>
7 -#include <stdlib.h>  
8 -#include <string.h> 7 +#include <cstdlib>
9 8
10 // This program demonstrates use of form XObjects to overlay a page 9 // This program demonstrates use of form XObjects to overlay a page
11 // from one file onto all pages of another file. The qpdf program's 10 // from one file onto all pages of another file. The qpdf program's
examples/pdf-parse-content.cc
1 #include <iostream> 1 #include <iostream>
2 -#include <stdlib.h>  
3 -#include <string.h> 2 +#include <cstdlib>
4 3
5 #include <qpdf/QIntC.hh> 4 #include <qpdf/QIntC.hh>
6 #include <qpdf/QPDF.hh> 5 #include <qpdf/QPDF.hh>
@@ -23,10 +22,10 @@ usage() @@ -23,10 +22,10 @@ usage()
23 class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks 22 class ParserCallbacks: public QPDFObjectHandle::ParserCallbacks
24 { 23 {
25 public: 24 public:
26 - virtual ~ParserCallbacks() = default;  
27 - virtual void contentSize(size_t);  
28 - virtual void handleObject(QPDFObjectHandle, size_t offset, size_t length);  
29 - virtual void handleEOF(); 25 + ~ParserCallbacks() override = default;
  26 + void contentSize(size_t) override;
  27 + void handleObject(QPDFObjectHandle, size_t offset, size_t length) override;
  28 + void handleEOF() override;
30 }; 29 };
31 30
32 void 31 void
examples/pdf-set-form-values.cc
@@ -4,9 +4,7 @@ @@ -4,9 +4,7 @@
4 #include <qpdf/QPDFWriter.hh> 4 #include <qpdf/QPDFWriter.hh>
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 #include <iostream> 6 #include <iostream>
7 -#include <stdio.h>  
8 -#include <stdlib.h>  
9 -#include <string.h> 7 +#include <cstdlib>
10 8
11 static char const* whoami = nullptr; 9 static char const* whoami = nullptr;
12 10
examples/pdf-split-pages.cc
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 12
13 #include <cstring> 13 #include <cstring>
14 #include <iostream> 14 #include <iostream>
15 -#include <stdlib.h> 15 +#include <cstdlib>
16 #include <string> 16 #include <string>
17 17
18 static bool static_id = false; 18 static bool static_id = false;
examples/qpdf-job.cc
1 -#include <qpdf/QIntC.hh>  
2 #include <qpdf/QPDFJob.hh> 1 #include <qpdf/QPDFJob.hh>
3 #include <qpdf/QUtil.hh> 2 #include <qpdf/QUtil.hh>
4 3
5 -#include <cstring>  
6 #include <iostream> 4 #include <iostream>
7 5
8 // This program is a simple demonstration of different ways to use the 6 // This program is a simple demonstration of different ways to use the
examples/qpdfjob-c-save-attachment.c
1 -#include <qpdf/Constants.h>  
2 #include <qpdf/qpdfjob-c.h> 1 #include <qpdf/qpdfjob-c.h>
3 #include <qpdf/qpdflogger-c.h> 2 #include <qpdf/qpdflogger-c.h>
4 3
examples/qpdfjob-remove-annotations.cc
@@ -4,7 +4,6 @@ @@ -4,7 +4,6 @@
4 4
5 #include <cstdio> 5 #include <cstdio>
6 #include <cstdlib> 6 #include <cstdlib>
7 -#include <cstring>  
8 #include <iostream> 7 #include <iostream>
9 8
10 // This example demonstrates how we can use the QPDFJob createQPDF and writeQPDF 9 // This example demonstrates how we can use the QPDFJob createQPDF and writeQPDF
@@ -12,7 +11,7 @@ @@ -12,7 +11,7 @@
12 // The example is a full copy of the qpdf program modified to allways remove all 11 // The example is a full copy of the qpdf program modified to allways remove all
13 // annotations from the final output. 12 // annotations from the final output.
14 13
15 -static char const* whoami = 0; 14 +static char const* whoami = nullptr;
16 15
17 static void 16 static void
18 usageExit(std::string const& msg) 17 usageExit(std::string const& msg)
fuzz/qpdf_fuzzer.cc
@@ -14,13 +14,13 @@ @@ -14,13 +14,13 @@
14 class DiscardContents: public QPDFObjectHandle::ParserCallbacks 14 class DiscardContents: public QPDFObjectHandle::ParserCallbacks
15 { 15 {
16 public: 16 public:
17 - virtual ~DiscardContents() = default;  
18 - virtual void  
19 - handleObject(QPDFObjectHandle) 17 + ~DiscardContents() override = default;
  18 + void
  19 + handleObject(QPDFObjectHandle) override
20 { 20 {
21 } 21 }
22 - virtual void  
23 - handleEOF() 22 + void
  23 + handleEOF() override
24 { 24 {
25 } 25 }
26 }; 26 };
include/qpdf/Buffer.hh
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 #include <qpdf/PointerHolder.hh> // unused -- remove in qpdf 12 (see #785) 26 #include <qpdf/PointerHolder.hh> // unused -- remove in qpdf 12 (see #785)
27 27
28 #include <memory> 28 #include <memory>
29 -#include <stddef.h> 29 +#include <cstddef>
30 30
31 class Buffer 31 class Buffer
32 { 32 {
include/qpdf/InputSource.hh
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 #include <qpdf/Types.h> 27 #include <qpdf/Types.h>
28 28
29 #include <memory> 29 #include <memory>
30 -#include <stdio.h> 30 +#include <cstdio>
31 #include <string> 31 #include <string>
32 32
33 // Remember to use QPDF_DLL_CLASS on anything derived from InputSource 33 // Remember to use QPDF_DLL_CLASS on anything derived from InputSource
include/qpdf/JSON.hh
@@ -369,8 +369,8 @@ class JSON @@ -369,8 +369,8 @@ class JSON
369 JSON_value(vt_dictionary) 369 JSON_value(vt_dictionary)
370 { 370 {
371 } 371 }
372 - virtual ~JSON_dictionary() = default;  
373 - virtual void write(Pipeline*, size_t depth) const; 372 + ~JSON_dictionary() override = default;
  373 + void write(Pipeline*, size_t depth) const override;
374 std::map<std::string, JSON> members; 374 std::map<std::string, JSON> members;
375 std::set<std::string> parsed_keys; 375 std::set<std::string> parsed_keys;
376 }; 376 };
@@ -380,15 +380,15 @@ class JSON @@ -380,15 +380,15 @@ class JSON
380 JSON_value(vt_array) 380 JSON_value(vt_array)
381 { 381 {
382 } 382 }
383 - virtual ~JSON_array() = default;  
384 - virtual void write(Pipeline*, size_t depth) const; 383 + ~JSON_array() override = default;
  384 + void write(Pipeline*, size_t depth) const override;
385 std::vector<JSON> elements; 385 std::vector<JSON> elements;
386 }; 386 };
387 struct JSON_string: public JSON_value 387 struct JSON_string: public JSON_value
388 { 388 {
389 JSON_string(std::string const& utf8); 389 JSON_string(std::string const& utf8);
390 - virtual ~JSON_string() = default;  
391 - virtual void write(Pipeline*, size_t depth) const; 390 + ~JSON_string() override = default;
  391 + void write(Pipeline*, size_t depth) const override;
392 std::string utf8; 392 std::string utf8;
393 std::string encoded; 393 std::string encoded;
394 }; 394 };
@@ -397,15 +397,15 @@ class JSON @@ -397,15 +397,15 @@ class JSON
397 JSON_number(long long val); 397 JSON_number(long long val);
398 JSON_number(double val); 398 JSON_number(double val);
399 JSON_number(std::string const& val); 399 JSON_number(std::string const& val);
400 - virtual ~JSON_number() = default;  
401 - virtual void write(Pipeline*, size_t depth) const; 400 + ~JSON_number() override = default;
  401 + void write(Pipeline*, size_t depth) const override;
402 std::string encoded; 402 std::string encoded;
403 }; 403 };
404 struct JSON_bool: public JSON_value 404 struct JSON_bool: public JSON_value
405 { 405 {
406 JSON_bool(bool val); 406 JSON_bool(bool val);
407 - virtual ~JSON_bool() = default;  
408 - virtual void write(Pipeline*, size_t depth) const; 407 + ~JSON_bool() override = default;
  408 + void write(Pipeline*, size_t depth) const override;
409 bool value; 409 bool value;
410 }; 410 };
411 struct JSON_null: public JSON_value 411 struct JSON_null: public JSON_value
@@ -414,14 +414,14 @@ class JSON @@ -414,14 +414,14 @@ class JSON
414 JSON_value(vt_null) 414 JSON_value(vt_null)
415 { 415 {
416 } 416 }
417 - virtual ~JSON_null() = default;  
418 - virtual void write(Pipeline*, size_t depth) const; 417 + ~JSON_null() override = default;
  418 + void write(Pipeline*, size_t depth) const override;
419 }; 419 };
420 struct JSON_blob: public JSON_value 420 struct JSON_blob: public JSON_value
421 { 421 {
422 JSON_blob(std::function<void(Pipeline*)> fn); 422 JSON_blob(std::function<void(Pipeline*)> fn);
423 - virtual ~JSON_blob() = default;  
424 - virtual void write(Pipeline*, size_t depth) const; 423 + ~JSON_blob() override = default;
  424 + void write(Pipeline*, size_t depth) const override;
425 std::function<void(Pipeline*)> fn; 425 std::function<void(Pipeline*)> fn;
426 }; 426 };
427 427
include/qpdf/Pl_Buffer.hh
@@ -43,13 +43,13 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline @@ -43,13 +43,13 @@ class QPDF_DLL_CLASS Pl_Buffer: public Pipeline
43 { 43 {
44 public: 44 public:
45 QPDF_DLL 45 QPDF_DLL
46 - Pl_Buffer(char const* identifier, Pipeline* next = 0); 46 + Pl_Buffer(char const* identifier, Pipeline* next = nullptr);
47 QPDF_DLL 47 QPDF_DLL
48 - virtual ~Pl_Buffer(); 48 + ~Pl_Buffer() override;
49 QPDF_DLL 49 QPDF_DLL
50 - virtual void write(unsigned char const*, size_t); 50 + void write(unsigned char const*, size_t) override;
51 QPDF_DLL 51 QPDF_DLL
52 - virtual void finish(); 52 + void finish() override;
53 53
54 // Each call to getBuffer() resets this object -- see notes above. 54 // Each call to getBuffer() resets this object -- see notes above.
55 // The caller is responsible for deleting the returned Buffer 55 // The caller is responsible for deleting the returned Buffer
include/qpdf/Pl_DCT.hh
@@ -57,7 +57,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline @@ -57,7 +57,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
57 JDIMENSION image_height, 57 JDIMENSION image_height,
58 int components, 58 int components,
59 J_COLOR_SPACE color_space, 59 J_COLOR_SPACE color_space,
60 - CompressConfig* config_callback = 0); 60 + CompressConfig* config_callback = nullptr);
61 61
62 QPDF_DLL 62 QPDF_DLL
63 virtual ~Pl_DCT(); 63 virtual ~Pl_DCT();
@@ -91,7 +91,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline @@ -91,7 +91,7 @@ class QPDF_DLL_CLASS Pl_DCT: public Pipeline
91 JDIMENSION image_height = 0, 91 JDIMENSION image_height = 0,
92 int components = 1, 92 int components = 1,
93 J_COLOR_SPACE color_space = JCS_GRAYSCALE, 93 J_COLOR_SPACE color_space = JCS_GRAYSCALE,
94 - CompressConfig* config_callback = 0); 94 + CompressConfig* config_callback = nullptr);
95 Members(Members const&) = delete; 95 Members(Members const&) = delete;
96 96
97 action_e action; 97 action_e action;
include/qpdf/Pl_QPDFTokenizer.hh
@@ -51,7 +51,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline @@ -51,7 +51,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
51 Pl_QPDFTokenizer( 51 Pl_QPDFTokenizer(
52 char const* identifier, 52 char const* identifier,
53 QPDFObjectHandle::TokenFilter* filter, 53 QPDFObjectHandle::TokenFilter* filter,
54 - Pipeline* next = 0); 54 + Pipeline* next = nullptr);
55 QPDF_DLL 55 QPDF_DLL
56 virtual ~Pl_QPDFTokenizer(); 56 virtual ~Pl_QPDFTokenizer();
57 QPDF_DLL 57 QPDF_DLL
include/qpdf/Pl_StdioFile.hh
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 26
27 #include <qpdf/Pipeline.hh> 27 #include <qpdf/Pipeline.hh>
28 28
29 -#include <stdio.h> 29 +#include <cstdio>
30 30
31 // 31 //
32 // This pipeline is reusable. 32 // This pipeline is reusable.
include/qpdf/QPDF.hh
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 #include <list> 30 #include <list>
31 #include <map> 31 #include <map>
32 #include <memory> 32 #include <memory>
33 -#include <stdio.h> 33 +#include <cstdio>
34 #include <string> 34 #include <string>
35 #include <string_view> 35 #include <string_view>
36 #include <vector> 36 #include <vector>
@@ -83,7 +83,7 @@ class QPDF @@ -83,7 +83,7 @@ class QPDF
83 // interpreted as a raw encryption key. See comments on 83 // interpreted as a raw encryption key. See comments on
84 // setPasswordIsHexKey for more information. 84 // setPasswordIsHexKey for more information.
85 QPDF_DLL 85 QPDF_DLL
86 - void processFile(char const* filename, char const* password = 0); 86 + void processFile(char const* filename, char const* password = nullptr);
87 87
88 // Parse a PDF from a stdio FILE*. The FILE must be open in 88 // Parse a PDF from a stdio FILE*. The FILE must be open in
89 // binary mode and must be seekable. It may be open read only. 89 // binary mode and must be seekable. It may be open read only.
@@ -96,7 +96,7 @@ class QPDF @@ -96,7 +96,7 @@ class QPDF
96 char const* description, 96 char const* description,
97 FILE* file, 97 FILE* file,
98 bool close_file, 98 bool close_file,
99 - char const* password = 0); 99 + char const* password = nullptr);
100 100
101 // Parse a PDF file loaded into a memory buffer. This works 101 // Parse a PDF file loaded into a memory buffer. This works
102 // exactly like processFile except that the PDF file is in memory 102 // exactly like processFile except that the PDF file is in memory
@@ -107,14 +107,14 @@ class QPDF @@ -107,14 +107,14 @@ class QPDF
107 char const* description, 107 char const* description,
108 char const* buf, 108 char const* buf,
109 size_t length, 109 size_t length,
110 - char const* password = 0); 110 + char const* password = nullptr);
111 111
112 // Parse a PDF file loaded from a custom InputSource. If you have 112 // Parse a PDF file loaded from a custom InputSource. If you have
113 // your own method of retrieving a PDF file, you can subclass 113 // your own method of retrieving a PDF file, you can subclass
114 // InputSource and use this method. 114 // InputSource and use this method.
115 QPDF_DLL 115 QPDF_DLL
116 void 116 void
117 - processInputSource(std::shared_ptr<InputSource>, char const* password = 0); 117 + processInputSource(std::shared_ptr<InputSource>, char const* password = nullptr);
118 118
119 // Create a PDF from an input source that contains JSON as written 119 // Create a PDF from an input source that contains JSON as written
120 // by writeJSON (or qpdf --json-output, version 2 or higher). The 120 // by writeJSON (or qpdf --json-output, version 2 or higher). The
include/qpdf/QPDFCryptoImpl.hh
@@ -80,7 +80,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl @@ -80,7 +80,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
80 virtual void RC4_process( 80 virtual void RC4_process(
81 unsigned char const* in_data, 81 unsigned char const* in_data,
82 size_t len, 82 size_t len,
83 - unsigned char* out_data = 0) = 0; 83 + unsigned char* out_data = nullptr) = 0;
84 QPDF_DLL 84 QPDF_DLL
85 virtual void RC4_finalize() = 0; 85 virtual void RC4_finalize() = 0;
86 86
include/qpdf/QPDFJob.hh
@@ -497,7 +497,7 @@ class QPDFJob @@ -497,7 +497,7 @@ class QPDFJob
497 497
498 // Helper functions 498 // Helper functions
499 static void usage(std::string const& msg); 499 static void usage(std::string const& msg);
500 - static JSON json_schema(int json_version, std::set<std::string>* keys = 0); 500 + static JSON json_schema(int json_version, std::set<std::string>* keys = nullptr);
501 static void parse_object_id( 501 static void parse_object_id(
502 std::string const& objspec, bool& trailer, int& obj, int& gen); 502 std::string const& objspec, bool& trailer, int& obj, int& gen);
503 void parseRotationParameter(std::string const&); 503 void parseRotationParameter(std::string const&);
include/qpdf/QPDFObjectHandle.hh
@@ -526,7 +526,7 @@ class QPDFObjectHandle @@ -526,7 +526,7 @@ class QPDFObjectHandle
526 QPDF_DLL 526 QPDF_DLL
527 void parsePageContents(ParserCallbacks* callbacks); 527 void parsePageContents(ParserCallbacks* callbacks);
528 QPDF_DLL 528 QPDF_DLL
529 - void filterPageContents(TokenFilter* filter, Pipeline* next = 0); 529 + void filterPageContents(TokenFilter* filter, Pipeline* next = nullptr);
530 // See comments for QPDFPageObjectHelper::pipeContents. 530 // See comments for QPDFPageObjectHelper::pipeContents.
531 QPDF_DLL 531 QPDF_DLL
532 void pipePageContents(Pipeline* p); 532 void pipePageContents(Pipeline* p);
@@ -538,7 +538,7 @@ class QPDFObjectHandle @@ -538,7 +538,7 @@ class QPDFObjectHandle
538 // contents. This can be used to apply a TokenFilter to a form 538 // contents. This can be used to apply a TokenFilter to a form
539 // XObject, whose data is in the same format as a content stream. 539 // XObject, whose data is in the same format as a content stream.
540 QPDF_DLL 540 QPDF_DLL
541 - void filterAsContents(TokenFilter* filter, Pipeline* next = 0); 541 + void filterAsContents(TokenFilter* filter, Pipeline* next = nullptr);
542 // Called on a stream to parse the stream as page contents. This 542 // Called on a stream to parse the stream as page contents. This
543 // can be used to parse a form XObject. 543 // can be used to parse a form XObject.
544 QPDF_DLL 544 QPDF_DLL
include/qpdf/QPDFOutlineObjectHelper.hh
@@ -42,7 +42,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper @@ -42,7 +42,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper
42 { 42 {
43 // This must be cleared explicitly to avoid circular references 43 // This must be cleared explicitly to avoid circular references
44 // that prevent cleanup of pointer holders. 44 // that prevent cleanup of pointer holders.
45 - this->m->parent = 0; 45 + this->m->parent = nullptr;
46 } 46 }
47 47
48 // All constructors are private. You can only create one of these 48 // All constructors are private. You can only create one of these
include/qpdf/QPDFPageObjectHelper.hh
@@ -320,12 +320,12 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -320,12 +320,12 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
320 // examples/pdf-count-strings.cc for an example. 320 // examples/pdf-count-strings.cc for an example.
321 QPDF_DLL 321 QPDF_DLL
322 void 322 void
323 - filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0); 323 + filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
324 324
325 // Old name -- calls filterContents() 325 // Old name -- calls filterContents()
326 QPDF_DLL 326 QPDF_DLL
327 void filterPageContents( 327 void filterPageContents(
328 - QPDFObjectHandle::TokenFilter* filter, Pipeline* next = 0); 328 + QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
329 329
330 // Pipe a page's contents through the given pipeline. This method 330 // Pipe a page's contents through the given pipeline. This method
331 // works whether the contents are a single stream or an array of 331 // works whether the contents are a single stream or an array of
include/qpdf/QPDFTokenizer.hh
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 #include <qpdf/PointerHolder.hh> // unused -- remove in qpdf 12 (see #785) 28 #include <qpdf/PointerHolder.hh> // unused -- remove in qpdf 12 (see #785)
29 29
30 #include <memory> 30 #include <memory>
31 -#include <stdio.h> 31 +#include <cstdio>
32 #include <string> 32 #include <string>
33 33
34 class QPDFTokenizer 34 class QPDFTokenizer
include/qpdf/QPDFWriter.hh
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 #include <map> 34 #include <map>
35 #include <memory> 35 #include <memory>
36 #include <set> 36 #include <set>
37 -#include <stdio.h> 37 +#include <cstdio>
38 #include <string> 38 #include <string>
39 #include <string_view> 39 #include <string_view>
40 #include <vector> 40 #include <vector>
@@ -102,7 +102,7 @@ class QPDFWriter @@ -102,7 +102,7 @@ class QPDFWriter
102 QPDF_DLL 102 QPDF_DLL
103 virtual ~FunctionProgressReporter(); 103 virtual ~FunctionProgressReporter();
104 QPDF_DLL 104 QPDF_DLL
105 - virtual void reportProgress(int) override; 105 + void reportProgress(int) override;
106 106
107 private: 107 private:
108 std::function<void(int)> handler; 108 std::function<void(int)> handler;
@@ -539,7 +539,7 @@ class QPDFWriter @@ -539,7 +539,7 @@ class QPDFWriter
539 friend class QPDFWriter; 539 friend class QPDFWriter;
540 540
541 public: 541 public:
542 - PipelinePopper(QPDFWriter* qw, std::shared_ptr<Buffer>* bp = 0) : 542 + PipelinePopper(QPDFWriter* qw, std::shared_ptr<Buffer>* bp = nullptr) :
543 qw(qw), 543 qw(qw),
544 bp(bp) 544 bp(bp)
545 { 545 {
include/qpdf/QUtil.hh
@@ -30,9 +30,9 @@ @@ -30,9 +30,9 @@
30 #include <list> 30 #include <list>
31 #include <memory> 31 #include <memory>
32 #include <stdexcept> 32 #include <stdexcept>
33 -#include <stdio.h> 33 +#include <cstdio>
34 #include <string> 34 #include <string>
35 -#include <time.h> 35 +#include <ctime>
36 #include <vector> 36 #include <vector>
37 37
38 class RandomDataProvider; 38 class RandomDataProvider;
@@ -245,7 +245,7 @@ namespace QUtil @@ -245,7 +245,7 @@ namespace QUtil
245 // Returns true iff the variable is defined. If `value' is 245 // Returns true iff the variable is defined. If `value' is
246 // non-null, initializes it with the value of the variable. 246 // non-null, initializes it with the value of the variable.
247 QPDF_DLL 247 QPDF_DLL
248 - bool get_env(std::string const& var, std::string* value = 0); 248 + bool get_env(std::string const& var, std::string* value = nullptr);
249 249
250 QPDF_DLL 250 QPDF_DLL
251 time_t get_current_time(); 251 time_t get_current_time();
include/qpdf/RandomDataProvider.hh
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 #define RANDOMDATAPROVIDER_HH 23 #define RANDOMDATAPROVIDER_HH
24 24
25 #include <qpdf/DLL.h> 25 #include <qpdf/DLL.h>
26 -#include <string.h> // for size_t 26 +#include <cstring> // for size_t
27 27
28 class QPDF_DLL_CLASS RandomDataProvider 28 class QPDF_DLL_CLASS RandomDataProvider
29 { 29 {
libqpdf/BufferInputSource.cc
@@ -2,10 +2,8 @@ @@ -2,10 +2,8 @@
2 2
3 #include <qpdf/QIntC.hh> 3 #include <qpdf/QIntC.hh>
4 #include <algorithm> 4 #include <algorithm>
5 -#include <limits>  
6 #include <sstream> 5 #include <sstream>
7 -#include <stdexcept>  
8 -#include <string.h> 6 +#include <cstring>
9 7
10 BufferInputSource::BufferInputSource( 8 BufferInputSource::BufferInputSource(
11 std::string const& description, Buffer* buf, bool own_memory) : 9 std::string const& description, Buffer* buf, bool own_memory) :
libqpdf/FileInputSource.cc
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #include <qpdf/QPDFExc.hh> 3 #include <qpdf/QPDFExc.hh>
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
5 #include <algorithm> 5 #include <algorithm>
6 -#include <string.h> 6 +#include <cstring>
7 7
8 FileInputSource::FileInputSource() : 8 FileInputSource::FileInputSource() :
9 close_file(false), 9 close_file(false),
libqpdf/InputSource.cc
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #include <qpdf/QIntC.hh> 3 #include <qpdf/QIntC.hh>
4 #include <qpdf/QTC.hh> 4 #include <qpdf/QTC.hh>
5 #include <stdexcept> 5 #include <stdexcept>
6 -#include <string.h> 6 +#include <cstring>
7 7
8 void 8 void
9 InputSource::setLastOffset(qpdf_offset_t offset) 9 InputSource::setLastOffset(qpdf_offset_t offset)
libqpdf/InsecureRandomDataProvider.cc
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 #include <qpdf/QUtil.hh> 3 #include <qpdf/QUtil.hh>
4 #include <qpdf/qpdf-config.h> 4 #include <qpdf/qpdf-config.h>
5 -#include <stdlib.h> 5 +#include <cstdlib>
6 6
7 InsecureRandomDataProvider::InsecureRandomDataProvider() : 7 InsecureRandomDataProvider::InsecureRandomDataProvider() :
8 seeded_random(false) 8 seeded_random(false)
@@ -24,7 +24,7 @@ InsecureRandomDataProvider::random() @@ -24,7 +24,7 @@ InsecureRandomDataProvider::random()
24 // Seed the random number generator with something simple, but 24 // Seed the random number generator with something simple, but
25 // just to be interesting, don't use the unmodified current 25 // just to be interesting, don't use the unmodified current
26 // time. It would be better if this were a more secure seed. 26 // time. It would be better if this were a more secure seed.
27 - unsigned int seed = 27 + auto seed =
28 static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc); 28 static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc);
29 #ifdef HAVE_RANDOM 29 #ifdef HAVE_RANDOM
30 ::srandom(seed); 30 ::srandom(seed);
libqpdf/JSON.cc
@@ -294,7 +294,7 @@ JSON::addDictionaryMember(std::string const&amp; key, JSON const&amp; val) @@ -294,7 +294,7 @@ JSON::addDictionaryMember(std::string const&amp; key, JSON const&amp; val)
294 bool 294 bool
295 JSON::checkDictionaryKeySeen(std::string const& key) 295 JSON::checkDictionaryKeySeen(std::string const& key)
296 { 296 {
297 - JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get()); 297 + auto* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
298 if (nullptr == obj) { 298 if (nullptr == obj) {
299 throw std::logic_error( 299 throw std::logic_error(
300 "JSON::checkDictionaryKey called on non-dictionary"); 300 "JSON::checkDictionaryKey called on non-dictionary");
@@ -315,7 +315,7 @@ JSON::makeArray() @@ -315,7 +315,7 @@ JSON::makeArray()
315 JSON 315 JSON
316 JSON::addArrayElement(JSON const& val) 316 JSON::addArrayElement(JSON const& val)
317 { 317 {
318 - JSON_array* arr = dynamic_cast<JSON_array*>(this->m->value.get()); 318 + auto* arr = dynamic_cast<JSON_array*>(this->m->value.get());
319 if (nullptr == arr) { 319 if (nullptr == arr) {
320 throw std::runtime_error("JSON::addArrayElement called on non-array"); 320 throw std::runtime_error("JSON::addArrayElement called on non-array");
321 } 321 }
@@ -470,13 +470,13 @@ JSON::checkSchemaInternal( @@ -470,13 +470,13 @@ JSON::checkSchemaInternal(
470 std::list<std::string>& errors, 470 std::list<std::string>& errors,
471 std::string prefix) 471 std::string prefix)
472 { 472 {
473 - JSON_array* this_arr = dynamic_cast<JSON_array*>(this_v);  
474 - JSON_dictionary* this_dict = dynamic_cast<JSON_dictionary*>(this_v); 473 + auto* this_arr = dynamic_cast<JSON_array*>(this_v);
  474 + auto* this_dict = dynamic_cast<JSON_dictionary*>(this_v);
475 475
476 - JSON_array* sch_arr = dynamic_cast<JSON_array*>(sch_v);  
477 - JSON_dictionary* sch_dict = dynamic_cast<JSON_dictionary*>(sch_v); 476 + auto* sch_arr = dynamic_cast<JSON_array*>(sch_v);
  477 + auto* sch_dict = dynamic_cast<JSON_dictionary*>(sch_v);
478 478
479 - JSON_string* sch_str = dynamic_cast<JSON_string*>(sch_v); 479 + auto* sch_str = dynamic_cast<JSON_string*>(sch_v);
480 480
481 std::string err_prefix; 481 std::string err_prefix;
482 if (prefix.empty()) { 482 if (prefix.empty()) {
libqpdf/MD5.cc
@@ -4,11 +4,7 @@ @@ -4,11 +4,7 @@
4 #include <qpdf/QPDFCryptoProvider.hh> 4 #include <qpdf/QPDFCryptoProvider.hh>
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 6
7 -#include <errno.h>  
8 -#include <memory.h>  
9 -#include <stdio.h>  
10 -#include <stdlib.h>  
11 -#include <string.h> 7 +#include <cstring>
12 8
13 MD5::MD5() 9 MD5::MD5()
14 { 10 {
libqpdf/Pipeline.cc
1 #include <qpdf/Pipeline.hh> 1 #include <qpdf/Pipeline.hh>
2 2
3 -#include <qpdf/QUtil.hh>  
4 -  
5 #include <cstring> 3 #include <cstring>
6 #include <stdexcept> 4 #include <stdexcept>
7 5
libqpdf/Pl_AES_PDF.cc
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 #include <cstring> 6 #include <cstring>
7 #include <stdexcept> 7 #include <stdexcept>
8 -#include <stdlib.h>  
9 #include <string> 8 #include <string>
10 9
11 bool Pl_AES_PDF::use_static_iv = false; 10 bool Pl_AES_PDF::use_static_iv = false;
libqpdf/Pl_ASCII85Decoder.cc
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 #include <qpdf/QTC.hh> 3 #include <qpdf/QTC.hh>
4 #include <stdexcept> 4 #include <stdexcept>
5 -#include <string.h> 5 +#include <cstring>
6 6
7 Pl_ASCII85Decoder::Pl_ASCII85Decoder(char const* identifier, Pipeline* next) : 7 Pl_ASCII85Decoder::Pl_ASCII85Decoder(char const* identifier, Pipeline* next) :
8 Pipeline(identifier, next), 8 Pipeline(identifier, next),
libqpdf/Pl_ASCIIHexDecoder.cc
1 #include <qpdf/Pl_ASCIIHexDecoder.hh> 1 #include <qpdf/Pl_ASCIIHexDecoder.hh>
2 2
3 #include <qpdf/QTC.hh> 3 #include <qpdf/QTC.hh>
4 -#include <ctype.h> 4 +#include <cctype>
5 #include <stdexcept> 5 #include <stdexcept>
6 -#include <string.h>  
7 6
8 Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) : 7 Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) :
9 Pipeline(identifier, next), 8 Pipeline(identifier, next),
@@ -77,7 +76,7 @@ Pl_ASCIIHexDecoder::flush() @@ -77,7 +76,7 @@ Pl_ASCIIHexDecoder::flush()
77 b[i] = this->inbuf[i] - '0'; 76 b[i] = this->inbuf[i] - '0';
78 } 77 }
79 } 78 }
80 - unsigned char ch = static_cast<unsigned char>((b[0] << 4) + b[1]); 79 + auto ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
81 80
82 QTC::TC( 81 QTC::TC(
83 "libtests", 82 "libtests",
libqpdf/Pl_Base64.cc
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include <qpdf/QIntC.hh> 3 #include <qpdf/QIntC.hh>
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
5 -#include <algorithm>  
6 #include <cstring> 5 #include <cstring>
7 #include <stdexcept> 6 #include <stdexcept>
8 7
libqpdf/Pl_Buffer.cc
@@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
2 2
3 #include <algorithm> 3 #include <algorithm>
4 #include <stdexcept> 4 #include <stdexcept>
5 -#include <stdlib.h>  
6 -#include <string.h> 5 +#include <cstdlib>
  6 +#include <cstring>
7 7
8 Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) : 8 Pl_Buffer::Pl_Buffer(char const* identifier, Pipeline* next) :
9 Pipeline(identifier, next), 9 Pipeline(identifier, next),
@@ -45,7 +45,7 @@ Pl_Buffer::getBuffer() @@ -45,7 +45,7 @@ Pl_Buffer::getBuffer()
45 } 45 }
46 46
47 auto size = this->m->data.length(); 47 auto size = this->m->data.length();
48 - Buffer* b = new Buffer(size); 48 + auto* b = new Buffer(size);
49 if (size > 0) { 49 if (size > 0) {
50 unsigned char* p = b->getBuffer(); 50 unsigned char* p = b->getBuffer();
51 memcpy(p, this->m->data.data(), size); 51 memcpy(p, this->m->data.data(), size);
libqpdf/Pl_DCT.cc
@@ -2,12 +2,9 @@ @@ -2,12 +2,9 @@
2 2
3 #include <qpdf/QIntC.hh> 3 #include <qpdf/QIntC.hh>
4 #include <qpdf/QTC.hh> 4 #include <qpdf/QTC.hh>
5 -#include <qpdf/QUtil.hh>  
6 5
7 -#include <cstring>  
8 -#include <setjmp.h> 6 +#include <csetjmp>
9 #include <stdexcept> 7 #include <stdexcept>
10 -#include <stdlib.h>  
11 #include <string> 8 #include <string>
12 9
13 #if BITS_IN_JSAMPLE != 8 10 #if BITS_IN_JSAMPLE != 8
@@ -27,7 +24,7 @@ namespace @@ -27,7 +24,7 @@ namespace
27 static void 24 static void
28 error_handler(j_common_ptr cinfo) 25 error_handler(j_common_ptr cinfo)
29 { 26 {
30 - qpdf_jpeg_error_mgr* jerr = 27 + auto* jerr =
31 reinterpret_cast<qpdf_jpeg_error_mgr*>(cinfo->err); 28 reinterpret_cast<qpdf_jpeg_error_mgr*>(cinfo->err);
32 char buf[JMSG_LENGTH_MAX]; 29 char buf[JMSG_LENGTH_MAX];
33 (*cinfo->err->format_message)(cinfo, buf); 30 (*cinfo->err->format_message)(cinfo, buf);
@@ -170,7 +167,7 @@ static boolean @@ -170,7 +167,7 @@ static boolean
170 empty_pipeline_output_buffer(j_compress_ptr cinfo) 167 empty_pipeline_output_buffer(j_compress_ptr cinfo)
171 { 168 {
172 QTC::TC("libtests", "Pl_DCT empty_pipeline_output_buffer"); 169 QTC::TC("libtests", "Pl_DCT empty_pipeline_output_buffer");
173 - dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest); 170 + auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
174 dest->next->write(dest->buffer, dest->size); 171 dest->next->write(dest->buffer, dest->size);
175 dest->pub.next_output_byte = dest->buffer; 172 dest->pub.next_output_byte = dest->buffer;
176 dest->pub.free_in_buffer = dest->size; 173 dest->pub.free_in_buffer = dest->size;
@@ -181,7 +178,7 @@ static void @@ -181,7 +178,7 @@ static void
181 term_pipeline_destination(j_compress_ptr cinfo) 178 term_pipeline_destination(j_compress_ptr cinfo)
182 { 179 {
183 QTC::TC("libtests", "Pl_DCT term_pipeline_destination"); 180 QTC::TC("libtests", "Pl_DCT term_pipeline_destination");
184 - dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest); 181 + auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
185 dest->next->write(dest->buffer, dest->size - dest->pub.free_in_buffer); 182 dest->next->write(dest->buffer, dest->size - dest->pub.free_in_buffer);
186 } 183 }
187 184
@@ -195,7 +192,7 @@ jpeg_pipeline_dest( @@ -195,7 +192,7 @@ jpeg_pipeline_dest(
195 reinterpret_cast<j_common_ptr>(cinfo), 192 reinterpret_cast<j_common_ptr>(cinfo),
196 JPOOL_PERMANENT, 193 JPOOL_PERMANENT,
197 sizeof(dct_pipeline_dest))); 194 sizeof(dct_pipeline_dest)));
198 - dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest); 195 + auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
199 dest->pub.init_destination = init_pipeline_destination; 196 dest->pub.init_destination = init_pipeline_destination;
200 dest->pub.empty_output_buffer = empty_pipeline_output_buffer; 197 dest->pub.empty_output_buffer = empty_pipeline_output_buffer;
201 dest->pub.term_destination = term_pipeline_destination; 198 dest->pub.term_destination = term_pipeline_destination;
@@ -264,7 +261,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, Buffer* buffer) @@ -264,7 +261,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, Buffer* buffer)
264 void 261 void
265 Pl_DCT::compress(void* cinfo_p, Buffer* b) 262 Pl_DCT::compress(void* cinfo_p, Buffer* b)
266 { 263 {
267 - struct jpeg_compress_struct* cinfo = 264 + auto* cinfo =
268 reinterpret_cast<jpeg_compress_struct*>(cinfo_p); 265 reinterpret_cast<jpeg_compress_struct*>(cinfo_p);
269 266
270 #if ( \ 267 #if ( \
@@ -319,7 +316,7 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b) @@ -319,7 +316,7 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
319 void 316 void
320 Pl_DCT::decompress(void* cinfo_p, Buffer* b) 317 Pl_DCT::decompress(void* cinfo_p, Buffer* b)
321 { 318 {
322 - struct jpeg_decompress_struct* cinfo = 319 + auto* cinfo =
323 reinterpret_cast<jpeg_decompress_struct*>(cinfo_p); 320 reinterpret_cast<jpeg_decompress_struct*>(cinfo_p);
324 321
325 #if ( \ 322 #if ( \
libqpdf/Pl_Flate.cc
1 #include <qpdf/Pl_Flate.hh> 1 #include <qpdf/Pl_Flate.hh>
2 2
3 -#include <limits.h>  
4 -#include <string.h> 3 +#include <climits>
  4 +#include <cstring>
5 #include <zlib.h> 5 #include <zlib.h>
6 6
7 #include <qpdf/QIntC.hh> 7 #include <qpdf/QIntC.hh>
libqpdf/Pl_Function.cc
1 #include <qpdf/Pl_Function.hh> 1 #include <qpdf/Pl_Function.hh>
2 2
3 -#include <qpdf/QUtil.hh>  
4 -#include <errno.h>  
5 #include <stdexcept> 3 #include <stdexcept>
6 4
7 Pl_Function::Members::Members(writer_t fn) : 5 Pl_Function::Members::Members(writer_t fn) :
libqpdf/Pl_LZWDecoder.cc
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 #include <qpdf/QTC.hh> 4 #include <qpdf/QTC.hh>
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 #include <stdexcept> 6 #include <stdexcept>
7 -#include <string.h> 7 +#include <cstring>
8 8
9 Pl_LZWDecoder::Pl_LZWDecoder( 9 Pl_LZWDecoder::Pl_LZWDecoder(
10 char const* identifier, Pipeline* next, bool early_code_change) : 10 char const* identifier, Pipeline* next, bool early_code_change) :
@@ -189,7 +189,7 @@ Pl_LZWDecoder::handleCode(unsigned int code) @@ -189,7 +189,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
189 } 189 }
190 190
191 if (code < 256) { 191 if (code < 256) {
192 - unsigned char ch = static_cast<unsigned char>(code); 192 + auto ch = static_cast<unsigned char>(code);
193 getNext()->write(&ch, 1); 193 getNext()->write(&ch, 1);
194 } else { 194 } else {
195 unsigned int idx = code - 258; 195 unsigned int idx = code - 258;
libqpdf/Pl_OStream.cc
1 #include <qpdf/Pl_OStream.hh> 1 #include <qpdf/Pl_OStream.hh>
2 2
3 -#include <qpdf/QUtil.hh>  
4 -#include <errno.h>  
5 #include <stdexcept> 3 #include <stdexcept>
6 4
7 Pl_OStream::Members::Members(std::ostream& os) : 5 Pl_OStream::Members::Members(std::ostream& os) :
libqpdf/Pl_PNGFilter.cc
@@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
3 #include <qpdf/QTC.hh> 3 #include <qpdf/QTC.hh>
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
5 5
6 -#include <limits.h> 6 +#include <climits>
7 #include <stdexcept> 7 #include <stdexcept>
8 -#include <string.h> 8 +#include <cstring>
9 9
10 static int 10 static int
11 abs_diff(int a, int b) 11 abs_diff(int a, int b)
libqpdf/Pl_QPDFTokenizer.cc
@@ -2,9 +2,7 @@ @@ -2,9 +2,7 @@
2 2
3 #include <qpdf/BufferInputSource.hh> 3 #include <qpdf/BufferInputSource.hh>
4 #include <qpdf/QTC.hh> 4 #include <qpdf/QTC.hh>
5 -#include <qpdf/QUtil.hh>  
6 #include <stdexcept> 5 #include <stdexcept>
7 -#include <string.h>  
8 6
9 Pl_QPDFTokenizer::Members::Members() : 7 Pl_QPDFTokenizer::Members::Members() :
10 filter(nullptr), 8 filter(nullptr),
libqpdf/Pl_RunLength.cc
@@ -127,11 +127,11 @@ Pl_RunLength::flush_encode() @@ -127,11 +127,11 @@ Pl_RunLength::flush_encode()
127 throw std::logic_error( 127 throw std::logic_error(
128 "Pl_RunLength: invalid length in flush_encode for run"); 128 "Pl_RunLength: invalid length in flush_encode for run");
129 } 129 }
130 - unsigned char ch = static_cast<unsigned char>(257 - this->m->length); 130 + auto ch = static_cast<unsigned char>(257 - this->m->length);
131 this->getNext()->write(&ch, 1); 131 this->getNext()->write(&ch, 1);
132 this->getNext()->write(&this->m->buf[0], 1); 132 this->getNext()->write(&this->m->buf[0], 1);
133 } else if (this->m->length > 0) { 133 } else if (this->m->length > 0) {
134 - unsigned char ch = static_cast<unsigned char>(this->m->length - 1); 134 + auto ch = static_cast<unsigned char>(this->m->length - 1);
135 this->getNext()->write(&ch, 1); 135 this->getNext()->write(&ch, 1);
136 this->getNext()->write(this->m->buf, this->m->length); 136 this->getNext()->write(this->m->buf, this->m->length);
137 } 137 }
libqpdf/Pl_SHA2.cc
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include <qpdf/QPDFCryptoProvider.hh> 3 #include <qpdf/QPDFCryptoProvider.hh>
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
5 -#include <cstdio>  
6 #include <stdexcept> 5 #include <stdexcept>
7 6
8 Pl_SHA2::Pl_SHA2(int bits, Pipeline* next) : 7 Pl_SHA2::Pl_SHA2(int bits, Pipeline* next) :
libqpdf/Pl_StdioFile.cc
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #include <qpdf/Pl_StdioFile.hh> 3 #include <qpdf/Pl_StdioFile.hh>
4 4
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 -#include <errno.h> 6 +#include <cerrno>
7 #include <stdexcept> 7 #include <stdexcept>
8 8
9 Pl_StdioFile::Members::Members(FILE* f) : 9 Pl_StdioFile::Members::Members(FILE* f) :
libqpdf/Pl_String.cc
1 #include <qpdf/Pl_String.hh> 1 #include <qpdf/Pl_String.hh>
2 2
3 -#include <qpdf/QUtil.hh>  
4 -#include <errno.h>  
5 #include <stdexcept> 3 #include <stdexcept>
6 4
7 Pl_String::Members::Members(std::string& s) : 5 Pl_String::Members::Members(std::string& s) :
libqpdf/Pl_TIFFPredictor.cc
@@ -5,9 +5,9 @@ @@ -5,9 +5,9 @@
5 #include <qpdf/QTC.hh> 5 #include <qpdf/QTC.hh>
6 #include <qpdf/QUtil.hh> 6 #include <qpdf/QUtil.hh>
7 7
8 -#include <limits.h> 8 +#include <climits>
9 #include <stdexcept> 9 #include <stdexcept>
10 -#include <string.h> 10 +#include <cstring>
11 #include <vector> 11 #include <vector>
12 12
13 Pl_TIFFPredictor::Pl_TIFFPredictor( 13 Pl_TIFFPredictor::Pl_TIFFPredictor(
libqpdf/QPDF.cc
@@ -9,8 +9,8 @@ @@ -9,8 +9,8 @@
9 #include <memory.h> 9 #include <memory.h>
10 #include <regex> 10 #include <regex>
11 #include <sstream> 11 #include <sstream>
12 -#include <stdlib.h>  
13 -#include <string.h> 12 +#include <cstdlib>
  13 +#include <cstring>
14 #include <vector> 14 #include <vector>
15 15
16 #include <qpdf/BufferInputSource.hh> 16 #include <qpdf/BufferInputSource.hh>
@@ -60,42 +60,42 @@ namespace @@ -60,42 +60,42 @@ namespace
60 class InvalidInputSource: public InputSource 60 class InvalidInputSource: public InputSource
61 { 61 {
62 public: 62 public:
63 - virtual ~InvalidInputSource() = default;  
64 - virtual qpdf_offset_t 63 + ~InvalidInputSource() override = default;
  64 + qpdf_offset_t
65 findAndSkipNextEOL() override 65 findAndSkipNextEOL() override
66 { 66 {
67 throwException(); 67 throwException();
68 return 0; 68 return 0;
69 } 69 }
70 - virtual std::string const& 70 + std::string const&
71 getName() const override 71 getName() const override
72 { 72 {
73 static std::string name("closed input source"); 73 static std::string name("closed input source");
74 return name; 74 return name;
75 } 75 }
76 - virtual qpdf_offset_t 76 + qpdf_offset_t
77 tell() override 77 tell() override
78 { 78 {
79 throwException(); 79 throwException();
80 return 0; 80 return 0;
81 } 81 }
82 - virtual void 82 + void
83 seek(qpdf_offset_t offset, int whence) override 83 seek(qpdf_offset_t offset, int whence) override
84 { 84 {
85 throwException(); 85 throwException();
86 } 86 }
87 - virtual void 87 + void
88 rewind() override 88 rewind() override
89 { 89 {
90 throwException(); 90 throwException();
91 } 91 }
92 - virtual size_t 92 + size_t
93 read(char* buffer, size_t length) override 93 read(char* buffer, size_t length) override
94 { 94 {
95 throwException(); 95 throwException();
96 return 0; 96 return 0;
97 } 97 }
98 - virtual void 98 + void
99 unreadCh(char ch) override 99 unreadCh(char ch) override
100 { 100 {
101 throwException(); 101 throwException();
@@ -264,7 +264,7 @@ QPDF::create() @@ -264,7 +264,7 @@ QPDF::create()
264 void 264 void
265 QPDF::processFile(char const* filename, char const* password) 265 QPDF::processFile(char const* filename, char const* password)
266 { 266 {
267 - FileInputSource* fi = new FileInputSource(filename); 267 + auto* fi = new FileInputSource(filename);
268 processInputSource(std::shared_ptr<InputSource>(fi), password); 268 processInputSource(std::shared_ptr<InputSource>(fi), password);
269 } 269 }
270 270
@@ -272,7 +272,7 @@ void @@ -272,7 +272,7 @@ void
272 QPDF::processFile( 272 QPDF::processFile(
273 char const* description, FILE* filep, bool close_file, char const* password) 273 char const* description, FILE* filep, bool close_file, char const* password)
274 { 274 {
275 - FileInputSource* fi = new FileInputSource(description, filep, close_file); 275 + auto* fi = new FileInputSource(description, filep, close_file);
276 processInputSource(std::shared_ptr<InputSource>(fi), password); 276 processInputSource(std::shared_ptr<InputSource>(fi), password);
277 } 277 }
278 278
@@ -2537,7 +2537,7 @@ QPDF::getCompressibleObjGens() @@ -2537,7 +2537,7 @@ QPDF::getCompressibleObjGens()
2537 if (obj.isStream()) { 2537 if (obj.isStream()) {
2538 QPDFObjectHandle dict = obj.getDict(); 2538 QPDFObjectHandle dict = obj.getDict();
2539 std::set<std::string> keys = dict.getKeys(); 2539 std::set<std::string> keys = dict.getKeys();
2540 - for (std::set<std::string>::reverse_iterator iter = keys.rbegin(); 2540 + for (auto iter = keys.rbegin();
2541 iter != keys.rend(); 2541 iter != keys.rend();
2542 ++iter) { 2542 ++iter) {
2543 std::string const& key = *iter; 2543 std::string const& key = *iter;
@@ -2553,7 +2553,7 @@ QPDF::getCompressibleObjGens() @@ -2553,7 +2553,7 @@ QPDF::getCompressibleObjGens()
2553 } 2553 }
2554 } else if (obj.isDictionary()) { 2554 } else if (obj.isDictionary()) {
2555 std::set<std::string> keys = obj.getKeys(); 2555 std::set<std::string> keys = obj.getKeys();
2556 - for (std::set<std::string>::reverse_iterator iter = keys.rbegin(); 2556 + for (auto iter = keys.rbegin();
2557 iter != keys.rend(); 2557 iter != keys.rend();
2558 ++iter) { 2558 ++iter) {
2559 queue.push_front(obj.getKey(*iter)); 2559 queue.push_front(obj.getKey(*iter));
libqpdf/QPDFAnnotationObjectHelper.cc
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include <qpdf/QPDF.hh> 3 #include <qpdf/QPDF.hh>
4 #include <qpdf/QPDFMatrix.hh> 4 #include <qpdf/QPDFMatrix.hh>
5 -#include <qpdf/QPDFNameTreeObjectHelper.hh>  
6 #include <qpdf/QTC.hh> 5 #include <qpdf/QTC.hh>
7 #include <qpdf/QUtil.hh> 6 #include <qpdf/QUtil.hh>
8 7
libqpdf/QPDFExc.cc
1 #include <qpdf/QPDFExc.hh> 1 #include <qpdf/QPDFExc.hh>
2 2
3 -#include <qpdf/QUtil.hh>  
4 -  
5 QPDFExc::QPDFExc( 3 QPDFExc::QPDFExc(
6 qpdf_error_code_e error_code, 4 qpdf_error_code_e error_code,
7 std::string const& filename, 5 std::string const& filename,
libqpdf/QPDFFormFieldObjectHelper.cc
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 #include <qpdf/QPDFAnnotationObjectHelper.hh> 6 #include <qpdf/QPDFAnnotationObjectHelper.hh>
7 #include <qpdf/QTC.hh> 7 #include <qpdf/QTC.hh>
8 #include <qpdf/QUtil.hh> 8 #include <qpdf/QUtil.hh>
9 -#include <stdlib.h> 9 +#include <cstdlib>
10 10
11 QPDFFormFieldObjectHelper::QPDFFormFieldObjectHelper(QPDFObjectHandle oh) : 11 QPDFFormFieldObjectHelper::QPDFFormFieldObjectHelper(QPDFObjectHandle oh) :
12 QPDFObjectHelper(oh), 12 QPDFObjectHelper(oh),
@@ -515,9 +515,9 @@ namespace @@ -515,9 +515,9 @@ namespace
515 std::vector<std::string> const& opt, 515 std::vector<std::string> const& opt,
516 double tf, 516 double tf,
517 QPDFObjectHandle::Rectangle const& bbox); 517 QPDFObjectHandle::Rectangle const& bbox);
518 - virtual ~ValueSetter() = default;  
519 - virtual void handleToken(QPDFTokenizer::Token const&);  
520 - virtual void handleEOF(); 518 + ~ValueSetter() override = default;
  519 + void handleToken(QPDFTokenizer::Token const&) override;
  520 + void handleEOF() override;
521 void writeAppearance(); 521 void writeAppearance();
522 522
523 private: 523 private:
@@ -611,7 +611,7 @@ ValueSetter::writeAppearance() @@ -611,7 +611,7 @@ ValueSetter::writeAppearance()
611 // Write one or more lines, centered vertically, possibly with 611 // Write one or more lines, centered vertically, possibly with
612 // one row highlighted. 612 // one row highlighted.
613 613
614 - size_t max_rows = static_cast<size_t>((bbox.ury - bbox.lly) / tfh); 614 + auto max_rows = static_cast<size_t>((bbox.ury - bbox.lly) / tfh);
615 bool highlight = false; 615 bool highlight = false;
616 size_t highlight_idx = 0; 616 size_t highlight_idx = 0;
617 617
@@ -706,10 +706,10 @@ namespace @@ -706,10 +706,10 @@ namespace
706 { 706 {
707 public: 707 public:
708 TfFinder(); 708 TfFinder();
709 - virtual ~TfFinder() 709 + ~TfFinder() override
710 { 710 {
711 } 711 }
712 - virtual void handleToken(QPDFTokenizer::Token const&); 712 + void handleToken(QPDFTokenizer::Token const&) override;
713 double getTf(); 713 double getTf();
714 std::string getFontName(); 714 std::string getFontName();
715 std::string getDA(); 715 std::string getDA();
libqpdf/QPDFJob.cc
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #include <cstdio> 3 #include <cstdio>
4 #include <cstdlib> 4 #include <cstdlib>
5 #include <cstring> 5 #include <cstring>
6 -#include <ctype.h> 6 +#include <cctype>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <iostream> 8 #include <iostream>
9 #include <memory> 9 #include <memory>
@@ -48,8 +48,8 @@ namespace @@ -48,8 +48,8 @@ namespace
48 size_t oi_min_height, 48 size_t oi_min_height,
49 size_t oi_min_area, 49 size_t oi_min_area,
50 QPDFObjectHandle& image); 50 QPDFObjectHandle& image);
51 - virtual ~ImageOptimizer() = default;  
52 - virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline); 51 + ~ImageOptimizer() override = default;
  52 + void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
53 std::shared_ptr<Pipeline> 53 std::shared_ptr<Pipeline>
54 makePipeline(std::string const& description, Pipeline* next); 54 makePipeline(std::string const& description, Pipeline* next);
55 bool evaluate(std::string const& description); 55 bool evaluate(std::string const& description);
@@ -65,13 +65,13 @@ namespace @@ -65,13 +65,13 @@ namespace
65 class DiscardContents: public QPDFObjectHandle::ParserCallbacks 65 class DiscardContents: public QPDFObjectHandle::ParserCallbacks
66 { 66 {
67 public: 67 public:
68 - virtual ~DiscardContents() = default;  
69 - virtual void  
70 - handleObject(QPDFObjectHandle) 68 + ~DiscardContents() override = default;
  69 + void
  70 + handleObject(QPDFObjectHandle) override
71 { 71 {
72 } 72 }
73 - virtual void  
74 - handleEOF() 73 + void
  74 + handleEOF() override
75 { 75 {
76 } 76 }
77 }; 77 };
@@ -98,8 +98,8 @@ namespace @@ -98,8 +98,8 @@ namespace
98 filename(filename) 98 filename(filename)
99 { 99 {
100 } 100 }
101 - virtual ~ProgressReporter() = default;  
102 - virtual void reportProgress(int); 101 + ~ProgressReporter() override = default;
  102 + void reportProgress(int) override;
103 103
104 private: 104 private:
105 Pipeline& p; 105 Pipeline& p;
libqpdf/QPDFJob_argv.cc
@@ -3,12 +3,12 @@ @@ -3,12 +3,12 @@
3 // See "HOW TO ADD A COMMAND-LINE ARGUMENT" in README-maintainer. 3 // See "HOW TO ADD A COMMAND-LINE ARGUMENT" in README-maintainer.
4 4
5 #include <cstdio> 5 #include <cstdio>
6 -#include <ctype.h> 6 +#include <cctype>
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 #include <sstream> 9 #include <sstream>
10 -#include <stdlib.h>  
11 -#include <string.h> 10 +#include <cstdlib>
  11 +#include <cstring>
12 12
13 #include <qpdf/QIntC.hh> 13 #include <qpdf/QIntC.hh>
14 #include <qpdf/QPDFArgParser.hh> 14 #include <qpdf/QPDFArgParser.hh>
libqpdf/QPDFLogger.cc
@@ -17,14 +17,14 @@ namespace @@ -17,14 +17,14 @@ namespace
17 { 17 {
18 } 18 }
19 19
20 - virtual void 20 + void
21 write(unsigned char const* data, size_t len) override 21 write(unsigned char const* data, size_t len) override
22 { 22 {
23 this->used = true; 23 this->used = true;
24 getNext()->write(data, len); 24 getNext()->write(data, len);
25 } 25 }
26 26
27 - virtual void 27 + void
28 finish() override 28 finish() override
29 { 29 {
30 getNext()->finish(); 30 getNext()->finish();
libqpdf/QPDFNameTreeObjectHelper.cc
@@ -7,18 +7,18 @@ namespace @@ -7,18 +7,18 @@ namespace
7 class NameTreeDetails: public NNTreeDetails 7 class NameTreeDetails: public NNTreeDetails
8 { 8 {
9 public: 9 public:
10 - virtual std::string const& 10 + std::string const&
11 itemsKey() const override 11 itemsKey() const override
12 { 12 {
13 static std::string k("/Names"); 13 static std::string k("/Names");
14 return k; 14 return k;
15 } 15 }
16 - virtual bool 16 + bool
17 keyValid(QPDFObjectHandle oh) const override 17 keyValid(QPDFObjectHandle oh) const override
18 { 18 {
19 return oh.isString(); 19 return oh.isString();
20 } 20 }
21 - virtual int 21 + int
22 compareKeys(QPDFObjectHandle a, QPDFObjectHandle b) const override 22 compareKeys(QPDFObjectHandle a, QPDFObjectHandle b) const override
23 { 23 {
24 if (!(keyValid(a) && keyValid(b))) { 24 if (!(keyValid(a) && keyValid(b))) {
libqpdf/QPDFNumberTreeObjectHelper.cc
@@ -8,18 +8,18 @@ namespace @@ -8,18 +8,18 @@ namespace
8 class NumberTreeDetails: public NNTreeDetails 8 class NumberTreeDetails: public NNTreeDetails
9 { 9 {
10 public: 10 public:
11 - virtual std::string const& 11 + std::string const&
12 itemsKey() const override 12 itemsKey() const override
13 { 13 {
14 static std::string k("/Nums"); 14 static std::string k("/Nums");
15 return k; 15 return k;
16 } 16 }
17 - virtual bool 17 + bool
18 keyValid(QPDFObjectHandle oh) const override 18 keyValid(QPDFObjectHandle oh) const override
19 { 19 {
20 return oh.isInteger(); 20 return oh.isInteger();
21 } 21 }
22 - virtual int 22 + int
23 compareKeys(QPDFObjectHandle a, QPDFObjectHandle b) const override 23 compareKeys(QPDFObjectHandle a, QPDFObjectHandle b) const override
24 { 24 {
25 if (!(keyValid(a) && keyValid(b))) { 25 if (!(keyValid(a) && keyValid(b))) {
libqpdf/QPDFObjectHandle.cc
@@ -30,10 +30,10 @@ @@ -30,10 +30,10 @@
30 30
31 #include <algorithm> 31 #include <algorithm>
32 #include <cstring> 32 #include <cstring>
33 -#include <ctype.h>  
34 -#include <limits.h> 33 +#include <cctype>
  34 +#include <climits>
35 #include <stdexcept> 35 #include <stdexcept>
36 -#include <stdlib.h> 36 +#include <cstdlib>
37 37
38 using namespace std::literals; 38 using namespace std::literals;
39 39
@@ -111,8 +111,8 @@ namespace @@ -111,8 +111,8 @@ namespace
111 old_contents(old_contents) 111 old_contents(old_contents)
112 { 112 {
113 } 113 }
114 - virtual ~CoalesceProvider() = default;  
115 - virtual void provideStreamData(QPDFObjGen const&, Pipeline* pipeline); 114 + ~CoalesceProvider() override = default;
  115 + void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
116 116
117 private: 117 private:
118 QPDFObjectHandle containing_page; 118 QPDFObjectHandle containing_page;
@@ -200,9 +200,9 @@ namespace @@ -200,9 +200,9 @@ namespace
200 { 200 {
201 public: 201 public:
202 LastChar(Pipeline* next); 202 LastChar(Pipeline* next);
203 - virtual ~LastChar() = default;  
204 - virtual void write(unsigned char const* data, size_t len);  
205 - virtual void finish(); 203 + ~LastChar() override = default;
  204 + void write(unsigned char const* data, size_t len) override;
  205 + void finish() override;
206 unsigned char getLastChar(); 206 unsigned char getLastChar();
207 207
208 private: 208 private:
@@ -1446,13 +1446,13 @@ namespace @@ -1446,13 +1446,13 @@ namespace
1446 { 1446 {
1447 } 1447 }
1448 1448
1449 - virtual void 1449 + void
1450 provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override 1450 provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override
1451 { 1451 {
1452 p1(pipeline); 1452 p1(pipeline);
1453 } 1453 }
1454 1454
1455 - virtual bool 1455 + bool
1456 provideStreamData( 1456 provideStreamData(
1457 QPDFObjGen const&, 1457 QPDFObjGen const&,
1458 Pipeline* pipeline, 1458 Pipeline* pipeline,
libqpdf/QPDFParser.cc
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
16 #include <qpdf/QPDF_Reserved.hh> 16 #include <qpdf/QPDF_Reserved.hh>
17 #include <qpdf/QPDF_Stream.hh> 17 #include <qpdf/QPDF_Stream.hh>
18 #include <qpdf/QPDF_String.hh> 18 #include <qpdf/QPDF_String.hh>
19 -#include <qpdf/QPDF_Unresolved.hh>  
20 #include <qpdf/QTC.hh> 19 #include <qpdf/QTC.hh>
21 #include <qpdf/QUtil.hh> 20 #include <qpdf/QUtil.hh>
22 21
libqpdf/QPDFSystemError.cc
1 #include <qpdf/QPDFSystemError.hh> 1 #include <qpdf/QPDFSystemError.hh>
2 2
3 -#include <qpdf/QUtil.hh>  
4 -#include <string.h> 3 +#include <cstring>
5 4
6 QPDFSystemError::QPDFSystemError( 5 QPDFSystemError::QPDFSystemError(
7 std::string const& description, int system_errno) : 6 std::string const& description, int system_errno) :
libqpdf/QPDFTokenizer.cc
@@ -11,8 +11,8 @@ @@ -11,8 +11,8 @@
11 #include <qpdf/QUtil.hh> 11 #include <qpdf/QUtil.hh>
12 12
13 #include <stdexcept> 13 #include <stdexcept>
14 -#include <stdlib.h>  
15 -#include <string.h> 14 +#include <cstdlib>
  15 +#include <cstring>
16 16
17 static inline bool 17 static inline bool
18 is_delimiter(char ch) 18 is_delimiter(char ch)
@@ -35,8 +35,8 @@ namespace @@ -35,8 +35,8 @@ namespace
35 str(str) 35 str(str)
36 { 36 {
37 } 37 }
38 - virtual ~QPDFWordTokenFinder() = default;  
39 - virtual bool check(); 38 + ~QPDFWordTokenFinder() override = default;
  39 + bool check() override;
40 40
41 private: 41 private:
42 std::shared_ptr<InputSource> is; 42 std::shared_ptr<InputSource> is;
libqpdf/QPDFWriter.cc
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 24
25 #include <algorithm> 25 #include <algorithm>
26 #include <stdexcept> 26 #include <stdexcept>
27 -#include <stdlib.h> 27 +#include <cstdlib>
28 28
29 QPDFWriter::ProgressReporter::~ProgressReporter() 29 QPDFWriter::ProgressReporter::~ProgressReporter()
30 { 30 {
@@ -997,7 +997,7 @@ void @@ -997,7 +997,7 @@ void
997 QPDFWriter::activatePipelineStack(PipelinePopper& pp) 997 QPDFWriter::activatePipelineStack(PipelinePopper& pp)
998 { 998 {
999 std::string stack_id("stack " + std::to_string(this->m->next_stack_id)); 999 std::string stack_id("stack " + std::to_string(this->m->next_stack_id));
1000 - Pl_Count* c = 1000 + auto* c =
1001 new Pl_Count(stack_id.c_str(), this->m->pipeline_stack.back()); 1001 new Pl_Count(stack_id.c_str(), this->m->pipeline_stack.back());
1002 ++this->m->next_stack_id; 1002 ++this->m->next_stack_id;
1003 this->m->pipeline_stack.push_back(c); 1003 this->m->pipeline_stack.push_back(c);
@@ -1030,7 +1030,7 @@ QPDFWriter::PipelinePopper::~PipelinePopper() @@ -1030,7 +1030,7 @@ QPDFWriter::PipelinePopper::~PipelinePopper()
1030 qw->m->md5_pipeline = nullptr; 1030 qw->m->md5_pipeline = nullptr;
1031 } 1031 }
1032 qw->m->pipeline_stack.pop_back(); 1032 qw->m->pipeline_stack.pop_back();
1033 - Pl_Buffer* buf = dynamic_cast<Pl_Buffer*>(p); 1033 + auto* buf = dynamic_cast<Pl_Buffer*>(p);
1034 if (bp && buf) { 1034 if (bp && buf) {
1035 *bp = buf->getBufferSharedPointer(); 1035 *bp = buf->getBufferSharedPointer();
1036 } 1036 }
libqpdf/QPDFXRefEntry.cc
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include <qpdf/QIntC.hh> 3 #include <qpdf/QIntC.hh>
4 #include <qpdf/QPDFExc.hh> 4 #include <qpdf/QPDFExc.hh>
5 -#include <qpdf/QUtil.hh>  
6 5
7 QPDFXRefEntry::QPDFXRefEntry() 6 QPDFXRefEntry::QPDFXRefEntry()
8 { 7 {
libqpdf/QPDF_Array.cc
@@ -83,7 +83,7 @@ QPDF_Array::copy(bool shallow) @@ -83,7 +83,7 @@ QPDF_Array::copy(bool shallow)
83 return do_create(new QPDF_Array(*this)); 83 return do_create(new QPDF_Array(*this));
84 } else { 84 } else {
85 if (sparse) { 85 if (sparse) {
86 - QPDF_Array* result = new QPDF_Array(); 86 + auto* result = new QPDF_Array();
87 result->sp_size = sp_size; 87 result->sp_size = sp_size;
88 for (auto const& element: sp_elements) { 88 for (auto const& element: sp_elements) {
89 auto const& obj = element.second; 89 auto const& obj = element.second;
libqpdf/QPDF_Name.cc
1 #include <qpdf/QPDF_Name.hh> 1 #include <qpdf/QPDF_Name.hh>
2 2
3 #include <qpdf/QUtil.hh> 3 #include <qpdf/QUtil.hh>
4 -#include <stdio.h>  
5 -#include <string.h>  
6 4
7 QPDF_Name::QPDF_Name(std::string const& name) : 5 QPDF_Name::QPDF_Name(std::string const& name) :
8 QPDFValue(::ot_name, "name"), 6 QPDFValue(::ot_name, "name"),
libqpdf/QPDF_Stream.cc
@@ -27,10 +27,10 @@ namespace @@ -27,10 +27,10 @@ namespace
27 { 27 {
28 public: 28 public:
29 SF_Crypt() = default; 29 SF_Crypt() = default;
30 - virtual ~SF_Crypt() = default; 30 + ~SF_Crypt() override = default;
31 31
32 - virtual bool  
33 - setDecodeParms(QPDFObjectHandle decode_parms) 32 + bool
  33 + setDecodeParms(QPDFObjectHandle decode_parms) override
34 { 34 {
35 if (decode_parms.isNull()) { 35 if (decode_parms.isNull()) {
36 return true; 36 return true;
@@ -49,8 +49,8 @@ namespace @@ -49,8 +49,8 @@ namespace
49 return filterable; 49 return filterable;
50 } 50 }
51 51
52 - virtual Pipeline*  
53 - getDecodePipeline(Pipeline*) 52 + Pipeline*
  53 + getDecodePipeline(Pipeline*) override
54 { 54 {
55 // Not used -- handled by pipeStreamData 55 // Not used -- handled by pipeStreamData
56 return nullptr; 56 return nullptr;
@@ -557,7 +557,7 @@ QPDF_Stream::pipeStreamData( @@ -557,7 +557,7 @@ QPDF_Stream::pipeStreamData(
557 if (decode_pipeline) { 557 if (decode_pipeline) {
558 pipeline = decode_pipeline; 558 pipeline = decode_pipeline;
559 } 559 }
560 - Pl_Flate* flate = dynamic_cast<Pl_Flate*>(pipeline); 560 + auto* flate = dynamic_cast<Pl_Flate*>(pipeline);
561 if (flate != nullptr) { 561 if (flate != nullptr) {
562 flate->setWarnCallback( 562 flate->setWarnCallback(
563 [this](char const* msg, int code) { warn(msg); }); 563 [this](char const* msg, int code) { warn(msg); });
libqpdf/QPDF_String.cc
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 // DO NOT USE ctype -- it is locale dependent for some things, and 5 // DO NOT USE ctype -- it is locale dependent for some things, and
6 // it's not worth the risk of including it in case it may accidentally 6 // it's not worth the risk of including it in case it may accidentally
7 // be used. 7 // be used.
8 -#include <string.h>  
9 8
10 static bool 9 static bool
11 is_iso_latin1_printable(char ch) 10 is_iso_latin1_printable(char ch)
libqpdf/QPDF_encryption.cc
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 #include <qpdf/RC4.hh> 17 #include <qpdf/RC4.hh>
18 18
19 #include <algorithm> 19 #include <algorithm>
20 -#include <string.h> 20 +#include <cstring>
21 21
22 static unsigned char const padding_string[] = { 22 static unsigned char const padding_string[] = {
23 0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 23 0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e,
libqpdf/QPDF_json.cc
@@ -242,13 +242,13 @@ class QPDF::JSONReactor: public JSON::Reactor @@ -242,13 +242,13 @@ class QPDF::JSONReactor: public JSON::Reactor
242 } 242 }
243 } 243 }
244 virtual ~JSONReactor() = default; 244 virtual ~JSONReactor() = default;
245 - virtual void dictionaryStart() override;  
246 - virtual void arrayStart() override;  
247 - virtual void containerEnd(JSON const& value) override;  
248 - virtual void topLevelScalar() override;  
249 - virtual bool 245 + void dictionaryStart() override;
  246 + void arrayStart() override;
  247 + void containerEnd(JSON const& value) override;
  248 + void topLevelScalar() override;
  249 + bool
250 dictionaryItem(std::string const& key, JSON const& value) override; 250 dictionaryItem(std::string const& key, JSON const& value) override;
251 - virtual bool arrayItem(JSON const& value) override; 251 + bool arrayItem(JSON const& value) override;
252 252
253 bool anyErrors() const; 253 bool anyErrors() const;
254 254
libqpdf/QPDF_linearization.cc
@@ -13,9 +13,8 @@ @@ -13,9 +13,8 @@
13 #include <qpdf/QUtil.hh> 13 #include <qpdf/QUtil.hh>
14 14
15 #include <algorithm> 15 #include <algorithm>
16 -#include <iostream>  
17 -#include <math.h>  
18 -#include <string.h> 16 +#include <cmath>
  17 +#include <cstring>
19 18
20 template <class T, class int_type> 19 template <class T, class int_type>
21 static void 20 static void
libqpdf/QPDF_optimization.cc
@@ -115,7 +115,7 @@ QPDF::optimize( @@ -115,7 +115,7 @@ QPDF::optimize(
115 } 115 }
116 116
117 ObjUser root_ou = ObjUser(ObjUser::ou_root); 117 ObjUser root_ou = ObjUser(ObjUser::ou_root);
118 - QPDFObjGen root_og = QPDFObjGen(root.getObjGen()); 118 + auto root_og = QPDFObjGen(root.getObjGen());
119 this->m->obj_user_to_objects[root_ou].insert(root_og); 119 this->m->obj_user_to_objects[root_ou].insert(root_og);
120 this->m->object_to_obj_users[root_og].insert(root_ou); 120 this->m->object_to_obj_users[root_og].insert(root_ou);
121 121
libqpdf/QTC.cc
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #include <qpdf/QUtil.hh> 3 #include <qpdf/QUtil.hh>
4 #include <map> 4 #include <map>
5 #include <set> 5 #include <set>
6 -#include <stdio.h> 6 +#include <cstdio>
7 7
8 static bool 8 static bool
9 tc_active(char const* const scope) 9 tc_active(char const* const scope)
libqpdf/QUtil.cc
@@ -9,9 +9,8 @@ @@ -9,9 +9,8 @@
9 #include <qpdf/QPDFSystemError.hh> 9 #include <qpdf/QPDFSystemError.hh>
10 #include <qpdf/QTC.hh> 10 #include <qpdf/QTC.hh>
11 11
12 -#include <cmath>  
13 -#include <ctype.h>  
14 -#include <errno.h> 12 +#include <cctype>
  13 +#include <cerrno>
15 #include <fcntl.h> 14 #include <fcntl.h>
16 #include <fstream> 15 #include <fstream>
17 #include <iomanip> 16 #include <iomanip>
@@ -22,9 +21,9 @@ @@ -22,9 +21,9 @@
22 #include <set> 21 #include <set>
23 #include <sstream> 22 #include <sstream>
24 #include <stdexcept> 23 #include <stdexcept>
25 -#include <stdio.h>  
26 -#include <stdlib.h>  
27 -#include <string.h> 24 +#include <cstdio>
  25 +#include <cstdlib>
  26 +#include <cstring>
28 #ifndef QPDF_NO_WCHAR_T 27 #ifndef QPDF_NO_WCHAR_T
29 # include <cwchar> 28 # include <cwchar>
30 #endif 29 #endif
@@ -837,8 +836,8 @@ char* @@ -837,8 +836,8 @@ char*
837 QUtil::getWhoami(char* argv0) 836 QUtil::getWhoami(char* argv0)
838 { 837 {
839 char* whoami = nullptr; 838 char* whoami = nullptr;
840 - if (((whoami = strrchr(argv0, '/')) == NULL) &&  
841 - ((whoami = strrchr(argv0, '\\')) == NULL)) { 839 + if (((whoami = strrchr(argv0, '/')) == nullptr) &&
  840 + ((whoami = strrchr(argv0, '\\')) == nullptr)) {
842 whoami = argv0; 841 whoami = argv0;
843 } else { 842 } else {
844 ++whoami; 843 ++whoami;
libqpdf/RC4.cc
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include <qpdf/QPDFCryptoProvider.hh> 3 #include <qpdf/QPDFCryptoProvider.hh>
4 4
5 -#include <string.h>  
6 5
7 RC4::RC4(unsigned char const* key_data, int key_len) : 6 RC4::RC4(unsigned char const* key_data, int key_len) :
8 crypto(QPDFCryptoProvider::getImpl()) 7 crypto(QPDFCryptoProvider::getImpl())
libqpdf/qpdf-c.cc
@@ -15,7 +15,6 @@ @@ -15,7 +15,6 @@
15 #include <qpdf/qpdf-c_impl.hh> 15 #include <qpdf/qpdf-c_impl.hh>
16 #include <qpdf/qpdflogger-c_impl.hh> 16 #include <qpdf/qpdflogger-c_impl.hh>
17 17
18 -#include <cstring>  
19 #include <functional> 18 #include <functional>
20 #include <list> 19 #include <list>
21 #include <stdexcept> 20 #include <stdexcept>
@@ -107,7 +106,7 @@ qpdf_data @@ -107,7 +106,7 @@ qpdf_data
107 qpdf_init() 106 qpdf_init()
108 { 107 {
109 QTC::TC("qpdf", "qpdf-c called qpdf_init"); 108 QTC::TC("qpdf", "qpdf-c called qpdf_init");
110 - qpdf_data qpdf = new _qpdf_data(); 109 + auto qpdf = new _qpdf_data();
111 qpdf->qpdf = QPDF::create(); 110 qpdf->qpdf = QPDF::create();
112 return qpdf; 111 return qpdf;
113 } 112 }
libqpdf/qpdf/BitStream.hh
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #ifndef BITSTREAM_HH 3 #ifndef BITSTREAM_HH
4 #define BITSTREAM_HH 4 #define BITSTREAM_HH
5 5
6 -#include <stddef.h> 6 +#include <cstddef>
7 7
8 class BitStream 8 class BitStream
9 { 9 {
libqpdf/qpdf/BitWriter.hh
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #ifndef BITWRITER_HH 3 #ifndef BITWRITER_HH
4 #define BITWRITER_HH 4 #define BITWRITER_HH
5 5
6 -#include <stddef.h> 6 +#include <cstddef>
7 7
8 class Pipeline; 8 class Pipeline;
9 9
libqpdf/qpdf/ContentNormalizer.hh
@@ -7,8 +7,8 @@ class ContentNormalizer: public QPDFObjectHandle::TokenFilter @@ -7,8 +7,8 @@ class ContentNormalizer: public QPDFObjectHandle::TokenFilter
7 { 7 {
8 public: 8 public:
9 ContentNormalizer(); 9 ContentNormalizer();
10 - virtual ~ContentNormalizer() = default;  
11 - virtual void handleToken(QPDFTokenizer::Token const&); 10 + ~ContentNormalizer() override = default;
  11 + void handleToken(QPDFTokenizer::Token const&) override;
12 12
13 bool anyBadTokens() const; 13 bool anyBadTokens() const;
14 bool lastTokenWasBad() const; 14 bool lastTokenWasBad() const;
libqpdf/qpdf/CryptoRandomDataProvider.hh
@@ -7,8 +7,8 @@ class CryptoRandomDataProvider: public RandomDataProvider @@ -7,8 +7,8 @@ class CryptoRandomDataProvider: public RandomDataProvider
7 { 7 {
8 public: 8 public:
9 CryptoRandomDataProvider() = default; 9 CryptoRandomDataProvider() = default;
10 - virtual ~CryptoRandomDataProvider() = default;  
11 - virtual void provideRandomData(unsigned char* data, size_t len); 10 + ~CryptoRandomDataProvider() override = default;
  11 + void provideRandomData(unsigned char* data, size_t len) override;
12 static RandomDataProvider* getInstance(); 12 static RandomDataProvider* getInstance();
13 }; 13 };
14 14
libqpdf/qpdf/InsecureRandomDataProvider.hh
@@ -7,8 +7,8 @@ class InsecureRandomDataProvider: public RandomDataProvider @@ -7,8 +7,8 @@ class InsecureRandomDataProvider: public RandomDataProvider
7 { 7 {
8 public: 8 public:
9 InsecureRandomDataProvider(); 9 InsecureRandomDataProvider();
10 - virtual ~InsecureRandomDataProvider() = default;  
11 - virtual void provideRandomData(unsigned char* data, size_t len); 10 + ~InsecureRandomDataProvider() override = default;
  11 + void provideRandomData(unsigned char* data, size_t len) override;
12 static RandomDataProvider* getInstance(); 12 static RandomDataProvider* getInstance();
13 13
14 private: 14 private:
libqpdf/qpdf/OffsetInputSource.hh
@@ -11,15 +11,15 @@ class OffsetInputSource: public InputSource @@ -11,15 +11,15 @@ class OffsetInputSource: public InputSource
11 public: 11 public:
12 OffsetInputSource( 12 OffsetInputSource(
13 std::shared_ptr<InputSource>, qpdf_offset_t global_offset); 13 std::shared_ptr<InputSource>, qpdf_offset_t global_offset);
14 - virtual ~OffsetInputSource() = default; 14 + ~OffsetInputSource() override = default;
15 15
16 - virtual qpdf_offset_t findAndSkipNextEOL();  
17 - virtual std::string const& getName() const;  
18 - virtual qpdf_offset_t tell();  
19 - virtual void seek(qpdf_offset_t offset, int whence);  
20 - virtual void rewind();  
21 - virtual size_t read(char* buffer, size_t length);  
22 - virtual void unreadCh(char ch); 16 + qpdf_offset_t findAndSkipNextEOL() override;
  17 + std::string const& getName() const override;
  18 + qpdf_offset_t tell() override;
  19 + void seek(qpdf_offset_t offset, int whence) override;
  20 + void rewind() override;
  21 + size_t read(char* buffer, size_t length) override;
  22 + void unreadCh(char ch) override;
23 23
24 private: 24 private:
25 std::shared_ptr<InputSource> proxied; 25 std::shared_ptr<InputSource> proxied;
libqpdf/qpdf/Pl_AES_PDF.hh
@@ -18,10 +18,10 @@ class Pl_AES_PDF: public Pipeline @@ -18,10 +18,10 @@ class Pl_AES_PDF: public Pipeline
18 bool encrypt, 18 bool encrypt,
19 unsigned char const* key, 19 unsigned char const* key,
20 size_t key_bytes); 20 size_t key_bytes);
21 - virtual ~Pl_AES_PDF() = default; 21 + ~Pl_AES_PDF() override = default;
22 22
23 - virtual void write(unsigned char const* data, size_t len);  
24 - virtual void finish(); 23 + void write(unsigned char const* data, size_t len) override;
  24 + void finish() override;
25 25
26 // Use zero initialization vector; needed for AESV3 26 // Use zero initialization vector; needed for AESV3
27 void useZeroIV(); 27 void useZeroIV();
libqpdf/qpdf/Pl_ASCII85Decoder.hh
@@ -7,9 +7,9 @@ class Pl_ASCII85Decoder: public Pipeline @@ -7,9 +7,9 @@ class Pl_ASCII85Decoder: public Pipeline
7 { 7 {
8 public: 8 public:
9 Pl_ASCII85Decoder(char const* identifier, Pipeline* next); 9 Pl_ASCII85Decoder(char const* identifier, Pipeline* next);
10 - virtual ~Pl_ASCII85Decoder() = default;  
11 - virtual void write(unsigned char const* buf, size_t len);  
12 - virtual void finish(); 10 + ~Pl_ASCII85Decoder() override = default;
  11 + void write(unsigned char const* buf, size_t len) override;
  12 + void finish() override;
13 13
14 private: 14 private:
15 void flush(); 15 void flush();
libqpdf/qpdf/Pl_ASCIIHexDecoder.hh
@@ -7,9 +7,9 @@ class Pl_ASCIIHexDecoder: public Pipeline @@ -7,9 +7,9 @@ class Pl_ASCIIHexDecoder: public Pipeline
7 { 7 {
8 public: 8 public:
9 Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next); 9 Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next);
10 - virtual ~Pl_ASCIIHexDecoder() = default;  
11 - virtual void write(unsigned char const* buf, size_t len);  
12 - virtual void finish(); 10 + ~Pl_ASCIIHexDecoder() override = default;
  11 + void write(unsigned char const* buf, size_t len) override;
  12 + void finish() override;
13 13
14 private: 14 private:
15 void flush(); 15 void flush();
libqpdf/qpdf/Pl_Base64.hh
@@ -8,9 +8,9 @@ class Pl_Base64: public Pipeline @@ -8,9 +8,9 @@ class Pl_Base64: public Pipeline
8 public: 8 public:
9 enum action_e { a_encode, a_decode }; 9 enum action_e { a_encode, a_decode };
10 Pl_Base64(char const* identifier, Pipeline* next, action_e); 10 Pl_Base64(char const* identifier, Pipeline* next, action_e);
11 - virtual ~Pl_Base64() = default;  
12 - virtual void write(unsigned char const* buf, size_t len) override;  
13 - virtual void finish() override; 11 + ~Pl_Base64() override = default;
  12 + void write(unsigned char const* buf, size_t len) override;
  13 + void finish() override;
14 14
15 private: 15 private:
16 void decode(unsigned char const* buf, size_t len); 16 void decode(unsigned char const* buf, size_t len);
libqpdf/qpdf/Pl_PNGFilter.hh
@@ -22,10 +22,10 @@ class Pl_PNGFilter: public Pipeline @@ -22,10 +22,10 @@ class Pl_PNGFilter: public Pipeline
22 unsigned int columns, 22 unsigned int columns,
23 unsigned int samples_per_pixel = 1, 23 unsigned int samples_per_pixel = 1,
24 unsigned int bits_per_sample = 8); 24 unsigned int bits_per_sample = 8);
25 - virtual ~Pl_PNGFilter() = default; 25 + ~Pl_PNGFilter() override = default;
26 26
27 - virtual void write(unsigned char const* data, size_t len);  
28 - virtual void finish(); 27 + void write(unsigned char const* data, size_t len) override;
  28 + void finish() override;
29 29
30 private: 30 private:
31 void decodeSub(); 31 void decodeSub();
libqpdf/qpdf/Pl_RC4.hh
@@ -17,10 +17,10 @@ class Pl_RC4: public Pipeline @@ -17,10 +17,10 @@ class Pl_RC4: public Pipeline
17 unsigned char const* key_data, 17 unsigned char const* key_data,
18 int key_len = -1, 18 int key_len = -1,
19 size_t out_bufsize = def_bufsize); 19 size_t out_bufsize = def_bufsize);
20 - virtual ~Pl_RC4() = default; 20 + ~Pl_RC4() override = default;
21 21
22 - virtual void write(unsigned char const* data, size_t len);  
23 - virtual void finish(); 22 + void write(unsigned char const* data, size_t len) override;
  23 + void finish() override;
24 24
25 private: 25 private:
26 std::shared_ptr<unsigned char> outbuf; 26 std::shared_ptr<unsigned char> outbuf;
libqpdf/qpdf/Pl_SHA2.hh
@@ -20,10 +20,10 @@ @@ -20,10 +20,10 @@
20 class Pl_SHA2: public Pipeline 20 class Pl_SHA2: public Pipeline
21 { 21 {
22 public: 22 public:
23 - Pl_SHA2(int bits = 0, Pipeline* next = 0);  
24 - virtual ~Pl_SHA2() = default;  
25 - virtual void write(unsigned char const*, size_t);  
26 - virtual void finish(); 23 + Pl_SHA2(int bits = 0, Pipeline* next = nullptr);
  24 + ~Pl_SHA2() override = default;
  25 + void write(unsigned char const*, size_t) override;
  26 + void finish() override;
27 void resetBits(int bits); 27 void resetBits(int bits);
28 std::string getHexDigest(); 28 std::string getHexDigest();
29 std::string getRawDigest(); 29 std::string getRawDigest();
libqpdf/qpdf/Pl_TIFFPredictor.hh
@@ -18,10 +18,10 @@ class Pl_TIFFPredictor: public Pipeline @@ -18,10 +18,10 @@ class Pl_TIFFPredictor: public Pipeline
18 unsigned int columns, 18 unsigned int columns,
19 unsigned int samples_per_pixel = 1, 19 unsigned int samples_per_pixel = 1,
20 unsigned int bits_per_sample = 8); 20 unsigned int bits_per_sample = 8);
21 - virtual ~Pl_TIFFPredictor() = default; 21 + ~Pl_TIFFPredictor() override = default;
22 22
23 - virtual void write(unsigned char const* data, size_t len);  
24 - virtual void finish(); 23 + void write(unsigned char const* data, size_t len) override;
  24 + void finish() override;
25 25
26 private: 26 private:
27 void processRow(); 27 void processRow();
libqpdf/qpdf/QPDFArgParser.hh
@@ -177,9 +177,9 @@ class QPDFArgParser @@ -177,9 +177,9 @@ class QPDFArgParser
177 { 177 {
178 OptionEntry() : 178 OptionEntry() :
179 parameter_needed(false), 179 parameter_needed(false),
180 - bare_arg_handler(0),  
181 - param_arg_handler(0),  
182 - invalid_choice_handler(0) 180 + bare_arg_handler(nullptr),
  181 + param_arg_handler(nullptr),
  182 + invalid_choice_handler(nullptr)
183 { 183 {
184 } 184 }
185 bool parameter_needed; 185 bool parameter_needed;
libqpdf/qpdf/QPDFCrypto_openssl.hh
@@ -39,7 +39,7 @@ class QPDFCrypto_openssl: public QPDFCryptoImpl @@ -39,7 +39,7 @@ class QPDFCrypto_openssl: public QPDFCryptoImpl
39 void RC4_process( 39 void RC4_process(
40 unsigned char const* in_data, 40 unsigned char const* in_data,
41 size_t len, 41 size_t len,
42 - unsigned char* out_data = 0) override; 42 + unsigned char* out_data = nullptr) override;
43 void RC4_finalize() override; 43 void RC4_finalize() override;
44 44
45 void SHA2_init(int bits) override; 45 void SHA2_init(int bits) override;
libqpdf/qpdf/ResourceFinder.hh
@@ -8,8 +8,8 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks @@ -8,8 +8,8 @@ class ResourceFinder: public QPDFObjectHandle::ParserCallbacks
8 public: 8 public:
9 ResourceFinder(); 9 ResourceFinder();
10 virtual ~ResourceFinder() = default; 10 virtual ~ResourceFinder() = default;
11 - virtual void handleObject(QPDFObjectHandle, size_t, size_t) override;  
12 - virtual void handleEOF() override; 11 + void handleObject(QPDFObjectHandle, size_t, size_t) override;
  12 + void handleEOF() override;
13 std::set<std::string> const& getNames() const; 13 std::set<std::string> const& getNames() const;
14 std::map<std::string, std::map<std::string, std::set<size_t>>> const& 14 std::map<std::string, std::map<std::string, std::set<size_t>>> const&
15 getNamesByResourceType() const; 15 getNamesByResourceType() const;
libqpdf/qpdf/SF_ASCII85Decode.hh
@@ -11,7 +11,7 @@ class SF_ASCII85Decode: public QPDFStreamFilter @@ -11,7 +11,7 @@ class SF_ASCII85Decode: public QPDFStreamFilter
11 SF_ASCII85Decode() = default; 11 SF_ASCII85Decode() = default;
12 virtual ~SF_ASCII85Decode() = default; 12 virtual ~SF_ASCII85Decode() = default;
13 13
14 - virtual Pipeline* 14 + Pipeline*
15 getDecodePipeline(Pipeline* next) override 15 getDecodePipeline(Pipeline* next) override
16 { 16 {
17 this->pipeline = 17 this->pipeline =
libqpdf/qpdf/SF_ASCIIHexDecode.hh
@@ -11,7 +11,7 @@ class SF_ASCIIHexDecode: public QPDFStreamFilter @@ -11,7 +11,7 @@ class SF_ASCIIHexDecode: public QPDFStreamFilter
11 SF_ASCIIHexDecode() = default; 11 SF_ASCIIHexDecode() = default;
12 virtual ~SF_ASCIIHexDecode() = default; 12 virtual ~SF_ASCIIHexDecode() = default;
13 13
14 - virtual Pipeline* 14 + Pipeline*
15 getDecodePipeline(Pipeline* next) override 15 getDecodePipeline(Pipeline* next) override
16 { 16 {
17 this->pipeline = 17 this->pipeline =
libqpdf/qpdf/SF_DCTDecode.hh
@@ -11,7 +11,7 @@ class SF_DCTDecode: public QPDFStreamFilter @@ -11,7 +11,7 @@ class SF_DCTDecode: public QPDFStreamFilter
11 SF_DCTDecode() = default; 11 SF_DCTDecode() = default;
12 virtual ~SF_DCTDecode() = default; 12 virtual ~SF_DCTDecode() = default;
13 13
14 - virtual Pipeline* 14 + Pipeline*
15 getDecodePipeline(Pipeline* next) override 15 getDecodePipeline(Pipeline* next) override
16 { 16 {
17 this->pipeline = std::make_shared<Pl_DCT>("DCT decode", next); 17 this->pipeline = std::make_shared<Pl_DCT>("DCT decode", next);
@@ -24,13 +24,13 @@ class SF_DCTDecode: public QPDFStreamFilter @@ -24,13 +24,13 @@ class SF_DCTDecode: public QPDFStreamFilter
24 return std::make_shared<SF_DCTDecode>(); 24 return std::make_shared<SF_DCTDecode>();
25 } 25 }
26 26
27 - virtual bool 27 + bool
28 isSpecializedCompression() override 28 isSpecializedCompression() override
29 { 29 {
30 return true; 30 return true;
31 } 31 }
32 32
33 - virtual bool 33 + bool
34 isLossyCompression() override 34 isLossyCompression() override
35 { 35 {
36 return true; 36 return true;
libqpdf/qpdf/SF_RunLengthDecode.hh
@@ -11,7 +11,7 @@ class SF_RunLengthDecode: public QPDFStreamFilter @@ -11,7 +11,7 @@ class SF_RunLengthDecode: public QPDFStreamFilter
11 SF_RunLengthDecode() = default; 11 SF_RunLengthDecode() = default;
12 virtual ~SF_RunLengthDecode() = default; 12 virtual ~SF_RunLengthDecode() = default;
13 13
14 - virtual Pipeline* 14 + Pipeline*
15 getDecodePipeline(Pipeline* next) override 15 getDecodePipeline(Pipeline* next) override
16 { 16 {
17 this->pipeline = std::make_shared<Pl_RunLength>( 17 this->pipeline = std::make_shared<Pl_RunLength>(
@@ -25,7 +25,7 @@ class SF_RunLengthDecode: public QPDFStreamFilter @@ -25,7 +25,7 @@ class SF_RunLengthDecode: public QPDFStreamFilter
25 return std::make_shared<SF_RunLengthDecode>(); 25 return std::make_shared<SF_RunLengthDecode>();
26 } 26 }
27 27
28 - virtual bool 28 + bool
29 isSpecializedCompression() override 29 isSpecializedCompression() override
30 { 30 {
31 return true; 31 return true;
libqpdf/qpdfjob-c.cc
1 #include <qpdf/qpdfjob-c.h> 1 #include <qpdf/qpdfjob-c.h>
2 2
3 #include <qpdf/QPDFJob.hh> 3 #include <qpdf/QPDFJob.hh>
4 -#include <qpdf/QPDFLogger.hh>  
5 #include <qpdf/QPDFUsage.hh> 4 #include <qpdf/QPDFUsage.hh>
6 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
7 #include <qpdf/qpdf-c_impl.hh> 6 #include <qpdf/qpdf-c_impl.hh>
8 #include <qpdf/qpdflogger-c_impl.hh> 7 #include <qpdf/qpdflogger-c_impl.hh>
9 8
10 #include <cstdio> 9 #include <cstdio>
11 -#include <cstring>  
12 10
13 struct _qpdfjob_handle 11 struct _qpdfjob_handle
14 { 12 {
libqpdf/qpdflogger-c.cc
@@ -4,7 +4,6 @@ @@ -4,7 +4,6 @@
4 4
5 #include <qpdf/Pipeline.hh> 5 #include <qpdf/Pipeline.hh>
6 #include <qpdf/Pl_Function.hh> 6 #include <qpdf/Pl_Function.hh>
7 -#include <qpdf/QIntC.hh>  
8 #include <qpdf/QPDFLogger.hh> 7 #include <qpdf/QPDFLogger.hh>
9 #include <functional> 8 #include <functional>
10 #include <memory> 9 #include <memory>
libtests/aes.cc
@@ -4,9 +4,9 @@ @@ -4,9 +4,9 @@
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
5 5
6 #include <iostream> 6 #include <iostream>
7 -#include <stdio.h>  
8 -#include <stdlib.h>  
9 -#include <string.h> 7 +#include <cstdio>
  8 +#include <cstdlib>
  9 +#include <cstring>
10 10
11 static void 11 static void
12 usage() 12 usage()
@@ -29,9 +29,9 @@ main(int argc, char* argv[]) @@ -29,9 +29,9 @@ main(int argc, char* argv[])
29 { 29 {
30 bool encrypt = true; 30 bool encrypt = true;
31 bool cbc_mode = true; 31 bool cbc_mode = true;
32 - char* hexkey = 0;  
33 - char* infilename = 0;  
34 - char* outfilename = 0; 32 + char* hexkey = nullptr;
  33 + char* infilename = nullptr;
  34 + char* outfilename = nullptr;
35 bool zero_iv = false; 35 bool zero_iv = false;
36 bool static_iv = false; 36 bool static_iv = false;
37 bool disable_padding = false; 37 bool disable_padding = false;
@@ -65,7 +65,7 @@ main(int argc, char* argv[]) @@ -65,7 +65,7 @@ main(int argc, char* argv[])
65 usage(); 65 usage();
66 } 66 }
67 } 67 }
68 - if (outfilename == 0) { 68 + if (outfilename == nullptr) {
69 usage(); 69 usage();
70 } 70 }
71 71
@@ -74,21 +74,21 @@ main(int argc, char* argv[]) @@ -74,21 +74,21 @@ main(int argc, char* argv[])
74 74
75 FILE* infile = QUtil::safe_fopen(infilename, "rb"); 75 FILE* infile = QUtil::safe_fopen(infilename, "rb");
76 FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); 76 FILE* outfile = QUtil::safe_fopen(outfilename, "wb");
77 - unsigned char* key = new unsigned char[keylen]; 77 + auto* key = new unsigned char[keylen];
78 for (unsigned int i = 0; i < strlen(hexkey); i += 2) { 78 for (unsigned int i = 0; i < strlen(hexkey); i += 2) {
79 char t[3]; 79 char t[3];
80 t[0] = hexkey[i]; 80 t[0] = hexkey[i];
81 t[1] = hexkey[i + 1]; 81 t[1] = hexkey[i + 1];
82 t[2] = '\0'; 82 t[2] = '\0';
83 83
84 - long val = strtol(t, 0, 16); 84 + long val = strtol(t, nullptr, 16);
85 key[i / 2] = static_cast<unsigned char>(val); 85 key[i / 2] = static_cast<unsigned char>(val);
86 } 86 }
87 87
88 - Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile);  
89 - Pl_AES_PDF* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen); 88 + auto* out = new Pl_StdioFile("stdout", outfile);
  89 + auto* aes = new Pl_AES_PDF("aes_128_cbc", out, encrypt, key, keylen);
90 delete[] key; 90 delete[] key;
91 - key = 0; 91 + key = nullptr;
92 if (!cbc_mode) { 92 if (!cbc_mode) {
93 aes->disableCBC(); 93 aes->disableCBC();
94 } 94 }
libtests/arg_parser.cc
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include <qpdf/QPDFArgParser.hh> 3 #include <qpdf/QPDFArgParser.hh>
4 #include <qpdf/QPDFUsage.hh> 4 #include <qpdf/QPDFUsage.hh>
5 -#include <qpdf/QUtil.hh>  
6 #include <cstring> 5 #include <cstring>
7 #include <iostream> 6 #include <iostream>
8 7
@@ -52,7 +51,7 @@ ArgParser::initOptions() @@ -52,7 +51,7 @@ ArgParser::initOptions()
52 ap.addBare("potato", b(&ArgParser::handlePotato)); 51 ap.addBare("potato", b(&ArgParser::handlePotato));
53 ap.addRequiredParameter("salad", p(&ArgParser::handleSalad), "tossed"); 52 ap.addRequiredParameter("salad", p(&ArgParser::handleSalad), "tossed");
54 ap.addOptionalParameter("moo", p(&ArgParser::handleMoo)); 53 ap.addOptionalParameter("moo", p(&ArgParser::handleMoo));
55 - char const* choices[] = {"pig", "boar", "sow", 0}; 54 + char const* choices[] = {"pig", "boar", "sow", nullptr};
56 ap.addChoices("oink", p(&ArgParser::handleOink), true, choices); 55 ap.addChoices("oink", p(&ArgParser::handleOink), true, choices);
57 ap.selectHelpOptionTable(); 56 ap.selectHelpOptionTable();
58 ap.addBare("version", [this]() { output("3.14159"); }); 57 ap.addBare("version", [this]() { output("3.14159"); });
libtests/ascii85.cc
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 #include <qpdf/Pl_StdioFile.hh> 3 #include <qpdf/Pl_StdioFile.hh>
4 #include <iostream> 4 #include <iostream>
5 -#include <stdlib.h> 5 +#include <cstdlib>
6 6
7 int 7 int
8 main() 8 main()
libtests/bits.cc
@@ -4,8 +4,7 @@ @@ -4,8 +4,7 @@
4 #include <qpdf/QIntC.hh> 4 #include <qpdf/QIntC.hh>
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 #include <iostream> 6 #include <iostream>
7 -#include <stdio.h>  
8 -#include <stdlib.h> 7 +#include <cstdlib>
9 8
10 // See comments in bits_functions.hh 9 // See comments in bits_functions.hh
11 #define BITS_TESTING 1 10 #define BITS_TESTING 1
@@ -142,7 +141,7 @@ test() @@ -142,7 +141,7 @@ test()
142 141
143 unsigned char ch = 0; 142 unsigned char ch = 0;
144 bit_offset = 7; 143 bit_offset = 7;
145 - Pl_Buffer* bp = new Pl_Buffer("buffer"); 144 + auto* bp = new Pl_Buffer("buffer");
146 145
147 test_write_bits(ch, bit_offset, 30UL, 5, bp); 146 test_write_bits(ch, bit_offset, 30UL, 5, bp);
148 test_write_bits(ch, bit_offset, 10UL, 4, bp); 147 test_write_bits(ch, bit_offset, 10UL, 4, bp);
libtests/buffer.cc
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 #include <cstring> 7 #include <cstring>
8 #include <iostream> 8 #include <iostream>
9 #include <stdexcept> 9 #include <stdexcept>
10 -#include <stdlib.h> 10 +#include <cstdlib>
11 11
12 static unsigned char* 12 static unsigned char*
13 uc(char const* s) 13 uc(char const* s)
libtests/closed_file_input_source.cc
@@ -2,9 +2,7 @@ @@ -2,9 +2,7 @@
2 #include <qpdf/FileInputSource.hh> 2 #include <qpdf/FileInputSource.hh>
3 3
4 #include <iostream> 4 #include <iostream>
5 -#include <stdio.h>  
6 -#include <stdlib.h>  
7 -#include <string.h> 5 +#include <cstdio>
8 6
9 void 7 void
10 check(std::string const& what, bool result) 8 check(std::string const& what, bool result)
libtests/cxx11.cc
1 #include <qpdf/assert_test.h> 1 #include <qpdf/assert_test.h>
2 2
3 -#include <cstdint>  
4 #include <cstdlib> 3 #include <cstdlib>
5 #include <cstring> 4 #include <cstring>
6 #include <functional> 5 #include <functional>
libtests/dct_compress.cc
@@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
3 #include <qpdf/QUtil.hh> 3 #include <qpdf/QUtil.hh>
4 4
5 #include <iostream> 5 #include <iostream>
6 -#include <stdio.h>  
7 -#include <stdlib.h>  
8 -#include <string.h> 6 +#include <cstdio>
  7 +#include <cstdlib>
  8 +#include <cstring>
9 9
10 static void 10 static void
11 usage() 11 usage()
@@ -22,8 +22,8 @@ class Callback: public Pl_DCT::CompressConfig @@ -22,8 +22,8 @@ class Callback: public Pl_DCT::CompressConfig
22 called(false) 22 called(false)
23 { 23 {
24 } 24 }
25 - virtual ~Callback() = default;  
26 - virtual void apply(jpeg_compress_struct*); 25 + ~Callback() override = default;
  26 + void apply(jpeg_compress_struct*) override;
27 bool called; 27 bool called;
28 }; 28 };
29 29
libtests/dct_uncompress.cc
@@ -3,9 +3,8 @@ @@ -3,9 +3,8 @@
3 #include <qpdf/QUtil.hh> 3 #include <qpdf/QUtil.hh>
4 4
5 #include <iostream> 5 #include <iostream>
6 -#include <stdio.h>  
7 -#include <stdlib.h>  
8 -#include <string.h> 6 +#include <cstdio>
  7 +#include <cstdlib>
9 8
10 int 9 int
11 main(int argc, char* argv[]) 10 main(int argc, char* argv[])
libtests/flate.cc
@@ -4,10 +4,8 @@ @@ -4,10 +4,8 @@
4 #include <qpdf/Pl_StdioFile.hh> 4 #include <qpdf/Pl_StdioFile.hh>
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 6
7 -#include <errno.h>  
8 #include <iostream> 7 #include <iostream>
9 -#include <stdlib.h>  
10 -#include <string.h> 8 +#include <cstdlib>
11 9
12 void 10 void
13 run(char const* filename) 11 run(char const* filename)
@@ -30,7 +28,7 @@ run(char const* filename) @@ -30,7 +28,7 @@ run(char const* filename)
30 Pipeline* inf2 = new Pl_Flate("inf2", out2, Pl_Flate::a_inflate); 28 Pipeline* inf2 = new Pl_Flate("inf2", out2, Pl_Flate::a_inflate);
31 29
32 // Count bytes written to o3 30 // Count bytes written to o3
33 - Pl_Count* count3 = new Pl_Count("count3", out3); 31 + auto* count3 = new Pl_Count("count3", out3);
34 32
35 // Do both simultaneously 33 // Do both simultaneously
36 Pipeline* inf3 = new Pl_Flate("inf3", count3, Pl_Flate::a_inflate); 34 Pipeline* inf3 = new Pl_Flate("inf3", count3, Pl_Flate::a_inflate);
libtests/hex.cc
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 #include <qpdf/Pl_StdioFile.hh> 3 #include <qpdf/Pl_StdioFile.hh>
4 #include <iostream> 4 #include <iostream>
5 -#include <stdlib.h> 5 +#include <cstdlib>
6 6
7 int 7 int
8 main() 8 main()
libtests/input_source.cc
@@ -24,8 +24,8 @@ class Finder: public InputSource::Finder @@ -24,8 +24,8 @@ class Finder: public InputSource::Finder
24 after(after) 24 after(after)
25 { 25 {
26 } 26 }
27 - virtual ~Finder() = default;  
28 - virtual bool check(); 27 + ~Finder() override = default;
  28 + bool check() override;
29 29
30 private: 30 private:
31 std::shared_ptr<InputSource> is; 31 std::shared_ptr<InputSource> is;
libtests/json_parse.cc
1 #include <qpdf/FileInputSource.hh> 1 #include <qpdf/FileInputSource.hh>
2 #include <qpdf/JSON.hh> 2 #include <qpdf/JSON.hh>
3 -#include <qpdf/QUtil.hh>  
4 #include <cstdlib> 3 #include <cstdlib>
5 #include <cstring> 4 #include <cstring>
6 #include <iostream> 5 #include <iostream>
@@ -12,13 +11,13 @@ namespace @@ -12,13 +11,13 @@ namespace
12 { 11 {
13 public: 12 public:
14 virtual ~Reactor() = default; 13 virtual ~Reactor() = default;
15 - virtual void dictionaryStart() override;  
16 - virtual void arrayStart() override;  
17 - virtual void containerEnd(JSON const& value) override;  
18 - virtual void topLevelScalar() override;  
19 - virtual bool 14 + void dictionaryStart() override;
  15 + void arrayStart() override;
  16 + void containerEnd(JSON const& value) override;
  17 + void topLevelScalar() override;
  18 + bool
20 dictionaryItem(std::string const& key, JSON const& value) override; 19 dictionaryItem(std::string const& key, JSON const& value) override;
21 - virtual bool arrayItem(JSON const& value) override; 20 + bool arrayItem(JSON const& value) override;
22 21
23 private: 22 private:
24 void printItem(JSON const&); 23 void printItem(JSON const&);
libtests/logger_c.c
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include <qpdf/qpdflogger-c.h> 3 #include <qpdf/qpdflogger-c.h>
4 4
5 -#include <qpdf/Constants.h>  
6 #include <qpdf/qpdfjob-c.h> 5 #include <qpdf/qpdfjob-c.h>
7 6
8 #include <stdio.h> 7 #include <stdio.h>
libtests/lzw.cc
@@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
3 #include <qpdf/Pl_StdioFile.hh> 3 #include <qpdf/Pl_StdioFile.hh>
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
5 #include <iostream> 5 #include <iostream>
6 -#include <stdlib.h>  
7 -#include <string.h> 6 +#include <cstdlib>
  7 +#include <cstring>
8 8
9 int 9 int
10 main(int argc, char* argv[]) 10 main(int argc, char* argv[])
libtests/md5.cc
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 #include <qpdf/Pl_MD5.hh> 3 #include <qpdf/Pl_MD5.hh>
4 #include <qpdf/QUtil.hh> 4 #include <qpdf/QUtil.hh>
5 #include <iostream> 5 #include <iostream>
6 -#include <stdio.h> 6 +#include <cstdio>
7 7
8 static void 8 static void
9 test_string(char const* str) 9 test_string(char const* str)
libtests/numrange.cc
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 static void 4 static void
5 test_numrange(char const* range) 5 test_numrange(char const* range)
6 { 6 {
7 - if (range == 0) { 7 + if (range == nullptr) {
8 std::cout << "null" << std::endl; 8 std::cout << "null" << std::endl;
9 } else { 9 } else {
10 std::vector<int> result = QUtil::parse_numrange(range, 15); 10 std::vector<int> result = QUtil::parse_numrange(range, 15);
libtests/pointer_holder.cc
@@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
7 7
8 #include <iostream> 8 #include <iostream>
9 #include <list> 9 #include <list>
10 -#include <stdlib.h>  
11 10
12 class Object 11 class Object
13 { 12 {
@@ -73,7 +72,7 @@ test_ph() @@ -73,7 +72,7 @@ test_ph()
73 ObjectHolder oh0; 72 ObjectHolder oh0;
74 { 73 {
75 std::cout << "hello" << std::endl; 74 std::cout << "hello" << std::endl;
76 - Object* o1 = new Object; 75 + auto* o1 = new Object;
77 ObjectHolder oh1(o1); 76 ObjectHolder oh1(o1);
78 std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl; 77 std::cout << "oh1 refcount = " << oh1.getRefcount() << std::endl;
79 ObjectHolder oh2(oh1); 78 ObjectHolder oh2(oh1);
@@ -96,7 +95,7 @@ test_ph() @@ -96,7 +95,7 @@ test_ph()
96 } 95 }
97 ol1.push_back(oh3); 96 ol1.push_back(oh3);
98 ol1.push_back(oh3); 97 ol1.push_back(oh3);
99 - Object* o3 = new Object; 98 + auto* o3 = new Object;
100 oh0 = o3; 99 oh0 = o3;
101 PointerHolder<Object const> oh6(new Object()); 100 PointerHolder<Object const> oh6(new Object());
102 oh6->hello(); 101 oh6->hello();
libtests/predictors.cc
@@ -6,10 +6,9 @@ @@ -6,10 +6,9 @@
6 #include <qpdf/QIntC.hh> 6 #include <qpdf/QIntC.hh>
7 #include <qpdf/QUtil.hh> 7 #include <qpdf/QUtil.hh>
8 8
9 -#include <errno.h>  
10 #include <iostream> 9 #include <iostream>
11 -#include <stdlib.h>  
12 -#include <string.h> 10 +#include <cstdlib>
  11 +#include <cstring>
13 12
14 void 13 void
15 run(char const* filename, 14 run(char const* filename,
@@ -22,7 +21,7 @@ run(char const* filename, @@ -22,7 +21,7 @@ run(char const* filename,
22 FILE* in = QUtil::safe_fopen(filename, "rb"); 21 FILE* in = QUtil::safe_fopen(filename, "rb");
23 FILE* o1 = QUtil::safe_fopen("out", "wb"); 22 FILE* o1 = QUtil::safe_fopen("out", "wb");
24 Pipeline* out = new Pl_StdioFile("out", o1); 23 Pipeline* out = new Pl_StdioFile("out", o1);
25 - Pipeline* pl = 0; 24 + Pipeline* pl = nullptr;
26 if (strcmp(filter, "png") == 0) { 25 if (strcmp(filter, "png") == 0) {
27 pl = new Pl_PNGFilter( 26 pl = new Pl_PNGFilter(
28 "png", 27 "png",
libtests/qintc.cc
1 #include <qpdf/assert_test.h> 1 #include <qpdf/assert_test.h>
2 2
3 #include <qpdf/QIntC.hh> 3 #include <qpdf/QIntC.hh>
4 -#include <stdint.h> 4 +#include <cstdint>
5 5
6 #define try_convert(exp_pass, fn, i) \ 6 #define try_convert(exp_pass, fn, i) \
7 try_convert_real(#fn "(" #i ")", exp_pass, fn, i) 7 try_convert_real(#fn "(" #i ")", exp_pass, fn, i)
@@ -74,7 +74,7 @@ main() @@ -74,7 +74,7 @@ main()
74 uint64_t ul1 = 1099511627776LL; // Too big for 32-bit 74 uint64_t ul1 = 1099511627776LL; // Too big for 32-bit
75 uint64_t ul2 = 12345; // Fits into 32-bit 75 uint64_t ul2 = 12345; // Fits into 32-bit
76 int32_t i2 = 81; // Fits in char and uchar 76 int32_t i2 = 81; // Fits in char and uchar
77 - signed char c1 = static_cast<signed char>('\xf7'); // Signed value when char 77 + auto c1 = static_cast<signed char>('\xf7'); // Signed value when char
78 char c2 = 'W'; // char; may be signed or unsigned 78 char c2 = 'W'; // char; may be signed or unsigned
79 79
80 // Verify i1 and u1 have same bit pattern 80 // Verify i1 and u1 have same bit pattern
libtests/qutil.cc
@@ -3,15 +3,11 @@ @@ -3,15 +3,11 @@
3 #include <qpdf/Pl_Buffer.hh> 3 #include <qpdf/Pl_Buffer.hh>
4 #include <qpdf/QPDFSystemError.hh> 4 #include <qpdf/QPDFSystemError.hh>
5 #include <qpdf/QUtil.hh> 5 #include <qpdf/QUtil.hh>
6 -#include <fcntl.h>  
7 #include <fstream> 6 #include <fstream>
8 #include <iostream> 7 #include <iostream>
9 -#include <limits.h>  
10 -#include <locale>  
11 -#include <stdio.h>  
12 -#include <string.h>  
13 -#include <sys/stat.h>  
14 -#include <sys/types.h> 8 +#include <climits>
  9 +#include <cstdio>
  10 +#include <cstring>
15 11
16 #ifdef _WIN32 12 #ifdef _WIN32
17 # include <io.h> 13 # include <io.h>
@@ -493,7 +489,7 @@ same_file_test() @@ -493,7 +489,7 @@ same_file_test()
493 assert_same_file("qutil.out", "qutil.out", true); 489 assert_same_file("qutil.out", "qutil.out", true);
494 assert_same_file("qutil.out", "other-file", false); 490 assert_same_file("qutil.out", "other-file", false);
495 assert_same_file("qutil.out", "", false); 491 assert_same_file("qutil.out", "", false);
496 - assert_same_file("qutil.out", 0, false); 492 + assert_same_file("qutil.out", nullptr, false);
497 assert_same_file("", "qutil.out", false); 493 assert_same_file("", "qutil.out", false);
498 } 494 }
499 495
libtests/random.cc
1 #include <qpdf/InsecureRandomDataProvider.hh> 1 #include <qpdf/InsecureRandomDataProvider.hh>
2 #include <qpdf/QUtil.hh> 2 #include <qpdf/QUtil.hh>
3 #include <qpdf/SecureRandomDataProvider.hh> 3 #include <qpdf/SecureRandomDataProvider.hh>
4 -#include <qpdf/qpdf-config.h>  
5 #include <iostream> 4 #include <iostream>
6 5
7 class BogusRandomDataProvider: public RandomDataProvider 6 class BogusRandomDataProvider: public RandomDataProvider
@@ -57,7 +56,7 @@ main() @@ -57,7 +56,7 @@ main()
57 if (!((buf[0] == 0) && (buf[1] == 1) && (buf[2] == 2) && (buf[3] == 3))) { 56 if (!((buf[0] == 0) && (buf[1] == 1) && (buf[2] == 2) && (buf[3] == 3))) {
58 std::cout << "fail: bogus random didn't provide correct bytes\n"; 57 std::cout << "fail: bogus random didn't provide correct bytes\n";
59 } 58 }
60 - QUtil::setRandomDataProvider(0); 59 + QUtil::setRandomDataProvider(nullptr);
61 if (QUtil::getRandomDataProvider() != orig_rdp) { 60 if (QUtil::getRandomDataProvider() != orig_rdp) {
62 std::cout << "fail: passing null to setRandomDataProvider " 61 std::cout << "fail: passing null to setRandomDataProvider "
63 "didn't reset the random data provider\n"; 62 "didn't reset the random data provider\n";
libtests/rc4.cc
@@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
6 #include <qpdf/QUtil.hh> 6 #include <qpdf/QUtil.hh>
7 7
8 #include <iostream> 8 #include <iostream>
9 -#include <stdio.h>  
10 -#include <stdlib.h>  
11 -#include <string.h> 9 +#include <cstdio>
  10 +#include <cstdlib>
  11 +#include <cstring>
12 12
13 static void 13 static void
14 other_tests() 14 other_tests()
@@ -41,7 +41,7 @@ main(int argc, char* argv[]) @@ -41,7 +41,7 @@ main(int argc, char* argv[])
41 char* outfilename = argv[3]; 41 char* outfilename = argv[3];
42 unsigned int hexkeylen = QIntC::to_uint(strlen(hexkey)); 42 unsigned int hexkeylen = QIntC::to_uint(strlen(hexkey));
43 unsigned int keylen = hexkeylen / 2; 43 unsigned int keylen = hexkeylen / 2;
44 - unsigned char* key = new unsigned char[keylen + 1]; 44 + auto* key = new unsigned char[keylen + 1];
45 key[keylen] = '\0'; 45 key[keylen] = '\0';
46 46
47 FILE* infile = QUtil::safe_fopen(infilename, "rb"); 47 FILE* infile = QUtil::safe_fopen(infilename, "rb");
@@ -51,14 +51,14 @@ main(int argc, char* argv[]) @@ -51,14 +51,14 @@ main(int argc, char* argv[])
51 t[1] = hexkey[i + 1]; 51 t[1] = hexkey[i + 1];
52 t[2] = '\0'; 52 t[2] = '\0';
53 53
54 - long val = strtol(t, 0, 16); 54 + long val = strtol(t, nullptr, 16);
55 key[i / 2] = static_cast<unsigned char>(val); 55 key[i / 2] = static_cast<unsigned char>(val);
56 } 56 }
57 57
58 FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); 58 FILE* outfile = QUtil::safe_fopen(outfilename, "wb");
59 - Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); 59 + auto* out = new Pl_StdioFile("stdout", outfile);
60 // Use a small buffer size (64) for testing 60 // Use a small buffer size (64) for testing
61 - Pl_RC4* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U); 61 + auto* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U);
62 delete[] key; 62 delete[] key;
63 63
64 // 64 < buffer size < 512, buffer_size is not a power of 2 for testing 64 // 64 < buffer size < 512, buffer_size is not a power of 2 for testing
libtests/runlength.cc
@@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
3 #include <qpdf/QUtil.hh> 3 #include <qpdf/QUtil.hh>
4 4
5 #include <iostream> 5 #include <iostream>
6 -#include <stdio.h>  
7 -#include <stdlib.h>  
8 -#include <string.h> 6 +#include <cstdio>
  7 +#include <cstdlib>
  8 +#include <cstring>
9 9
10 int 10 int
11 main(int argc, char* argv[]) 11 main(int argc, char* argv[])
libtests/sha2.cc
1 #include <qpdf/Pl_SHA2.hh> 1 #include <qpdf/Pl_SHA2.hh>
2 #include <qpdf/QUtil.hh> 2 #include <qpdf/QUtil.hh>
3 #include <iostream> 3 #include <iostream>
4 -#include <stdlib.h>  
5 -#include <string.h> 4 +#include <cstring>
6 5
7 static void 6 static void
8 test( 7 test(
qpdf/fix-qdf.cc
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 #include <regex> 8 #include <regex>
9 #include <string_view> 9 #include <string_view>
10 10
11 -static char const* whoami = 0; 11 +static char const* whoami = nullptr;
12 12
13 static void 13 static void
14 usage() 14 usage()
@@ -392,7 +392,7 @@ realmain(int argc, char* argv[]) @@ -392,7 +392,7 @@ realmain(int argc, char* argv[])
392 { 392 {
393 whoami = QUtil::getWhoami(argv[0]); 393 whoami = QUtil::getWhoami(argv[0]);
394 QUtil::setLineBuf(stdout); 394 QUtil::setLineBuf(stdout);
395 - char const* filename = 0; 395 + char const* filename = nullptr;
396 if (argc > 2) { 396 if (argc > 2) {
397 usage(); 397 usage();
398 } else if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) { 398 } else if ((argc > 1) && (strcmp(argv[1], "--version") == 0)) {
@@ -405,7 +405,7 @@ realmain(int argc, char* argv[]) @@ -405,7 +405,7 @@ realmain(int argc, char* argv[])
405 filename = argv[1]; 405 filename = argv[1];
406 } 406 }
407 std::string input; 407 std::string input;
408 - if (filename == 0) { 408 + if (filename == nullptr) {
409 filename = "standard input"; 409 filename = "standard input";
410 QUtil::binary_stdin(); 410 QUtil::binary_stdin();
411 input = QUtil::read_file_into_string(stdin); 411 input = QUtil::read_file_into_string(stdin);
qpdf/pdf_from_scratch.cc
@@ -3,14 +3,13 @@ @@ -3,14 +3,13 @@
3 #include <qpdf/QPDFObjectHandle.hh> 3 #include <qpdf/QPDFObjectHandle.hh>
4 #include <qpdf/QPDFPageDocumentHelper.hh> 4 #include <qpdf/QPDFPageDocumentHelper.hh>
5 #include <qpdf/QPDFWriter.hh> 5 #include <qpdf/QPDFWriter.hh>
6 -#include <qpdf/QTC.hh>  
7 #include <qpdf/QUtil.hh> 6 #include <qpdf/QUtil.hh>
8 #include <iostream> 7 #include <iostream>
9 -#include <stdio.h>  
10 -#include <stdlib.h>  
11 -#include <string.h> 8 +#include <cstdio>
  9 +#include <cstdlib>
  10 +#include <cstring>
12 11
13 -static char const* whoami = 0; 12 +static char const* whoami = nullptr;
14 13
15 void 14 void
16 usage() 15 usage()
@@ -87,7 +86,7 @@ int @@ -87,7 +86,7 @@ int
87 main(int argc, char* argv[]) 86 main(int argc, char* argv[])
88 { 87 {
89 QUtil::setLineBuf(stdout); 88 QUtil::setLineBuf(stdout);
90 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 89 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
91 whoami = argv[0]; 90 whoami = argv[0];
92 } else { 91 } else {
93 ++whoami; 92 ++whoami;
qpdf/qpdf.cc
@@ -4,10 +4,9 @@ @@ -4,10 +4,9 @@
4 4
5 #include <cstdio> 5 #include <cstdio>
6 #include <cstdlib> 6 #include <cstdlib>
7 -#include <cstring>  
8 #include <iostream> 7 #include <iostream>
9 8
10 -static char const* whoami = 0; 9 +static char const* whoami = nullptr;
11 10
12 static void 11 static void
13 usageExit(std::string const& msg) 12 usageExit(std::string const& msg)
qpdf/qpdfjob-ctest.c
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 #include <qpdf/qpdfjob-c.h> 3 #include <qpdf/qpdfjob-c.h>
4 #include <stdio.h> 4 #include <stdio.h>
5 -#include <stdlib.h>  
6 #include <string.h> 5 #include <string.h>
7 6
8 #ifndef QPDF_NO_WCHAR_T 7 #ifndef QPDF_NO_WCHAR_T
qpdf/test_driver.cc
@@ -26,19 +26,18 @@ @@ -26,19 +26,18 @@
26 #include <qpdf/QPDFWriter.hh> 26 #include <qpdf/QPDFWriter.hh>
27 #include <qpdf/QTC.hh> 27 #include <qpdf/QTC.hh>
28 #include <qpdf/QUtil.hh> 28 #include <qpdf/QUtil.hh>
29 -#include <algorithm>  
30 #include <iostream> 29 #include <iostream>
31 -#include <limits.h> 30 +#include <climits>
32 #include <map> 31 #include <map>
33 #include <sstream> 32 #include <sstream>
34 -#include <stdio.h>  
35 -#include <stdlib.h>  
36 -#include <string.h> 33 +#include <cstdio>
  34 +#include <cstdlib>
  35 +#include <cstring>
37 36
38 #define QPDF_OBJECT_NOWARN 37 #define QPDF_OBJECT_NOWARN
39 #include <qpdf/QPDFObject.hh> 38 #include <qpdf/QPDFObject.hh>
40 39
41 -static char const* whoami = 0; 40 +static char const* whoami = nullptr;
42 41
43 void 42 void
44 usage() 43 usage()
@@ -287,7 +286,7 @@ test_0_1(QPDF&amp; pdf, char const* arg2) @@ -287,7 +286,7 @@ test_0_1(QPDF&amp; pdf, char const* arg2)
287 qtest.pipeStreamData(out.get(), 0, qpdf_dl_none); 286 qtest.pipeStreamData(out.get(), 0, qpdf_dl_none);
288 287
289 std::cout << std::endl << "Uncompressed stream data:" << std::endl; 288 std::cout << std::endl << "Uncompressed stream data:" << std::endl;
290 - if (qtest.pipeStreamData(0, 0, qpdf_dl_all)) { 289 + if (qtest.pipeStreamData(nullptr, 0, qpdf_dl_all)) {
291 std::cout.flush(); 290 std::cout.flush();
292 QUtil::binary_stdout(); 291 QUtil::binary_stdout();
293 out = std::make_shared<Pl_StdioFile>("filtered", stdout); 292 out = std::make_shared<Pl_StdioFile>("filtered", stdout);
@@ -388,7 +387,7 @@ test_4(QPDF&amp; pdf, char const* arg2) @@ -388,7 +387,7 @@ test_4(QPDF&amp; pdf, char const* arg2)
388 } 387 }
389 388
390 trailer.replaceKey("/Info", pdf.makeIndirectObject(qtest)); 389 trailer.replaceKey("/Info", pdf.makeIndirectObject(qtest));
391 - QPDFWriter w(pdf, 0); 390 + QPDFWriter w(pdf, nullptr);
392 w.setQDFMode(true); 391 w.setQDFMode(true);
393 w.setStaticID(true); 392 w.setStaticID(true);
394 w.write(); 393 w.write();
@@ -500,7 +499,7 @@ test_8(QPDF&amp; pdf, char const* arg2) @@ -500,7 +499,7 @@ test_8(QPDF&amp; pdf, char const* arg2)
500 auto b = p1.getBufferSharedPointer(); 499 auto b = p1.getBufferSharedPointer();
501 // This is a bogus way to use StreamDataProvider, but it does 500 // This is a bogus way to use StreamDataProvider, but it does
502 // adequately test its functionality. 501 // adequately test its functionality.
503 - Provider* provider = new Provider(b); 502 + auto* provider = new Provider(b);
504 auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(provider); 503 auto p = std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(provider);
505 qstream.replaceStreamData( 504 qstream.replaceStreamData(
506 p, 505 p,
@@ -600,7 +599,7 @@ test_12(QPDF&amp; pdf, char const* arg2) @@ -600,7 +599,7 @@ test_12(QPDF&amp; pdf, char const* arg2)
600 # pragma GCC diagnostic push 599 # pragma GCC diagnostic push
601 # pragma GCC diagnostic ignored "-Wdeprecated-declarations" 600 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
602 #endif 601 #endif
603 - pdf.setOutputStreams(0, 0); 602 + pdf.setOutputStreams(nullptr, nullptr);
604 #if (defined(__GNUC__) || defined(__clang__)) 603 #if (defined(__GNUC__) || defined(__clang__))
605 # pragma GCC diagnostic pop 604 # pragma GCC diagnostic pop
606 #endif 605 #endif
@@ -1010,7 +1009,7 @@ test_25(QPDF&amp; pdf, char const* arg2) @@ -1010,7 +1009,7 @@ test_25(QPDF&amp; pdf, char const* arg2)
1010 // Copy qtest without crossing page boundaries. Should get O1 1009 // Copy qtest without crossing page boundaries. Should get O1
1011 // and O2 and their streams but not O3 or any other pages. 1010 // and O2 and their streams but not O3 or any other pages.
1012 1011
1013 - assert(arg2 != 0); 1012 + assert(arg2 != nullptr);
1014 { 1013 {
1015 // Make sure original PDF is out of scope when we write. 1014 // Make sure original PDF is out of scope when we write.
1016 QPDF oldpdf; 1015 QPDF oldpdf;
@@ -1036,7 +1035,7 @@ test_26(QPDF&amp; pdf, char const* arg2) @@ -1036,7 +1035,7 @@ test_26(QPDF&amp; pdf, char const* arg2)
1036 1035
1037 { 1036 {
1038 // Make sure original PDF is out of scope when we write. 1037 // Make sure original PDF is out of scope when we write.
1039 - assert(arg2 != 0); 1038 + assert(arg2 != nullptr);
1040 QPDF oldpdf; 1039 QPDF oldpdf;
1041 oldpdf.processFile(arg2); 1040 oldpdf.processFile(arg2);
1042 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest"); 1041 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest");
@@ -1069,7 +1068,7 @@ test_27(QPDF&amp; pdf, char const* arg2) @@ -1069,7 +1068,7 @@ test_27(QPDF&amp; pdf, char const* arg2)
1069 pl.writeCStr("new data for stream\n"); 1068 pl.writeCStr("new data for stream\n");
1070 pl.finish(); 1069 pl.finish();
1071 auto b = pl.getBufferSharedPointer(); 1070 auto b = pl.getBufferSharedPointer();
1072 - Provider* provider = new Provider(b); 1071 + auto* provider = new Provider(b);
1073 p1 = decltype(p1)(provider); 1072 p1 = decltype(p1)(provider);
1074 } 1073 }
1075 // Create a stream that uses a provider in empty1 and copy it 1074 // Create a stream that uses a provider in empty1 and copy it
@@ -1096,7 +1095,7 @@ test_27(QPDF&amp; pdf, char const* arg2) @@ -1096,7 +1095,7 @@ test_27(QPDF&amp; pdf, char const* arg2)
1096 pl.writeCStr("more data for stream\n"); 1095 pl.writeCStr("more data for stream\n");
1097 pl.finish(); 1096 pl.finish();
1098 auto b = pl.getBufferSharedPointer(); 1097 auto b = pl.getBufferSharedPointer();
1099 - Provider* provider = new Provider(b); 1098 + auto* provider = new Provider(b);
1100 p2 = decltype(p2)(provider); 1099 p2 = decltype(p2)(provider);
1101 } 1100 }
1102 QPDF empty3; 1101 QPDF empty3;
@@ -1105,7 +1104,7 @@ test_27(QPDF&amp; pdf, char const* arg2) @@ -1105,7 +1104,7 @@ test_27(QPDF&amp; pdf, char const* arg2)
1105 QPDFObjectHandle s3 = QPDFObjectHandle::newStream(&empty3); 1104 QPDFObjectHandle s3 = QPDFObjectHandle::newStream(&empty3);
1106 s3.replaceStreamData( 1105 s3.replaceStreamData(
1107 p2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); 1106 p2, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
1108 - assert(arg2 != 0); 1107 + assert(arg2 != nullptr);
1109 QPDF oldpdf; 1108 QPDF oldpdf;
1110 oldpdf.processFile(arg2); 1109 oldpdf.processFile(arg2);
1111 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest"); 1110 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest");
@@ -1152,7 +1151,7 @@ static void @@ -1152,7 +1151,7 @@ static void
1152 test_29(QPDF& pdf, char const* arg2) 1151 test_29(QPDF& pdf, char const* arg2)
1153 { 1152 {
1154 // Detect mixed objects in QPDFWriter 1153 // Detect mixed objects in QPDFWriter
1155 - assert(arg2 != 0); 1154 + assert(arg2 != nullptr);
1156 auto other = QPDF::create(); 1155 auto other = QPDF::create();
1157 other->processFile(arg2); 1156 other->processFile(arg2);
1158 // We need to create a QPDF with mixed ownership to exercise 1157 // We need to create a QPDF with mixed ownership to exercise
@@ -1202,7 +1201,7 @@ test_29(QPDF&amp; pdf, char const* arg2) @@ -1202,7 +1201,7 @@ test_29(QPDF&amp; pdf, char const* arg2)
1202 static void 1201 static void
1203 test_30(QPDF& pdf, char const* arg2) 1202 test_30(QPDF& pdf, char const* arg2)
1204 { 1203 {
1205 - assert(arg2 != 0); 1204 + assert(arg2 != nullptr);
1206 QPDF encrypted; 1205 QPDF encrypted;
1207 encrypted.processFile(arg2, "user"); 1206 encrypted.processFile(arg2, "user");
1208 QPDFWriter w(pdf, "b.pdf"); 1207 QPDFWriter w(pdf, "b.pdf");
@@ -1434,7 +1433,7 @@ test_40(QPDF&amp; pdf, char const* arg2) @@ -1434,7 +1433,7 @@ test_40(QPDF&amp; pdf, char const* arg2)
1434 // feature was implemented by Sahil Arora 1433 // feature was implemented by Sahil Arora
1435 // <sahilarora.535@gmail.com> as part of a Google Summer of 1434 // <sahilarora.535@gmail.com> as part of a Google Summer of
1436 // Code project in 2017. 1435 // Code project in 2017.
1437 - assert(arg2 != 0); 1436 + assert(arg2 != nullptr);
1438 QPDFWriter w(pdf, arg2); 1437 QPDFWriter w(pdf, arg2);
1439 w.setPCLm(true); 1438 w.setPCLm(true);
1440 w.setStaticID(true); 1439 w.setStaticID(true);
@@ -3559,11 +3558,11 @@ runtest(int n, char const* filename1, char const* arg2) @@ -3559,11 +3558,11 @@ runtest(int n, char const* filename1, char const* arg2)
3559 3558
3560 QPDF pdf; 3559 QPDF pdf;
3561 std::shared_ptr<char> file_buf; 3560 std::shared_ptr<char> file_buf;
3562 - FILE* filep = 0; 3561 + FILE* filep = nullptr;
3563 if (n == 0) { 3562 if (n == 0) {
3564 pdf.setAttemptRecovery(false); 3563 pdf.setAttemptRecovery(false);
3565 } 3564 }
3566 - if (((n == 35) || (n == 36)) && (arg2 != 0)) { 3565 + if (((n == 35) || (n == 36)) && (arg2 != nullptr)) {
3567 // arg2 is password 3566 // arg2 is password
3568 pdf.processFile(filename1, arg2); 3567 pdf.processFile(filename1, arg2);
3569 } else if (n == 45) { 3568 } else if (n == 45) {
@@ -3653,7 +3652,7 @@ int @@ -3653,7 +3652,7 @@ int
3653 main(int argc, char* argv[]) 3652 main(int argc, char* argv[])
3654 { 3653 {
3655 QUtil::setLineBuf(stdout); 3654 QUtil::setLineBuf(stdout);
3656 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 3655 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
3657 whoami = argv[0]; 3656 whoami = argv[0];
3658 } else { 3657 } else {
3659 ++whoami; 3658 ++whoami;
qpdf/test_large_file.cc
@@ -13,8 +13,8 @@ @@ -13,8 +13,8 @@
13 #include <qpdf/QPDFWriter.hh> 13 #include <qpdf/QPDFWriter.hh>
14 #include <qpdf/QUtil.hh> 14 #include <qpdf/QUtil.hh>
15 #include <iostream> 15 #include <iostream>
16 -#include <stdlib.h>  
17 -#include <string.h> 16 +#include <cstdlib>
  17 +#include <cstring>
18 18
19 // Run "test_large_file write small a.pdf" to get a PDF file that you 19 // Run "test_large_file write small a.pdf" to get a PDF file that you
20 // can look at in a reader. 20 // can look at in a reader.
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 // reading the large file then allows us to verify large file support 35 // reading the large file then allows us to verify large file support
36 // with confidence. 36 // with confidence.
37 37
38 -static char const* whoami = 0; 38 +static char const* whoami = nullptr;
39 39
40 // Height should be a multiple of 10 40 // Height should be a multiple of 10
41 static size_t const nstripes = 10; 41 static size_t const nstripes = 10;
@@ -47,7 +47,7 @@ static size_t const npages = 200; @@ -47,7 +47,7 @@ static size_t const npages = 200;
47 size_t stripesize = 0; 47 size_t stripesize = 0;
48 size_t width = 0; 48 size_t width = 0;
49 size_t height = 0; 49 size_t height = 0;
50 -static unsigned char* buf = 0; 50 +static unsigned char* buf = nullptr;
51 51
52 static inline unsigned char 52 static inline unsigned char
53 get_pixel_color(size_t n, size_t row) 53 get_pixel_color(size_t n, size_t row)
@@ -73,7 +73,7 @@ class ImageChecker: public Pipeline @@ -73,7 +73,7 @@ class ImageChecker: public Pipeline
73 }; 73 };
74 74
75 ImageChecker::ImageChecker(size_t n) : 75 ImageChecker::ImageChecker(size_t n) :
76 - Pipeline("image checker", 0), 76 + Pipeline("image checker", nullptr),
77 n(n), 77 n(n),
78 offset(0), 78 offset(0),
79 okay(true) 79 okay(true)
@@ -122,7 +122,7 @@ ImageProvider::ImageProvider(size_t n) : @@ -122,7 +122,7 @@ ImageProvider::ImageProvider(size_t n) :
122 void 122 void
123 ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline) 123 ImageProvider::provideStreamData(int objid, int generation, Pipeline* pipeline)
124 { 124 {
125 - if (buf == 0) { 125 + if (buf == nullptr) {
126 buf = new unsigned char[width * stripesize]; 126 buf = new unsigned char[width * stripesize];
127 } 127 }
128 std::cout << "page " << n << " of " << npages << std::endl; 128 std::cout << "page " << n << " of " << npages << std::endl;
@@ -218,7 +218,7 @@ create_pdf(char const* filename) @@ -218,7 +218,7 @@ create_pdf(char const* filename)
218 image_dict.replaceKey("/BitsPerComponent", newInteger(8)); 218 image_dict.replaceKey("/BitsPerComponent", newInteger(8));
219 image_dict.replaceKey("/Width", newInteger(width)); 219 image_dict.replaceKey("/Width", newInteger(width));
220 image_dict.replaceKey("/Height", newInteger(height)); 220 image_dict.replaceKey("/Height", newInteger(height));
221 - ImageProvider* p = new ImageProvider(pageno); 221 + auto* p = new ImageProvider(pageno);
222 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p); 222 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> provider(p);
223 image.replaceStreamData( 223 image.replaceStreamData(
224 provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); 224 provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
qpdf/test_pdf_doc_encoding.cc
1 #include <qpdf/QPDFObjectHandle.hh> 1 #include <qpdf/QPDFObjectHandle.hh>
2 #include <qpdf/QUtil.hh> 2 #include <qpdf/QUtil.hh>
3 #include <iostream> 3 #include <iostream>
4 -#include <stdlib.h>  
5 -#include <string.h> 4 +#include <cstdlib>
  5 +#include <cstring>
6 6
7 -static char const* whoami = 0; 7 +static char const* whoami = nullptr;
8 8
9 void 9 void
10 usage() 10 usage()
@@ -16,7 +16,7 @@ usage() @@ -16,7 +16,7 @@ usage()
16 int 16 int
17 main(int argc, char* argv[]) 17 main(int argc, char* argv[])
18 { 18 {
19 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 19 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
20 whoami = argv[0]; 20 whoami = argv[0];
21 } else { 21 } else {
22 ++whoami; 22 ++whoami;
qpdf/test_pdf_unicode.cc
1 #include <qpdf/QPDFObjectHandle.hh> 1 #include <qpdf/QPDFObjectHandle.hh>
2 #include <qpdf/QUtil.hh> 2 #include <qpdf/QUtil.hh>
3 #include <iostream> 3 #include <iostream>
4 -#include <stdlib.h>  
5 -#include <string.h> 4 +#include <cstdlib>
  5 +#include <cstring>
6 6
7 -static char const* whoami = 0; 7 +static char const* whoami = nullptr;
8 8
9 void 9 void
10 usage() 10 usage()
@@ -16,7 +16,7 @@ usage() @@ -16,7 +16,7 @@ usage()
16 int 16 int
17 main(int argc, char* argv[]) 17 main(int argc, char* argv[])
18 { 18 {
19 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 19 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
20 whoami = argv[0]; 20 whoami = argv[0];
21 } else { 21 } else {
22 ++whoami; 22 ++whoami;
qpdf/test_renumber.cc
1 -#include <qpdf/Buffer.hh>  
2 #include <qpdf/Constants.h> 1 #include <qpdf/Constants.h>
3 #include <qpdf/QPDF.hh> 2 #include <qpdf/QPDF.hh>
4 #include <qpdf/QPDFObjGen.hh> 3 #include <qpdf/QPDFObjGen.hh>
@@ -6,7 +5,6 @@ @@ -6,7 +5,6 @@
6 #include <qpdf/QPDFWriter.hh> 5 #include <qpdf/QPDFWriter.hh>
7 #include <qpdf/QPDFXRefEntry.hh> 6 #include <qpdf/QPDFXRefEntry.hh>
8 7
9 -#include <algorithm>  
10 #include <cstdlib> 8 #include <cstdlib>
11 #include <iostream> 9 #include <iostream>
12 #include <set> 10 #include <set>
qpdf/test_shell_glob.cc
1 #include <qpdf/QUtil.hh> 1 #include <qpdf/QUtil.hh>
2 -#include <cstring>  
3 #include <iostream> 2 #include <iostream>
4 3
5 int 4 int
qpdf/test_tokenizer.cc
@@ -4,15 +4,14 @@ @@ -4,15 +4,14 @@
4 #include <qpdf/QIntC.hh> 4 #include <qpdf/QIntC.hh>
5 #include <qpdf/QPDF.hh> 5 #include <qpdf/QPDF.hh>
6 #include <qpdf/QPDFPageDocumentHelper.hh> 6 #include <qpdf/QPDFPageDocumentHelper.hh>
7 -#include <qpdf/QPDFPageObjectHelper.hh>  
8 #include <qpdf/QPDFTokenizer.hh> 7 #include <qpdf/QPDFTokenizer.hh>
9 #include <qpdf/QUtil.hh> 8 #include <qpdf/QUtil.hh>
10 #include <iostream> 9 #include <iostream>
11 -#include <stdio.h>  
12 -#include <stdlib.h>  
13 -#include <string.h> 10 +#include <cstdio>
  11 +#include <cstdlib>
  12 +#include <cstring>
14 13
15 -static char const* whoami = 0; 14 +static char const* whoami = nullptr;
16 15
17 void 16 void
18 usage() 17 usage()
@@ -92,7 +91,7 @@ tokenTypeName(QPDFTokenizer::token_type_e ttype) @@ -92,7 +91,7 @@ tokenTypeName(QPDFTokenizer::token_type_e ttype)
92 case QPDFTokenizer::tt_inline_image: 91 case QPDFTokenizer::tt_inline_image:
93 return "inline-image"; 92 return "inline-image";
94 } 93 }
95 - return 0; 94 + return nullptr;
96 } 95 }
97 96
98 static std::string 97 static std::string
@@ -191,7 +190,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) @@ -191,7 +190,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
191 std::shared_ptr<InputSource> is; 190 std::shared_ptr<InputSource> is;
192 191
193 // Tokenize file, skipping streams 192 // Tokenize file, skipping streams
194 - FileInputSource* fis = new FileInputSource(filename); 193 + auto* fis = new FileInputSource(filename);
195 is = std::shared_ptr<InputSource>(fis); 194 is = std::shared_ptr<InputSource>(fis);
196 dump_tokens(is, "FILE", max_len, include_ignorable, true, false); 195 dump_tokens(is, "FILE", max_len, include_ignorable, true, false);
197 196
@@ -204,7 +203,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) @@ -204,7 +203,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
204 Pl_Buffer plb("buffer"); 203 Pl_Buffer plb("buffer");
205 page.pipeContents(&plb); 204 page.pipeContents(&plb);
206 auto content_data = plb.getBufferSharedPointer(); 205 auto content_data = plb.getBufferSharedPointer();
207 - BufferInputSource* bis = 206 + auto* bis =
208 new BufferInputSource("content data", content_data.get()); 207 new BufferInputSource("content data", content_data.get());
209 is = std::shared_ptr<InputSource>(bis); 208 is = std::shared_ptr<InputSource>(bis);
210 dump_tokens( 209 dump_tokens(
@@ -221,7 +220,7 @@ process(char const* filename, bool include_ignorable, size_t max_len) @@ -221,7 +220,7 @@ process(char const* filename, bool include_ignorable, size_t max_len)
221 if (obj.isStream() && obj.getDict().getKey("/Type").isName() && 220 if (obj.isStream() && obj.getDict().getKey("/Type").isName() &&
222 obj.getDict().getKey("/Type").getName() == "/ObjStm") { 221 obj.getDict().getKey("/Type").getName() == "/ObjStm") {
223 std::shared_ptr<Buffer> b = obj.getStreamData(qpdf_dl_specialized); 222 std::shared_ptr<Buffer> b = obj.getStreamData(qpdf_dl_specialized);
224 - BufferInputSource* bis = 223 + auto* bis =
225 new BufferInputSource("object stream data", b.get()); 224 new BufferInputSource("object stream data", b.get());
226 is = std::shared_ptr<InputSource>(bis); 225 is = std::shared_ptr<InputSource>(bis);
227 dump_tokens( 226 dump_tokens(
@@ -239,13 +238,13 @@ int @@ -239,13 +238,13 @@ int
239 main(int argc, char* argv[]) 238 main(int argc, char* argv[])
240 { 239 {
241 QUtil::setLineBuf(stdout); 240 QUtil::setLineBuf(stdout);
242 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 241 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
243 whoami = argv[0]; 242 whoami = argv[0];
244 } else { 243 } else {
245 ++whoami; 244 ++whoami;
246 } 245 }
247 246
248 - char const* filename = 0; 247 + char const* filename = nullptr;
249 size_t max_len = 0; 248 size_t max_len = 0;
250 bool include_ignorable = true; 249 bool include_ignorable = true;
251 for (int i = 1; i < argc; ++i) { 250 for (int i = 1; i < argc; ++i) {
@@ -266,7 +265,7 @@ main(int argc, char* argv[]) @@ -266,7 +265,7 @@ main(int argc, char* argv[])
266 filename = argv[i]; 265 filename = argv[i];
267 } 266 }
268 } 267 }
269 - if (filename == 0) { 268 + if (filename == nullptr) {
270 usage(); 269 usage();
271 } 270 }
272 271
qpdf/test_unicode_filenames.cc
@@ -6,13 +6,13 @@ @@ -6,13 +6,13 @@
6 #endif 6 #endif
7 7
8 #include <iostream> 8 #include <iostream>
9 -#include <stdio.h>  
10 -#include <stdlib.h> 9 +#include <cstdio>
  10 +#include <cstdlib>
11 11
12 static void 12 static void
13 do_copy(FILE* in, FILE* out) 13 do_copy(FILE* in, FILE* out)
14 { 14 {
15 - if ((in == 0) || (out == 0)) { 15 + if ((in == nullptr) || (out == nullptr)) {
16 std::cerr << "errors opening files" << std::endl; 16 std::cerr << "errors opening files" << std::endl;
17 exit(2); 17 exit(2);
18 } 18 }
qpdf/test_xref.cc
1 #include <qpdf/QPDF.hh> 1 #include <qpdf/QPDF.hh>
2 -#include <qpdf/QPDFObjGen.hh>  
3 -#include <qpdf/QPDFXRefEntry.hh>  
4 2
5 #include <cstdlib> 3 #include <cstdlib>
6 #include <iostream> 4 #include <iostream>
7 #include <map> 5 #include <map>
8 -#include <string>  
9 6
10 int 7 int
11 main(int argc, char* argv[]) 8 main(int argc, char* argv[])
zlib-flate/zlib-flate.cc
@@ -5,11 +5,11 @@ @@ -5,11 +5,11 @@
5 5
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <iostream> 7 #include <iostream>
8 -#include <stdio.h>  
9 -#include <stdlib.h>  
10 -#include <string.h> 8 +#include <cstdio>
  9 +#include <cstdlib>
  10 +#include <cstring>
11 11
12 -static char const* whoami = 0; 12 +static char const* whoami = nullptr;
13 13
14 void 14 void
15 usage() 15 usage()
@@ -27,7 +27,7 @@ usage() @@ -27,7 +27,7 @@ usage()
27 int 27 int
28 main(int argc, char* argv[]) 28 main(int argc, char* argv[])
29 { 29 {
30 - if ((whoami = strrchr(argv[0], '/')) == NULL) { 30 + if ((whoami = strrchr(argv[0], '/')) == nullptr) {
31 whoami = argv[0]; 31 whoami = argv[0];
32 } else { 32 } else {
33 ++whoami; 33 ++whoami;