Commit b45420a98038829e4d8d505d4332edc14caa340f

Authored by m-holger
1 parent 706106da

Remove QPDFTokenizer::unread_char

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