summaryrefslogtreecommitdiff
path: root/userland/libc/string/strcspn.c
blob: 2ad38d5b822e7ddbfc47bd9a49659c88bc6af65d (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;
}