aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFTokenizer.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-08-24 01:36:24 +0200
committerm-holger <m-holger@kubitscheck.org>2022-08-25 12:31:45 +0200
commit10fda01b07a29bb2e1dec9a51bb6197bc7aa72bf (patch)
treeeabaaa308cc72c86ffbe2b08cb7058189b03eef2 /libqpdf/QPDFTokenizer.cc
parente4073ee868da50a7c5197d5f95e3cf64895b2b4d (diff)
downloadqpdf-10fda01b07a29bb2e1dec9a51bb6197bc7aa72bf.tar.zst
In QPDFTokenizer::readToken move call to getToken out of loop
Diffstat (limited to 'libqpdf/QPDFTokenizer.cc')
-rw-r--r--libqpdf/QPDFTokenizer.cc34
1 files changed, 17 insertions, 17 deletions
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc
index 6e492f2b..9f45a374 100644
--- a/libqpdf/QPDFTokenizer.cc
+++ b/libqpdf/QPDFTokenizer.cc
@@ -975,25 +975,21 @@ QPDFTokenizer::readToken(
size_t max_len)
{
qpdf_offset_t offset = input->tell();
- Token token;
- bool unread_char;
- char char_to_unread;
- bool presented_eof = false;
- while (!getToken(token, unread_char, char_to_unread)) {
+
+ while (this->state != st_token_ready) {
char ch;
if (input->read(&ch, 1) == 0) {
- if (!presented_eof) {
- presentEOF();
- presented_eof = true;
- if ((this->type == tt_eof) && (!this->allow_eof)) {
- // Nothing in the qpdf library calls readToken
- // without allowEOF anymore, so this case is not
- // exercised.
- this->type = tt_bad;
- this->error_message = "unexpected EOF";
- offset = input->getLastOffset();
- }
- } else {
+ presentEOF();
+
+ if ((this->type == tt_eof) && (!this->allow_eof)) {
+ // Nothing in the qpdf library calls readToken
+ // without allowEOF anymore, so this case is not
+ // exercised.
+ this->type = tt_bad;
+ this->error_message = "unexpected EOF";
+ offset = input->getLastOffset();
+ }
+ if (this->state != st_token_ready) {
throw std::logic_error(
"getToken returned false after presenting EOF");
}
@@ -1014,6 +1010,10 @@ QPDFTokenizer::readToken(
}
}
+ Token token;
+ bool unread_char;
+ char char_to_unread;
+ getToken(token, unread_char, char_to_unread);
if (unread_char) {
input->unreadCh(char_to_unread);
}