need to use the old syntax since the C++11 [[xxx:always_inline]] cannot be used here
| 548 | #if defined(__GNUC__) |
| 549 | // need to use the old syntax since the C++11 [[xxx:always_inline]] cannot be used here |
| 550 | inline __attribute__((always_inline)) |
| 551 | #endif |
| 552 | int multiCompareImpl(const Token *tok, const char *haystack, nonneg int varid) |
| 553 | { |
| 554 | const char *needle = tok->str().c_str(); |
| 555 | const char *needlePointer = needle; |
| 556 | for (;;) { |
| 557 | if (needlePointer == needle && haystack[0] == '%' && haystack[1] != '|' && haystack[1] != '\0' && haystack[1] != ' ' && haystack[1] != '=') { |
| 558 | const int ret = multiComparePercent(tok, haystack, varid); |
| 559 | if (ret < 2) |
| 560 | return ret; |
| 561 | } else if (*haystack == '|') { |
| 562 | if (*needlePointer == 0) { |
| 563 | // If needle is at the end, we have a match. |
| 564 | return 1; |
| 565 | } |
| 566 | |
| 567 | needlePointer = needle; |
| 568 | ++haystack; |
| 569 | } else if (*needlePointer == *haystack) { |
| 570 | if (*needlePointer == '\0') |
| 571 | return 1; |
| 572 | ++needlePointer; |
| 573 | ++haystack; |
| 574 | } else if (*haystack == ' ' || *haystack == '\0') { |
| 575 | if (needlePointer == needle) |
| 576 | return 0; |
| 577 | break; |
| 578 | } |
| 579 | // If haystack and needle don't share the same character, |
| 580 | // find next '|' character. |
| 581 | else { |
| 582 | needlePointer = needle; |
| 583 | |
| 584 | do { |
| 585 | ++haystack; |
| 586 | |
| 587 | if (*haystack == ' ' || *haystack == '\0') { |
| 588 | return -1; |
| 589 | } |
| 590 | if (*haystack == '|') { |
| 591 | break; |
| 592 | } |
| 593 | } while (true); |
| 594 | |
| 595 | ++haystack; |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | if (*needlePointer == '\0') |
| 600 | return 1; |
| 601 | |
| 602 | return -1; |
| 603 | } |
| 604 | |
| 605 | // cppcheck-suppress unusedFunction - used in tests only |
| 606 | int Token::multiCompare(const Token *tok, const char *haystack, nonneg int varid) |
no test coverage detected