File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,21 @@ extern __kernel_size_t strlen(const char *);
7676#ifndef __HAVE_ARCH_STRNLEN
7777extern __kernel_size_t strnlen (const char * ,__kernel_size_t );
7878#endif
79+
80+ #ifndef __HAVE_ARCH_STRCSPN
81+ /**
82+ * strcspn() - find span of string without given characters
83+ *
84+ * Calculates the length of the initial segment of @s which consists entirely
85+ * of bsytes not in reject.
86+ *
87+ * @s: string to search
88+ * @reject: strings which cause the search to halt
89+ * @return number of characters at the start of @s which are not in @reject
90+ */
91+ size_t strcspn (const char * s , const char * reject );
92+ #endif
93+
7994#ifndef __HAVE_ARCH_STRDUP
8095extern char * strdup (const char * );
8196#endif
Original file line number Diff line number Diff line change @@ -286,6 +286,30 @@ size_t strnlen(const char * s, size_t count)
286286}
287287#endif
288288
289+ #ifndef __HAVE_ARCH_STRCSPN
290+ /**
291+ * strcspn - Calculate the length of the initial substring of @s which does
292+ * not contain letters in @reject
293+ * @s: The string to be searched
294+ * @reject: The string to avoid
295+ */
296+ size_t strcspn (const char * s , const char * reject )
297+ {
298+ const char * p ;
299+ const char * r ;
300+ size_t count = 0 ;
301+
302+ for (p = s ; * p != '\0' ; ++ p ) {
303+ for (r = reject ; * r != '\0' ; ++ r ) {
304+ if (* p == * r )
305+ return count ;
306+ }
307+ ++ count ;
308+ }
309+ return count ;
310+ }
311+ #endif
312+
289313#ifndef __HAVE_ARCH_STRDUP
290314char * strdup (const char * s )
291315{
You can’t perform that action at this time.
0 commit comments