Commit b45420a98038829e4d8d505d4332edc14caa340f

Authored by m-holger
1 parent 706106da

Remove QPDFTokenizer::unread_char

include/qpdf/QPDFTokenizer.hh
... ... @@ -260,7 +260,6 @@ class QPDFTokenizer
260 260 std::string error_message;
261 261 bool before_token;
262 262 bool in_token;
263   - bool unread_char;
264 263 char char_to_unread;
265 264 size_t inline_image_bytes;
266 265 bool bad;
... ...
libqpdf/QPDFTokenizer.cc
... ... @@ -83,7 +83,6 @@ QPDFTokenizer::reset()
83 83 error_message = "";
84 84 before_token = true;
85 85 in_token = false;
86   - unread_char = false;
87 86 char_to_unread = '\0';
88 87 inline_image_bytes = 0;
89 88 string_depth = 0;
... ... @@ -138,7 +137,7 @@ QPDFTokenizer::presentCharacter(char ch)
138 137 {
139 138 handleCharacter(ch);
140 139  
141   - if (this->in_token && !this->unread_char) {
  140 + if (this->in_token) { //} && !this->unread_char) {
142 141 this->raw_val += ch;
143 142 }
144 143 }
... ... @@ -370,7 +369,7 @@ QPDFTokenizer::inSpace(char ch)
370 369 // We only enter this state if include_ignorable is true.
371 370 if (!isSpace(ch)) {
372 371 this->type = tt_space;
373   - this->unread_char = true;
  372 + this->in_token = false;
374 373 this->char_to_unread = ch;
375 374 this->state = st_token_ready;
376 375 return;
... ... @@ -386,7 +385,7 @@ QPDFTokenizer::inComment(char ch)
386 385 if ((ch == '\r') || (ch == '\n')) {
387 386 if (this->include_ignorable) {
388 387 this->type = tt_comment;
389   - this->unread_char = true;
  388 + this->in_token = false;
390 389 this->char_to_unread = ch;
391 390 this->state = st_token_ready;
392 391 } else {
... ... @@ -449,7 +448,7 @@ QPDFTokenizer::inName(char ch)
449 448 // writing.
450 449  
451 450 this->type = this->bad ? tt_bad : tt_name;
452   - this->unread_char = true;
  451 + this->in_token = false;
453 452 this->char_to_unread = ch;
454 453 this->state = st_token_ready;
455 454 } else if (ch == '#') {
... ... @@ -561,7 +560,7 @@ QPDFTokenizer::inNumber(char ch)
561 560 } else if (isDelimiter(ch)) {
562 561 this->type = tt_integer;
563 562 this->state = st_token_ready;
564   - this->unread_char = true;
  563 + this->in_token = false;
565 564 this->char_to_unread = ch;
566 565 } else {
567 566 this->state = st_literal;
... ... @@ -577,7 +576,7 @@ QPDFTokenizer::inReal(char ch)
577 576 } else if (isDelimiter(ch)) {
578 577 this->type = tt_real;
579 578 this->state = st_token_ready;
580   - this->unread_char = true;
  579 + this->in_token = false;
581 580 this->char_to_unread = ch;
582 581 } else {
583 582 this->state = st_literal;
... ... @@ -672,7 +671,7 @@ QPDFTokenizer::inGt(char ch)
672 671 this->type = tt_bad;
673 672 QTC::TC("qpdf", "QPDFTokenizer bad >");
674 673 this->error_message = "unexpected >";
675   - this->unread_char = true;
  674 + this->in_token = false;
676 675 this->char_to_unread = ch;
677 676 this->state = st_token_ready;
678 677 }
... ... @@ -690,7 +689,7 @@ QPDFTokenizer::inLiteral(char ch)
690 689 // though not on any files in the test suite as of this
691 690 // writing.
692 691  
693   - this->unread_char = true;
  692 + this->in_token = false;
694 693 this->char_to_unread = ch;
695 694 this->state = st_token_ready;
696 695 this->type = (this->val == "true") || (this->val == "false")
... ... @@ -809,7 +808,7 @@ QPDFTokenizer::presentEOF()
809 808 // Push any delimiter to the state machine to finish off the final
810 809 // token.
811 810 presentCharacter('\f');
812   - this->unread_char = false;
  811 + this->in_token = true;
813 812 break;
814 813  
815 814 case st_top:
... ... @@ -949,7 +948,7 @@ bool
949 948 QPDFTokenizer::getToken(Token& token, bool& unread_char, char& ch)
950 949 {
951 950 bool ready = (this->state == st_token_ready);
952   - unread_char = this->unread_char;
  951 + unread_char = !this->in_token && !this->before_token;
953 952 ch = this->char_to_unread;
954 953 if (ready) {
955 954 if (this->type == tt_bad) {
... ...