2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

Remove QPDFTokenizer::unread_char

This commit is contained in:
m-holger 2022-08-24 18:53:34 +01:00
parent 706106dabb
commit b45420a980
2 changed files with 10 additions and 12 deletions

View File

@ -260,7 +260,6 @@ class QPDFTokenizer
std::string error_message; std::string error_message;
bool before_token; bool before_token;
bool in_token; bool in_token;
bool unread_char;
char char_to_unread; char char_to_unread;
size_t inline_image_bytes; size_t inline_image_bytes;
bool bad; bool bad;

View File

@ -83,7 +83,6 @@ QPDFTokenizer::reset()
error_message = ""; error_message = "";
before_token = true; before_token = true;
in_token = false; in_token = false;
unread_char = false;
char_to_unread = '\0'; char_to_unread = '\0';
inline_image_bytes = 0; inline_image_bytes = 0;
string_depth = 0; string_depth = 0;
@ -138,7 +137,7 @@ QPDFTokenizer::presentCharacter(char ch)
{ {
handleCharacter(ch); handleCharacter(ch);
if (this->in_token && !this->unread_char) { if (this->in_token) { //} && !this->unread_char) {
this->raw_val += ch; this->raw_val += ch;
} }
} }
@ -370,7 +369,7 @@ QPDFTokenizer::inSpace(char ch)
// We only enter this state if include_ignorable is true. // We only enter this state if include_ignorable is true.
if (!isSpace(ch)) { if (!isSpace(ch)) {
this->type = tt_space; this->type = tt_space;
this->unread_char = true; this->in_token = false;
this->char_to_unread = ch; this->char_to_unread = ch;
this->state = st_token_ready; this->state = st_token_ready;
return; return;
@ -386,7 +385,7 @@ QPDFTokenizer::inComment(char ch)
if ((ch == '\r') || (ch == '\n')) { if ((ch == '\r') || (ch == '\n')) {
if (this->include_ignorable) { if (this->include_ignorable) {
this->type = tt_comment; this->type = tt_comment;
this->unread_char = true; this->in_token = false;
this->char_to_unread = ch; this->char_to_unread = ch;
this->state = st_token_ready; this->state = st_token_ready;
} else { } else {
@ -449,7 +448,7 @@ QPDFTokenizer::inName(char ch)
// writing. // writing.
this->type = this->bad ? tt_bad : tt_name; this->type = this->bad ? tt_bad : tt_name;
this->unread_char = true; this->in_token = false;
this->char_to_unread = ch; this->char_to_unread = ch;
this->state = st_token_ready; this->state = st_token_ready;
} else if (ch == '#') { } else if (ch == '#') {
@ -561,7 +560,7 @@ QPDFTokenizer::inNumber(char ch)
} else if (isDelimiter(ch)) { } else if (isDelimiter(ch)) {
this->type = tt_integer; this->type = tt_integer;
this->state = st_token_ready; this->state = st_token_ready;
this->unread_char = true; this->in_token = false;
this->char_to_unread = ch; this->char_to_unread = ch;
} else { } else {
this->state = st_literal; this->state = st_literal;
@ -577,7 +576,7 @@ QPDFTokenizer::inReal(char ch)
} else if (isDelimiter(ch)) { } else if (isDelimiter(ch)) {
this->type = tt_real; this->type = tt_real;
this->state = st_token_ready; this->state = st_token_ready;
this->unread_char = true; this->in_token = false;
this->char_to_unread = ch; this->char_to_unread = ch;
} else { } else {
this->state = st_literal; this->state = st_literal;
@ -672,7 +671,7 @@ QPDFTokenizer::inGt(char ch)
this->type = tt_bad; this->type = tt_bad;
QTC::TC("qpdf", "QPDFTokenizer bad >"); QTC::TC("qpdf", "QPDFTokenizer bad >");
this->error_message = "unexpected >"; this->error_message = "unexpected >";
this->unread_char = true; this->in_token = false;
this->char_to_unread = ch; this->char_to_unread = ch;
this->state = st_token_ready; this->state = st_token_ready;
} }
@ -690,7 +689,7 @@ QPDFTokenizer::inLiteral(char ch)
// though not on any files in the test suite as of this // though not on any files in the test suite as of this
// writing. // writing.
this->unread_char = true; this->in_token = false;
this->char_to_unread = ch; this->char_to_unread = ch;
this->state = st_token_ready; this->state = st_token_ready;
this->type = (this->val == "true") || (this->val == "false") this->type = (this->val == "true") || (this->val == "false")
@ -809,7 +808,7 @@ QPDFTokenizer::presentEOF()
// Push any delimiter to the state machine to finish off the final // Push any delimiter to the state machine to finish off the final
// token. // token.
presentCharacter('\f'); presentCharacter('\f');
this->unread_char = false; this->in_token = true;
break; break;
case st_top: case st_top:
@ -949,7 +948,7 @@ bool
QPDFTokenizer::getToken(Token& token, bool& unread_char, char& ch) QPDFTokenizer::getToken(Token& token, bool& unread_char, char& ch)
{ {
bool ready = (this->state == st_token_ready); bool ready = (this->state == st_token_ready);
unread_char = this->unread_char; unread_char = !this->in_token && !this->before_token;
ch = this->char_to_unread; ch = this->char_to_unread;
if (ready) { if (ready) {
if (this->type == tt_bad) { if (this->type == tt_bad) {