static void blk_part_exp(MACRO_PROT_ARGS) { int la, nl; enum margserr ac; struct roff_node *head; /* keep track of head */ char *p; nl = MDOC_NEWLINE & mdoc->flags; /* * The opening of an explicit macro having zero or more leading * punctuation nodes; a head with optional single element (the * case of `Eo'); and a body that may be empty. */ roff_block_alloc(mdoc, line, ppos, tok); head = NULL; for (;;) { la = *pos; ac = mdoc_args(mdoc, line, pos, buf, tok, &p); if (ac == ARGS_PUNCT || ac == ARGS_EOLN) break; /* Flush out leading punctuation. */ if (head == NULL && ac != ARGS_QWORD && mdoc_isdelim(p) == DELIM_OPEN) { dword(mdoc, line, la, p, DELIM_OPEN, 0); continue; } if (head == NULL) { head = roff_head_alloc(mdoc, line, ppos, tok); if (tok == MDOC_Eo) /* Not parsed. */ dword(mdoc, line, la, p, DELIM_MAX, 0); rew_last(mdoc, head); roff_body_alloc(mdoc, line, ppos, tok); if (tok == MDOC_Eo) continue; } if (macro_or_word(mdoc, tok, line, la, pos, buf, 1)) break; } /* Clean-up to leave in a consistent state. */ if (head == NULL) { rew_last(mdoc, roff_head_alloc(mdoc, line, ppos, tok)); roff_body_alloc(mdoc, line, ppos, tok); } if (nl) append_delims(mdoc, line, pos, buf); }
/* * Parse an implicit-block macro. These contain a ROFFT_HEAD and a * ROFFT_BODY contained within a ROFFT_BLOCK. Rules for closing out other * scopes, such as `SH' closing out an `SS', are defined in the rew * routines. */ void blk_imp(MACRO_PROT_ARGS) { int la; char *p; struct roff_node *n; rew_scope(man, tok); n = roff_block_alloc(man, line, ppos, tok); if (n->tok == MAN_SH || n->tok == MAN_SS) man->flags &= ~MAN_LITERAL; n = roff_head_alloc(man, line, ppos, tok); /* Add line arguments. */ for (;;) { la = *pos; if ( ! man_args(man, line, pos, buf, &p)) break; roff_word_alloc(man, line, la, p); } /* * For macros having optional next-line scope, * keep the head open if there were no arguments. * For `TP', always keep the head open. */ if (man_macros[tok].flags & MAN_SCOPED && (tok == MAN_TP || n == man->last)) { man->flags |= MAN_BLINE; return; } /* Close out the head and open the body. */ man_unscope(man, n); roff_body_alloc(man, line, ppos, tok); }
void blk_exp(MACRO_PROT_ARGS) { struct roff_node *head; char *p; int la; rew_scope(man, tok); roff_block_alloc(man, line, ppos, tok); head = roff_head_alloc(man, line, ppos, tok); la = *pos; if (man_args(man, line, pos, buf, &p)) roff_word_alloc(man, line, la, p); if (buf[*pos] != '\0') mandoc_vmsg(MANDOCERR_ARG_EXCESS, man->parse, line, *pos, "%s ... %s", roff_name[tok], buf + *pos); man_unscope(man, head); roff_body_alloc(man, line, ppos, tok); }