ReactOS 0.4.15-dev-8191-gbc6c731
strpbrk.c File Reference
#include <limits.h>
#include <string.h>
Include dependency graph for strpbrk.c:

Go to the source code of this file.

Macros

#define BIT_SIZE   (CHAR_BIT * sizeof(unsigned long) / sizeof(char))
 

Functions

char *__cdecl strpbrk (const char *s1, const char *s2)
 

Macro Definition Documentation

◆ BIT_SIZE

#define BIT_SIZE   (CHAR_BIT * sizeof(unsigned long) / sizeof(char))

Definition at line 5 of file strpbrk.c.

Function Documentation

◆ strpbrk()

char *__cdecl strpbrk ( const char s1,
const char s2 
)

Definition at line 7 of file strpbrk.c.

8{
9 if (*s2 == 0)
10 {
11 return 0;
12 }
13 if (*(s2+1) == 0)
14 {
15 return strchr(s1, *s2);
16 }
17 else if (*(s2+2) == 0)
18 {
19 char *s3, *s4;
20 s3 = strchr(s1, *s2);
21 s4 = strchr(s1, *(s2+1));
22 if (s3 == 0)
23 {
24 return s4;
25 }
26 else if (s4 == 0)
27 {
28 return s3;
29 }
30 return s3 < s4 ? s3 : s4;
31 }
32 else
33 {
34 unsigned long char_map[(1 << CHAR_BIT) / BIT_SIZE] = {0, };
35 const unsigned char* str = (const unsigned char*)s1;
36 while (*s2)
37 {
38 char_map[*(const unsigned char*)s2 / BIT_SIZE] |= (1 << (*(const unsigned char*)s2 % BIT_SIZE));
39 s2++;
40 }
41 while (*str)
42 {
43 if (char_map[*str / BIT_SIZE] & (1 << (*str % BIT_SIZE)))
44 {
45 return (char*)((size_t)str);
46 }
47 str++;
48 }
49 }
50 return 0;
51}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define CHAR_BIT
Definition: urlcache.c:62
__kernel_size_t size_t
Definition: linux.h:237
struct S1 s1
struct S2 s2
const WCHAR * str
#define BIT_SIZE
Definition: strpbrk.c:5

Referenced by aexpand(), Fatalv(), get_lineA(), GetExpandedNameA(), File::getline(), getnetconfigent(), gl_do_tab_completion(), HalpDebugPciDumpBus(), hist_save(), interpret(), process_preprocessor(), and SQLValidDSN().