summaryrefslogtreecommitdiff
path: root/userland/libc/string/strspn.c
blob: d6b159559ed2f70a967c31d3db1a051d32f8c374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <string.h>

size_t strspn(const char *s1, const char *s2) {
  size_t r = 0;
  for (; *s1; s1++) {
    int e = 0;
    for (const char *t = s2; *t; t++) {
      if (*s1 == *t) {
        e = 1;
        break;
      }
    }
    if (!e) {
      break;
    }
    r++;
  }
  return r;
}