| 3416 | } |
| 3417 | |
| 3418 | int String::rfindn(const String &p_str, int p_from) const { |
| 3419 | // establish a limit |
| 3420 | int limit = length() - p_str.length(); |
| 3421 | if (limit < 0) { |
| 3422 | return -1; |
| 3423 | } |
| 3424 | |
| 3425 | // establish a starting point |
| 3426 | if (p_from < 0) { |
| 3427 | p_from = limit; |
| 3428 | } else if (p_from > limit) { |
| 3429 | p_from = limit; |
| 3430 | } |
| 3431 | |
| 3432 | int src_len = p_str.length(); |
| 3433 | int len = length(); |
| 3434 | |
| 3435 | if (src_len == 0 || len == 0) { |
| 3436 | return -1; // won't find anything! |
| 3437 | } |
| 3438 | |
| 3439 | const char32_t *src = get_data(); |
| 3440 | |
| 3441 | for (int i = p_from; i >= 0; i--) { |
| 3442 | bool found = true; |
| 3443 | for (int j = 0; j < src_len; j++) { |
| 3444 | int read_pos = i + j; |
| 3445 | |
| 3446 | if (read_pos >= len) { |
| 3447 | ERR_PRINT("read_pos>=len"); |
| 3448 | return -1; |
| 3449 | } |
| 3450 | |
| 3451 | char32_t srcc = _find_lower(src[read_pos]); |
| 3452 | char32_t dstc = _find_lower(p_str[j]); |
| 3453 | |
| 3454 | if (srcc != dstc) { |
| 3455 | found = false; |
| 3456 | break; |
| 3457 | } |
| 3458 | } |
| 3459 | |
| 3460 | if (found) { |
| 3461 | return i; |
| 3462 | } |
| 3463 | } |
| 3464 | |
| 3465 | return -1; |
| 3466 | } |
| 3467 | |
| 3468 | int String::rfindn(const char *p_str, int p_from) const { |
| 3469 | const int source_length = length(); |
no test coverage detected