| 533 | } |
| 534 | |
| 535 | static _FORCE_INLINE_ signed char natural_cmp_common(const char32_t *&r_this_str, const char32_t *&r_that_str) { |
| 536 | // Keep ptrs to start of numerical sequences. |
| 537 | const char32_t *this_substr = r_this_str; |
| 538 | const char32_t *that_substr = r_that_str; |
| 539 | |
| 540 | // Compare lengths of both numerical sequences, ignoring leading zeros. |
| 541 | while (is_digit(*r_this_str)) { |
| 542 | r_this_str++; |
| 543 | } |
| 544 | while (is_digit(*r_that_str)) { |
| 545 | r_that_str++; |
| 546 | } |
| 547 | while (*this_substr == '0') { |
| 548 | this_substr++; |
| 549 | } |
| 550 | while (*that_substr == '0') { |
| 551 | that_substr++; |
| 552 | } |
| 553 | int this_len = r_this_str - this_substr; |
| 554 | int that_len = r_that_str - that_substr; |
| 555 | |
| 556 | if (this_len < that_len) { |
| 557 | return -1; |
| 558 | } else if (this_len > that_len) { |
| 559 | return 1; |
| 560 | } |
| 561 | |
| 562 | // If lengths equal, compare lexicographically. |
| 563 | while (this_substr != r_this_str && that_substr != r_that_str) { |
| 564 | if (*this_substr < *that_substr) { |
| 565 | return -1; |
| 566 | } else if (*this_substr > *that_substr) { |
| 567 | return 1; |
| 568 | } |
| 569 | this_substr++; |
| 570 | that_substr++; |
| 571 | } |
| 572 | |
| 573 | return 0; |
| 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) { |
no test coverage detected