[hackers] [scc] [libc] Add strspn() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 23 Feb 2017 16:20:45 +0100 (CET)

commit 8d6947fe3b9bb922c105f7a7e8636018e0034db0
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Feb 23 16:19:41 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Feb 23 16:19:41 2017 +0100

    [libc] Add strspn()

diff --git a/libc/src/Makefile b/libc/src/Makefile
index 2984f58..e401f13 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
_AT_@ -3,7 +3,7 @@
 
 LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
           strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \
- strxfrm.o strtok.o strstr.o \
+ strxfrm.o strtok.o strstr.o strspn.o \
           memset.o memcpy.o memmove.o memcmp.o memchr.o \
           isalnum.o isalpha.o isascii.o isblank.o iscntrl.o isdigit.o \
           isgraph.o islower.o isprint.o ispunct.o isspace.o isupper.o \
diff --git a/libc/src/strspn.c b/libc/src/strspn.c
new file mode 100644
index 0000000..2280de7
--- /dev/null
+++ b/libc/src/strspn.c
_AT_@ -0,0 +1,19 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+size_t
+strspn(const char *s1, const char *s2)
+{
+ size_t n;
+ int c;
+ const char *p;
+
+ for (n = 0; c = *s1++; ++n) {
+ for (p = s2; *p && *p != c; ++p)
+ /* nothing */;
+ if (*p == '\0')
+ break;
+ }
+ return n;
+}
Received on Thu Feb 23 2017 - 16:20:45 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 23 2017 - 16:24:34 CET