php-internal-docs
8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
gdhelpers.c
Go to the documentation of this file.
1
#ifdef HAVE_CONFIG_H
2
#include "config.h"
3
#endif
4
5
#include "
gd.h
"
6
#include "
gdhelpers.h
"
7
#include <stdlib.h>
8
#include <string.h>
9
10
/* TBB: gd_strtok_r is not portable; provide an implementation */
11
12
#define SEP_TEST (separators[*((unsigned char *) s)])
13
14
char
*
15
gd_strtok_r
(
char
*
s
,
char
*sep,
char
**
state
)
16
{
17
char
separators[256];
18
char
*
result
= 0;
19
memset
(separators, 0,
sizeof
(separators));
20
while
(*sep)
21
{
22
separators[*((
unsigned
char
*) sep)] = 1;
23
sep++;
24
}
25
if
(!
s
)
26
{
27
/* Pick up where we left off */
28
s
= *
state
;
29
}
30
/* 1. EOS */
31
if
(!(*
s
))
32
{
33
*
state
=
s
;
34
return
0;
35
}
36
/* 2. Leading separators, if any */
37
if
(
SEP_TEST
)
38
{
39
do
40
{
41
s
++;
42
}
43
while
(
SEP_TEST
);
44
/* 2a. EOS after separators only */
45
if
(!(*
s
))
46
{
47
*
state
=
s
;
48
return
0;
49
}
50
}
51
/* 3. A token */
52
result
=
s
;
53
do
54
{
55
/* 3a. Token at end of string */
56
if
(!(*
s
))
57
{
58
*
state
=
s
;
59
return
result
;
60
}
61
s
++;
62
}
63
while
(!
SEP_TEST
);
64
/* 4. Terminate token and skip trailing separators */
65
*
s
=
'\0'
;
66
do
67
{
68
s
++;
69
}
70
while
(
SEP_TEST
);
71
/* 5. Return token */
72
*
state
=
s
;
73
return
result
;
74
}
s
char s[4]
Definition
cdf.c:77
memset
memset(ptr, 0, type->size)
gd.h
SEP_TEST
#define SEP_TEST
Definition
gdhelpers.c:12
gd_strtok_r
char * gd_strtok_r(char *s, char *sep, char **state)
Definition
gdhelpers.c:15
gdhelpers.h
state
state
Definition
php_http_parser.h:114
result
bool result
Definition
zend_vm_def.h:455
ext
gd
libgd
gdhelpers.c
Generated on Sat Aug 23 2025 01:46:08 for php-internal-docs by
1.13.2