Lines Matching refs:tp
161 #define SKIP(tp, cond) { \ argument
162 while (tp->type && (cond)) \
163 tp = tp->prev; \
166 #define MOVE_COMMENT_AND_CONTINUE(tp, right) { \ argument
167 TOK822 *prev = tok822_unlink(tp); \
168 right = tok822_prepend(right, tp); \
169 tp = prev; \
173 #define SKIP_MOVE_COMMENT(tp, cond, right) { \ argument
174 while (tp->type && (cond)) { \
175 if (tp->type == TOK822_COMMENT) \
176 MOVE_COMMENT_AND_CONTINUE(tp, right); \
177 tp = tp->prev; \
203 TOK822 *tp; in tok822_internalize() local
208 for (tp = tree; tp; tp = tp->next) { in tok822_internalize()
209 switch (tp->type) { in tok822_internalize()
211 VSTRING_ADDCH(vp, tp->type); in tok822_internalize()
218 tok822_internalize(vp, tp->head, TOK822_STR_NONE); in tok822_internalize()
223 vstring_strcat(vp, vstring_str(tp->vstr)); in tok822_internalize()
227 vstring_strcat(vp, vstring_str(tp->vstr)); in tok822_internalize()
234 if (tp->type >= TOK822_MINTOK) in tok822_internalize()
235 msg_panic("tok822_internalize: unknown operator %d", tp->type); in tok822_internalize()
236 VSTRING_ADDCH(vp, tp->type); in tok822_internalize()
238 if (tok822_append_space(tp)) in tok822_internalize()
275 TOK822 *tp; in tok822_externalize() local
327 for (tp = tree; tp; tp = tp->next) { in tok822_externalize()
328 switch (tp->type) { in tok822_externalize()
332 VSTRING_ADDCH(vp, tp->type); in tok822_externalize()
346 addr = tp; in tok822_externalize()
348 tok822_internalize(tmp, tp->head, TOK822_STR_TERM); in tok822_externalize()
357 vstring_strcat(vp, vstring_str(tp->vstr)); in tok822_externalize()
361 tok822_copy_quoted(vp, vstring_str(tp->vstr), "\"\\\r\n"); in tok822_externalize()
366 tok822_copy_quoted(vp, vstring_str(tp->vstr), "\\\r\n"); in tok822_externalize()
373 if (tp->next && tp->next->type == '>') { in tok822_externalize()
374 addr = tp; in tok822_externalize()
380 if (tp->type >= TOK822_MINTOK) in tok822_externalize()
381 msg_panic("tok822_externalize: unknown operator %d", tp->type); in tok822_externalize()
382 VSTRING_ADDCH(vp, tp->type); in tok822_externalize()
384 if (tok822_append_space(tp)) in tok822_externalize()
410 static int tok822_append_space(TOK822 *tp) in tok822_append_space() argument
414 if (tp == 0 || (next = tp->next) == 0 || tp->owner != 0) in tok822_append_space()
416 if (tp->type == ',' || tp->type == TOK822_STARTGRP || next->type == '<') in tok822_append_space()
424 return (NON_OPERATOR(tp) && NON_OPERATOR(next)); in tok822_append_space()
433 TOK822 *tp; in tok822_scan_limit() local
448 tp = tok822_alloc(TOK822_COMMENT, (char *) 0); in tok822_scan_limit()
449 str = tok822_comment(tp, str); in tok822_scan_limit()
451 tp = tok822_alloc(TOK822_DOMLIT, (char *) 0); in tok822_scan_limit()
452 COLLECT_SKIP_LAST(tp, str, ch, ch != ']'); in tok822_scan_limit()
454 tp = tok822_alloc(TOK822_QSTRING, (char *) 0); in tok822_scan_limit()
455 COLLECT_SKIP_LAST(tp, str, ch, ch != '"'); in tok822_scan_limit()
457 tp = tok822_alloc(ch, (char *) 0); in tok822_scan_limit()
459 tp = tok822_alloc(TOK822_ATOM, (char *) 0); in tok822_scan_limit()
461 COLLECT(tp, str, ch, !IS_SPACE_TAB_CR_LF(ch) && !strchr(tok822_opchar, ch)); in tok822_scan_limit()
462 tok822_quote_atom(tp); in tok822_scan_limit()
465 head = tail = tp; in tok822_scan_limit()
469 tail = tok822_append(tail, tp); in tok822_scan_limit()
488 TOK822 *tp; in tok822_parse_limit() local
519 tp = tail->prev; in tok822_parse_limit()
520 while (tp->type) { in tok822_parse_limit()
521 if (tp->type == TOK822_COMMENT) { /* move comment to the side */ in tok822_parse_limit()
522 MOVE_COMMENT_AND_CONTINUE(tp, right); in tok822_parse_limit()
523 } else if (tp->type == ';') { /* rh side of named group */ in tok822_parse_limit()
524 right = tok822_group(TOK822_ADDR, tp, right, ADD_COMMA); in tok822_parse_limit()
526 } else if (tp->type == ':' && (state & DO_GROUP) != 0) { in tok822_parse_limit()
527 tp->type = TOK822_STARTGRP; in tok822_parse_limit()
528 (void) tok822_group(TOK822_ADDR, tp, right, NO_MISSING_COMMA); in tok822_parse_limit()
529 SKIP(tp, tp->type != ','); in tok822_parse_limit()
530 right = tp; in tok822_parse_limit()
532 } else if (tp->type == '>') { /* rh side of <route> */ in tok822_parse_limit()
533 right = tok822_group(TOK822_ADDR, tp, right, ADD_COMMA); in tok822_parse_limit()
534 SKIP_MOVE_COMMENT(tp, tp->type != '<', right); in tok822_parse_limit()
535 (void) tok822_group(TOK822_ADDR, tp, right, NO_MISSING_COMMA); in tok822_parse_limit()
536 SKIP(tp, tp->type > 0xff || strchr(">;,:", tp->type) == 0); in tok822_parse_limit()
537 right = tp; in tok822_parse_limit()
540 } else if (tp->type == TOK822_ATOM || tp->type == TOK822_QSTRING in tok822_parse_limit()
541 || tp->type == TOK822_DOMLIT) { in tok822_parse_limit()
543 right = tok822_group(TOK822_ADDR, tp, right, ADD_COMMA)->next; in tok822_parse_limit()
545 } else if (tp->type == ',') { in tok822_parse_limit()
546 right = tok822_group(TOK822_ADDR, tp, right, NO_MISSING_COMMA); in tok822_parse_limit()
551 tp = tp->prev; in tok822_parse_limit()
553 (void) tok822_group(TOK822_ADDR, tp, right, NO_MISSING_COMMA); in tok822_parse_limit()
559 tp = (head->next != tail ? head->next : 0); in tok822_parse_limit()
564 return (tp); in tok822_parse_limit()
569 static void tok822_quote_atom(TOK822 *tp) in tok822_quote_atom() argument
578 for (cp = vstring_str(tp->vstr); (ch = *(unsigned char *) cp) != 0; cp++) { in tok822_quote_atom()
581 tp->type = TOK822_QSTRING; in tok822_quote_atom()
589 static const char *tok822_comment(TOK822 *tp, const char *str) in tok822_comment() argument
600 VSTRING_ADDCH(tp->vstr, '('); in tok822_comment()
603 VSTRING_ADDCH(tp->vstr, ch); in tok822_comment()
613 VSTRING_ADDCH(tp->vstr, ch); in tok822_comment()
617 VSTRING_TERMINATE(tp->vstr); in tok822_comment()
668 TOK822 *tp; in tok822_print() local
670 for (tp = list; tp; tp = tp->next) { in tok822_print()
671 if (tp->type < TOK822_MINTOK) { in tok822_print()
672 vstream_printf("%*s %s \"%c\"\n", indent, "", "OP", tp->type); in tok822_print()
673 } else if (tp->type == TOK822_ADDR) { in tok822_print()
675 tok822_print(tp->head, indent + 2); in tok822_print()
676 } else if (tp->type == TOK822_STARTGRP) { in tok822_print()
680 tp->type == TOK822_COMMENT ? "comment" : in tok822_print()
681 tp->type == TOK822_ATOM ? "atom" : in tok822_print()
682 tp->type == TOK822_QSTRING ? "quoted string" : in tok822_print()
683 tp->type == TOK822_DOMLIT ? "domain literal" : in tok822_print()
684 tp->type == TOK822_ADDR ? "address" : in tok822_print()
685 "unknown\n", vstring_str(tp->vstr)); in tok822_print()