MCPcopy Create free account
hub / github.com/coreboot/coreboot / strspn

Function strspn

payloads/libpayload/libc/string.c:466–482  ·  view source on GitHub ↗

* Determine the number of leading characters in s that match characters in a * @param s A pointer to the string to analyse * @param a A pointer to an array of characters that match the prefix * @return The number of matching characters */

Source from the content-addressed store, hash-verified

464 * @return The number of matching characters
465 */
466size_t strspn(const char *s, const char *a)
467{
468 size_t i;
469 size_t al = strlen(a);
470 for (i = 0; s[i] != 0; i++) {
471 int found = 0;
472 for (size_t j = 0; j < al; j++) {
473 if (s[i] == a[j]) {
474 found = 1;
475 break;
476 }
477 }
478 if (!found)
479 break;
480 }
481 return i;
482}
483
484/**
485 * Determine the number of leading characters in s that do not match characters in a

Callers 1

strtok_rFunction · 0.70

Calls 1

strlenFunction · 0.85

Tested by

no test coverage detected