From 7ede03992a963d56754fc522f4c6f0bf944947cd Mon Sep 17 00:00:00 2001 From: m-holger Date: Tue, 11 Mar 2025 13:54:12 +0000 Subject: [PATCH] Remove 'this->' from QPDFTokenizer.cc and QPDFAcroFormDocumentHelper.cc --- libqpdf/QPDFAcroFormDocumentHelper.cc | 60 ++++++++++++++++++++++++++++++------------------------------ libqpdf/QPDFTokenizer.cc | 360 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 2 files changed, 210 insertions(+), 210 deletions(-) diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc index 2857870..8f47616 100644 --- a/libqpdf/QPDFAcroFormDocumentHelper.cc +++ b/libqpdf/QPDFAcroFormDocumentHelper.cc @@ -34,16 +34,16 @@ QPDFAcroFormDocumentHelper::invalidateCache() bool QPDFAcroFormDocumentHelper::hasAcroForm() { - return this->qpdf.getRoot().hasKey("/AcroForm"); + return qpdf.getRoot().hasKey("/AcroForm"); } QPDFObjectHandle QPDFAcroFormDocumentHelper::getOrCreateAcroForm() { - auto acroform = this->qpdf.getRoot().getKey("/AcroForm"); + auto acroform = qpdf.getRoot().getKey("/AcroForm"); if (!acroform.isDictionary()) { - acroform = this->qpdf.getRoot().replaceKeyAndGetNew( - "/AcroForm", this->qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary())); + acroform = qpdf.getRoot().replaceKeyAndGetNew( + "/AcroForm", qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary())); } return acroform; } @@ -115,7 +115,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector void QPDFAcroFormDocumentHelper::removeFormFields(std::set const& to_remove) { - auto acroform = this->qpdf.getRoot().getKey("/AcroForm"); + auto acroform = qpdf.getRoot().getKey("/AcroForm"); if (!acroform.isDictionary()) { return; } @@ -168,7 +168,7 @@ QPDFAcroFormDocumentHelper::getFormFields() analyze(); std::vector result; for (auto const& iter: m->field_to_annotations) { - result.emplace_back(this->qpdf.getObject(iter.first)); + result.emplace_back(qpdf.getObject(iter.first)); } return result; } @@ -267,7 +267,7 @@ QPDFAcroFormDocumentHelper::analyze() // a file that contains this kind of error will probably not // actually work with most viewers. - for (auto const& ph: QPDFPageDocumentHelper(this->qpdf).getAllPages()) { + for (auto const& ph: QPDFPageDocumentHelper(qpdf).getAllPages()) { for (auto const& iter: getWidgetAnnotationsForPage(ph)) { QPDFObjectHandle annot(iter.getObjectHandle()); QPDFObjGen og(annot.getObjGen()); @@ -368,7 +368,7 @@ bool QPDFAcroFormDocumentHelper::getNeedAppearances() { bool result = false; - QPDFObjectHandle acroform = this->qpdf.getRoot().getKey("/AcroForm"); + QPDFObjectHandle acroform = qpdf.getRoot().getKey("/AcroForm"); if (acroform.isDictionary() && acroform.getKey("/NeedAppearances").isBool()) { result = acroform.getKey("/NeedAppearances").getBoolValue(); } @@ -378,9 +378,9 @@ QPDFAcroFormDocumentHelper::getNeedAppearances() void QPDFAcroFormDocumentHelper::setNeedAppearances(bool val) { - QPDFObjectHandle acroform = this->qpdf.getRoot().getKey("/AcroForm"); + QPDFObjectHandle acroform = qpdf.getRoot().getKey("/AcroForm"); if (!acroform.isDictionary()) { - this->qpdf.getRoot().warnIfPossible( + qpdf.getRoot().warnIfPossible( "ignoring call to QPDFAcroFormDocumentHelper::setNeedAppearances" " on a file that lacks an /AcroForm dictionary"); return; @@ -399,7 +399,7 @@ QPDFAcroFormDocumentHelper::generateAppearancesIfNeeded() return; } - for (auto const& page: QPDFPageDocumentHelper(this->qpdf).getAllPages()) { + for (auto const& page: QPDFPageDocumentHelper(qpdf).getAllPages()) { for (auto& aoh: getWidgetAnnotationsForPage(page)) { QPDFFormFieldObjectHelper ffh = getFieldForAnnotation(aoh); if (ffh.getFieldType() == "/Btn") { @@ -548,7 +548,7 @@ ResourceReplacer::handleToken(QPDFTokenizer::Token const& token) wrote = true; } } - this->offset += token.getRawValue().length(); + offset += token.getRawValue().length(); if (!wrote) { writeToken(token); } @@ -590,11 +590,11 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances( // stream out of the string and then filter it. We don't attach the stream to anything, so it // will get discarded. ResourceFinder rf; - auto da_stream = QPDFObjectHandle::newStream(&this->qpdf, DA.getUTF8Value()); + auto da_stream = QPDFObjectHandle::newStream(&qpdf, DA.getUTF8Value()); try { - auto nwarnings = this->qpdf.numWarnings(); + auto nwarnings = qpdf.numWarnings(); da_stream.parseAsContents(&rf); - if (this->qpdf.numWarnings() > nwarnings) { + if (qpdf.numWarnings() > nwarnings) { QTC::TC("qpdf", "QPDFAcroFormDocumentHelper /DA parse error"); } } catch (std::exception& e) { @@ -632,7 +632,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream( bool was_indirect = resources.isIndirect(); resources = resources.shallowCopy(); if (was_indirect) { - resources = this->qpdf.makeIndirectObject(resources); + resources = qpdf.makeIndirectObject(resources); } dict.replaceKey("/Resources", resources); // Create a dictionary with top-level keys so we can use mergeResources to force them to be @@ -683,9 +683,9 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream( // Now attach a token filter to replace the actual resources. ResourceFinder rf; try { - auto nwarnings = this->qpdf.numWarnings(); + auto nwarnings = qpdf.numWarnings(); stream.parseAsContents(&rf); - if (this->qpdf.numWarnings() > nwarnings) { + if (qpdf.numWarnings() > nwarnings) { QTC::TC("qpdf", "QPDFAcroFormDocumentHelper AP parse error"); } auto rr = new ResourceReplacer(dr_map, rf.getNamesByResourceType()); @@ -711,18 +711,18 @@ QPDFAcroFormDocumentHelper::transformAnnotations( std::shared_ptr afdhph; if (!from_qpdf) { // Assume these are from the same QPDF. - from_qpdf = &this->qpdf; + from_qpdf = &qpdf; from_afdh = this; - } else if ((from_qpdf != &this->qpdf) && (!from_afdh)) { + } else if ((from_qpdf != &qpdf) && (!from_afdh)) { afdhph = std::make_shared(*from_qpdf); from_afdh = afdhph.get(); } - bool foreign = (from_qpdf != &this->qpdf); + bool foreign = (from_qpdf != &qpdf); // It's possible that we will transform annotations that don't include any form fields. This // code takes care not to muck around with /AcroForm unless we have to. - QPDFObjectHandle acroform = this->qpdf.getRoot().getKey("/AcroForm"); + QPDFObjectHandle acroform = qpdf.getRoot().getKey("/AcroForm"); QPDFObjectHandle from_acroform = from_qpdf->getRoot().getKey("/AcroForm"); // /DA and /Q may be inherited from the document-level /AcroForm dictionary. If we are copying a @@ -753,7 +753,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( if (!from_dr.isIndirect()) { from_dr = from_qpdf->makeIndirectObject(from_dr); } - from_dr = this->qpdf.copyForeignObject(from_dr); + from_dr = qpdf.copyForeignObject(from_dr); } if (from_acroform.getKey("/DA").isString()) { from_default_da = from_acroform.getKey("/DA").getUTF8Value(); @@ -787,14 +787,14 @@ QPDFAcroFormDocumentHelper::transformAnnotations( if (!dr.isDictionary()) { dr = QPDFObjectHandle::newDictionary(); } - dr.makeResourcesIndirect(this->qpdf); + dr.makeResourcesIndirect(qpdf); if (!dr.isIndirect()) { - dr = acroform.replaceKeyAndGetNew("/DR", this->qpdf.makeIndirectObject(dr)); + dr = acroform.replaceKeyAndGetNew("/DR", qpdf.makeIndirectObject(dr)); } // Merge the other document's /DR, creating a conflict map. mergeResources checks to // make sure both objects are dictionaries. By this point, if this is foreign, from_dr // has been copied, so we use the target qpdf as the owning qpdf. - from_dr.makeResourcesIndirect(this->qpdf); + from_dr.makeResourcesIndirect(qpdf); dr.mergeResources(from_dr, &dr_map); if (from_afdh->getNeedAppearances()) { @@ -811,7 +811,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( to_copy = orig_to_copy[og]; return false; } else { - to_copy = this->qpdf.makeIndirectObject(to_copy.shallowCopy()); + to_copy = qpdf.makeIndirectObject(to_copy.shallowCopy()); orig_to_copy[og] = to_copy; return true; } @@ -872,8 +872,8 @@ QPDFAcroFormDocumentHelper::transformAnnotations( // so we'll get the right object back. // top_field and ffield_oh are known to be indirect. - top_field = this->qpdf.copyForeignObject(top_field); - ffield_oh = this->qpdf.copyForeignObject(ffield_oh); + top_field = qpdf.copyForeignObject(top_field); + ffield_oh = qpdf.copyForeignObject(ffield_oh); } else { // We don't need to add top_field to old_fields if it's foreign because the new copy // of the foreign field won't be referenced anywhere. It's just the starting point @@ -957,7 +957,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( if (!annot.isIndirect()) { annot = from_qpdf->makeIndirectObject(annot); } - annot = this->qpdf.copyForeignObject(annot); + annot = qpdf.copyForeignObject(annot); } maybe_copy_object(annot); diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc index f156cab..bf7fcf6 100644 --- a/libqpdf/QPDFTokenizer.cc +++ b/libqpdf/QPDFTokenizer.cc @@ -166,8 +166,8 @@ Tokenizer::presentCharacter(char ch) { handleCharacter(ch); - if (this->in_token) { - this->raw_val += ch; + if (in_token) { + raw_val += ch; } } @@ -177,7 +177,7 @@ Tokenizer::handleCharacter(char ch) // In some cases, functions called below may call a second handler. This happens whenever you // have to use a character from the next token to detect the end of the current token. - switch (this->state) { + switch (state) { case st_top: inTop(ch); return; @@ -283,18 +283,18 @@ Tokenizer::inBeforeToken(char ch) { // Note: we specifically do not use ctype here. It is locale-dependent. if (isSpace(ch)) { - this->before_token = !this->include_ignorable; - this->in_token = this->include_ignorable; - if (this->include_ignorable) { - this->state = st_in_space; + before_token = !include_ignorable; + in_token = include_ignorable; + if (include_ignorable) { + state = st_in_space; } } else if (ch == '%') { - this->before_token = !this->include_ignorable; - this->in_token = this->include_ignorable; - this->state = st_in_comment; + before_token = !include_ignorable; + in_token = include_ignorable; + state = st_in_comment; } else { - this->before_token = false; - this->in_token = true; + before_token = false; + in_token = true; inTop(ch); } } @@ -304,48 +304,48 @@ Tokenizer::inTop(char ch) { switch (ch) { case '(': - this->string_depth = 1; - this->state = st_in_string; + string_depth = 1; + state = st_in_string; return; case '<': - this->state = st_lt; + state = st_lt; return; case '>': - this->state = st_gt; + state = st_gt; return; case (')'): - this->type = tt::tt_bad; + type = tt::tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad )"); - this->error_message = "unexpected )"; - this->state = st_token_ready; + error_message = "unexpected )"; + state = st_token_ready; return; case '[': - this->type = tt::tt_array_open; - this->state = st_token_ready; + type = tt::tt_array_open; + state = st_token_ready; return; case ']': - this->type = tt::tt_array_close; - this->state = st_token_ready; + type = tt::tt_array_close; + state = st_token_ready; return; case '{': - this->type = tt::tt_brace_open; - this->state = st_token_ready; + type = tt::tt_brace_open; + state = st_token_ready; return; case '}': - this->type = tt::tt_brace_close; - this->state = st_token_ready; + type = tt::tt_brace_close; + state = st_token_ready; return; case '/': - this->state = st_name; - this->val += ch; + state = st_name; + val += ch; return; case '0': @@ -358,20 +358,20 @@ Tokenizer::inTop(char ch) case '7': case '8': case '9': - this->state = st_number; + state = st_number; return; case '+': case '-': - this->state = st_sign; + state = st_sign; return; case '.': - this->state = st_decimal; + state = st_decimal; return; default: - this->state = st_literal; + state = st_literal; return; } } @@ -381,10 +381,10 @@ Tokenizer::inSpace(char ch) { // We only enter this state if include_ignorable is true. if (!isSpace(ch)) { - this->type = tt::tt_space; - this->in_token = false; - this->char_to_unread = ch; - this->state = st_token_ready; + type = tt::tt_space; + in_token = false; + char_to_unread = ch; + state = st_token_ready; } } @@ -392,13 +392,13 @@ void Tokenizer::inComment(char ch) { if ((ch == '\r') || (ch == '\n')) { - if (this->include_ignorable) { - this->type = tt::tt_comment; - this->in_token = false; - this->char_to_unread = ch; - this->state = st_token_ready; + if (include_ignorable) { + type = tt::tt_comment; + in_token = false; + char_to_unread = ch; + state = st_token_ready; } else { - this->state = st_before_token; + state = st_before_token; } } } @@ -408,36 +408,36 @@ Tokenizer::inString(char ch) { switch (ch) { case '\\': - this->state = st_string_escape; + state = st_string_escape; return; case '(': - this->val += ch; - ++this->string_depth; + val += ch; + ++string_depth; return; case ')': - if (--this->string_depth == 0) { - this->type = tt::tt_string; - this->state = st_token_ready; + if (--string_depth == 0) { + type = tt::tt_string; + state = st_token_ready; return; } - this->val += ch; + val += ch; return; case '\r': // CR by itself is converted to LF - this->val += '\n'; - this->state = st_string_after_cr; + val += '\n'; + state = st_string_after_cr; return; case '\n': - this->val += ch; + val += ch; return; default: - this->val += ch; + val += ch; return; } } @@ -452,32 +452,32 @@ Tokenizer::inName(char ch) // though not on any files in the test suite as of this // writing. - this->type = this->bad ? tt::tt_bad : tt::tt_name; - this->in_token = false; - this->char_to_unread = ch; - this->state = st_token_ready; + type = bad ? tt::tt_bad : tt::tt_name; + in_token = false; + char_to_unread = ch; + state = st_token_ready; } else if (ch == '#') { - this->char_code = 0; - this->state = st_name_hex1; + char_code = 0; + state = st_name_hex1; } else { - this->val += ch; + val += ch; } } void Tokenizer::inNameHex1(char ch) { - this->hex_char = ch; + hex_char = ch; if (char hval = util::hex_decode_char(ch); hval < '\20') { - this->char_code = int(hval) << 4; - this->state = st_name_hex2; + char_code = int(hval) << 4; + state = st_name_hex2; } else { QTC::TC("qpdf", "QPDFTokenizer bad name 1"); - this->error_message = "name with stray # will not work with PDF >= 1.2"; + error_message = "name with stray # will not work with PDF >= 1.2"; // Use null to encode a bad # -- this is reversed in QPDF_Name::normalizeName. - this->val += '\0'; - this->state = st_name; + val += '\0'; + state = st_name; inName(ch); } } @@ -486,26 +486,26 @@ void Tokenizer::inNameHex2(char ch) { if (char hval = util::hex_decode_char(ch); hval < '\20') { - this->char_code |= int(hval); + char_code |= int(hval); } else { QTC::TC("qpdf", "QPDFTokenizer bad name 2"); - this->error_message = "name with stray # will not work with PDF >= 1.2"; + error_message = "name with stray # will not work with PDF >= 1.2"; // Use null to encode a bad # -- this is reversed in QPDF_Name::normalizeName. - this->val += '\0'; - this->val += this->hex_char; - this->state = st_name; + val += '\0'; + val += hex_char; + state = st_name; inName(ch); return; } - if (this->char_code == 0) { + if (char_code == 0) { QTC::TC("qpdf", "QPDFTokenizer null in name"); - this->error_message = "null character not allowed in name token"; - this->val += "#00"; - this->state = st_name; - this->bad = true; + error_message = "null character not allowed in name token"; + val += "#00"; + state = st_name; + bad = true; } else { - this->val += char(this->char_code); - this->state = st_name; + val += char(char_code); + state = st_name; } } @@ -513,11 +513,11 @@ void Tokenizer::inSign(char ch) { if (util::is_digit(ch)) { - this->state = st_number; + state = st_number; } else if (ch == '.') { - this->state = st_decimal; + state = st_decimal; } else { - this->state = st_literal; + state = st_literal; inLiteral(ch); } } @@ -526,9 +526,9 @@ void Tokenizer::inDecimal(char ch) { if (util::is_digit(ch)) { - this->state = st_real; + state = st_real; } else { - this->state = st_literal; + state = st_literal; inLiteral(ch); } } @@ -538,14 +538,14 @@ Tokenizer::inNumber(char ch) { if (util::is_digit(ch)) { } else if (ch == '.') { - this->state = st_real; + state = st_real; } else if (isDelimiter(ch)) { - this->type = tt::tt_integer; - this->state = st_token_ready; - this->in_token = false; - this->char_to_unread = ch; + type = tt::tt_integer; + state = st_token_ready; + in_token = false; + char_to_unread = ch; } else { - this->state = st_literal; + state = st_literal; } } @@ -554,18 +554,18 @@ Tokenizer::inReal(char ch) { if (util::is_digit(ch)) { } else if (isDelimiter(ch)) { - this->type = tt::tt_real; - this->state = st_token_ready; - this->in_token = false; - this->char_to_unread = ch; + type = tt::tt_real; + state = st_token_ready; + in_token = false; + char_to_unread = ch; } else { - this->state = st_literal; + state = st_literal; } } void Tokenizer::inStringEscape(char ch) { - this->state = st_in_string; + state = st_in_string; switch (ch) { case '0': case '1': @@ -575,42 +575,42 @@ Tokenizer::inStringEscape(char ch) case '5': case '6': case '7': - this->state = st_char_code; - this->char_code = 0; - this->digit_count = 0; + state = st_char_code; + char_code = 0; + digit_count = 0; inCharCode(ch); return; case 'n': - this->val += '\n'; + val += '\n'; return; case 'r': - this->val += '\r'; + val += '\r'; return; case 't': - this->val += '\t'; + val += '\t'; return; case 'b': - this->val += '\b'; + val += '\b'; return; case 'f': - this->val += '\f'; + val += '\f'; return; case '\n': return; case '\r': - this->state = st_string_after_cr; + state = st_string_after_cr; return; default: // PDF spec says backslash is ignored before anything else - this->val += ch; + val += ch; return; } } @@ -618,7 +618,7 @@ Tokenizer::inStringEscape(char ch) void Tokenizer::inStringAfterCR(char ch) { - this->state = st_in_string; + state = st_in_string; if (ch != '\n') { inString(ch); } @@ -628,12 +628,12 @@ void Tokenizer::inLt(char ch) { if (ch == '<') { - this->type = tt::tt_dict_open; - this->state = st_token_ready; + type = tt::tt_dict_open; + state = st_token_ready; return; } - this->state = st_in_hexstring; + state = st_in_hexstring; inHexstring(ch); } @@ -641,15 +641,15 @@ void Tokenizer::inGt(char ch) { if (ch == '>') { - this->type = tt::tt_dict_close; - this->state = st_token_ready; + type = tt::tt_dict_close; + state = st_token_ready; } else { - this->type = tt::tt_bad; + type = tt::tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad >"); - this->error_message = "unexpected >"; - this->in_token = false; - this->char_to_unread = ch; - this->state = st_token_ready; + error_message = "unexpected >"; + in_token = false; + char_to_unread = ch; + state = st_token_ready; } } @@ -662,12 +662,12 @@ Tokenizer::inLiteral(char ch) // stream keyword. Removing it here could make the stream-reading code break on some files, // though not on any files in the test suite as of this writing. - this->in_token = false; - this->char_to_unread = ch; - this->state = st_token_ready; - this->type = (this->raw_val == "true") || (this->raw_val == "false") + in_token = false; + char_to_unread = ch; + state = st_token_ready; + type = (raw_val == "true") || (raw_val == "false") ? tt::tt_bool - : (this->raw_val == "null" ? tt::tt_null : tt::tt_word); + : (raw_val == "null" ? tt::tt_null : tt::tt_word); } } @@ -675,21 +675,21 @@ void Tokenizer::inHexstring(char ch) { if (char hval = util::hex_decode_char(ch); hval < '\20') { - this->char_code = int(hval) << 4; - this->state = st_in_hexstring_2nd; + char_code = int(hval) << 4; + state = st_in_hexstring_2nd; } else if (ch == '>') { - this->type = tt::tt_string; - this->state = st_token_ready; + type = tt::tt_string; + state = st_token_ready; } else if (isSpace(ch)) { // ignore } else { - this->type = tt::tt_bad; + type = tt::tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad hexstring character"); - this->error_message = std::string("invalid character (") + ch + ") in hexstring"; - this->state = st_token_ready; + error_message = std::string("invalid character (") + ch + ") in hexstring"; + state = st_token_ready; } } @@ -697,23 +697,23 @@ void Tokenizer::inHexstring2nd(char ch) { if (char hval = util::hex_decode_char(ch); hval < '\20') { - this->val += char(this->char_code) | hval; - this->state = st_in_hexstring; + val += char(char_code) | hval; + state = st_in_hexstring; } else if (ch == '>') { // PDF spec says odd hexstrings have implicit trailing 0. - this->val += char(this->char_code); - this->type = tt::tt_string; - this->state = st_token_ready; + val += char(char_code); + type = tt::tt_string; + state = st_token_ready; } else if (isSpace(ch)) { // ignore } else { - this->type = tt::tt_bad; + type = tt::tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad hexstring 2nd character"); - this->error_message = std::string("invalid character (") + ch + ") in hexstring"; - this->state = st_token_ready; + error_message = std::string("invalid character (") + ch + ") in hexstring"; + state = st_token_ready; } } @@ -722,16 +722,16 @@ Tokenizer::inCharCode(char ch) { bool handled = false; if (('0' <= ch) && (ch <= '7')) { - this->char_code = 8 * this->char_code + (int(ch) - int('0')); - if (++(this->digit_count) < 3) { + char_code = 8 * char_code + (int(ch) - int('0')); + if (++(digit_count) < 3) { return; } handled = true; } // We've accumulated \ddd or we have \d or \dd followed by other than an octal digit. The PDF // Spec says to ignore high-order overflow. - this->val += char(this->char_code % 256); - this->state = st_in_string; + val += char(char_code % 256); + state = st_in_string; if (!handled) { inString(ch); } @@ -740,11 +740,11 @@ Tokenizer::inCharCode(char ch) void Tokenizer::inInlineImage(char ch) { - if ((this->raw_val.length() + 1) == this->inline_image_bytes) { + if ((raw_val.length() + 1) == inline_image_bytes) { QTC::TC("qpdf", "QPDFTokenizer found EI by byte count"); - this->type = tt::tt_inline_image; - this->inline_image_bytes = 0; - this->state = st_token_ready; + type = tt::tt_inline_image; + inline_image_bytes = 0; + state = st_token_ready; } } @@ -757,7 +757,7 @@ QPDFTokenizer::presentEOF() void Tokenizer::presentEOF() { - switch (this->state) { + switch (state) { case st_name: case st_name_hex1: case st_name_hex2: @@ -769,20 +769,20 @@ Tokenizer::presentEOF() QTC::TC("qpdf", "QPDFTokenizer EOF reading appendable token"); // Push any delimiter to the state machine to finish off the final token. presentCharacter('\f'); - this->in_token = true; + in_token = true; break; case st_top: case st_before_token: - this->type = tt::tt_eof; + type = tt::tt_eof; break; case st_in_space: - this->type = this->include_ignorable ? tt::tt_space : tt::tt_eof; + type = include_ignorable ? tt::tt_space : tt::tt_eof; break; case st_in_comment: - this->type = this->include_ignorable ? tt::tt_comment : tt::tt_bad; + type = include_ignorable ? tt::tt_comment : tt::tt_bad; break; case st_token_ready: @@ -790,10 +790,10 @@ Tokenizer::presentEOF() default: QTC::TC("qpdf", "QPDFTokenizer EOF reading token"); - this->type = tt::tt_bad; - this->error_message = "EOF while reading token"; + type = tt::tt_bad; + error_message = "EOF while reading token"; } - this->state = st_token_ready; + state = st_token_ready; } void @@ -811,16 +811,16 @@ QPDFTokenizer::expectInlineImage(InputSource& input) void Tokenizer::expectInlineImage(InputSource& input) { - if (this->state == st_token_ready) { + if (state == st_token_ready) { reset(); - } else if (this->state != st_before_token) { + } else if (state != st_before_token) { throw std::logic_error( "QPDFTokenizer::expectInlineImage called when tokenizer is in improper state"); } findEI(input); - this->before_token = false; - this->in_token = true; - this->state = st_inline_image; + before_token = false; + in_token = true; + state = st_inline_image; } void @@ -913,15 +913,15 @@ QPDFTokenizer::getToken(Token& token, bool& unread_char, char& ch) bool Tokenizer::getToken(Token& token, bool& unread_char, char& ch) { - bool ready = (this->state == st_token_ready); - unread_char = !this->in_token && !this->before_token; - ch = this->char_to_unread; + bool ready = (state == st_token_ready); + unread_char = !in_token && !before_token; + ch = char_to_unread; if (ready) { - token = (!(this->type == tt::tt_name || this->type == tt::tt_string)) - ? Token(this->type, this->raw_val, this->raw_val, this->error_message) - : Token(this->type, this->val, this->raw_val, this->error_message); + token = (!(type == tt::tt_name || type == tt::tt_string)) + ? Token(type, raw_val, raw_val, error_message) + : Token(type, val, raw_val, error_message); - this->reset(); + reset(); } return ready; } @@ -980,46 +980,46 @@ Tokenizer::readToken(InputSource& input, std::string const& context, bool allow_ bool Tokenizer::nextToken(InputSource& input, std::string const& context, size_t max_len) { - if (this->state != st_inline_image) { + if (state != st_inline_image) { reset(); } qpdf_offset_t offset = input.fastTell(); - while (this->state != st_token_ready) { + while (state != st_token_ready) { char ch; if (!input.fastRead(ch)) { presentEOF(); - if ((this->type == tt::tt_eof) && (!this->allow_eof)) { + if ((type == tt::tt_eof) && (!allow_eof)) { // Nothing in the qpdf library calls readToken without allowEOF anymore, so this // case is not exercised. - this->type = tt::tt_bad; - this->error_message = "unexpected EOF"; + type = tt::tt_bad; + error_message = "unexpected EOF"; offset = input.getLastOffset(); } } else { handleCharacter(ch); - if (this->before_token) { + if (before_token) { ++offset; } - if (this->in_token) { - this->raw_val += ch; + if (in_token) { + raw_val += ch; } - if (max_len && (this->raw_val.length() >= max_len) && (this->state != st_token_ready)) { + if (max_len && (raw_val.length() >= max_len) && (state != st_token_ready)) { // terminate this token now QTC::TC("qpdf", "QPDFTokenizer block long token"); - this->type = tt::tt_bad; - this->state = st_token_ready; - this->error_message = "exceeded allowable length while reading token"; + type = tt::tt_bad; + state = st_token_ready; + error_message = "exceeded allowable length while reading token"; } } } - input.fastUnread(!this->in_token && !this->before_token); + input.fastUnread(!in_token && !before_token); - if (this->type != tt::tt_eof) { + if (type != tt::tt_eof) { input.setLastOffset(offset); } - return this->error_message.empty(); + return error_message.empty(); } -- libgit2 0.21.4