diff options
Diffstat (limited to 'libqpdf/ContentNormalizer.cc')
-rw-r--r-- | libqpdf/ContentNormalizer.cc | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libqpdf/ContentNormalizer.cc b/libqpdf/ContentNormalizer.cc index 35a8ad74..f85ab829 100644 --- a/libqpdf/ContentNormalizer.cc +++ b/libqpdf/ContentNormalizer.cc @@ -1,7 +1,9 @@ #include <qpdf/ContentNormalizer.hh> #include <qpdf/QUtil.hh> -ContentNormalizer::ContentNormalizer() +ContentNormalizer::ContentNormalizer() : + any_bad_tokens(false), + last_token_was_bad(false) { } @@ -15,6 +17,16 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const& token) std::string value = token.getRawValue(); QPDFTokenizer::token_type_e token_type = token.getType(); + if (token_type == QPDFTokenizer::tt_bad) + { + this->any_bad_tokens = true; + this->last_token_was_bad = true; + } + else if (token_type != QPDFTokenizer::tt_eof) + { + this->last_token_was_bad = false; + } + switch (token_type) { case QPDFTokenizer::tt_space: @@ -75,3 +87,15 @@ ContentNormalizer::handleEOF() { finish(); } + +bool +ContentNormalizer::anyBadTokens() const +{ + return this->any_bad_tokens; +} + +bool +ContentNormalizer::lastTokenWasBad()const +{ + return this->last_token_was_bad; +} |