FreeBSD/contrib/mdocml/roff.c
/*
 * Handle in-line equation delimiters.
 */
Handle in-line equation delimiters.
Handle in - line equation delimiters .
static enum rofferr
roff_eqndelim(struct roff *r, struct buf *buf, int pos)
{
	char		*cp1, *cp2;
	const char	*bef_pr, *bef_nl, *mac, *aft_nl, *aft_pr;
	cp1 = buf->buf + pos;
	cp2 = strchr(cp1, r->eqn == NULL ?
	    r->last_eqn->odelim : r->last_eqn->cdelim);
	if (cp2 == NULL)
		return ROFF_CONT;
	*cp2++ = '\0';
	bef_pr = bef_nl = aft_nl = aft_pr = "";
	if (*buf->buf != '\0') {
		if (r->eqn == NULL)
			bef_pr = "\\&";
		bef_nl = "\n";
	}
	if (r->eqn == NULL) {
		while (*cp2 == ' ')
			cp2++;
		mac = ".EQ";
	} else
		mac = ".EN";
	if (*cp2 != '\0') {
		aft_nl = "\n";
		if (r->eqn != NULL)
			aft_pr = "\\&";
	}
	buf->sz = mandoc_asprintf(&cp1, "%s%s%s%s%s%s%s", buf->buf,
	    bef_pr, bef_nl, mac, aft_nl, aft_pr, cp2) + 1;
	free(buf->buf);
	buf->buf = cp1;
	r->eqn_inline = r->eqn == NULL;
	return ROFF_REPARSE;
}
static enum rofferr roff_eqndelim ( struct roff * r , struct buf * buf , int pos ) { char * cp1 , * cp2 ; const char * bef_pr , * bef_nl , * mac , * aft_nl , * aft_pr ; cp1 = buf -> buf + pos ; cp2 = strchr ( cp1 , r -> eqn == NULL ? r -> last_eqn -> odelim : r -> last_eqn -> cdelim ) ; if ( cp2 == NULL ) return ROFF_CONT ; * cp2 ++ = ' \0 ' ; bef_pr = bef_nl = aft_nl = aft_pr = " " ; if ( * buf -> buf != ' \0 ' ) { if ( r -> eqn == NULL ) bef_pr = " \\ " ; bef_nl = " \n " ; } if ( r -> eqn == NULL ) { while ( * cp2 == ' ' ) cp2 ++ ; mac = " " ; } else mac = " " ; if ( * cp2 != ' \0 ' ) { aft_nl = " \n " ; if ( r -> eqn != NULL ) aft_pr = " \\ " ; } buf -> sz = mandoc_asprintf ( & cp1 , " " , buf -> buf , bef_pr , bef_nl , mac , aft_nl , aft_pr , cp2 ) + 1 ; free ( buf -> buf ) ; buf -> buf = cp1 ; r -> eqn_inline = r -> eqn == NULL ; return ROFF_REPARSE ; }
Handle in-line equation delimiters.
Handle in - line equation delimiters .
/*
	 * Outside equations, look for an opening delimiter.
	 * If we are inside an equation, we already know it is
	 * in-line, or this function wouldn't have been called;
	 * so look for a closing delimiter.
	 */ /* Handle preceding text, protecting whitespace. */ /*
	 * Prepare replacing the delimiter with an equation macro
	 * and drop leading white space from the equation.
	 */ /* Handle following text, protecting whitespace. */ /* Do the actual replacement. */ /* Toggle the in-line state of the eqn subsystem. */