Commit 6371b90ae3e1fc65a02882d16f289846cb02848e
1 parent
42ed58e4
Refactor QPDFTokenizer::presentEOF
Showing
1 changed file
with
26 additions
and
11 deletions
libqpdf/QPDFTokenizer.cc
| ... | ... | @@ -782,23 +782,38 @@ QPDFTokenizer::inInlineImage(char ch) |
| 782 | 782 | void |
| 783 | 783 | QPDFTokenizer::presentEOF() |
| 784 | 784 | { |
| 785 | - if (this->state == st_name || this->state == st_name_hex1 || | |
| 786 | - this->state == st_name_hex2 || this->state == st_number || | |
| 787 | - this->state == st_real || this->state == st_sign || | |
| 788 | - this->state == st_decimal || this->state == st_literal) { | |
| 789 | - | |
| 785 | + switch (this->state) { | |
| 786 | + case st_name: | |
| 787 | + case st_name_hex1: | |
| 788 | + case st_name_hex2: | |
| 789 | + case st_number: | |
| 790 | + case st_real: | |
| 791 | + case st_sign: | |
| 792 | + case st_decimal: | |
| 793 | + case st_literal: | |
| 790 | 794 | QTC::TC("qpdf", "QPDFTokenizer EOF reading appendable token"); |
| 791 | 795 | // Push any delimiter to the state machine to finish off the final |
| 792 | 796 | // token. |
| 793 | 797 | presentCharacter('\f'); |
| 794 | 798 | this->unread_char = false; |
| 795 | - } else if ((this->include_ignorable) && (this->state == st_in_space)) { | |
| 796 | - this->type = tt_space; | |
| 797 | - } else if ((this->include_ignorable) && (this->state == st_in_comment)) { | |
| 798 | - this->type = tt_comment; | |
| 799 | - } else if (betweenTokens()) { | |
| 799 | + break; | |
| 800 | + | |
| 801 | + case st_top: | |
| 800 | 802 | this->type = tt_eof; |
| 801 | - } else if (this->state != st_token_ready) { | |
| 803 | + break; | |
| 804 | + | |
| 805 | + case st_in_space: | |
| 806 | + this->type = this->include_ignorable ? tt_space : tt_eof; | |
| 807 | + break; | |
| 808 | + | |
| 809 | + case st_in_comment: | |
| 810 | + this->type = this->include_ignorable ? tt_comment : tt_bad; | |
| 811 | + break; | |
| 812 | + | |
| 813 | + case st_token_ready: | |
| 814 | + break; | |
| 815 | + | |
| 816 | + default: | |
| 802 | 817 | QTC::TC("qpdf", "QPDFTokenizer EOF reading token"); |
| 803 | 818 | this->type = tt_bad; |
| 804 | 819 | this->error_message = "EOF while reading token"; | ... | ... |