=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.248 retrieving revision 1.252 diff -u -p -r1.248 -r1.252 --- mandoc/mdoc.c 2015/04/19 14:00:19 1.248 +++ mandoc/mdoc.c 2015/04/23 16:17:44 1.252 @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.248 2015/04/19 14:00:19 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.252 2015/04/23 16:17:44 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012-2015 Ingo Schwarze @@ -89,38 +89,6 @@ static int mdoc_ptext(struct roff_man *, int, char static int mdoc_pmacro(struct roff_man *, int, char *, int); -void -mdoc_endparse(struct roff_man *mdoc) -{ - - mdoc_macroend(mdoc); -} - -void -mdoc_addeqn(struct roff_man *mdoc, const struct eqn *ep) -{ - struct roff_node *n; - - n = roff_node_alloc(mdoc, ep->ln, ep->pos, ROFFT_EQN, TOKEN_NONE); - n->eqn = ep; - if (ep->ln > mdoc->last->line) - n->flags |= MDOC_LINE; - roff_node_append(mdoc, n); - mdoc->next = ROFF_NEXT_SIBLING; -} - -void -mdoc_addspan(struct roff_man *mdoc, const struct tbl_span *sp) -{ - struct roff_node *n; - - n = roff_node_alloc(mdoc, sp->line, 0, ROFFT_TBL, TOKEN_NONE); - n->span = sp; - roff_node_append(mdoc, n); - mdoc_valid_post(mdoc); - mdoc->next = ROFF_NEXT_SIBLING; -} - /* * Main parse routine. Parses a single line -- really just hands off to * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()). @@ -255,33 +223,6 @@ mdoc_elem_alloc(struct roff_man *mdoc, int line, int p } void -mdoc_word_alloc(struct roff_man *mdoc, int line, int pos, const char *p) -{ - struct roff_node *n; - - n = roff_node_alloc(mdoc, line, pos, ROFFT_TEXT, TOKEN_NONE); - n->string = roff_strdup(mdoc->roff, p); - roff_node_append(mdoc, n); - mdoc_valid_post(mdoc); - mdoc->next = ROFF_NEXT_SIBLING; -} - -void -mdoc_word_append(struct roff_man *mdoc, const char *p) -{ - struct roff_node *n; - char *addstr, *newstr; - - n = mdoc->last; - addstr = roff_strdup(mdoc->roff, p); - mandoc_asprintf(&newstr, "%s %s", n->string, addstr); - free(addstr); - free(n->string); - n->string = newstr; - mdoc->next = ROFF_NEXT_SIBLING; -} - -void mdoc_node_relink(struct roff_man *mdoc, struct roff_node *p) { @@ -381,13 +322,13 @@ mdoc_ptext(struct roff_man *mdoc, int line, char *buf, * blank lines aren't allowed, but enough manuals assume this * behaviour that we want to work around it. */ - mdoc_elem_alloc(mdoc, line, offs, MDOC_sp, NULL); + roff_elem_alloc(mdoc, line, offs, MDOC_sp); mdoc->next = ROFF_NEXT_SIBLING; mdoc_valid_post(mdoc); return(1); } - mdoc_word_alloc(mdoc, line, offs, buf+offs); + roff_word_alloc(mdoc, line, offs, buf+offs); if (mdoc->flags & MDOC_LITERAL) return(1); @@ -565,43 +506,4 @@ mdoc_isdelim(const char *p) return(DELIM_MIDDLE); return(DELIM_NONE); -} - -void -mdoc_deroff(char **dest, const struct roff_node *n) -{ - char *cp; - size_t sz; - - if (n->type != ROFFT_TEXT) { - for (n = n->child; n; n = n->next) - mdoc_deroff(dest, n); - return; - } - - /* Skip leading whitespace. */ - - for (cp = n->string; '\0' != *cp; cp++) - if (0 == isspace((unsigned char)*cp)) - break; - - /* Skip trailing whitespace. */ - - for (sz = strlen(cp); sz; sz--) - if (0 == isspace((unsigned char)cp[sz-1])) - break; - - /* Skip empty strings. */ - - if (0 == sz) - return; - - if (NULL == *dest) { - *dest = mandoc_strndup(cp, sz); - return; - } - - mandoc_asprintf(&cp, "%s %*s", *dest, (int)sz, cp); - free(*dest); - *dest = cp; }