Commit e0f1be5a4f0936798a429175fa3d017eae02ff45

Authored by m-holger
1 parent 2dea7ad7

Remove redundant `this->` usage across the codebase. Simplify member variable ac…

…cess for consistency and readability.
libqpdf/AES_PDF_native.cc
... ... @@ -11,7 +11,7 @@
11 11  
12 12 AES_PDF_native::AES_PDF_native(
13 13 bool encrypt,
14   - unsigned char const* key,
  14 + unsigned char const* a_key,
15 15 size_t key_bytes,
16 16 bool cbc_mode,
17 17 unsigned char* cbc_block) :
... ... @@ -20,38 +20,38 @@ AES_PDF_native::AES_PDF_native(
20 20 cbc_block(cbc_block)
21 21 {
22 22 size_t keybits = 8 * key_bytes;
23   - this->key = std::make_unique<unsigned char[]>(key_bytes);
24   - this->rk = std::make_unique<uint32_t[]>(RKLENGTH(keybits));
  23 + key = std::make_unique<unsigned char[]>(key_bytes);
  24 + rk = std::make_unique<uint32_t[]>(RKLENGTH(keybits));
25 25 size_t rk_bytes = RKLENGTH(keybits) * sizeof(uint32_t);
26   - std::memcpy(this->key.get(), key, key_bytes);
27   - std::memset(this->rk.get(), 0, rk_bytes);
  26 + std::memcpy(key.get(), a_key, key_bytes);
  27 + std::memset(rk.get(), 0, rk_bytes);
28 28 if (encrypt) {
29   - this->nrounds = rijndaelSetupEncrypt(this->rk.get(), this->key.get(), keybits);
  29 + nrounds = rijndaelSetupEncrypt(rk.get(), key.get(), keybits);
30 30 } else {
31   - this->nrounds = rijndaelSetupDecrypt(this->rk.get(), this->key.get(), keybits);
  31 + nrounds = rijndaelSetupDecrypt(rk.get(), key.get(), keybits);
32 32 }
33 33 }
34 34  
35 35 void
36 36 AES_PDF_native::update(unsigned char* in_data, unsigned char* out_data)
37 37 {
38   - if (this->encrypt) {
39   - if (this->cbc_mode) {
  38 + if (encrypt) {
  39 + if (cbc_mode) {
40 40 for (size_t i = 0; i < QPDFCryptoImpl::rijndael_buf_size; ++i) {
41   - in_data[i] ^= this->cbc_block[i];
  41 + in_data[i] ^= cbc_block[i];
42 42 }
43 43 }
44   - rijndaelEncrypt(this->rk.get(), this->nrounds, in_data, out_data);
45   - if (this->cbc_mode) {
46   - memcpy(this->cbc_block, out_data, QPDFCryptoImpl::rijndael_buf_size);
  44 + rijndaelEncrypt(rk.get(), nrounds, in_data, out_data);
  45 + if (cbc_mode) {
  46 + memcpy(cbc_block, out_data, QPDFCryptoImpl::rijndael_buf_size);
47 47 }
48 48 } else {
49   - rijndaelDecrypt(this->rk.get(), this->nrounds, in_data, out_data);
50   - if (this->cbc_mode) {
  49 + rijndaelDecrypt(rk.get(), nrounds, in_data, out_data);
  50 + if (cbc_mode) {
51 51 for (size_t i = 0; i < QPDFCryptoImpl::rijndael_buf_size; ++i) {
52   - out_data[i] ^= this->cbc_block[i];
  52 + out_data[i] ^= cbc_block[i];
53 53 }
54   - memcpy(this->cbc_block, in_data, QPDFCryptoImpl::rijndael_buf_size);
  54 + memcpy(cbc_block, in_data, QPDFCryptoImpl::rijndael_buf_size);
55 55 }
56 56 }
57 57 }
... ...
libqpdf/BufferInputSource.cc
... ... @@ -26,42 +26,42 @@ BufferInputSource::BufferInputSource(std::string const&amp; description, std::string
26 26  
27 27 BufferInputSource::~BufferInputSource()
28 28 {
29   - if (this->own_memory) {
30   - delete this->buf;
  29 + if (own_memory) {
  30 + delete buf;
31 31 }
32 32 }
33 33  
34 34 qpdf_offset_t
35 35 BufferInputSource::findAndSkipNextEOL()
36 36 {
37   - if (this->cur_offset < 0) {
  37 + if (cur_offset < 0) {
38 38 throw std::logic_error("INTERNAL ERROR: BufferInputSource offset < 0");
39 39 }
40   - qpdf_offset_t end_pos = this->max_offset;
41   - if (this->cur_offset >= end_pos) {
42   - this->last_offset = end_pos;
43   - this->cur_offset = end_pos;
  40 + qpdf_offset_t end_pos = max_offset;
  41 + if (cur_offset >= end_pos) {
  42 + last_offset = end_pos;
  43 + cur_offset = end_pos;
44 44 return end_pos;
45 45 }
46 46  
47 47 qpdf_offset_t result = 0;
48   - unsigned char const* buffer = this->buf->getBuffer();
  48 + unsigned char const* buffer = buf->getBuffer();
49 49 unsigned char const* end = buffer + end_pos;
50   - unsigned char const* p = buffer + this->cur_offset;
  50 + unsigned char const* p = buffer + cur_offset;
51 51  
52 52 while ((p < end) && !((*p == '\r') || (*p == '\n'))) {
53 53 ++p;
54 54 }
55 55 if (p < end) {
56 56 result = p - buffer;
57   - this->cur_offset = result + 1;
  57 + cur_offset = result + 1;
58 58 ++p;
59   - while ((this->cur_offset < end_pos) && ((*p == '\r') || (*p == '\n'))) {
  59 + while ((cur_offset < end_pos) && ((*p == '\r') || (*p == '\n'))) {
60 60 ++p;
61   - ++this->cur_offset;
  61 + ++cur_offset;
62 62 }
63 63 } else {
64   - this->cur_offset = end_pos;
  64 + cur_offset = end_pos;
65 65 result = end_pos;
66 66 }
67 67 return result;
... ... @@ -70,13 +70,13 @@ BufferInputSource::findAndSkipNextEOL()
70 70 std::string const&
71 71 BufferInputSource::getName() const
72 72 {
73   - return this->description;
  73 + return description;
74 74 }
75 75  
76 76 qpdf_offset_t
77 77 BufferInputSource::tell()
78 78 {
79   - return this->cur_offset;
  79 + return cur_offset;
80 80 }
81 81  
82 82 void
... ... @@ -84,17 +84,17 @@ BufferInputSource::seek(qpdf_offset_t offset, int whence)
84 84 {
85 85 switch (whence) {
86 86 case SEEK_SET:
87   - this->cur_offset = offset;
  87 + cur_offset = offset;
88 88 break;
89 89  
90 90 case SEEK_END:
91   - QIntC::range_check(this->max_offset, offset);
92   - this->cur_offset = this->max_offset + offset;
  91 + QIntC::range_check(max_offset, offset);
  92 + cur_offset = max_offset + offset;
93 93 break;
94 94  
95 95 case SEEK_CUR:
96   - QIntC::range_check(this->cur_offset, offset);
97   - this->cur_offset += offset;
  96 + QIntC::range_check(cur_offset, offset);
  97 + cur_offset += offset;
98 98 break;
99 99  
100 100 default:
... ... @@ -102,40 +102,40 @@ BufferInputSource::seek(qpdf_offset_t offset, int whence)
102 102 break;
103 103 }
104 104  
105   - if (this->cur_offset < 0) {
106   - throw std::runtime_error(this->description + ": seek before beginning of buffer");
  105 + if (cur_offset < 0) {
  106 + throw std::runtime_error(description + ": seek before beginning of buffer");
107 107 }
108 108 }
109 109  
110 110 void
111 111 BufferInputSource::rewind()
112 112 {
113   - this->cur_offset = 0;
  113 + cur_offset = 0;
114 114 }
115 115  
116 116 size_t
117 117 BufferInputSource::read(char* buffer, size_t length)
118 118 {
119   - if (this->cur_offset < 0) {
  119 + if (cur_offset < 0) {
120 120 throw std::logic_error("INTERNAL ERROR: BufferInputSource offset < 0");
121 121 }
122   - qpdf_offset_t end_pos = this->max_offset;
123   - if (this->cur_offset >= end_pos) {
124   - this->last_offset = end_pos;
  122 + qpdf_offset_t end_pos = max_offset;
  123 + if (cur_offset >= end_pos) {
  124 + last_offset = end_pos;
125 125 return 0;
126 126 }
127 127  
128   - this->last_offset = this->cur_offset;
129   - size_t len = std::min(QIntC::to_size(end_pos - this->cur_offset), length);
130   - memcpy(buffer, this->buf->getBuffer() + this->cur_offset, len);
131   - this->cur_offset += QIntC::to_offset(len);
  128 + last_offset = cur_offset;
  129 + size_t len = std::min(QIntC::to_size(end_pos - cur_offset), length);
  130 + memcpy(buffer, buf->getBuffer() + cur_offset, len);
  131 + cur_offset += QIntC::to_offset(len);
132 132 return len;
133 133 }
134 134  
135 135 void
136 136 BufferInputSource::unreadCh(char ch)
137 137 {
138   - if (this->cur_offset > 0) {
139   - --this->cur_offset;
  138 + if (cur_offset > 0) {
  139 + --cur_offset;
140 140 }
141 141 }
... ...
libqpdf/MD5.cc
... ... @@ -14,14 +14,14 @@ MD5::MD5()
14 14 void
15 15 MD5::init()
16 16 {
17   - this->crypto = QPDFCryptoProvider::getImpl();
18   - this->crypto->MD5_init();
  17 + crypto = QPDFCryptoProvider::getImpl();
  18 + crypto->MD5_init();
19 19 }
20 20  
21 21 void
22 22 MD5::finalize()
23 23 {
24   - this->crypto->MD5_finalize();
  24 + crypto->MD5_finalize();
25 25 }
26 26  
27 27 void
... ... @@ -48,7 +48,7 @@ MD5::appendString(char const* input_string)
48 48 void
49 49 MD5::encodeDataIncrementally(char const* data, size_t len)
50 50 {
51   - this->crypto->MD5_update(QUtil::unsigned_char_pointer(data), len);
  51 + crypto->MD5_update(QUtil::unsigned_char_pointer(data), len);
52 52 }
53 53  
54 54 void
... ... @@ -84,14 +84,14 @@ MD5::encodeFile(char const* filename, qpdf_offset_t up_to_offset)
84 84 }
85 85 (void)fclose(file);
86 86  
87   - this->crypto->MD5_finalize();
  87 + crypto->MD5_finalize();
88 88 }
89 89  
90 90 void
91 91 MD5::digest(Digest result)
92 92 {
93   - this->crypto->MD5_finalize();
94   - this->crypto->MD5_digest(result);
  93 + crypto->MD5_finalize();
  94 + crypto->MD5_digest(result);
95 95 }
96 96  
97 97 void
... ... @@ -110,7 +110,7 @@ MD5::print()
110 110 std::string
111 111 MD5::unparse()
112 112 {
113   - this->crypto->MD5_finalize();
  113 + crypto->MD5_finalize();
114 114 Digest digest_val;
115 115 digest(digest_val);
116 116 return QUtil::hex_encode(std::string(reinterpret_cast<char*>(digest_val), 16));
... ...
libqpdf/NNTree.cc
... ... @@ -49,12 +49,12 @@ NNTreeIterator::updateIValue(bool allow_invalid)
49 49 // call updateIValue in operator* and operator->.
50 50  
51 51 bool okay = false;
52   - if ((item_number >= 0) && this->node.isDictionary()) {
53   - auto items = this->node.getKey(impl.details.itemsKey());
54   - if (this->item_number + 1 < items.getArrayNItems()) {
  52 + if (item_number >= 0 && node.isDictionary()) {
  53 + auto items = node.getKey(impl.details.itemsKey());
  54 + if (item_number + 1 < items.getArrayNItems()) {
55 55 okay = true;
56   - this->ivalue.first = items.getArrayItem(this->item_number);
57   - this->ivalue.second = items.getArrayItem(1 + this->item_number);
  56 + ivalue.first = items.getArrayItem(item_number);
  57 + ivalue.second = items.getArrayItem(1 + item_number);
58 58 } else {
59 59 error(impl.qpdf, node, "update ivalue: items array is too short");
60 60 }
... ... @@ -64,8 +64,8 @@ NNTreeIterator::updateIValue(bool allow_invalid)
64 64 throw std::logic_error(
65 65 "attempt made to dereference an invalid name/number tree iterator");
66 66 }
67   - this->ivalue.first = QPDFObjectHandle();
68   - this->ivalue.second = QPDFObjectHandle();
  67 + ivalue.first = QPDFObjectHandle();
  68 + ivalue.second = QPDFObjectHandle();
69 69 }
70 70 }
71 71  
... ... @@ -106,45 +106,45 @@ NNTreeIterator::getNextKid(PathElement&amp; pe, bool backward)
106 106 bool
107 107 NNTreeIterator::valid() const
108 108 {
109   - return this->item_number >= 0;
  109 + return item_number >= 0;
110 110 }
111 111  
112 112 void
113 113 NNTreeIterator::increment(bool backward)
114 114 {
115   - if (this->item_number < 0) {
  115 + if (item_number < 0) {
116 116 QTC::TC("qpdf", "NNTree increment end()");
117 117 deepen(impl.oh, !backward, true);
118 118 return;
119 119 }
120 120 bool found_valid_key = false;
121   - while (valid() && (!found_valid_key)) {
122   - this->item_number += backward ? -2 : 2;
123   - auto items = this->node.getKey(impl.details.itemsKey());
124   - if ((this->item_number < 0) || (this->item_number >= items.getArrayNItems())) {
  121 + while (valid() && !found_valid_key) {
  122 + item_number += backward ? -2 : 2;
  123 + auto items = node.getKey(impl.details.itemsKey());
  124 + if (item_number < 0 || item_number >= items.getArrayNItems()) {
125 125 bool found = false;
126 126 setItemNumber(QPDFObjectHandle(), -1);
127   - while (!(found || this->path.empty())) {
128   - auto& element = this->path.back();
  127 + while (!(found || path.empty())) {
  128 + auto& element = path.back();
129 129 auto pe_node = getNextKid(element, backward);
130 130 if (pe_node.isNull()) {
131   - this->path.pop_back();
  131 + path.pop_back();
132 132 } else {
133 133 found = deepen(pe_node, !backward, false);
134 134 }
135 135 }
136 136 }
137   - if (this->item_number >= 0) {
138   - items = this->node.getKey(impl.details.itemsKey());
139   - if (this->item_number + 1 >= items.getArrayNItems()) {
  137 + if (item_number >= 0) {
  138 + items = node.getKey(impl.details.itemsKey());
  139 + if (item_number + 1 >= items.getArrayNItems()) {
140 140 QTC::TC("qpdf", "NNTree skip item at end of short items");
141   - warn(impl.qpdf, this->node, "items array doesn't have enough elements");
142   - } else if (!impl.details.keyValid(items.getArrayItem(this->item_number))) {
  141 + warn(impl.qpdf, node, "items array doesn't have enough elements");
  142 + } else if (!impl.details.keyValid(items.getArrayItem(item_number))) {
143 143 QTC::TC("qpdf", "NNTree skip invalid key");
144 144 warn(
145 145 impl.qpdf,
146   - this->node,
147   - ("item " + std::to_string(this->item_number) + " has the wrong type"));
  146 + node,
  147 + ("item " + std::to_string(item_number) + " has the wrong type"));
148 148 } else {
149 149 found_valid_key = true;
150 150 }
... ... @@ -153,19 +153,19 @@ NNTreeIterator::increment(bool backward)
153 153 }
154 154  
155 155 void
156   -NNTreeIterator::resetLimits(QPDFObjectHandle node, std::list<PathElement>::iterator parent)
  156 +NNTreeIterator::resetLimits(QPDFObjectHandle a_node, std::list<PathElement>::iterator parent)
157 157 {
158 158 bool done = false;
159 159 while (!done) {
160   - if (parent == this->path.end()) {
  160 + if (parent == path.end()) {
161 161 QTC::TC("qpdf", "NNTree remove limits from root");
162   - node.removeKey("/Limits");
  162 + a_node.removeKey("/Limits");
163 163 done = true;
164 164 break;
165 165 }
166   - auto kids = node.getKey("/Kids");
  166 + auto kids = a_node.getKey("/Kids");
167 167 int nkids = kids.isArray() ? kids.getArrayNItems() : 0;
168   - auto items = node.getKey(impl.details.itemsKey());
  168 + auto items = a_node.getKey(impl.details.itemsKey());
169 169 int nitems = items.isArray() ? items.getArrayNItems() : 0;
170 170  
171 171 bool changed = true;
... ... @@ -191,7 +191,7 @@ NNTreeIterator::resetLimits(QPDFObjectHandle node, std::list&lt;PathElement&gt;::itera
191 191 auto limits = QPDFObjectHandle::newArray();
192 192 limits.appendItem(first);
193 193 limits.appendItem(last);
194   - auto olimits = node.getKey("/Limits");
  194 + auto olimits = a_node.getKey("/Limits");
195 195 if (olimits.isArray() && (olimits.getArrayNItems() == 2)) {
196 196 auto ofirst = olimits.getArrayItem(0);
197 197 auto olast = olimits.getArrayItem(1);
... ... @@ -202,18 +202,18 @@ NNTreeIterator::resetLimits(QPDFObjectHandle node, std::list&lt;PathElement&gt;::itera
202 202 changed = false;
203 203 }
204 204 }
205   - if (changed && !node.isSameObjectAs(path.begin()->node)) {
206   - node.replaceKey("/Limits", limits);
  205 + if (changed && !a_node.isSameObjectAs(path.begin()->node)) {
  206 + a_node.replaceKey("/Limits", limits);
207 207 }
208 208 } else {
209 209 QTC::TC("qpdf", "NNTree unable to determine limits");
210   - warn(impl.qpdf, node, "unable to determine limits");
  210 + warn(impl.qpdf, a_node, "unable to determine limits");
211 211 }
212 212  
213   - if ((!changed) || (parent == this->path.begin())) {
  213 + if (!changed || parent == path.begin()) {
214 214 done = true;
215 215 } else {
216   - node = parent->node;
  216 + a_node = parent->node;
217 217 --parent;
218 218 }
219 219 }
... ... @@ -283,7 +283,7 @@ NNTreeIterator::split(QPDFObjectHandle to_split, std::list&lt;PathElement&gt;::iterato
283 283 return;
284 284 }
285 285  
286   - bool is_root = (parent == this->path.end());
  286 + bool is_root = (parent == path.end());
287 287 bool is_leaf = (nitems > 0);
288 288  
289 289 // CURRENT STATE: tree is in original state; iterator is valid and unchanged.
... ... @@ -312,14 +312,14 @@ NNTreeIterator::split(QPDFObjectHandle to_split, std::list&lt;PathElement&gt;::iterato
312 312 to_split.replaceKey("/Kids", new_kids);
313 313 if (is_leaf) {
314 314 QTC::TC("qpdf", "NNTree split root + leaf");
315   - this->node = first_node;
  315 + node = first_node;
316 316 } else {
317 317 QTC::TC("qpdf", "NNTree split root + !leaf");
318   - auto next = this->path.begin();
  318 + auto next = path.begin();
319 319 next->node = first_node;
320 320 }
321 321 this->path.emplace_front(to_split, 0);
322   - parent = this->path.begin();
  322 + parent = path.begin();
323 323 to_split = first_node;
324 324 }
325 325  
... ... @@ -353,12 +353,12 @@ NNTreeIterator::split(QPDFObjectHandle to_split, std::list&lt;PathElement&gt;::iterato
353 353 parent_kids.insertItem(parent->kid_number + 1, second_node);
354 354 auto cur_elem = parent;
355 355 ++cur_elem; // points to end() for leaf nodes
356   - int old_idx = (is_leaf ? this->item_number : cur_elem->kid_number);
  356 + int old_idx = (is_leaf ? item_number : cur_elem->kid_number);
357 357 if (old_idx >= start_idx) {
358 358 ++parent->kid_number;
359 359 if (is_leaf) {
360 360 QTC::TC("qpdf", "NNTree split second half item");
361   - setItemNumber(second_node, this->item_number - start_idx);
  361 + setItemNumber(second_node, item_number - start_idx);
362 362 } else {
363 363 QTC::TC("qpdf", "NNTree split second half kid");
364 364 cur_elem->node = second_node;
... ... @@ -377,8 +377,8 @@ NNTreeIterator::split(QPDFObjectHandle to_split, std::list&lt;PathElement&gt;::iterato
377 377 std::list<NNTreeIterator::PathElement>::iterator
378 378 NNTreeIterator::lastPathElement()
379 379 {
380   - auto result = this->path.end();
381   - if (!this->path.empty()) {
  380 + auto result = path.end();
  381 + if (!path.empty()) {
382 382 --result;
383 383 }
384 384 return result;
... ... @@ -394,17 +394,17 @@ NNTreeIterator::insertAfter(QPDFObjectHandle key, QPDFObjectHandle value)
394 394 return;
395 395 }
396 396  
397   - auto items = this->node.getKey(impl.details.itemsKey());
  397 + auto items = node.getKey(impl.details.itemsKey());
398 398 if (!items.isArray()) {
399 399 error(impl.qpdf, node, "node contains no items array");
400 400 }
401   - if (items.getArrayNItems() < this->item_number + 2) {
  401 + if (items.getArrayNItems() < item_number + 2) {
402 402 error(impl.qpdf, node, "insert: items array is too short");
403 403 }
404   - items.insertItem(this->item_number + 2, key);
405   - items.insertItem(this->item_number + 3, value);
406   - resetLimits(this->node, lastPathElement());
407   - split(this->node, lastPathElement());
  404 + items.insertItem(item_number + 2, key);
  405 + items.insertItem(item_number + 3, value);
  406 + resetLimits(node, lastPathElement());
  407 + split(node, lastPathElement());
408 408 increment(false);
409 409 }
410 410  
... ... @@ -416,33 +416,33 @@ NNTreeIterator::remove()
416 416 if (!valid()) {
417 417 throw std::logic_error("attempt made to remove an invalid iterator");
418 418 }
419   - auto items = this->node.getKey(impl.details.itemsKey());
  419 + auto items = node.getKey(impl.details.itemsKey());
420 420 int nitems = items.getArrayNItems();
421   - if (this->item_number + 2 > nitems) {
422   - error(impl.qpdf, this->node, "found short items array while removing an item");
  421 + if (item_number + 2 > nitems) {
  422 + error(impl.qpdf, node, "found short items array while removing an item");
423 423 }
424 424  
425   - items.eraseItem(this->item_number);
426   - items.eraseItem(this->item_number);
  425 + items.eraseItem(item_number);
  426 + items.eraseItem(item_number);
427 427 nitems -= 2;
428 428  
429 429 if (nitems > 0) {
430 430 // There are still items left
431 431  
432   - if ((this->item_number == 0) || (this->item_number == nitems)) {
  432 + if (item_number == 0 || item_number == nitems) {
433 433 // We removed either the first or last item of an items array that remains non-empty, so
434 434 // we have to adjust limits.
435 435 QTC::TC("qpdf", "NNTree remove reset limits");
436   - resetLimits(this->node, lastPathElement());
  436 + resetLimits(node, lastPathElement());
437 437 }
438 438  
439   - if (this->item_number == nitems) {
  439 + if (item_number == nitems) {
440 440 // We removed the last item of a non-empty items array, so advance to the successor of
441 441 // the previous item.
442 442 QTC::TC("qpdf", "NNTree erased last item");
443   - this->item_number -= 2;
  443 + item_number -= 2;
444 444 increment(false);
445   - } else if (this->item_number < nitems) {
  445 + } else if (item_number < nitems) {
446 446 // We don't have to do anything since the removed item's successor now occupies its
447 447 // former location.
448 448 QTC::TC("qpdf", "NNTree erased non-last item");
... ... @@ -454,7 +454,7 @@ NNTreeIterator::remove()
454 454 return;
455 455 }
456 456  
457   - if (this->path.empty()) {
  457 + if (path.empty()) {
458 458 // Special case: if this is the root node, we can leave it empty.
459 459 QTC::TC("qpdf", "NNTree erased all items on leaf/root");
460 460 setItemNumber(impl.oh, -1);
... ... @@ -498,18 +498,18 @@ NNTreeIterator::remove()
498 498 deepen(kids.getArrayItem(element->kid_number), true, true);
499 499 }
500 500 done = true;
501   - } else if (parent == this->path.end()) {
  501 + } else if (parent == path.end()) {
502 502 // We erased the very last item. Convert the root to an empty items array.
503 503 QTC::TC("qpdf", "NNTree non-flat tree is empty after remove");
504 504 element->node.removeKey("/Kids");
505 505 element->node.replaceKey(impl.details.itemsKey(), QPDFObjectHandle::newArray());
506   - this->path.clear();
  506 + path.clear();
507 507 setItemNumber(impl.oh, -1);
508 508 done = true;
509 509 } else {
510 510 // Walk up the tree and continue
511 511 QTC::TC("qpdf", "NNTree remove walking up tree");
512   - this->path.pop_back();
  512 + path.pop_back();
513 513 }
514 514 }
515 515 }
... ... @@ -532,99 +532,99 @@ NNTreeIterator::reference
532 532 NNTreeIterator::operator*()
533 533 {
534 534 updateIValue(false);
535   - return this->ivalue;
  535 + return ivalue;
536 536 }
537 537  
538 538 NNTreeIterator::pointer
539 539 NNTreeIterator::operator->()
540 540 {
541 541 updateIValue(false);
542   - return &(this->ivalue);
  542 + return &ivalue;
543 543 }
544 544  
545 545 bool
546 546 NNTreeIterator::operator==(NNTreeIterator const& other) const
547 547 {
548   - if ((this->item_number == -1) && (other.item_number == -1)) {
  548 + if (item_number == -1 && other.item_number == -1) {
549 549 return true;
550 550 }
551   - if (this->path.size() != other.path.size()) {
  551 + if (path.size() != other.path.size()) {
552 552 return false;
553 553 }
554   - auto tpi = this->path.begin();
  554 + auto tpi = path.begin();
555 555 auto opi = other.path.begin();
556   - while (tpi != this->path.end()) {
  556 + while (tpi != path.end()) {
557 557 if (tpi->kid_number != opi->kid_number) {
558 558 return false;
559 559 }
560 560 ++tpi;
561 561 ++opi;
562 562 }
563   - if (this->item_number != other.item_number) {
  563 + if (item_number != other.item_number) {
564 564 return false;
565 565 }
566 566 return true;
567 567 }
568 568  
569 569 void
570   -NNTreeIterator::setItemNumber(QPDFObjectHandle const& node, int n)
  570 +NNTreeIterator::setItemNumber(QPDFObjectHandle const& a_node, int n)
571 571 {
572   - this->node = node;
573   - this->item_number = n;
  572 + node = a_node;
  573 + item_number = n;
574 574 updateIValue();
575 575 }
576 576  
577 577 void
578   -NNTreeIterator::addPathElement(QPDFObjectHandle const& node, int kid_number)
  578 +NNTreeIterator::addPathElement(QPDFObjectHandle const& a_node, int kid_number)
579 579 {
580   - this->path.emplace_back(node, kid_number);
  580 + path.emplace_back(a_node, kid_number);
581 581 }
582 582  
583 583 bool
584   -NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
  584 +NNTreeIterator::deepen(QPDFObjectHandle a_node, bool first, bool allow_empty)
585 585 {
586 586 // Starting at this node, descend through the first or last kid until we reach a node with
587 587 // items. If we succeed, return true; otherwise return false and leave path alone.
588 588  
589   - auto opath = this->path;
  589 + auto opath = path;
590 590 bool failed = false;
591 591  
592 592 QPDFObjGen::set seen;
593   - for (auto const& i: this->path) {
  593 + for (auto const& i: path) {
594 594 seen.add(i.node);
595 595 }
596 596 while (!failed) {
597   - if (!seen.add(node)) {
  597 + if (!seen.add(a_node)) {
598 598 QTC::TC("qpdf", "NNTree deepen: loop");
599   - warn(impl.qpdf, node, "loop detected while traversing name/number tree");
  599 + warn(impl.qpdf, a_node, "loop detected while traversing name/number tree");
600 600 failed = true;
601 601 break;
602 602 }
603 603  
604   - if (!node.isDictionary()) {
  604 + if (!a_node.isDictionary()) {
605 605 QTC::TC("qpdf", "NNTree node is not a dictionary");
606   - warn(impl.qpdf, node, "non-dictionary node while traversing name/number tree");
  606 + warn(impl.qpdf, a_node, "non-dictionary node while traversing name/number tree");
607 607 failed = true;
608 608 break;
609 609 }
610 610  
611   - auto kids = node.getKey("/Kids");
  611 + auto kids = a_node.getKey("/Kids");
612 612 int nkids = kids.isArray() ? kids.getArrayNItems() : 0;
613   - auto items = node.getKey(impl.details.itemsKey());
  613 + auto items = a_node.getKey(impl.details.itemsKey());
614 614 int nitems = items.isArray() ? items.getArrayNItems() : 0;
615 615 if (nitems > 0) {
616   - setItemNumber(node, first ? 0 : nitems - 2);
  616 + setItemNumber(a_node, first ? 0 : nitems - 2);
617 617 break;
618 618 } else if (nkids > 0) {
619 619 int kid_number = first ? 0 : nkids - 1;
620   - addPathElement(node, kid_number);
  620 + addPathElement(a_node, kid_number);
621 621 auto next = kids.getArrayItem(kid_number);
622 622 if (!next.isIndirect()) {
623 623 if (impl.auto_repair) {
624 624 QTC::TC("qpdf", "NNTree fix indirect kid");
625 625 warn(
626 626 impl.qpdf,
627   - node,
  627 + a_node,
628 628 ("converting kid number " + std::to_string(kid_number) +
629 629 " to an indirect object"));
630 630 next = impl.qpdf.makeIndirectObject(next);
... ... @@ -633,21 +633,21 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
633 633 QTC::TC("qpdf", "NNTree warn indirect kid");
634 634 warn(
635 635 impl.qpdf,
636   - node,
  636 + a_node,
637 637 ("kid number " + std::to_string(kid_number) +
638 638 " is not an indirect object"));
639 639 }
640 640 }
641   - node = next;
  641 + a_node = next;
642 642 } else if (allow_empty && items.isArray()) {
643 643 QTC::TC("qpdf", "NNTree deepen found empty");
644   - setItemNumber(node, -1);
  644 + setItemNumber(a_node, -1);
645 645 break;
646 646 } else {
647 647 QTC::TC("qpdf", "NNTree deepen: invalid node");
648 648 warn(
649 649 impl.qpdf,
650   - node,
  650 + a_node,
651 651 ("name/number tree node has neither non-empty " + impl.details.itemsKey() +
652 652 " nor /Kids"));
653 653 failed = true;
... ... @@ -655,7 +655,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
655 655 }
656 656 }
657 657 if (failed) {
658   - this->path = opath;
  658 + path = opath;
659 659 return false;
660 660 }
661 661 return true;
... ... @@ -671,16 +671,16 @@ NNTreeImpl::NNTreeImpl(
671 671 }
672 672  
673 673 void
674   -NNTreeImpl::setSplitThreshold(int split_threshold)
  674 +NNTreeImpl::setSplitThreshold(int threshold)
675 675 {
676   - this->split_threshold = split_threshold;
  676 + split_threshold = threshold;
677 677 }
678 678  
679 679 NNTreeImpl::iterator
680 680 NNTreeImpl::begin()
681 681 {
682 682 iterator result(*this);
683   - result.deepen(this->oh, true, true);
  683 + result.deepen(oh, true, true);
684 684 return result;
685 685 }
686 686  
... ... @@ -694,7 +694,7 @@ NNTreeImpl::iterator
694 694 NNTreeImpl::last()
695 695 {
696 696 iterator result(*this);
697   - result.deepen(this->oh, false, true);
  697 + result.deepen(oh, false, true);
698 698 return result;
699 699 }
700 700  
... ... @@ -782,10 +782,7 @@ NNTreeImpl::compareKeyItem(QPDFObjectHandle&amp; key, QPDFObjectHandle&amp; items, int i
782 782 if (!((items.isArray() && (items.getArrayNItems() > (2 * idx)) &&
783 783 details.keyValid(items.getArrayItem(2 * idx))))) {
784 784 QTC::TC("qpdf", "NNTree item is wrong type");
785   - error(
786   - qpdf,
787   - this->oh,
788   - ("item at index " + std::to_string(2 * idx) + " is not the right type"));
  785 + error(qpdf, oh, ("item at index " + std::to_string(2 * idx) + " is not the right type"));
789 786 }
790 787 return details.compareKeys(key, items.getArrayItem(2 * idx));
791 788 }
... ... @@ -796,7 +793,7 @@ NNTreeImpl::compareKeyKid(QPDFObjectHandle&amp; key, QPDFObjectHandle&amp; kids, int idx
796 793 if (!(kids.isArray() && (idx < kids.getArrayNItems()) &&
797 794 kids.getArrayItem(idx).isDictionary())) {
798 795 QTC::TC("qpdf", "NNTree kid is invalid");
799   - error(qpdf, this->oh, "invalid kid at index " + std::to_string(idx));
  796 + error(qpdf, oh, "invalid kid at index " + std::to_string(idx));
800 797 }
801 798 return withinLimits(key, kids.getArrayItem(idx));
802 799 }
... ... @@ -810,8 +807,8 @@ NNTreeImpl::repair()
810 807 for (auto const& i: *this) {
811 808 repl.insert(i.first, i.second);
812 809 }
813   - this->oh.replaceKey("/Kids", new_node.getKey("/Kids"));
814   - this->oh.replaceKey(details.itemsKey(), new_node.getKey(details.itemsKey()));
  810 + oh.replaceKey("/Kids", new_node.getKey("/Kids"));
  811 + oh.replaceKey(details.itemsKey(), new_node.getKey(details.itemsKey()));
815 812 }
816 813  
817 814 NNTreeImpl::iterator
... ... @@ -820,9 +817,9 @@ NNTreeImpl::find(QPDFObjectHandle key, bool return_prev_if_not_found)
820 817 try {
821 818 return findInternal(key, return_prev_if_not_found);
822 819 } catch (QPDFExc& e) {
823   - if (this->auto_repair) {
  820 + if (auto_repair) {
824 821 QTC::TC("qpdf", "NNTree repair");
825   - warn(qpdf, this->oh, std::string("attempting to repair after error: ") + e.what());
  822 + warn(qpdf, oh, std::string("attempting to repair after error: ") + e.what());
826 823 repair();
827 824 return findInternal(key, return_prev_if_not_found);
828 825 } else {
... ... @@ -856,7 +853,7 @@ NNTreeImpl::findInternal(QPDFObjectHandle key, bool return_prev_if_not_found)
856 853 }
857 854  
858 855 QPDFObjGen::set seen;
859   - auto node = this->oh;
  856 + auto node = oh;
860 857 iterator result(*this);
861 858  
862 859 while (true) {
... ... @@ -907,7 +904,7 @@ NNTreeImpl::insertFirst(QPDFObjectHandle key, QPDFObjectHandle value)
907 904 }
908 905 if (!(items.isArray())) {
909 906 QTC::TC("qpdf", "NNTree no valid items node in insertFirst");
910   - error(qpdf, this->oh, "unable to find a valid items node");
  907 + error(qpdf, oh, "unable to find a valid items node");
911 908 }
912 909 items.insertItem(0, key);
913 910 items.insertItem(1, value);
... ...
libqpdf/Pl_ASCII85Decoder.cc
... ... @@ -57,7 +57,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
57 57 break;
58 58  
59 59 default:
60   - if ((buf[i] < 33) || (buf[i] > 117)) {
  60 + if (buf[i] < 33 || buf[i] > 117) {
61 61 error = true;
62 62 throw std::runtime_error("character out of range during base 85 decode");
63 63 } else {
... ...
libqpdf/Pl_ASCIIHexDecoder.cc
... ... @@ -17,7 +17,7 @@ Pl_ASCIIHexDecoder::Pl_ASCIIHexDecoder(char const* identifier, Pipeline* next) :
17 17 void
18 18 Pl_ASCIIHexDecoder::write(unsigned char const* buf, size_t len)
19 19 {
20   - if (this->eod) {
  20 + if (eod) {
21 21 return;
22 22 }
23 23 for (size_t i = 0; i < len; ++i) {
... ... @@ -34,14 +34,14 @@ Pl_ASCIIHexDecoder::write(unsigned char const* buf, size_t len)
34 34 break;
35 35  
36 36 case '>':
37   - this->eod = true;
  37 + eod = true;
38 38 flush();
39 39 break;
40 40  
41 41 default:
42   - if (((ch >= '0') && (ch <= '9')) || ((ch >= 'A') && (ch <= 'F'))) {
43   - this->inbuf[this->pos++] = ch;
44   - if (this->pos == 2) {
  42 + if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F')) {
  43 + inbuf[pos++] = ch;
  44 + if (pos == 2) {
45 45 flush();
46 46 }
47 47 } else {
... ... @@ -52,7 +52,7 @@ Pl_ASCIIHexDecoder::write(unsigned char const* buf, size_t len)
52 52 }
53 53 break;
54 54 }
55   - if (this->eod) {
  55 + if (eod) {
56 56 break;
57 57 }
58 58 }
... ... @@ -61,26 +61,26 @@ Pl_ASCIIHexDecoder::write(unsigned char const* buf, size_t len)
61 61 void
62 62 Pl_ASCIIHexDecoder::flush()
63 63 {
64   - if (this->pos == 0) {
  64 + if (pos == 0) {
65 65 QTC::TC("libtests", "Pl_ASCIIHexDecoder no-op flush");
66 66 return;
67 67 }
68 68 int b[2];
69 69 for (int i = 0; i < 2; ++i) {
70   - if (this->inbuf[i] >= 'A') {
71   - b[i] = this->inbuf[i] - 'A' + 10;
  70 + if (inbuf[i] >= 'A') {
  71 + b[i] = inbuf[i] - 'A' + 10;
72 72 } else {
73   - b[i] = this->inbuf[i] - '0';
  73 + b[i] = inbuf[i] - '0';
74 74 }
75 75 }
76 76 auto ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
77 77  
78   - QTC::TC("libtests", "Pl_ASCIIHexDecoder partial flush", (this->pos == 2) ? 0 : 1);
  78 + QTC::TC("libtests", "Pl_ASCIIHexDecoder partial flush", (pos == 2) ? 0 : 1);
79 79 // Reset before calling getNext()->write in case that throws an exception.
80   - this->pos = 0;
81   - this->inbuf[0] = '0';
82   - this->inbuf[1] = '0';
83   - this->inbuf[2] = '\0';
  80 + pos = 0;
  81 + inbuf[0] = '0';
  82 + inbuf[1] = '0';
  83 + inbuf[2] = '\0';
84 84  
85 85 next()->write(&ch, 1);
86 86 }
... ...
libqpdf/Pl_Base64.cc
... ... @@ -102,17 +102,17 @@ Pl_Base64::flush_decode()
102 102 for (size_t i = 0; i < 4; ++i) {
103 103 int v = 0;
104 104 char ch = to_c(buf[i]);
105   - if ((ch >= 'A') && (ch <= 'Z')) {
  105 + if (ch >= 'A' && ch <= 'Z') {
106 106 v = ch - 'A';
107   - } else if ((ch >= 'a') && (ch <= 'z')) {
  107 + } else if (ch >= 'a' && ch <= 'z') {
108 108 v = ch - 'a' + 26;
109   - } else if ((ch >= '0') && (ch <= '9')) {
  109 + } else if (ch >= '0' && ch <= '9') {
110 110 v = ch - '0' + 52;
111   - } else if ((ch == '+') || (ch == '-')) {
  111 + } else if (ch == '+' || ch == '-') {
112 112 v = 62;
113   - } else if ((ch == '/') || (ch == '_')) {
  113 + } else if (ch == '/' || ch == '_') {
114 114 v = 63;
115   - } else if ((ch == '=') && ((i == 3) || ((i == 2) && (buf[3] == '=')))) {
  115 + } else if (ch == '=' && (i == 3 || (i == 2 && buf[3] == '='))) {
116 116 ++pad;
117 117 end_of_data = true;
118 118 v = 0;
... ... @@ -134,7 +134,7 @@ Pl_Base64::flush_decode()
134 134 void
135 135 Pl_Base64::flush_encode()
136 136 {
137   - int outval = ((buf[0] << 16) | (buf[1] << 8) | (buf[2]));
  137 + int outval = ((buf[0] << 16) | (buf[1] << 8) | buf[2]);
138 138 unsigned char out[4] = {
139 139 to_uc(outval >> 18),
140 140 to_uc(0x3f & (outval >> 12)),
... ...
libqpdf/Pl_LZWDecoder.cc
... ... @@ -23,8 +23,8 @@ Pl_LZWDecoder::write(unsigned char const* bytes, size_t len)
23 23 if (next_char_ == 3) {
24 24 next_char_ = 0;
25 25 }
26   - this->bits_available += 8;
27   - if (this->bits_available >= this->code_size) {
  26 + bits_available += 8;
  27 + if (bits_available >= code_size) {
28 28 sendNextCode();
29 29 }
30 30 }
... ... @@ -39,12 +39,12 @@ Pl_LZWDecoder::finish()
39 39 void
40 40 Pl_LZWDecoder::sendNextCode()
41 41 {
42   - unsigned int high = this->byte_pos;
43   - unsigned int med = (this->byte_pos + 1) % 3;
44   - unsigned int low = (this->byte_pos + 2) % 3;
  42 + unsigned int high = byte_pos;
  43 + unsigned int med = (byte_pos + 1) % 3;
  44 + unsigned int low = (byte_pos + 2) % 3;
45 45  
46   - unsigned int bits_from_high = 8 - this->bit_pos;
47   - unsigned int bits_from_med = this->code_size - bits_from_high;
  46 + unsigned int bits_from_high = 8 - bit_pos;
  47 + unsigned int bits_from_med = code_size - bits_from_high;
48 48 unsigned int bits_from_low = 0;
49 49 if (bits_from_med > 8) {
50 50 bits_from_low = bits_from_med - 8;
... ... @@ -54,23 +54,23 @@ Pl_LZWDecoder::sendNextCode()
54 54 unsigned int med_mask = 0xff - ((1U << (8 - bits_from_med)) - 1U);
55 55 unsigned int low_mask = 0xff - ((1U << (8 - bits_from_low)) - 1U);
56 56 unsigned int code = 0;
57   - code += (this->buf[high] & high_mask) << bits_from_med;
58   - code += ((this->buf[med] & med_mask) >> (8 - bits_from_med));
  57 + code += (buf[high] & high_mask) << bits_from_med;
  58 + code += ((buf[med] & med_mask) >> (8 - bits_from_med));
59 59 if (bits_from_low) {
60 60 code <<= bits_from_low;
61   - code += ((this->buf[low] & low_mask) >> (8 - bits_from_low));
62   - this->byte_pos = low;
63   - this->bit_pos = bits_from_low;
  61 + code += ((buf[low] & low_mask) >> (8 - bits_from_low));
  62 + byte_pos = low;
  63 + bit_pos = bits_from_low;
64 64 } else {
65   - this->byte_pos = med;
66   - this->bit_pos = bits_from_med;
  65 + byte_pos = med;
  66 + bit_pos = bits_from_med;
67 67 }
68   - if (this->bit_pos == 8) {
69   - this->bit_pos = 0;
70   - ++this->byte_pos;
71   - this->byte_pos %= 3;
  68 + if (bit_pos == 8) {
  69 + bit_pos = 0;
  70 + ++byte_pos;
  71 + byte_pos %= 3;
72 72 }
73   - this->bits_available -= this->code_size;
  73 + bits_available -= code_size;
74 74  
75 75 handleCode(code);
76 76 }
... ... @@ -102,12 +102,12 @@ Pl_LZWDecoder::addToTable(unsigned char c)
102 102 unsigned char const* last_data = nullptr;
103 103 unsigned char tmp[1];
104 104  
105   - if (this->last_code < 256) {
106   - tmp[0] = static_cast<unsigned char>(this->last_code);
  105 + if (last_code < 256) {
  106 + tmp[0] = static_cast<unsigned char>(last_code);
107 107 last_data = tmp;
108 108 last_size = 1;
109   - } else if (this->last_code > 257) {
110   - unsigned int idx = this->last_code - 258;
  109 + } else if (last_code > 257) {
  110 + unsigned int idx = last_code - 258;
111 111 if (idx >= table.size()) {
112 112 throw std::runtime_error("Pl_LZWDecoder::addToTable: table overflow");
113 113 }
... ... @@ -116,34 +116,34 @@ Pl_LZWDecoder::addToTable(unsigned char c)
116 116 last_size = QIntC::to_uint(b.getSize());
117 117 } else {
118 118 throw std::runtime_error(
119   - "Pl_LZWDecoder::addToTable called with invalid code (" +
120   - std::to_string(this->last_code) + ")");
  119 + "Pl_LZWDecoder::addToTable called with invalid code (" + std::to_string(last_code) +
  120 + ")");
121 121 }
122 122  
123 123 Buffer entry(1 + last_size);
124 124 unsigned char* new_data = entry.getBuffer();
125 125 memcpy(new_data, last_data, last_size);
126 126 new_data[last_size] = c;
127   - this->table.push_back(std::move(entry));
  127 + table.push_back(std::move(entry));
128 128 }
129 129  
130 130 void
131 131 Pl_LZWDecoder::handleCode(unsigned int code)
132 132 {
133   - if (this->eod) {
  133 + if (eod) {
134 134 return;
135 135 }
136 136  
137 137 if (code == 256) {
138   - if (!this->table.empty()) {
  138 + if (!table.empty()) {
139 139 QTC::TC("libtests", "Pl_LZWDecoder intermediate reset");
140 140 }
141   - this->table.clear();
142   - this->code_size = 9;
  141 + table.clear();
  142 + code_size = 9;
143 143 } else if (code == 257) {
144   - this->eod = true;
  144 + eod = true;
145 145 } else {
146   - if (this->last_code != 256) {
  146 + if (last_code != 256) {
147 147 // Add to the table from last time. New table entry would be what we read last plus the
148 148 // first character of what we're reading now.
149 149 unsigned char next_c = '\0';
... ... @@ -159,7 +159,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
159 159 // The encoder would have just created this entry, so the first character of
160 160 // this entry would have been the same as the first character of the last entry.
161 161 QTC::TC("libtests", "Pl_LZWDecoder last was table size");
162   - next_c = getFirstChar(this->last_code);
  162 + next_c = getFirstChar(last_code);
163 163 } else {
164 164 next_c = getFirstChar(code);
165 165 }
... ... @@ -171,7 +171,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
171 171 addToTable(next_c);
172 172 unsigned int change_idx = new_idx + code_change_delta;
173 173 if ((change_idx == 511) || (change_idx == 1023) || (change_idx == 2047)) {
174   - ++this->code_size;
  174 + ++code_size;
175 175 }
176 176 }
177 177  
... ... @@ -188,5 +188,5 @@ Pl_LZWDecoder::handleCode(unsigned int code)
188 188 }
189 189 }
190 190  
191   - this->last_code = code;
  191 + last_code = code;
192 192 }
... ...
libqpdf/Pl_MD5.cc
... ... @@ -13,10 +13,10 @@ Pl_MD5::Pl_MD5(char const* identifier, Pipeline* next) :
13 13 void
14 14 Pl_MD5::write(unsigned char const* buf, size_t len)
15 15 {
16   - if (this->enabled) {
17   - if (!this->in_progress) {
18   - this->md5.reset();
19   - this->in_progress = true;
  16 + if (enabled) {
  17 + if (!in_progress) {
  18 + md5.reset();
  19 + in_progress = true;
20 20 }
21 21  
22 22 // Write in chunks in case len is too big to fit in an int. Assume int is at least 32 bits.
... ... @@ -25,7 +25,7 @@ Pl_MD5::write(unsigned char const* buf, size_t len)
25 25 unsigned char const* data = buf;
26 26 while (bytes_left > 0) {
27 27 size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left);
28   - this->md5.encodeDataIncrementally(reinterpret_cast<char const*>(data), bytes);
  28 + md5.encodeDataIncrementally(reinterpret_cast<char const*>(data), bytes);
29 29 bytes_left -= bytes;
30 30 data += bytes;
31 31 }
... ... @@ -38,29 +38,29 @@ void
38 38 Pl_MD5::finish()
39 39 {
40 40 next()->finish();
41   - if (!this->persist_across_finish) {
42   - this->in_progress = false;
  41 + if (!persist_across_finish) {
  42 + in_progress = false;
43 43 }
44 44 }
45 45  
46 46 void
47   -Pl_MD5::enable(bool enabled)
  47 +Pl_MD5::enable(bool is_enabled)
48 48 {
49   - this->enabled = enabled;
  49 + enabled = is_enabled;
50 50 }
51 51  
52 52 void
53 53 Pl_MD5::persistAcrossFinish(bool persist)
54 54 {
55   - this->persist_across_finish = persist;
  55 + persist_across_finish = persist;
56 56 }
57 57  
58 58 std::string
59 59 Pl_MD5::getHexDigest()
60 60 {
61   - if (!this->enabled) {
  61 + if (!enabled) {
62 62 throw std::logic_error("digest requested for a disabled MD5 Pipeline");
63 63 }
64   - this->in_progress = false;
65   - return this->md5.unparse();
  64 + in_progress = false;
  65 + return md5.unparse();
66 66 }
... ...
libqpdf/Pl_SHA2.cc
... ... @@ -2,6 +2,7 @@
2 2  
3 3 #include <qpdf/QPDFCryptoProvider.hh>
4 4 #include <qpdf/QUtil.hh>
  5 +
5 6 #include <stdexcept>
6 7  
7 8 Pl_SHA2::Pl_SHA2(int bits, Pipeline* next) :
... ... @@ -15,8 +16,8 @@ Pl_SHA2::Pl_SHA2(int bits, Pipeline* next) :
15 16 void
16 17 Pl_SHA2::write(unsigned char const* buf, size_t len)
17 18 {
18   - if (!this->in_progress) {
19   - this->in_progress = true;
  19 + if (!in_progress) {
  20 + in_progress = true;
20 21 }
21 22  
22 23 // Write in chunks in case len is too big to fit in an int. Assume int is at least 32 bits.
... ... @@ -25,7 +26,7 @@ Pl_SHA2::write(unsigned char const* buf, size_t len)
25 26 unsigned char const* data = buf;
26 27 while (bytes_left > 0) {
27 28 size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left);
28   - this->crypto->SHA2_update(data, bytes);
  29 + crypto->SHA2_update(data, bytes);
29 30 bytes_left -= bytes;
30 31 data += bytes;
31 32 }
... ... @@ -41,33 +42,33 @@ Pl_SHA2::finish()
41 42 if (next()) {
42 43 next()->finish();
43 44 }
44   - this->crypto->SHA2_finalize();
45   - this->in_progress = false;
  45 + crypto->SHA2_finalize();
  46 + in_progress = false;
46 47 }
47 48  
48 49 void
49 50 Pl_SHA2::resetBits(int bits)
50 51 {
51   - if (this->in_progress) {
  52 + if (in_progress) {
52 53 throw std::logic_error("bit reset requested for in-progress SHA2 Pipeline");
53 54 }
54   - this->crypto = QPDFCryptoProvider::getImpl();
55   - this->crypto->SHA2_init(bits);
  55 + crypto = QPDFCryptoProvider::getImpl();
  56 + crypto->SHA2_init(bits);
56 57 }
57 58  
58 59 std::string
59 60 Pl_SHA2::getRawDigest()
60 61 {
61   - if (this->in_progress) {
  62 + if (in_progress) {
62 63 throw std::logic_error("digest requested for in-progress SHA2 Pipeline");
63 64 }
64   - return this->crypto->SHA2_digest();
  65 + return crypto->SHA2_digest();
65 66 }
66 67  
67 68 std::string
68 69 Pl_SHA2::getHexDigest()
69 70 {
70   - if (this->in_progress) {
  71 + if (in_progress) {
71 72 throw std::logic_error("digest requested for in-progress SHA2 Pipeline");
72 73 }
73 74 return QUtil::hex_encode(getRawDigest());
... ...
libqpdf/QPDFCrypto_gnutls.cc
... ... @@ -18,14 +18,14 @@ QPDFCrypto_gnutls::QPDFCrypto_gnutls() :
18 18  
19 19 QPDFCrypto_gnutls::~QPDFCrypto_gnutls()
20 20 {
21   - if (this->hash_ctx) {
22   - gnutls_hash_deinit(this->hash_ctx, digest);
  21 + if (hash_ctx) {
  22 + gnutls_hash_deinit(hash_ctx, digest);
23 23 }
24 24 if (cipher_ctx) {
25   - gnutls_cipher_deinit(this->cipher_ctx);
  25 + gnutls_cipher_deinit(cipher_ctx);
26 26 }
27   - this->aes_key_data = nullptr;
28   - this->aes_key_len = 0;
  27 + aes_key_data = nullptr;
  28 + aes_key_len = 0;
29 29 }
30 30  
31 31 void
... ... @@ -43,9 +43,9 @@ void
43 43 QPDFCrypto_gnutls::MD5_init()
44 44 {
45 45 MD5_finalize();
46   - int code = gnutls_hash_init(&this->hash_ctx, GNUTLS_DIG_MD5);
  46 + int code = gnutls_hash_init(&hash_ctx, GNUTLS_DIG_MD5);
47 47 if (code < 0) {
48   - this->hash_ctx = nullptr;
  48 + hash_ctx = nullptr;
49 49 throw std::runtime_error(
50 50 std::string("gnutls: MD5 error: ") + std::string(gnutls_strerror(code)));
51 51 }
... ... @@ -54,22 +54,22 @@ QPDFCrypto_gnutls::MD5_init()
54 54 void
55 55 QPDFCrypto_gnutls::MD5_update(unsigned char const* data, size_t len)
56 56 {
57   - gnutls_hash(this->hash_ctx, data, len);
  57 + gnutls_hash(hash_ctx, data, len);
58 58 }
59 59  
60 60 void
61 61 QPDFCrypto_gnutls::MD5_finalize()
62 62 {
63   - if (this->hash_ctx) {
64   - gnutls_hash_deinit(this->hash_ctx, this->digest);
65   - this->hash_ctx = nullptr;
  63 + if (hash_ctx) {
  64 + gnutls_hash_deinit(hash_ctx, digest);
  65 + hash_ctx = nullptr;
66 66 }
67 67 }
68 68  
69 69 void
70 70 QPDFCrypto_gnutls::MD5_digest(MD5_Digest d)
71 71 {
72   - memcpy(d, this->digest, sizeof(MD5_Digest));
  72 + memcpy(d, digest, sizeof(MD5_Digest));
73 73 }
74 74  
75 75 void
... ... @@ -83,9 +83,9 @@ QPDFCrypto_gnutls::RC4_init(unsigned char const* key_data, int key_len)
83 83 key.data = const_cast<unsigned char*>(key_data);
84 84 key.size = QIntC::to_uint(key_len);
85 85  
86   - int code = gnutls_cipher_init(&this->cipher_ctx, GNUTLS_CIPHER_ARCFOUR_128, &key, nullptr);
  86 + int code = gnutls_cipher_init(&cipher_ctx, GNUTLS_CIPHER_ARCFOUR_128, &key, nullptr);
87 87 if (code < 0) {
88   - this->cipher_ctx = nullptr;
  88 + cipher_ctx = nullptr;
89 89 throw std::runtime_error(
90 90 std::string("gnutls: RC4 error: ") + std::string(gnutls_strerror(code)));
91 91 }
... ... @@ -94,15 +94,15 @@ QPDFCrypto_gnutls::RC4_init(unsigned char const* key_data, int key_len)
94 94 void
95 95 QPDFCrypto_gnutls::RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data)
96 96 {
97   - gnutls_cipher_encrypt2(this->cipher_ctx, in_data, len, out_data, len);
  97 + gnutls_cipher_encrypt2(cipher_ctx, in_data, len, out_data, len);
98 98 }
99 99  
100 100 void
101 101 QPDFCrypto_gnutls::RC4_finalize()
102 102 {
103   - if (this->cipher_ctx) {
104   - gnutls_cipher_deinit(this->cipher_ctx);
105   - this->cipher_ctx = nullptr;
  103 + if (cipher_ctx) {
  104 + gnutls_cipher_deinit(cipher_ctx);
  105 + cipher_ctx = nullptr;
106 106 }
107 107 }
108 108  
... ... @@ -125,10 +125,10 @@ QPDFCrypto_gnutls::SHA2_init(int bits)
125 125 badBits();
126 126 break;
127 127 }
128   - this->sha2_bits = bits;
129   - int code = gnutls_hash_init(&this->hash_ctx, alg);
  128 + sha2_bits = bits;
  129 + int code = gnutls_hash_init(&hash_ctx, alg);
130 130 if (code < 0) {
131   - this->hash_ctx = nullptr;
  131 + hash_ctx = nullptr;
132 132 throw std::runtime_error(
133 133 std::string("gnutls: SHA") + std::to_string(bits) +
134 134 " error: " + std::string(gnutls_strerror(code)));
... ... @@ -138,15 +138,15 @@ QPDFCrypto_gnutls::SHA2_init(int bits)
138 138 void
139 139 QPDFCrypto_gnutls::SHA2_update(unsigned char const* data, size_t len)
140 140 {
141   - gnutls_hash(this->hash_ctx, data, len);
  141 + gnutls_hash(hash_ctx, data, len);
142 142 }
143 143  
144 144 void
145 145 QPDFCrypto_gnutls::SHA2_finalize()
146 146 {
147   - if (this->hash_ctx) {
148   - gnutls_hash_deinit(this->hash_ctx, this->digest);
149   - this->hash_ctx = nullptr;
  147 + if (hash_ctx) {
  148 + gnutls_hash_deinit(hash_ctx, digest);
  149 + hash_ctx = nullptr;
150 150 }
151 151 }
152 152  
... ... @@ -154,15 +154,15 @@ std::string
154 154 QPDFCrypto_gnutls::SHA2_digest()
155 155 {
156 156 std::string result;
157   - switch (this->sha2_bits) {
  157 + switch (sha2_bits) {
158 158 case 256:
159   - result = std::string(reinterpret_cast<char*>(this->digest), 32);
  159 + result = std::string(reinterpret_cast<char*>(digest), 32);
160 160 break;
161 161 case 384:
162   - result = std::string(reinterpret_cast<char*>(this->digest), 48);
  162 + result = std::string(reinterpret_cast<char*>(digest), 48);
163 163 break;
164 164 case 512:
165   - result = std::string(reinterpret_cast<char*>(this->digest), 64);
  165 + result = std::string(reinterpret_cast<char*>(digest), 64);
166 166 break;
167 167 default:
168 168 badBits();
... ... @@ -184,8 +184,8 @@ QPDFCrypto_gnutls::rijndael_init(
184 184 this->cbc_mode = cbc_mode;
185 185 if (!cbc_mode) {
186 186 // Save the key so we can re-initialize.
187   - this->aes_key_data = key_data;
188   - this->aes_key_len = key_len;
  187 + aes_key_data = key_data;
  188 + aes_key_len = key_len;
189 189 }
190 190  
191 191 gnutls_cipher_algorithm_t alg = GNUTLS_CIPHER_UNKNOWN;
... ... @@ -214,9 +214,9 @@ QPDFCrypto_gnutls::rijndael_init(
214 214 iv.data = cbc_block;
215 215 iv.size = rijndael_buf_size;
216 216  
217   - int code = gnutls_cipher_init(&this->cipher_ctx, alg, &cipher_key, &iv);
  217 + int code = gnutls_cipher_init(&cipher_ctx, alg, &cipher_key, &iv);
218 218 if (code < 0) {
219   - this->cipher_ctx = nullptr;
  219 + cipher_ctx = nullptr;
220 220 throw std::runtime_error(
221 221 std::string("gnutls: AES error: ") + std::string(gnutls_strerror(code)));
222 222 }
... ... @@ -225,29 +225,27 @@ QPDFCrypto_gnutls::rijndael_init(
225 225 void
226 226 QPDFCrypto_gnutls::rijndael_process(unsigned char* in_data, unsigned char* out_data)
227 227 {
228   - if (this->encrypt) {
229   - gnutls_cipher_encrypt2(
230   - this->cipher_ctx, in_data, rijndael_buf_size, out_data, rijndael_buf_size);
  228 + if (encrypt) {
  229 + gnutls_cipher_encrypt2(cipher_ctx, in_data, rijndael_buf_size, out_data, rijndael_buf_size);
231 230 } else {
232   - gnutls_cipher_decrypt2(
233   - this->cipher_ctx, in_data, rijndael_buf_size, out_data, rijndael_buf_size);
  231 + gnutls_cipher_decrypt2(cipher_ctx, in_data, rijndael_buf_size, out_data, rijndael_buf_size);
234 232 }
235 233  
236 234 // Gnutls doesn't support AES in ECB (non-CBC) mode, but the result is the same as if you just
237 235 // reset the cbc block to all zeroes each time. We jump through a few hoops here to make this
238 236 // work.
239   - if (!this->cbc_mode) {
  237 + if (!cbc_mode) {
240 238 static unsigned char zeroes[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
241   - rijndael_init(this->encrypt, this->aes_key_data, this->aes_key_len, false, zeroes);
  239 + rijndael_init(encrypt, aes_key_data, aes_key_len, false, zeroes);
242 240 }
243 241 }
244 242  
245 243 void
246 244 QPDFCrypto_gnutls::rijndael_finalize()
247 245 {
248   - if (this->cipher_ctx) {
249   - gnutls_cipher_deinit(this->cipher_ctx);
250   - this->cipher_ctx = nullptr;
  246 + if (cipher_ctx) {
  247 + gnutls_cipher_deinit(cipher_ctx);
  248 + cipher_ctx = nullptr;
251 249 }
252 250 }
253 251  
... ...
libqpdf/QPDFCrypto_native.cc
... ... @@ -40,37 +40,37 @@ QPDFCrypto_native::provideRandomData(unsigned char* data, size_t len)
40 40 void
41 41 QPDFCrypto_native::MD5_init()
42 42 {
43   - this->md5 = std::make_shared<MD5_native>();
  43 + md5 = std::make_shared<MD5_native>();
44 44 }
45 45  
46 46 void
47 47 QPDFCrypto_native::MD5_update(unsigned char const* data, size_t len)
48 48 {
49   - this->md5->update(const_cast<unsigned char*>(data), len);
  49 + md5->update(const_cast<unsigned char*>(data), len);
50 50 }
51 51  
52 52 void
53 53 QPDFCrypto_native::MD5_finalize()
54 54 {
55   - this->md5->finalize();
  55 + md5->finalize();
56 56 }
57 57  
58 58 void
59 59 QPDFCrypto_native::MD5_digest(MD5_Digest d)
60 60 {
61   - this->md5->digest(d);
  61 + md5->digest(d);
62 62 }
63 63  
64 64 void
65 65 QPDFCrypto_native::RC4_init(unsigned char const* key_data, int key_len)
66 66 {
67   - this->rc4 = std::make_shared<RC4_native>(key_data, key_len);
  67 + rc4 = std::make_shared<RC4_native>(key_data, key_len);
68 68 }
69 69  
70 70 void
71 71 QPDFCrypto_native::RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data)
72 72 {
73   - this->rc4->process(in_data, len, out_data);
  73 + rc4->process(in_data, len, out_data);
74 74 }
75 75  
76 76 void
... ... @@ -81,25 +81,25 @@ QPDFCrypto_native::RC4_finalize()
81 81 void
82 82 QPDFCrypto_native::SHA2_init(int bits)
83 83 {
84   - this->sha2 = std::make_shared<SHA2_native>(bits);
  84 + sha2 = std::make_shared<SHA2_native>(bits);
85 85 }
86 86  
87 87 void
88 88 QPDFCrypto_native::SHA2_update(unsigned char const* data, size_t len)
89 89 {
90   - this->sha2->update(data, len);
  90 + sha2->update(data, len);
91 91 }
92 92  
93 93 void
94 94 QPDFCrypto_native::SHA2_finalize()
95 95 {
96   - this->sha2->finalize();
  96 + sha2->finalize();
97 97 }
98 98  
99 99 std::string
100 100 QPDFCrypto_native::SHA2_digest()
101 101 {
102   - return this->sha2->getRawDigest();
  102 + return sha2->getRawDigest();
103 103 }
104 104  
105 105 void
... ... @@ -111,14 +111,13 @@ QPDFCrypto_native::rijndael_init(
111 111 unsigned char* cbc_block)
112 112  
113 113 {
114   - this->aes_pdf =
115   - std::make_shared<AES_PDF_native>(encrypt, key_data, key_len, cbc_mode, cbc_block);
  114 + aes_pdf = std::make_shared<AES_PDF_native>(encrypt, key_data, key_len, cbc_mode, cbc_block);
116 115 }
117 116  
118 117 void
119 118 QPDFCrypto_native::rijndael_process(unsigned char* in_data, unsigned char* out_data)
120 119 {
121   - this->aes_pdf->update(in_data, out_data);
  120 + aes_pdf->update(in_data, out_data);
122 121 }
123 122  
124 123 void
... ...
libqpdf/QPDFCrypto_openssl.cc
... ... @@ -236,9 +236,7 @@ QPDFCrypto_openssl::rijndael_init(
236 236 }
237 237  
238 238 check_openssl(EVP_CIPHER_CTX_reset(cipher_ctx));
239   - check_openssl(
240   - // line-break
241   - EVP_CipherInit_ex(cipher_ctx, cipher, nullptr, key_data, cbc_block, encrypt));
  239 + check_openssl(EVP_CipherInit_ex(cipher_ctx, cipher, nullptr, key_data, cbc_block, encrypt));
242 240 check_openssl(EVP_CIPHER_CTX_set_padding(cipher_ctx, 0));
243 241 }
244 242  
... ...
libqpdf/QPDFEmbeddedFileDocumentHelper.cc
... ... @@ -63,7 +63,7 @@ QPDFEmbeddedFileDocumentHelper::initEmbeddedFiles()
63 63 }
64 64 auto embedded_files = names.getKey("/EmbeddedFiles");
65 65 if (!embedded_files.isDictionary()) {
66   - auto nth = QPDFNameTreeObjectHelper::newEmpty(this->qpdf);
  66 + auto nth = QPDFNameTreeObjectHelper::newEmpty(qpdf);
67 67 names.replaceKey("/EmbeddedFiles", nth.getObjectHandle());
68 68 m->embedded_files = std::make_shared<QPDFNameTreeObjectHelper>(nth);
69 69 }
... ... @@ -115,7 +115,7 @@ QPDFEmbeddedFileDocumentHelper::removeEmbeddedFile(std::string const&amp; name)
115 115 auto oh = iter->second;
116 116 iter.remove();
117 117 if (oh.isIndirect()) {
118   - this->qpdf.replaceObject(oh.getObjGen(), QPDFObjectHandle::newNull());
  118 + qpdf.replaceObject(oh.getObjGen(), QPDFObjectHandle::newNull());
119 119 }
120 120  
121 121 return true;
... ...
libqpdf/QPDFNameTreeObjectHelper.cc
... ... @@ -89,11 +89,11 @@ QPDFNameTreeObjectHelper::iterator::updateIValue()
89 89 {
90 90 if (impl->valid()) {
91 91 auto p = *impl;
92   - this->ivalue.first = p->first.getUTF8Value();
93   - this->ivalue.second = p->second;
  92 + ivalue.first = p->first.getUTF8Value();
  93 + ivalue.second = p->second;
94 94 } else {
95   - this->ivalue.first = "";
96   - this->ivalue.second = QPDFObjectHandle();
  95 + ivalue.first = "";
  96 + ivalue.second = QPDFObjectHandle();
97 97 }
98 98 }
99 99  
... ... @@ -101,14 +101,14 @@ QPDFNameTreeObjectHelper::iterator::reference
101 101 QPDFNameTreeObjectHelper::iterator::operator*()
102 102 {
103 103 updateIValue();
104   - return this->ivalue;
  104 + return ivalue;
105 105 }
106 106  
107 107 QPDFNameTreeObjectHelper::iterator::pointer
108 108 QPDFNameTreeObjectHelper::iterator::operator->()
109 109 {
110 110 updateIValue();
111   - return &this->ivalue;
  111 + return &ivalue;
112 112 }
113 113  
114 114 bool
... ...
libqpdf/QPDF_objects.cc
... ... @@ -1169,8 +1169,8 @@ QPDFObjectHandle
1169 1169 QPDF::readTrailer()
1170 1170 {
1171 1171 qpdf_offset_t offset = m->file->tell();
1172   - auto [object, empty] = QPDFParser::parse(
1173   - *m->file, "trailer", m->tokenizer, nullptr, *this, m->reconstructed_xref);
  1172 + auto [object, empty] =
  1173 + QPDFParser::parse(*m->file, "trailer", m->tokenizer, nullptr, *this, m->reconstructed_xref);
1174 1174 if (empty) {
1175 1175 // Nothing in the PDF spec appears to allow empty objects, but they have been encountered in
1176 1176 // actual PDF files and Adobe Reader appears to ignore them.
... ...
libqpdf/RC4.cc
... ... @@ -5,11 +5,11 @@
5 5 RC4::RC4(unsigned char const* key_data, int key_len) :
6 6 crypto(QPDFCryptoProvider::getImpl())
7 7 {
8   - this->crypto->RC4_init(key_data, key_len);
  8 + crypto->RC4_init(key_data, key_len);
9 9 }
10 10  
11 11 void
12 12 RC4::process(unsigned char const* in_data, size_t len, unsigned char* out_data)
13 13 {
14   - this->crypto->RC4_process(in_data, len, out_data);
  14 + crypto->RC4_process(in_data, len, out_data);
15 15 }
... ...
libqpdf/qpdf/QPDFCrypto_native.hh
... ... @@ -6,6 +6,7 @@
6 6 #include <qpdf/QPDFCryptoImpl.hh>
7 7 #include <qpdf/RC4_native.hh>
8 8 #include <qpdf/SHA2_native.hh>
  9 +
9 10 #include <memory>
10 11  
11 12 class QPDFCrypto_native final: public QPDFCryptoImpl
... ...