X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/fee8aca887653490f8c052e474d2a620140e741d..90b416207a9708302ecc3333c3f3aa4c660122b1:/man.c diff --git a/man.c b/man.c index 593777ac..61f2a5eb 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.109 2011/07/21 10:24:35 kristaps Exp $ */ +/* $Id: man.c,v 1.114 2011/11/16 22:39:05 joerg Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * @@ -320,16 +320,9 @@ int man_word_alloc(struct man *m, int line, int pos, const char *word) { struct man_node *n; - size_t sv, len; - - len = strlen(word); n = man_node_alloc(m, line, pos, MAN_TEXT, MAN_MAX); - n->string = mandoc_malloc(len + 1); - sv = strlcpy(n->string, word, len + 1); - - /* Prohibit truncation. */ - assert(sv < len + 1); + n->string = roff_strdup(m->roff, word); if ( ! man_node_append(m, n)) return(0); @@ -550,12 +543,44 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) n = n->parent; mandoc_vmsg(MANDOCERR_LINESCOPE, m->parse, n->line, - n->pos, "%s", man_macronames[n->tok]); + n->pos, "%s breaks %s", man_macronames[tok], + man_macronames[n->tok]); man_node_delete(m, n); m->flags &= ~MAN_ELINE; } + /* + * Remove prior BLINE macro that is being clobbered. + */ + if ((m->flags & MAN_BLINE) && + (MAN_BSCOPE & man_macros[tok].flags)) { + n = m->last; + + /* Might be a text node like 8 in + * .TP 8 + * .SH foo + */ + if (MAN_TEXT == n->type) + n = n->parent; + + /* Remove element that didn't end BLINE, if any. */ + if ( ! (MAN_BSCOPE & man_macros[n->tok].flags)) + n = n->parent; + + assert(MAN_HEAD == n->type); + n = n->parent; + assert(MAN_BLOCK == n->type); + assert(MAN_SCOPED & man_macros[n->tok].flags); + + mandoc_vmsg(MANDOCERR_LINESCOPE, m->parse, n->line, + n->pos, "%s breaks %s", man_macronames[tok], + man_macronames[n->tok]); + + man_node_delete(m, n); + m->flags &= ~MAN_BLINE; + } + /* * Save the fact that we're in the next-line for a block. In * this way, embedded roff instructions can "remember" state @@ -655,3 +680,11 @@ man_node_unlink(struct man *m, struct man_node *n) if (m && m->first == n) m->first = NULL; } + +const struct mparse * +man_mparse(const struct man *m) +{ + + assert(m && m->parse); + return(m->parse); +}