Пример #1
0
/* ARGSUSED */
static int
termp_an_pre(DECL_ARGS)
{

	if (NULL == n->child)
		return(1);

	/*
	 * If not in the AUTHORS section, `An -split' will cause
	 * newlines to occur before the author name.  If in the AUTHORS
	 * section, by default, the first `An' invocation is nosplit,
	 * then all subsequent ones, regardless of whether interspersed
	 * with other macros/text, are split.  -split, in this case,
	 * will override the condition of the implied first -nosplit.
	 */
	
	if (n->sec == SEC_AUTHORS) {
		if ( ! (TERMP_ANPREC & p->flags)) {
			if (TERMP_SPLIT & p->flags)
				term_newln(p);
			return(1);
		}
		if (TERMP_NOSPLIT & p->flags)
			return(1);
		term_newln(p);
		return(1);
	}

	if (TERMP_SPLIT & p->flags)
		term_newln(p);

	return(1);
}
Пример #2
0
/*
 * This decides how to assert whitespace before any of the SYNOPSIS set
 * of macros (which, as in the case of Ft/Fo and Ft/Fn, may contain
 * macro combos).
 */
static void
synopsis_pre(struct termp *p, const struct mdoc_node *n)
{
	/* 
	 * Obviously, if we're not in a SYNOPSIS or no prior macros
	 * exist, do nothing.
	 */
	if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
		return;

	/*
	 * If we're the second in a pair of like elements, emit our
	 * newline and return.  UNLESS we're `Fo', `Fn', `Fn', in which
	 * case we soldier on.
	 */
	if (n->prev->tok == n->tok && 
			MDOC_Ft != n->tok && 
			MDOC_Fo != n->tok && 
			MDOC_Fn != n->tok) {
		term_newln(p);
		return;
	}

	/*
	 * If we're one of the SYNOPSIS set and non-like pair-wise after
	 * another (or Fn/Fo, which we've let slip through) then assert
	 * vertical space, else only newline and move on.
	 */
	switch (n->prev->tok) {
	case (MDOC_Fd):
		/* FALLTHROUGH */
	case (MDOC_Fn):
		/* FALLTHROUGH */
	case (MDOC_Fo):
		/* FALLTHROUGH */
	case (MDOC_In):
		/* FALLTHROUGH */
	case (MDOC_Vt):
		term_vspace(p);
		break;
	case (MDOC_Ft):
		if (MDOC_Fn != n->tok && MDOC_Fo != n->tok) {
			term_vspace(p);
			break;
		}
		/* FALLTHROUGH */
	default:
		term_newln(p);
		break;
	}
}
Пример #3
0
static void
post_SH(DECL_ARGS)
{

	switch (n->type) {
	case ROFFT_HEAD:
		term_newln(p);
		break;
	case ROFFT_BODY:
		term_newln(p);
		break;
	default:
		break;
	}
}
Пример #4
0
/* ARGSUSED */
static void
post_SH(DECL_ARGS)
{
	
	switch (n->type) {
	case (MAN_HEAD):
		term_newln(p);
		break;
	case (MAN_BODY):
		term_newln(p);
		break;
	default:
		break;
	}
}
Пример #5
0
/* ARGSUSED */
static void
termp_bl_post(DECL_ARGS)
{

	if (MDOC_BLOCK == n->type)
		term_newln(p);
}
Пример #6
0
static void
post_HP(DECL_ARGS)
{

	switch (n->type) {
	case ROFFT_BODY:
		term_newln(p);

		/*
		 * Compatibility with a groff bug.
		 * The .HP macro uses the undocumented .tag request
		 * which causes a line break and cancels no-space
		 * mode even if there isn't any output.
		 */

		if (n->child == NULL)
			term_vspace(p);

		p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
		p->trailspace = 0;
		p->offset = mt->offset;
		p->rmargin = p->maxrmargin;
		break;
	default:
		break;
	}
}
Пример #7
0
static int
termp_an_pre(DECL_ARGS)
{

	if (n->norm->An.auth == AUTH_split) {
		p->flags &= ~TERMP_NOSPLIT;
		p->flags |= TERMP_SPLIT;
		return(0);
	}
	if (n->norm->An.auth == AUTH_nosplit) {
		p->flags &= ~TERMP_SPLIT;
		p->flags |= TERMP_NOSPLIT;
		return(0);
	}

	if (n->child == NULL)
		return(0);

	if (p->flags & TERMP_SPLIT)
		term_newln(p);

	if (n->sec == SEC_AUTHORS && ! (p->flags & TERMP_NOSPLIT))
		p->flags |= TERMP_SPLIT;

	return(1);
}
Пример #8
0
static int
termp_sp_pre(DECL_ARGS)
{
	struct roffsu	 su;
	int		 i, len;

	switch (n->tok) {
	case MDOC_sp:
		if (n->child) {
			if ( ! a2roffsu(n->child->string, &su, SCALE_VS))
				su.scale = 1.0;
			len = term_vspan(p, &su);
		} else
			len = 1;
		break;
	case MDOC_br:
		len = 0;
		break;
	default:
		len = 1;
		fn_prio = 0;
		break;
	}

	if (0 == len)
		term_newln(p);
	else if (len < 0)
		p->skipvsp -= len;
	else
		for (i = 0; i < len; i++)
			term_vspace(p);

	return 0;
}
Пример #9
0
static int
pre_RS(DECL_ARGS)
{
	struct roffsu	 su;

	switch (n->type) {
	case MAN_BLOCK:
		term_newln(p);
		return(1);
	case MAN_HEAD:
		return(0);
	default:
		break;
	}

	n = n->parent->head;
	n->aux = SHRT_MAX + 1;
	if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EN))
		n->aux = term_hspan(p, &su);
	if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
		n->aux = -mt->offset;
	else if (n->aux > SHRT_MAX)
		n->aux = term_len(p, p->defindent);

	mt->offset += n->aux;
	p->offset = mt->offset;
	p->rmargin = p->maxrmargin;

	if (++mt->lmarginsz < MAXMARGINS)
		mt->lmargincur = mt->lmarginsz;

	mt->lmargin[mt->lmargincur] = mt->lmargin[mt->lmargincur - 1];
	return(1);
}
Пример #10
0
/* ARGSUSED */
static void
termp_ss_post(DECL_ARGS)
{

	if (MDOC_HEAD == n->type)
		term_newln(p);
}
Пример #11
0
static void
termp_sh_post(DECL_ARGS)
{

	switch (n->type) {
	case ROFFT_HEAD:
		term_newln(p);
		break;
	case ROFFT_BODY:
		term_newln(p);
		p->offset = 0;
		break;
	default:
		break;
	}
}
Пример #12
0
static int
termp_ex_pre(DECL_ARGS)
{
	int		 nchild;

	term_newln(p);
	term_word(p, "The");

	nchild = n->nchild;
	for (n = n->child; n; n = n->next) {
		term_fontpush(p, TERMFONT_BOLD);
		term_word(p, n->string);
		term_fontpop(p);

		if (nchild > 2 && n->next) {
			p->flags |= TERMP_NOSPACE;
			term_word(p, ",");
		}

		if (n->next && NULL == n->next->next)
			term_word(p, "and");
	}

	if (nchild > 1)
		term_word(p, "utilities exit\\~0");
	else
		term_word(p, "utility exits\\~0");

	term_word(p, "on success, and\\~>0 if an error occurs.");

	p->flags |= TERMP_SENTENCE;
	return 0;
}
Пример #13
0
static int
termp_ex_pre(DECL_ARGS)
{
	struct roff_node *nch;

	term_newln(p);
	term_word(p, "The");

	for (nch = n->child; nch != NULL; nch = nch->next) {
		term_fontpush(p, TERMFONT_BOLD);
		term_word(p, nch->string);
		term_fontpop(p);

		if (nch->next == NULL)
			continue;

		if (nch->prev != NULL || nch->next->next != NULL) {
			p->flags |= TERMP_NOSPACE;
			term_word(p, ",");
		}

		if (nch->next->next == NULL)
			term_word(p, "and");
	}

	if (n->child != NULL && n->child->next != NULL)
		term_word(p, "utilities exit\\~0");
	else
		term_word(p, "utility exits\\~0");

	term_word(p, "on success, and\\~>0 if an error occurs.");

	p->flags |= TERMP_SENTENCE;
	return 0;
}
Пример #14
0
static void
termp_bl_post(DECL_ARGS)
{

	if (n->type == ROFFT_BLOCK)
		term_newln(p);
}
Пример #15
0
/* ARGSUSED */
static int
pre_RS(DECL_ARGS)
{
	int		 ival;
	size_t		 sz;

	switch (n->type) {
	case (MAN_BLOCK):
		term_newln(p);
		return(1);
	case (MAN_HEAD):
		return(0);
	default:
		break;
	}

	sz = term_len(p, p->defindent);

	if (NULL != (n = n->parent->head->child))
		if ((ival = a2width(p, n->string)) >= 0) 
			sz = (size_t)ival;

	mt->offset += sz;
	p->rmargin = p->maxrmargin;
	p->offset = mt->offset < p->rmargin ? mt->offset : p->rmargin;

	if (++mt->lmarginsz < MAXMARGINS)
		mt->lmargincur = mt->lmarginsz;

	mt->lmargin[mt->lmargincur] = mt->lmargin[mt->lmargincur - 1];
	return(1);
}
Пример #16
0
/* ARGSUSED */
static void
post_RS(DECL_ARGS)
{
	int		 ival;
	size_t		 sz;

	switch (n->type) {
	case (MAN_BLOCK):
		return;
	case (MAN_HEAD):
		return;
	default:
		term_newln(p);
		break;
	}

	sz = term_len(p, p->defindent);

	if (NULL != (n = n->parent->head->child)) 
		if ((ival = a2width(p, n->string)) >= 0) 
			sz = (size_t)ival;

	mt->offset = mt->offset < sz ?  0 : mt->offset - sz;
	p->offset = mt->offset;

	if (--mt->lmarginsz < MAXMARGINS)
		mt->lmargincur = mt->lmarginsz;
}
Пример #17
0
/* ARGSUSED */
static int
pre_sp(DECL_ARGS)
{
	size_t		 i, len;

	if ((NULL == n->prev && n->parent)) {
		if (MAN_SS == n->parent->tok)
			return(0);
		if (MAN_SH == n->parent->tok)
			return(0);
	}

	switch (n->tok) {
	case (MAN_br):
		len = 0;
		break;
	default:
		len = n->child ? a2height(p, n->child->string) : 1;
		break;
	}

	if (0 == len)
		term_newln(p);
	for (i = 0; i < len; i++)
		term_vspace(p);

	return(0);
}
Пример #18
0
/* ARGSUSED */
static int
pre_RS(DECL_ARGS)
{
	const struct man_node	*nn;
	int			 ival;

	switch (n->type) {
	case (MAN_BLOCK):
		term_newln(p);
		return(1);
	case (MAN_HEAD):
		return(0);
	default:
		break;
	}

	if (NULL == (nn = n->parent->head->child)) {
		mt->offset = mt->lmargin + term_len(p, INDENT);
		p->offset = mt->offset;
		return(1);
	}

	if ((ival = a2width(p, nn->string)) < 0)
		return(1);

	mt->offset = term_len(p, INDENT) + (size_t)ival;
	p->offset = mt->offset;

	return(1);
}
Пример #19
0
/* ARGSUSED */
static int
pre_literal(DECL_ARGS)
{

	term_newln(p);

	if (MAN_nf == n->tok)
		mt->fl |= MANT_LITERAL;
	else
		mt->fl &= ~MANT_LITERAL;

	/*
	 * Unlike .IP and .TP, .HP does not have a HEAD.
	 * So in case a second call to term_flushln() is needed,
	 * indentation has to be set up explicitly.
	 */
	if (MAN_HP == n->parent->tok && p->rmargin < p->maxrmargin) {
		p->offset = p->rmargin;
		p->rmargin = p->maxrmargin;
		p->flags &= ~(TERMP_NOBREAK | TERMP_TWOSPACE);
		p->flags |= TERMP_NOSPACE;
	}

	return(0);
}
Пример #20
0
static void
termp_ss_post(DECL_ARGS)
{

	if (n->type == ROFFT_HEAD || n->type == ROFFT_BODY)
		term_newln(p);
}
Пример #21
0
static void
termp_lb_post(DECL_ARGS)
{

	if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
		term_newln(p);
}
Пример #22
0
/* ARGSUSED */
static void
termp_d1_post(DECL_ARGS)
{

	if (MDOC_BLOCK != n->type) 
		return;
	term_newln(p);
}
Пример #23
0
/*
 * Asserts a vertical space (a full, empty line-break between lines).
 * Note that if used twice, this will cause two blank spaces and so on.
 * All data in the output buffer is flushed prior to the newline
 * assertion.
 */
