19 static char **tokenize(
const char *,
const char *,
const char *);
49 return tokenize(buf, delim,
NULL);
83 char **
G_tokenize2(
const char *buf,
const char *delim,
const char *valchar)
85 return tokenize(buf, delim, valchar);
88 char **tokenize(
const char *buf,
const char *delim,
const char *inchar)
99 enum { A_NO_OP, A_ADD_CHAR, A_NEW_FIELD, A_END_RECORD, A_ERROR };
101 int quo = inchar ? *inchar : -1;
107 tokens = (
char **)
G_malloc(2 *
sizeof(
char *));
112 for (
state = S_START;; p++) {
114 int action = A_NO_OP;
121 action = A_END_RECORD;
122 else if (strchr(delim, c))
123 action = A_NEW_FIELD;
129 state = S_AFTER_QUOTE;
137 state = S_IN_QUOTE, action = A_ADD_CHAR;
139 action = A_END_RECORD;
140 else if (strchr(delim, c))
141 state = S_START, action = A_NEW_FIELD;
156 tokens =
G_realloc(tokens, (i + 2) *
sizeof(
char *));
184 for (n = 0; tokens[n] !=
NULL; n++)
200 if (tokens[0] !=
NULL)
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
char * G_store(const char *)
Copy string to allocated memory.
void G_free_tokens(char **tokens)
Free memory allocated to tokens.
int G_number_of_tokens(char **tokens)
Return number of tokens.
char ** G_tokenize2(const char *buf, const char *delim, const char *valchar)
Tokenize string.
char ** G_tokenize(const char *buf, const char *delim)
Tokenize string.