diff options
author | m-holger <m-holger@kubitscheck.org> | 2022-08-20 16:14:21 +0200 |
---|---|---|
committer | m-holger <m-holger@kubitscheck.org> | 2022-08-25 11:51:51 +0200 |
commit | e7889ec5dc3ae5caf942bb242f802b7a19a6b2c5 (patch) | |
tree | 72f40dfcc54c0aa26c71aaa22b6166043220aa79 | |
parent | e4fe0d5cf57d1d5b7d34492ffb616746ecd6ae35 (diff) | |
download | qpdf-e7889ec5dc3ae5caf942bb242f802b7a19a6b2c5.tar.zst |
Refactor st_top case in QPDFTokenizer::handleCharacter
-rw-r--r-- | libqpdf/QPDFTokenizer.cc | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc index 6c4b1124..b07b6e1b 100644 --- a/libqpdf/QPDFTokenizer.cc +++ b/libqpdf/QPDFTokenizer.cc @@ -222,7 +222,7 @@ QPDFTokenizer::handleCharacter(char ch) "INTERNAL ERROR: QPDF tokenizer presented character " "while token is waiting"); - case (st_top): + case st_top: // Note: we specifically do not use ctype here. It is // locale-dependent. if (isSpace(ch)) { @@ -254,40 +254,42 @@ QPDFTokenizer::handleCharacter(char ch) this->state = st_gt; return; - default: + case (')'): + this->type = tt_bad; + QTC::TC("qpdf", "QPDFTokenizer bad )"); + this->error_message = "unexpected )"; this->val += ch; - switch (ch) { - case ')': - this->type = tt_bad; - QTC::TC("qpdf", "QPDFTokenizer bad )"); - this->error_message = "unexpected )"; - this->state = st_token_ready; - return; + this->state = st_token_ready; + return; - case '[': - this->type = tt_array_open; - this->state = st_token_ready; - return; + case '[': + this->type = tt_array_open; + this->state = st_token_ready; + this->val += ch; + return; - case ']': - this->type = tt_array_close; - this->state = st_token_ready; - return; + case ']': + this->type = tt_array_close; + this->val += ch; + this->state = st_token_ready; + return; - case '{': - this->type = tt_brace_open; - this->state = st_token_ready; - return; + case '{': + this->type = tt_brace_open; + this->state = st_token_ready; + this->val += ch; + return; - case '}': - this->type = tt_brace_close; - this->state = st_token_ready; - return; + case '}': + this->type = tt_brace_close; + this->state = st_token_ready; + this->val += ch; + return; - default: - this->state = st_literal; - return; - } + default: + this->state = st_literal; + this->val += ch; + return; } case st_in_space: @@ -297,10 +299,11 @@ QPDFTokenizer::handleCharacter(char ch) this->unread_char = true; this->char_to_unread = ch; this->state = st_token_ready; + return; } else { this->val += ch; + return; } - return; case st_in_comment: if ((ch == '\r') || (ch == '\n')) { @@ -345,7 +348,7 @@ QPDFTokenizer::handleCharacter(char ch) } return; - case st_in_string: + case (st_in_string): inString(ch); return; @@ -438,11 +441,11 @@ QPDFTokenizer::handleCharacter(char ch) } return; - case (st_in_hexstring): + case st_in_hexstring: inHexstring(ch); return; - case (st_in_hexstring_2nd): + case st_in_hexstring_2nd: inHexstring2nd(ch); return; |