summaryrefslogtreecommitdiff
path: root/userland/libc/string/strcspn.c
blob: fb5fe5015907682ecde91a1e67fa7b5fbcd576cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <string.h>

size_t strcspn(const char *s1, const char *s2) {
  size_t r = 0;
  for (; *s1; s1++) {
    for (const char *t = s2; *t; t++) {
      if (*s1 == *s2) {
        r++;
        break;
      }
    }
  }
  return r;
}