Mostly minor updates to the source tree for portcls.
[reactos.git] / reactos / lib / string / strxspn.h
1 /* $Id$
2 */
3
4 #include <limits.h>
5 #include <string.h>
6
7 size_t _strxspn(const char *s1, const char *s2)
8 {
9 unsigned char char_map[1 << CHAR_BIT * sizeof(char)];
10 const unsigned char * us2 = (const unsigned char *)s2;
11 const unsigned char * str = (const unsigned char *)s1;
12
13 memset(char_map, 0, sizeof(char_map));
14
15 for(; *us2; ++ us2)
16 char_map[*us2 / CHAR_BIT] |= (1 << (*us2 % CHAR_BIT));
17
18 for(; *str; ++ str)
19 if(_x(char_map[*str / CHAR_BIT] & (1 << (*str % CHAR_BIT)))) break;
20
21 return (size_t)str - (size_t)s1;
22 }
23
24 /* EOF */