FreeBSD/contrib/mdocml/man_macro.c
/*
 * Close out a generic explicit macro.
 */
Close out a generic explicit macro.
Close out a generic explicit macro .
void
blk_close(MACRO_PROT_ARGS)
{
	int			 ntok;
	const struct roff_node	*nn;
	char			*p;
	int			 nrew, target;
	nrew = 1;
	switch (tok) {
	case MAN_RE:
		ntok = MAN_RS;
		if ( ! man_args(man, line, pos, buf, &p))
			break;
		for (nn = man->last->parent; nn; nn = nn->parent)
			if (nn->tok == ntok && nn->type == ROFFT_BLOCK)
				nrew++;
		target = strtol(p, &p, 10);
		if (*p != '\0')
			mandoc_vmsg(MANDOCERR_ARG_EXCESS, man->parse,
			    line, p - buf, "RE ... %s", p);
		if (target == 0)
			target = 1;
		nrew -= target;
		if (nrew < 1) {
			mandoc_vmsg(MANDOCERR_RE_NOTOPEN, man->parse,
			    line, ppos, "RE %d", target);
			return;
		}
		break;
	case MAN_UE:
		ntok = MAN_UR;
		break;
	default:
		abort();
	}
	for (nn = man->last->parent; nn; nn = nn->parent)
		if (nn->tok == ntok && nn->type == ROFFT_BLOCK && ! --nrew)
			break;
	if (nn == NULL) {
		mandoc_msg(MANDOCERR_BLK_NOTOPEN, man->parse,
		    line, ppos, man_macronames[tok]);
		rew_scope(man, MAN_PP);
	} else {
		line = man->last->line;
		ppos = man->last->pos;
		ntok = man->last->tok;
		man_unscope(man, nn);
		if (ntok == MAN_LP || ntok == MAN_PP || ntok == MAN_P) {
			*pos = strlen(buf);
			blk_imp(man, ntok, line, ppos, pos, buf);
		}
	}
}
void blk_close ( MACRO_PROT_ARGS ) { int ntok ; const struct roff_node * nn ; char * p ; int nrew , target ; nrew = 1 ; switch ( tok ) { case MAN_RE : ntok = MAN_RS ; if ( ! man_args ( man , line , pos , buf , & p ) ) break ; for ( nn = man -> last -> parent ; nn ; nn = nn -> parent ) if ( nn -> tok == ntok && nn -> type == ROFFT_BLOCK ) nrew ++ ; target = strtol ( p , & p , 10 ) ; if ( * p != ' \0 ' ) mandoc_vmsg ( MANDOCERR_ARG_EXCESS , man -> parse , line , p - buf , " " , p ) ; if ( target == 0 ) target = 1 ; nrew -= target ; if ( nrew < 1 ) { mandoc_vmsg ( MANDOCERR_RE_NOTOPEN , man -> parse , line , ppos , " " , target ) ; return ; } break ; case MAN_UE : ntok = MAN_UR ; break ; default : abort ( ) ; } for ( nn = man -> last -> parent ; nn ; nn = nn -> parent ) if ( nn -> tok == ntok && nn -> type == ROFFT_BLOCK && ! -- nrew ) break ; if ( nn == NULL ) { mandoc_msg ( MANDOCERR_BLK_NOTOPEN , man -> parse , line , ppos , man_macronames [ tok ] ) ; rew_scope ( man , MAN_PP ) ; } else { line = man -> last -> line ; ppos = man -> last -> pos ; ntok = man -> last -> tok ; man_unscope ( man , nn ) ; if ( ntok == MAN_LP || ntok == MAN_PP || ntok == MAN_P ) { * pos = strlen ( buf ) ; blk_imp ( man , ntok , line , ppos , pos , buf ) ; } } }
Close out a generic explicit macro.
Close out a generic explicit macro .
/* Move a trailing paragraph behind the block. */