int8_t ELM327::nextIndex(char const *str, char const *target, uint8_t numOccur) Description: ------------ * Finds and returns the first char index of numOccur'th instance of target in str Inputs: ------- * char const *str - string to search target within * char const *target - String to search for in str * uint8_t
| 416 | numOccur'th instance of target in str |
| 417 | */ |
| 418 | int8_t ELM327::nextIndex(char const *str, |
| 419 | char const *target, |
| 420 | uint8_t numOccur) |
| 421 | { |
| 422 | char const *p = str; |
| 423 | char const *r = str; |
| 424 | uint8_t count; |
| 425 | |
| 426 | for (count = 0;; ++count) |
| 427 | { |
| 428 | p = strstr(p, target); |
| 429 | |
| 430 | if (count == (numOccur - 1)) |
| 431 | break; |
| 432 | |
| 433 | if (!p) |
| 434 | break; |
| 435 | |
| 436 | p++; |
| 437 | } |
| 438 | |
| 439 | if (!p) |
| 440 | return -1; |
| 441 | |
| 442 | return p - r; |
| 443 | } |
| 444 | |
| 445 | /* |
| 446 | void ELM327::removeChar(char *from, |
nothing calls this directly
no outgoing calls
no test coverage detected