scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

strpbrk.c (378B)


      1 #include <string.h>
      2 
      3 #undef strpbrk
      4 
      5 char *
      6 strpbrk(const char *s1, const char *s2)
      7 {
      8 	const unsigned char *s = (const unsigned char *) s1;
      9 	const unsigned char *accept = (const unsigned char *) s2;
     10 	unsigned ch;
     11 	char map[__NUMCHARS] = {0};
     12 
     13 	while ((ch = *accept++) != 0)
     14 		map[ch] = 1;
     15 
     16 	while ((ch = *s) != 0 && !map[ch])
     17 		s++;
     18 
     19 	return (ch == '\0') ? NULL : (char *) s;
     20 }