void
term_vspace(struct termp *p)
{

	term_newln(p);
	p->viscol = 0;
	(*p->endline)(p);
}
Пример #24
0
static int
termp_d1_pre(DECL_ARGS)
{

	if (n->type != ROFFT_BLOCK)
		return 1;
	term_newln(p);
	p->offset += term_len(p, p->defindent + 1);
	return 1;
}
Пример #25
0
/* ARGSUSED */
static int
termp_d1_pre(DECL_ARGS)
{

	if (MDOC_BLOCK != n->type)
		return(1);
	term_newln(p);
	p->offset += term_len(p, p->defindent + 1);
	return(1);
}
Пример #26
0
/*
 * Asserts a vertical space (a full, empty line-break between lines).
 * Note that if used twice, this will cause two blank spaces and so on.
 * All data in the output buffer is flushed prior to the newline
 * assertion.
 */
void
term_vspace(struct termp *p)
{

	term_newln(p);
	p->viscol = 0;
	if (0 < p->skipvsp)
		p->skipvsp--;
	else
		(*p->endline)(p);
}
Пример #27
0
static int
pre_sp(DECL_ARGS)
{
	char		*s;
	size_t		 i, len;
	int		 neg;

	if ((NULL == n->prev && n->parent)) {
		switch (n->parent->tok) {
		case MAN_SH:
			/* FALLTHROUGH */
		case MAN_SS:
			/* FALLTHROUGH */
		case MAN_PP:
			/* FALLTHROUGH */
		case MAN_LP:
			/* FALLTHROUGH */
		case MAN_P:
			/* FALLTHROUGH */
			return(0);
		default:
			break;
		}
	}

	neg = 0;
	switch (n->tok) {
	case MAN_br:
		len = 0;
		break;
	default:
		if (NULL == n->child) {
			len = 1;
			break;
		}
		s = n->child->string;
		if ('-' == *s) {
			neg = 1;
			s++;
		}
		len = a2height(p, s);
		break;
	}

	if (0 == len)
		term_newln(p);
	else if (neg)
		p->skipvsp += len;
	else
		for (i = 0; i < len; i++)
			term_vspace(p);

	return(0);
}
Пример #28
0
static void
roff_term_pre_br(ROFF_TERM_ARGS)
{
	term_newln(p);
	if (p->flags & TERMP_BRIND) {
		p->tcol->offset = p->tcol->rmargin;
		p->tcol->rmargin = p->maxrmargin;
		p->trailspace = 0;
		p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
		p->flags |= TERMP_NOSPACE;
	}
}
Пример #29
0
/* ARGSUSED */
static void
termp_it_post(DECL_ARGS)
{
	enum mdoc_list	   type;

	if (MDOC_BLOCK == n->type)
		return;

	type = n->parent->parent->parent->norm->Bl.type;

	switch (type) {
	case (LIST_item):
		/* FALLTHROUGH */
	case (LIST_diag):
		/* FALLTHROUGH */
	case (LIST_inset):
		if (MDOC_BODY == n->type)
			term_newln(p);
		break;
	case (LIST_column):
		if (MDOC_BODY == n->type)
			term_flushln(p);
		break;
	default:
		term_newln(p);
		break;
	}

	/* 
	 * Now that our output is flushed, we can reset our tags.  Since
	 * only `It' sets these flags, we're free to assume that nobody
	 * has munged them in the meanwhile.
	 */

	p->flags &= ~TERMP_DANGLE;
	p->flags &= ~TERMP_NOBREAK;
	p->flags &= ~TERMP_TWOSPACE;
	p->flags &= ~TERMP_NOLPAD;
	p->flags &= ~TERMP_HANG;
}
Пример #30
0
static int
termp_rv_pre(DECL_ARGS)
{
	int		 nchild;

	term_newln(p);

	nchild = n->nchild;
	if (nchild > 0) {
		term_word(p, "The");

		for (n = n->child; n; n = n->next) {
			term_fontpush(p, TERMFONT_BOLD);
			term_word(p, n->string);
			term_fontpop(p);

			p->flags |= TERMP_NOSPACE;
			term_word(p, "()");

			if (n->next == NULL)
				continue;

			if (nchild > 2) {
				p->flags |= TERMP_NOSPACE;
				term_word(p, ",");
			}
			if (n->next->next == NULL)
				term_word(p, "and");
		}

		if (nchild > 1)
			term_word(p, "functions return");
		else
			term_word(p, "function returns");

		term_word(p, "the value\\~0 if successful;");
	} else
		term_word(p, "Upon successful completion,"
		    " the value\\~0 is returned;");

	term_word(p, "otherwise the value\\~\\-1 is returned"
	    " and the global variable");

	term_fontpush(p, TERMFONT_UNDER);
	term_word(p, "errno");
	term_fontpop(p);

	term_word(p, "is set to indicate the error.");
	p->flags |= TERMP_SENTENCE;

	return 0;
}