diff options
Diffstat (limited to 'libqpdf/QPDFTokenizer.cc')
-rw-r--r-- | libqpdf/QPDFTokenizer.cc | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc index d2c66e29..da02a0fe 100644 --- a/libqpdf/QPDFTokenizer.cc +++ b/libqpdf/QPDFTokenizer.cc @@ -18,10 +18,9 @@ static inline bool is_delimiter(char ch) { return ( - ch == ' ' || ch == '\n' || ch == '/' || ch == '(' || ch == ')' || - ch == '{' || ch == '}' || ch == '<' || ch == '>' || ch == '[' || - ch == ']' || ch == '%' || ch == '\t' || ch == '\r' || ch == '\v' || - ch == '\f' || ch == 0); + ch == ' ' || ch == '\n' || ch == '/' || ch == '(' || ch == ')' || ch == '{' || ch == '}' || + ch == '<' || ch == '>' || ch == '[' || ch == ']' || ch == '%' || ch == '\t' || ch == '\r' || + ch == '\v' || ch == '\f' || ch == 0); } namespace @@ -29,8 +28,7 @@ namespace class QPDFWordTokenFinder: public InputSource::Finder { public: - QPDFWordTokenFinder( - std::shared_ptr<InputSource> is, std::string const& str) : + QPDFWordTokenFinder(std::shared_ptr<InputSource> is, std::string const& str) : is(is), str(str) { @@ -243,8 +241,7 @@ QPDFTokenizer::handleCharacter(char ch) return; default: - throw std::logic_error( - "INTERNAL ERROR: invalid state while reading token"); + throw std::logic_error("INTERNAL ERROR: invalid state while reading token"); } } @@ -673,8 +670,7 @@ QPDFTokenizer::inHexstring(char ch) } else { this->type = tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad hexstring character"); - this->error_message = - std::string("invalid character (") + ch + ") in hexstring"; + this->error_message = std::string("invalid character (") + ch + ") in hexstring"; this->state = st_token_ready; } } @@ -698,8 +694,7 @@ QPDFTokenizer::inHexstring2nd(char ch) } else { this->type = tt_bad; QTC::TC("qpdf", "QPDFTokenizer bad hexstring 2nd character"); - this->error_message = - std::string("invalid character (") + ch + ") in hexstring"; + this->error_message = std::string("invalid character (") + ch + ") in hexstring"; this->state = st_token_ready; } } @@ -846,14 +841,13 @@ QPDFTokenizer::findEI(std::shared_ptr<InputSource> input) bool found_non_printable = false; bool found_other = false; for (char ch: t.getValue()) { - if (((ch >= 'a') && (ch <= 'z')) || - ((ch >= 'A') && (ch <= 'Z')) || (ch == '*')) { + if (((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) || + (ch == '*')) { // Treat '*' as alpha since there are valid // PDF operators that contain * along with // alphabetic characters. found_alpha = true; - } else if ( - (static_cast<signed char>(ch) < 32) && (!isSpace(ch))) { + } else if ((static_cast<signed char>(ch) < 32) && (!isSpace(ch))) { // Compare ch as a signed char so characters // outside of 7-bit will be < 0. found_non_printable = true; @@ -893,8 +887,7 @@ QPDFTokenizer::getToken(Token& token, bool& unread_char, char& ch) ch = this->char_to_unread; if (ready) { token = (!(this->type == tt_name || this->type == tt_string)) - ? Token( - this->type, this->raw_val, this->raw_val, this->error_message) + ? Token(this->type, this->raw_val, this->raw_val, this->error_message) : Token(this->type, this->val, this->raw_val, this->error_message); this->reset(); @@ -910,10 +903,7 @@ QPDFTokenizer::betweenTokens() QPDFTokenizer::Token QPDFTokenizer::readToken( - std::shared_ptr<InputSource> input, - std::string const& context, - bool allow_bad, - size_t max_len) + std::shared_ptr<InputSource> input, std::string const& context, bool allow_bad, size_t max_len) { nextToken(*input, context, max_len); @@ -938,8 +928,7 @@ QPDFTokenizer::readToken( } bool -QPDFTokenizer::nextToken( - InputSource& input, std::string const& context, size_t max_len) +QPDFTokenizer::nextToken(InputSource& input, std::string const& context, size_t max_len) { if (this->state != st_inline_image) { reset(); @@ -967,14 +956,12 @@ QPDFTokenizer::nextToken( if (this->in_token) { this->raw_val += ch; } - if (max_len && (this->raw_val.length() >= max_len) && - (this->state != st_token_ready)) { + if (max_len && (this->raw_val.length() >= max_len) && (this->state != st_token_ready)) { // terminate this token now QTC::TC("qpdf", "QPDFTokenizer block long token"); this->type = tt_bad; this->state = st_token_ready; - this->error_message = - "exceeded allowable length while reading token"; + this->error_message = "exceeded allowable length while reading token"; } } } |