| 574 | } |
| 575 | |
| 576 | static _FORCE_INLINE_ signed char naturalcasecmp_to_base(const char32_t *p_this_str, const char32_t *p_that_str) { |
| 577 | if (p_this_str && p_that_str) { |
| 578 | while (*p_this_str == '.' || *p_that_str == '.') { |
| 579 | if (*p_this_str++ != '.') { |
| 580 | return 1; |
| 581 | } |
| 582 | if (*p_that_str++ != '.') { |
| 583 | return -1; |
| 584 | } |
| 585 | if (!*p_that_str) { |
| 586 | return 1; |
| 587 | } |
| 588 | if (!*p_this_str) { |
| 589 | return -1; |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | while (*p_this_str) { |
| 594 | if (!*p_that_str) { |
| 595 | return 1; |
| 596 | } else if (is_digit(*p_this_str)) { |
| 597 | if (!is_digit(*p_that_str)) { |
| 598 | return -1; |
| 599 | } |
| 600 | |
| 601 | signed char ret = natural_cmp_common(p_this_str, p_that_str); |
| 602 | if (ret) { |
| 603 | return ret; |
| 604 | } |
| 605 | } else if (is_digit(*p_that_str)) { |
| 606 | return 1; |
| 607 | } else { |
| 608 | if (*p_this_str < *p_that_str) { // If current character in this is less, we are less. |
| 609 | return -1; |
| 610 | } else if (*p_this_str > *p_that_str) { // If current character in this is greater, we are greater. |
| 611 | return 1; |
| 612 | } |
| 613 | |
| 614 | p_this_str++; |
| 615 | p_that_str++; |
| 616 | } |
| 617 | } |
| 618 | if (*p_that_str) { |
| 619 | return -1; |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | signed char String::naturalcasecmp_to(const String &p_str) const { |
| 627 | const char32_t *this_str = get_data(); |
no test coverage detected