12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include "gd.h"
- #include "gdhelpers.h"
- #include <stdlib.h>
- #include <string.h>
- #define SEP_TEST (separators[*((unsigned char *) s)])
- char *
- gd_strtok_r (char *s, char *sep, char **state)
- {
- char separators[256];
- char *start;
- char *result = 0;
- memset (separators, 0, sizeof (separators));
- while (*sep)
- {
- separators[*((unsigned char *) sep)] = 1;
- sep++;
- }
- if (!s)
- {
-
- s = *state;
- }
- start = s;
-
- if (!(*s))
- {
- *state = s;
- return 0;
- }
-
- if (SEP_TEST)
- {
- do
- {
- s++;
- }
- while (SEP_TEST);
-
- if (!(*s))
- {
- *state = s;
- return 0;
- }
- }
-
- result = s;
- do
- {
-
- if (!(*s))
- {
- *state = s;
- return result;
- }
- s++;
- }
- while (!SEP_TEST);
-
- *s = '\0';
- do
- {
- s++;
- }
- while (SEP_TEST);
-
- *state = s;
- return result;
- }
|