scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 23dd58a0a616e7695b58073349762e104cf604c2
parent b239791cf4effebb1916fa5723eabf71d0abcbf1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 23 Feb 2017 16:39:23 +0100

[tests] Add strpbr()

Diffstat:
libc/src/Makefile | 2+-
libc/src/strpbrk.c | 18++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/libc/src/Makefile b/libc/src/Makefile @@ -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 strspn.o strcspn.o \ + strxfrm.o strtok.o strstr.o strspn.o strcspn.o strpbrk.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/strpbrk.c b/libc/src/strpbrk.c @@ -0,0 +1,18 @@ +/* See LICENSE file for copyright and license details. */ + +#include <string.h> + +char * +strpbrk(const char *s1, const char *s2) +{ + int c; + const char *p; + + for (; c = *s1; ++s1) { + for (p = s2; *p && *p != c; ++p) + /* nothing */; + if (*p == c) + return s1; + } + return NULL; +}