| 3228 | } |
| 3229 | |
| 3230 | int String::findn(const String &p_str, int p_from) const { |
| 3231 | if (p_from < 0) { |
| 3232 | return -1; |
| 3233 | } |
| 3234 | |
| 3235 | int src_len = p_str.length(); |
| 3236 | |
| 3237 | if (src_len == 0 || length() == 0) { |
| 3238 | return -1; // won't find anything! |
| 3239 | } |
| 3240 | |
| 3241 | const char32_t *srcd = get_data(); |
| 3242 | |
| 3243 | for (int i = p_from; i <= (length() - src_len); i++) { |
| 3244 | bool found = true; |
| 3245 | for (int j = 0; j < src_len; j++) { |
| 3246 | int read_pos = i + j; |
| 3247 | |
| 3248 | if (read_pos >= length()) { |
| 3249 | ERR_PRINT("read_pos>=length()"); |
| 3250 | return -1; |
| 3251 | } |
| 3252 | |
| 3253 | char32_t src = _find_lower(srcd[read_pos]); |
| 3254 | char32_t dst = _find_lower(p_str[j]); |
| 3255 | |
| 3256 | if (src != dst) { |
| 3257 | found = false; |
| 3258 | break; |
| 3259 | } |
| 3260 | } |
| 3261 | |
| 3262 | if (found) { |
| 3263 | return i; |
| 3264 | } |
| 3265 | } |
| 3266 | |
| 3267 | return -1; |
| 3268 | } |
| 3269 | |
| 3270 | int String::findn(const char *p_str, int p_from) const { |
| 3271 | if (p_from < 0) { |
no test coverage detected