Commit a5d2e8877580fb74d21ca453dd143ce5d32904fd
1 parent
7c32f6cc
Code tidy: replace if with case statement in QPDFTokenizer::inString
Showing
1 changed file
with
20 additions
and
9 deletions
libqpdf/QPDFTokenizer.cc
| ... | ... | @@ -486,26 +486,37 @@ QPDFTokenizer::inHexstring(char ch) |
| 486 | 486 | void |
| 487 | 487 | QPDFTokenizer::inString(char ch) |
| 488 | 488 | { |
| 489 | - if (ch == '\\') { | |
| 489 | + switch (ch) { | |
| 490 | + case '\\': | |
| 490 | 491 | this->state = st_string_escape; |
| 491 | 492 | return; |
| 492 | - } else if (ch == '(') { | |
| 493 | + | |
| 494 | + case '(': | |
| 493 | 495 | this->val += ch; |
| 494 | 496 | ++this->string_depth; |
| 495 | 497 | return; |
| 496 | - } else if ((ch == ')') && (--this->string_depth == 0)) { | |
| 497 | - this->type = tt_string; | |
| 498 | - this->state = st_token_ready; | |
| 498 | + | |
| 499 | + case ')': | |
| 500 | + if (--this->string_depth == 0) { | |
| 501 | + this->type = tt_string; | |
| 502 | + this->state = st_token_ready; | |
| 503 | + return; | |
| 504 | + } | |
| 505 | + | |
| 506 | + this->val += ch; | |
| 499 | 507 | return; |
| 500 | - } else if (ch == '\r') { | |
| 508 | + | |
| 509 | + case '\r': | |
| 501 | 510 | // CR by itself is converted to LF |
| 502 | 511 | this->val += '\n'; |
| 503 | 512 | this->state = st_string_after_cr; |
| 504 | 513 | return; |
| 505 | - } else if (ch == '\n') { | |
| 514 | + | |
| 515 | + case '\n': | |
| 506 | 516 | this->val += ch; |
| 507 | 517 | return; |
| 508 | - } else { | |
| 518 | + | |
| 519 | + default: | |
| 509 | 520 | this->val += ch; |
| 510 | 521 | return; |
| 511 | 522 | } |
| ... | ... | @@ -524,7 +535,7 @@ QPDFTokenizer::inCharCode(char ch) |
| 524 | 535 | memset(this->bs_num_register, '\0', sizeof(this->bs_num_register)); |
| 525 | 536 | bs_num_count = 0; |
| 526 | 537 | this->state = st_in_string; |
| 527 | - handleCharacter(ch); | |
| 538 | + inString(ch); | |
| 528 | 539 | return; |
| 529 | 540 | } else if (ch_is_octal) { |
| 530 | 541 | this->bs_num_register[bs_num_count++] = ch; | ... | ... |