This source file includes following definitions.
- gd_strtok_r
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
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 *start;
19 char *result = 0;
20 memset (separators, 0, sizeof (separators));
21 while (*sep)
22 {
23 separators[*((unsigned char *) sep)] = 1;
24 sep++;
25 }
26 if (!s)
27 {
28
29 s = *state;
30 }
31 start = s;
32
33 if (!(*s))
34 {
35 *state = s;
36 return 0;
37 }
38
39 if (SEP_TEST)
40 {
41 do
42 {
43 s++;
44 }
45 while (SEP_TEST);
46
47 if (!(*s))
48 {
49 *state = s;
50 return 0;
51 }
52 }
53
54 result = s;
55 do
56 {
57
58 if (!(*s))
59 {
60 *state = s;
61 return result;
62 }
63 s++;
64 }
65 while (!SEP_TEST);
66
67 *s = '\0';
68 do
69 {
70 s++;
71 }
72 while (SEP_TEST);
73
74 *state = s;
75 return result;
76 }