aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFTokenizer.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-08-18 19:25:51 +0200
committerm-holger <m-holger@kubitscheck.org>2022-08-21 03:38:49 +0200
commitf9530a581522a418b8298791969ac8a0e002dfff (patch)
treecf1e2b173298e9e2976e2d97763ec0f2547918e0 /libqpdf/QPDFTokenizer.cc
parent86ade3f9cd367296e64ae86870ec12ebf34883f6 (diff)
downloadqpdf-f9530a581522a418b8298791969ac8a0e002dfff.tar.zst
Code tidy: replace if with case statement in QPDFTokenizer::handleCharacter
Diffstat (limited to 'libqpdf/QPDFTokenizer.cc')
-rw-r--r--libqpdf/QPDFTokenizer.cc46
1 files changed, 34 insertions, 12 deletions
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc
index f5a50695..6c83119f 100644
--- a/libqpdf/QPDFTokenizer.cc
+++ b/libqpdf/QPDFTokenizer.cc
@@ -233,46 +233,68 @@ QPDFTokenizer::handleCharacter(char ch)
this->state = st_in_space;
this->val += ch;
}
- } else if (ch == '%') {
+ return;
+ }
+ switch (ch) {
+ case '%':
this->state = st_in_comment;
if (this->include_ignorable) {
this->val += ch;
}
- } else if (ch == '(') {
+ return;
+
+ case '(':
this->string_depth = 1;
this->string_ignoring_newline = false;
memset(this->bs_num_register, '\0', sizeof(this->bs_num_register));
this->last_char_was_bs = false;
this->last_char_was_cr = false;
this->state = st_in_string;
- } else if (ch == '<') {
+ return;
+
+ case '<':
this->state = st_lt;
- } else if (ch == '>') {
+ return;
+
+ case '>':
this->state = st_gt;
- } else {
+ return;
+
+ default:
this->val += ch;
- if (ch == ')') {
+ switch (ch) {
+ case ')':
this->type = tt_bad;
QTC::TC("qpdf", "QPDFTokenizer bad )");
this->error_message = "unexpected )";
this->state = st_token_ready;
- } else if (ch == '[') {
+ return;
+
+ case '[':
this->type = tt_array_open;
this->state = st_token_ready;
- } else if (ch == ']') {
+ return;
+
+ case ']':
this->type = tt_array_close;
this->state = st_token_ready;
- } else if (ch == '{') {
+ return;
+
+ case '{':
this->type = tt_brace_open;
this->state = st_token_ready;
- } else if (ch == '}') {
+ return;
+
+ case '}':
this->type = tt_brace_close;
this->state = st_token_ready;
- } else {
+ return;
+
+ default:
this->state = st_literal;
+ return;
}
}
- return;
case st_in_space:
// We only enter this state if include_ignorable is true.