ReactOS
0.4.16-dev-1946-g52006dd
strpbrk.c
Go to the documentation of this file.
1
2
#include <limits.h>
3
#include <string.h>
4
5
#define BIT_SIZE (CHAR_BIT * sizeof(unsigned long) / sizeof(char))
6
7
char
*
__cdecl
strpbrk
(
const
char
*
s1
,
const
char
*
s2
)
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
}
52
strchr
char * strchr(const char *String, int ch)
Definition:
utclib.c:501
__cdecl
#define __cdecl
Definition:
accygwin.h:79
strpbrk
char *__cdecl strpbrk(const char *s1, const char *s2)
Definition:
strpbrk.c:7
BIT_SIZE
#define BIT_SIZE
Definition:
strpbrk.c:5
CHAR_BIT
#define CHAR_BIT
Definition:
urlcache.c:62
size_t
__kernel_size_t size_t
Definition:
linux.h:237
s1
struct S1 s1
str
const WCHAR * str
Definition:
rpc_transport.c:2696
s2
PCWSTR s2
Definition:
shell32_main.h:38
sdk
lib
crt
string
strpbrk.c
Generated on Thu Dec 4 2025 06:16:23 for ReactOS by
1.9.6