// SPDX-License-Identifier: GPL-2.0 /* * linux/lib/string.c * * Copyright (C) 1991, 1992 Linus Torvalds */ #include size_t strspn(const char *s, const char *accept) { const char *p; const char *a; size_t count = 0; for (p = s; *p != '\0'; ++p) { for (a = accept; *a != '\0'; ++a) { if (*p == *a) break; } if (*a == '\0') return count; ++count; } return count; } size_t strcspn(const char *s, const char *reject) { const char *p; const char *r; size_t count = 0; for (p = s; *p != '\0'; ++p) { for (r = reject; *r != '\0'; ++r) { if (*p == *r) return count; } ++count; } return count; } size_t strlen(const char *s) { const char *sc; for (sc = s; *sc != '\0'; ++sc) /* nothing */; return sc - s; } char *strchr(const char *s, int c) { for (; *s != (char)c; ++s) if (*s == '\0') return NULL; return (char *)s; }