20 static char **tokenize(
const char *,
const char *,
const char *);
50 return tokenize(buf, delim,
NULL);
84 char **
G_tokenize2(
const char *buf,
const char *delim,
const char *valchar)
86 return tokenize(buf, delim, valchar);
89 char **tokenize(
const char *buf,
const char *delim,
const char *inchar)
108 int quo = inchar ? *inchar : -1;
114 tokens = (
char **)
G_malloc(2 *
sizeof(
char *));
119 for (state = S_START; ; p++) {
121 int action = A_NO_OP;
127 action = A_END_RECORD;
128 else if (strchr(delim, c))
129 action = A_NEW_FIELD;
135 state = S_AFTER_QUOTE;
143 state = S_IN_QUOTE, action = A_ADD_CHAR;
145 action = A_END_RECORD;
146 else if (strchr(delim, c))
147 state = S_START, action = A_NEW_FIELD;
162 tokens =
G_realloc(tokens, (i + 2) *
sizeof(
char *));
190 for (n = 0; tokens[n] !=
NULL; n++)
206 if (tokens[0] !=
NULL)
char ** G_tokenize(const char *buf, const char *delim)
Tokenize string.
void G_free(void *)
Free allocated memory.
int G_number_of_tokens(char **tokens)
Return number of tokens.
void G_warning(const char *,...) __attribute__((format(printf
void G_free_tokens(char **tokens)
Free memory allocated to tokens.
char * G_store(const char *)
Copy string to allocated memory.
char ** G_tokenize2(const char *buf, const char *delim, const char *valchar)
Tokenize string.