version 1.148, 2015/01/24 02:41:49 |
version 1.149, 2015/01/30 21:28:46 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2011 Joerg Sonnenberger <joerg@netbsd.org> |
* Copyright (c) 2011 Joerg Sonnenberger <joerg@netbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 48 const char *const __man_macronames[MAN_MAX] = { |
|
Line 48 const char *const __man_macronames[MAN_MAX] = { |
|
|
|
const char * const *man_macronames = __man_macronames; |
const char * const *man_macronames = __man_macronames; |
|
|
|
static void man_alloc1(struct man *); |
|
static void man_breakscope(struct man *, enum mant); |
|
static void man_descope(struct man *, int, int); |
|
static void man_free1(struct man *); |
static struct man_node *man_node_alloc(struct man *, int, int, |
static struct man_node *man_node_alloc(struct man *, int, int, |
enum man_type, enum mant); |
enum man_type, enum mant); |
static void man_node_append(struct man *, struct man_node *); |
static void man_node_append(struct man *, struct man_node *); |
Line 56 static void man_node_unlink(struct man *, |
|
Line 60 static void man_node_unlink(struct man *, |
|
struct man_node *); |
struct man_node *); |
static int man_ptext(struct man *, int, char *, int); |
static int man_ptext(struct man *, int, char *, int); |
static int man_pmacro(struct man *, int, char *, int); |
static int man_pmacro(struct man *, int, char *, int); |
static void man_free1(struct man *); |
|
static void man_alloc1(struct man *); |
|
static void man_descope(struct man *, int, int); |
|
|
|
|
|
const struct man_node * |
const struct man_node * |
Line 337 man_addspan(struct man *man, const struct tbl_span *sp |
|
Line 338 man_addspan(struct man *man, const struct tbl_span *sp |
|
{ |
{ |
struct man_node *n; |
struct man_node *n; |
|
|
|
man_breakscope(man, MAN_MAX); |
n = man_node_alloc(man, sp->line, 0, MAN_TBL, MAN_MAX); |
n = man_node_alloc(man, sp->line, 0, MAN_TBL, MAN_MAX); |
n->span = sp; |
n->span = sp; |
man_node_append(man, n); |
man_node_append(man, n); |
Line 493 man_pmacro(struct man *man, int ln, char *buf, int off |
|
Line 495 man_pmacro(struct man *man, int ln, char *buf, int off |
|
ln, offs - 1, NULL); |
ln, offs - 1, NULL); |
|
|
/* |
/* |
* Remove prior ELINE macro, as it's being clobbered by a new |
* Some macros break next-line scopes; otherwise, remember |
* macro. Note that NSCOPED macros do not close out ELINE |
* whether we are in next-line scope for a block head. |
* macros---they don't print text---so we let those slip by. |
|
*/ |
*/ |
|
|
if ( ! (man_macros[tok].flags & MAN_NSCOPED) && |
man_breakscope(man, tok); |
man->flags & MAN_ELINE) { |
|
n = man->last; |
|
assert(MAN_TEXT != n->type); |
|
|
|
/* Remove repeated NSCOPED macros causing ELINE. */ |
|
|
|
if (man_macros[n->tok].flags & MAN_NSCOPED) |
|
n = n->parent; |
|
|
|
mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, n->line, |
|
n->pos, "%s breaks %s", man_macronames[tok], |
|
man_macronames[n->tok]); |
|
|
|
man_node_delete(man, n); |
|
man->flags &= ~MAN_ELINE; |
|
} |
|
|
|
/* |
|
* Remove prior BLINE macro that is being clobbered. |
|
*/ |
|
if ((man->flags & MAN_BLINE) && |
|
(man_macros[tok].flags & MAN_BSCOPE)) { |
|
n = man->last; |
|
|
|
/* Might be a text node like 8 in |
|
* .TP 8 |
|
* .SH foo |
|
*/ |
|
if (n->type == MAN_TEXT) |
|
n = n->parent; |
|
|
|
/* Remove element that didn't end BLINE, if any. */ |
|
if ( ! (man_macros[n->tok].flags & MAN_BSCOPE)) |
|
n = n->parent; |
|
|
|
assert(n->type == MAN_HEAD); |
|
n = n->parent; |
|
assert(n->type == MAN_BLOCK); |
|
assert(man_macros[n->tok].flags & MAN_SCOPED); |
|
|
|
mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, n->line, |
|
n->pos, "%s breaks %s", man_macronames[tok], |
|
man_macronames[n->tok]); |
|
|
|
man_node_delete(man, n); |
|
man->flags &= ~MAN_BLINE; |
|
} |
|
|
|
/* Remember whether we are in next-line scope for a block head. */ |
|
|
|
bline = man->flags & MAN_BLINE; |
bline = man->flags & MAN_BLINE; |
|
|
/* Call to handler... */ |
/* Call to handler... */ |
Line 581 man_pmacro(struct man *man, int ln, char *buf, int off |
|
Line 532 man_pmacro(struct man *man, int ln, char *buf, int off |
|
man_unscope(man, man->last->parent); |
man_unscope(man, man->last->parent); |
man_body_alloc(man, ln, ppos, man->last->tok); |
man_body_alloc(man, ln, ppos, man->last->tok); |
return(1); |
return(1); |
|
} |
|
|
|
void |
|
man_breakscope(struct man *man, enum mant tok) |
|
{ |
|
struct man_node *n; |
|
|
|
/* |
|
* An element next line scope is open, |
|
* and the new macro is not allowed inside elements. |
|
* Delete the element that is being broken. |
|
*/ |
|
|
|
if (man->flags & MAN_ELINE && (tok == MAN_MAX || |
|
! (man_macros[tok].flags & MAN_NSCOPED))) { |
|
n = man->last; |
|
assert(n->type != MAN_TEXT); |
|
if (man_macros[n->tok].flags & MAN_NSCOPED) |
|
n = n->parent; |
|
|
|
mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, |
|
n->line, n->pos, "%s breaks %s", |
|
tok == MAN_MAX ? "TS" : man_macronames[tok], |
|
man_macronames[n->tok]); |
|
|
|
man_node_delete(man, n); |
|
man->flags &= ~MAN_ELINE; |
|
} |
|
|
|
/* |
|
* A block header next line scope is open, |
|
* and the new macro is not allowed inside block headers. |
|
* Delete the block that is being broken. |
|
*/ |
|
|
|
if (man->flags & MAN_BLINE && (tok == MAN_MAX || |
|
man_macros[tok].flags & MAN_BSCOPE)) { |
|
n = man->last; |
|
if (n->type == MAN_TEXT) |
|
n = n->parent; |
|
if ( ! (man_macros[n->tok].flags & MAN_BSCOPE)) |
|
n = n->parent; |
|
|
|
assert(n->type == MAN_HEAD); |
|
n = n->parent; |
|
assert(n->type == MAN_BLOCK); |
|
assert(man_macros[n->tok].flags & MAN_SCOPED); |
|
|
|
mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, |
|
n->line, n->pos, "%s breaks %s", |
|
tok == MAN_MAX ? "TS" : man_macronames[tok], |
|
man_macronames[n->tok]); |
|
|
|
man_node_delete(man, n); |
|
man->flags &= ~MAN_BLINE; |
|
} |
} |
} |
|
|
/* |
/* |