Commit 611192f3c8e994f4b24c685f91c7c533e5e08b71
1 parent
0518d585
Use nextToken in Tokenizer::findEI and QPDFWordTokenFinder::check
Showing
1 changed file
with
10 additions
and
11 deletions
libqpdf/QPDFTokenizer.cc
| ... | ... | @@ -53,9 +53,9 @@ QPDFWordTokenFinder::check() |
| 53 | 53 | // Find a word token matching the given string, preceded by a delimiter, and followed by a |
| 54 | 54 | // delimiter or EOF. |
| 55 | 55 | Tokenizer tokenizer; |
| 56 | - auto t = tokenizer.readToken(is, "finder", true, str.size() + 2); | |
| 56 | + tokenizer.nextToken(is, "finder", str.size() + 2); | |
| 57 | 57 | qpdf_offset_t pos = is.tell(); |
| 58 | - if (!(t == QPDFTokenizer::Token(QPDFTokenizer::tt_word, str))) { | |
| 58 | + if (tokenizer.getType() != tt::tt_word || tokenizer.getValue() != str) { | |
| 59 | 59 | QTC::TC("qpdf", "QPDFTokenizer finder found wrong word"); |
| 60 | 60 | return false; |
| 61 | 61 | } |
| ... | ... | @@ -853,13 +853,13 @@ Tokenizer::findEI(InputSource& input) |
| 853 | 853 | // all required as well as a BI and ID. If we get 10 good tokens in a row or hit EOF, we can |
| 854 | 854 | // be pretty sure we've found the actual EI. |
| 855 | 855 | for (int i = 0; i < 10; ++i) { |
| 856 | - auto t = check.readToken(input, "checker", true); | |
| 857 | - auto type = t.getType(); | |
| 858 | - if (type == tt::tt_eof) { | |
| 856 | + check.nextToken(input, "checker"); | |
| 857 | + auto typ = check.getType(); | |
| 858 | + if (typ == tt::tt_eof) { | |
| 859 | 859 | okay = true; |
| 860 | - } else if (type == tt::tt_bad) { | |
| 860 | + } else if (typ == tt::tt_bad) { | |
| 861 | 861 | found_bad = true; |
| 862 | - } else if (t.isWord()) { | |
| 862 | + } else if (typ == tt::tt_word) { | |
| 863 | 863 | // The qpdf tokenizer lumps alphabetic and otherwise uncategorized characters into |
| 864 | 864 | // "words". We recognize strings of alphabetic characters as potential valid |
| 865 | 865 | // operators for purposes of telling whether we're in valid content or not. It's not |
| ... | ... | @@ -868,13 +868,12 @@ Tokenizer::findEI(InputSource& input) |
| 868 | 868 | bool found_alpha = false; |
| 869 | 869 | bool found_non_printable = false; |
| 870 | 870 | bool found_other = false; |
| 871 | - for (char ch: t.getValue()) { | |
| 872 | - if (((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) || | |
| 873 | - (ch == '*')) { | |
| 871 | + for (char ch: check.getValue()) { | |
| 872 | + if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch == '*')) { | |
| 874 | 873 | // Treat '*' as alpha since there are valid PDF operators that contain * |
| 875 | 874 | // along with alphabetic characters. |
| 876 | 875 | found_alpha = true; |
| 877 | - } else if ((static_cast<signed char>(ch) < 32) && (!isSpace(ch))) { | |
| 876 | + } else if (static_cast<signed char>(ch) < 32 && !isSpace(ch)) { | |
| 878 | 877 | // Compare ch as a signed char so characters outside of 7-bit will be < 0. |
| 879 | 878 | found_non_printable = true; |
| 880 | 879 | break; | ... | ... |