=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.224 retrieving revision 1.228 diff -u -p -r1.224 -r1.228 --- mandoc/mdoc.c 2014/08/10 23:54:41 1.224 +++ mandoc/mdoc.c 2014/10/20 15:50:24 1.228 @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.224 2014/08/10 23:54:41 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.228 2014/10/20 15:50:24 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -91,9 +91,6 @@ static struct mdoc_node *node_alloc(struct mdoc *, int enum mdoct, enum mdoc_type); static int node_append(struct mdoc *, struct mdoc_node *); -#if 0 -static int mdoc_preptext(struct mdoc *, int, char *, int); -#endif static int mdoc_ptext(struct mdoc *, int, char *, int); static int mdoc_pmacro(struct mdoc *, int, char *, int); @@ -208,6 +205,8 @@ mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep) n = node_alloc(mdoc, ep->ln, ep->pos, MDOC_MAX, MDOC_EQN); n->eqn = ep; + if (ep->ln > mdoc->last->line) + n->flags |= MDOC_LINE; if ( ! node_append(mdoc, n)) return(0); @@ -239,7 +238,8 @@ int mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs) { - mdoc->flags |= MDOC_NEWLINE; + if (mdoc->last->type != MDOC_EQN || ln > mdoc->last->line) + mdoc->flags |= MDOC_NEWLINE; /* * Let the roff nS register switch SYNOPSIS mode early, @@ -609,61 +609,7 @@ mdoc_node_relink(struct mdoc *mdoc, struct mdoc_node * return(node_append(mdoc, p)); } -#if 0 /* - * Pre-treat a text line. - * Text lines can consist of equations, which must be handled apart from - * the regular text. - * Thus, use this function to step through a line checking if it has any - * equations embedded in it. - * This must handle multiple equations AND equations that do not end at - * the end-of-line, i.e., will re-enter in the next roff parse. - */ -static int -mdoc_preptext(struct mdoc *mdoc, int line, char *buf, int offs) -{ - char *start, *end; - char delim; - - while ('\0' != buf[offs]) { - /* Mark starting position if eqn is set. */ - start = NULL; - if ('\0' != (delim = roff_eqndelim(mdoc->roff))) - if (NULL != (start = strchr(buf + offs, delim))) - *start++ = '\0'; - - /* Parse text as normal. */ - if ( ! mdoc_ptext(mdoc, line, buf, offs)) - return(0); - - /* Continue only if an equation exists. */ - if (NULL == start) - break; - - /* Read past the end of the equation. */ - offs += start - (buf + offs); - assert(start == &buf[offs]); - if (NULL != (end = strchr(buf + offs, delim))) { - *end++ = '\0'; - while (' ' == *end) - end++; - } - - /* Parse the equation itself. */ - roff_openeqn(mdoc->roff, NULL, line, offs, buf); - - /* Process a finished equation? */ - if (roff_closeeqn(mdoc->roff)) - if ( ! mdoc_addeqn(mdoc, roff_eqn(mdoc->roff))) - return(0); - offs += (end - (buf + offs)); - } - - return(1); -} -#endif - -/* * Parse free-form text, that is, a line that does not begin with the * control character. */ @@ -792,15 +738,6 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int int i, sv; char mac[5]; struct mdoc_node *n; - - /* Empty post-control lines are ignored. */ - - if ('"' == buf[offs]) { - mandoc_msg(MANDOCERR_COMMENT_BAD, mdoc->parse, - ln, offs, NULL); - return(1); - } else if ('\0' == buf[offs]) - return(1); sv = offs;