• Home
  • Raw
  • Download

Lines Matching refs:tok

86 private void FUN(tok,finish)(TYPE(Tokenizer) *);
93 FUN(tok,finish)(TYPE(Tokenizer) *tok) in FUN() argument
96 *tok->wptr = '\0'; in FUN()
97 if ((tok->flags & TOK_KEEP) || tok->wptr != tok->wstart) { in FUN()
98 tok->argv[tok->argc++] = tok->wstart; in FUN()
99 tok->argv[tok->argc] = NULL; in FUN()
100 tok->wstart = ++tok->wptr; in FUN()
102 tok->flags &= ~TOK_KEEP; in FUN()
110 FUN(tok,init)(const Char *ifs) in TYPE()
112 TYPE(Tokenizer) *tok = tok_malloc(sizeof(*tok)); in TYPE()
114 if (tok == NULL) in TYPE()
116 tok->ifs = tok_strdup(ifs ? ifs : IFS); in TYPE()
117 if (tok->ifs == NULL) { in TYPE()
118 tok_free(tok); in TYPE()
121 tok->argc = 0; in TYPE()
122 tok->amax = AINCR; in TYPE()
123 tok->argv = tok_malloc(sizeof(*tok->argv) * tok->amax); in TYPE()
124 if (tok->argv == NULL) { in TYPE()
125 tok_free(tok->ifs); in TYPE()
126 tok_free(tok); in TYPE()
129 tok->argv[0] = NULL; in TYPE()
130 tok->wspace = tok_malloc(WINCR * sizeof(*tok->wspace)); in TYPE()
131 if (tok->wspace == NULL) { in TYPE()
132 tok_free(tok->argv); in TYPE()
133 tok_free(tok->ifs); in TYPE()
134 tok_free(tok); in TYPE()
137 tok->wmax = tok->wspace + WINCR; in TYPE()
138 tok->wstart = tok->wspace; in TYPE()
139 tok->wptr = tok->wspace; in TYPE()
140 tok->flags = 0; in TYPE()
141 tok->quote = Q_none; in TYPE()
143 return tok; in TYPE()
151 FUN(tok,reset)(TYPE(Tokenizer) *tok) in FUN() argument
154 tok->argc = 0; in FUN()
155 tok->wstart = tok->wspace; in FUN()
156 tok->wptr = tok->wspace; in FUN()
157 tok->flags = 0; in FUN()
158 tok->quote = Q_none; in FUN()
166 FUN(tok,end)(TYPE(Tokenizer) *tok) in FUN() argument
169 tok_free(tok->ifs); in FUN()
170 tok_free(tok->wspace); in FUN()
171 tok_free(tok->argv); in FUN()
172 tok_free(tok); in FUN()
195 FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, in FUN() argument
207 cc = (int)tok->argc; in FUN()
208 co = (int)(tok->wptr - tok->wstart); in FUN()
212 tok->flags |= TOK_KEEP; in FUN()
213 tok->flags &= ~TOK_EAT; in FUN()
214 switch (tok->quote) { in FUN()
216 tok->quote = Q_single; /* Enter single quote in FUN()
221 tok->quote = Q_none; in FUN()
225 tok->quote = Q_none; in FUN()
226 *tok->wptr++ = *ptr; in FUN()
230 *tok->wptr++ = *ptr; in FUN()
234 tok->quote = Q_double; in FUN()
235 *tok->wptr++ = *ptr; in FUN()
244 tok->flags &= ~TOK_EAT; in FUN()
245 tok->flags |= TOK_KEEP; in FUN()
246 switch (tok->quote) { in FUN()
248 tok->quote = Q_double; in FUN()
252 tok->quote = Q_none; in FUN()
256 tok->quote = Q_none; in FUN()
257 *tok->wptr++ = *ptr; in FUN()
261 *tok->wptr++ = *ptr; in FUN()
265 tok->quote = Q_double; in FUN()
266 *tok->wptr++ = *ptr; in FUN()
275 tok->flags |= TOK_KEEP; in FUN()
276 tok->flags &= ~TOK_EAT; in FUN()
277 switch (tok->quote) { in FUN()
279 tok->quote = Q_one; in FUN()
283 tok->quote = Q_doubleone; in FUN()
287 *tok->wptr++ = *ptr; in FUN()
288 tok->quote = Q_none; in FUN()
292 *tok->wptr++ = *ptr; in FUN()
296 tok->quote = Q_double; in FUN()
297 *tok->wptr++ = *ptr; in FUN()
306 tok->flags &= ~TOK_EAT; in FUN()
307 switch (tok->quote) { in FUN()
313 *tok->wptr++ = *ptr; /* Add the return */ in FUN()
317 tok->flags |= TOK_EAT; in FUN()
318 tok->quote = Q_double; in FUN()
322 tok->flags |= TOK_EAT; in FUN()
323 tok->quote = Q_none; in FUN()
332 switch (tok->quote) { in FUN()
335 if (tok->flags & TOK_EAT) { in FUN()
336 tok->flags &= ~TOK_EAT; in FUN()
348 tok->quote = Q_double; in FUN()
349 *tok->wptr++ = *ptr; in FUN()
353 tok->quote = Q_none; in FUN()
354 *tok->wptr++ = *ptr; in FUN()
363 tok->flags &= ~TOK_EAT; in FUN()
364 switch (tok->quote) { in FUN()
366 if (Strchr(tok->ifs, *ptr) != NULL) in FUN()
367 FUN(tok,finish)(tok); in FUN() local
369 *tok->wptr++ = *ptr; in FUN()
374 *tok->wptr++ = *ptr; in FUN()
379 *tok->wptr++ = '\\'; in FUN()
380 tok->quote = Q_double; in FUN()
381 *tok->wptr++ = *ptr; in FUN()
385 tok->quote = Q_none; in FUN()
386 *tok->wptr++ = *ptr; in FUN()
396 if (tok->wptr >= tok->wmax - 4) { in FUN()
397 size_t size = (size_t)(tok->wmax - tok->wspace + WINCR); in FUN()
398 Char *s = tok_realloc(tok->wspace, in FUN()
403 if (s != tok->wspace) { in FUN()
405 for (i = 0; i < tok->argc; i++) { in FUN()
406 tok->argv[i] = in FUN()
407 (tok->argv[i] - tok->wspace) + s; in FUN()
409 tok->wptr = (tok->wptr - tok->wspace) + s; in FUN()
410 tok->wstart = (tok->wstart - tok->wspace) + s; in FUN()
411 tok->wspace = s; in FUN()
413 tok->wmax = s + size; in FUN()
415 if (tok->argc >= tok->amax - 4) { in FUN()
417 tok->amax += AINCR; in FUN()
418 p = tok_realloc(tok->argv, tok->amax * sizeof(*p)); in FUN()
421 tok->argv = p; in FUN()
426 cc = (int)tok->argc; in FUN()
427 co = (int)(tok->wptr - tok->wstart); in FUN()
433 FUN(tok,finish)(tok); in FUN() local
434 *argv = (const Char **)tok->argv; in FUN()
435 *argc = (int)tok->argc; in FUN()
444 FUN(tok,str)(TYPE(Tokenizer) *tok, const Char *line, int *argc, in FUN() argument
452 return FUN(tok,line(tok, &li, argc, argv, NULL, NULL)); in FUN()