aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFTokenizer.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-08-20 13:18:20 +0200
committerm-holger <m-holger@kubitscheck.org>2022-08-25 11:43:29 +0200
commita5d2e8877580fb74d21ca453dd143ce5d32904fd (patch)
treeef215d932a928eceabfa2d8ec06e63a74d2aaa2a /libqpdf/QPDFTokenizer.cc
parent7c32f6cc2e90058b8a1fbaec48e07bf21bd66afa (diff)
downloadqpdf-a5d2e8877580fb74d21ca453dd143ce5d32904fd.tar.zst
Code tidy: replace if with case statement in QPDFTokenizer::inString
Diffstat (limited to 'libqpdf/QPDFTokenizer.cc')
-rw-r--r--libqpdf/QPDFTokenizer.cc29
1 files changed, 20 insertions, 9 deletions
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc
index bf066e2a..0c6ba155 100644
--- a/libqpdf/QPDFTokenizer.cc
+++ b/libqpdf/QPDFTokenizer.cc
@@ -486,26 +486,37 @@ QPDFTokenizer::inHexstring(char ch)
void
QPDFTokenizer::inString(char ch)
{
- if (ch == '\\') {
+ switch (ch) {
+ case '\\':
this->state = st_string_escape;
return;
- } else if (ch == '(') {
+
+ case '(':
this->val += ch;
++this->string_depth;
return;
- } else if ((ch == ')') && (--this->string_depth == 0)) {
- this->type = tt_string;
- this->state = st_token_ready;
+
+ case ')':
+ if (--this->string_depth == 0) {
+ this->type = tt_string;
+ this->state = st_token_ready;
+ return;
+ }
+
+ this->val += ch;
return;
- } else if (ch == '\r') {
+
+ case '\r':
// CR by itself is converted to LF
this->val += '\n';
this->state = st_string_after_cr;
return;
- } else if (ch == '\n') {
+
+ case '\n':
this->val += ch;
return;
- } else {
+
+ default:
this->val += ch;
return;
}
@@ -524,7 +535,7 @@ QPDFTokenizer::inCharCode(char ch)
memset(this->bs_num_register, '\0', sizeof(this->bs_num_register));
bs_num_count = 0;
this->state = st_in_string;
- handleCharacter(ch);
+ inString(ch);
return;
} else if (ch_is_octal) {
this->bs_num_register[bs_num_count++] = ch;