MCPcopy Create free account
hub / github.com/PowerBroker2/ELMduino / nextIndex

Method nextIndex

src/ELMduino.cpp:418–443  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

416 numOccur'th instance of target in str
417*/
418int8_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,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected