* 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 */
| 464 | * @return The number of matching characters |
| 465 | */ |
| 466 | size_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 |