| 3452 | } |
| 3453 | |
| 3454 | int String::find(const String& p_str, int p_from) const |
| 3455 | { |
| 3456 | if (p_from < 0) |
| 3457 | { |
| 3458 | return -1; |
| 3459 | } |
| 3460 | |
| 3461 | const int src_len = p_str.length(); |
| 3462 | |
| 3463 | const int len = length(); |
| 3464 | |
| 3465 | if (src_len == 0 || len == 0) |
| 3466 | { |
| 3467 | return -1; // won't find anything! |
| 3468 | } |
| 3469 | |
| 3470 | const char32_t* src = get_data(); |
| 3471 | const char32_t* str = p_str.get_data(); |
| 3472 | |
| 3473 | for (int i = p_from; i <= (len - src_len); i++) |
| 3474 | { |
| 3475 | bool found = true; |
| 3476 | for (int j = 0; j < src_len; j++) |
| 3477 | { |
| 3478 | int read_pos = i + j; |
| 3479 | |
| 3480 | if (read_pos >= len) |
| 3481 | { |
| 3482 | ERR_PRINT("read_pos>=len"); |
| 3483 | return -1; |
| 3484 | } |
| 3485 | |
| 3486 | if (src[read_pos] != str[j]) |
| 3487 | { |
| 3488 | found = false; |
| 3489 | break; |
| 3490 | } |
| 3491 | } |
| 3492 | |
| 3493 | if (found) |
| 3494 | { |
| 3495 | return i; |
| 3496 | } |
| 3497 | } |
| 3498 | |
| 3499 | return -1; |
| 3500 | } |
| 3501 | |
| 3502 | int String::find(const char* p_str, int p_from) const |
| 3503 | { |
no test coverage detected