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

Function strcspn

payloads/libpayload/libc/string.c:490–506  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

488 * @return The number of not matching characters
489 */
490size_t strcspn(const char *s, const char *a)
491{
492 size_t i;
493 size_t al = strlen(a);
494 for (i = 0; s[i] != 0; i++) {
495 int found = 0;
496 for (size_t j = 0; j < al; j++) {
497 if (s[i] == a[j]) {
498 found = 1;
499 break;
500 }
501 }
502 if (found)
503 break;
504 }
505 return i;
506}
507
508/**
509 * Extract first token in string str that is delimited by a character in tokens.

Callers 1

strtok_rFunction · 0.70

Calls 1

strlenFunction · 0.85

Tested by

no test coverage detected