version 1.167, 2015/02/02 15:02:49 |
version 1.170, 2015/02/03 00:48:47 |
Line 54 static void append_delims(struct mdoc *, int, int *, |
|
Line 54 static void append_delims(struct mdoc *, int, int *, |
|
static enum mdoct lookup(struct mdoc *, enum mdoct, |
static enum mdoct lookup(struct mdoc *, enum mdoct, |
int, int, const char *); |
int, int, const char *); |
static int macro_or_word(MACRO_PROT_ARGS, int); |
static int macro_or_word(MACRO_PROT_ARGS, int); |
static int make_pending(struct mdoc_node *, enum mdoct, |
static void make_pending(struct mdoc *, struct mdoc_node *, |
struct mdoc *, int, int); |
struct mdoc_node *, int, int); |
static int parse_rest(struct mdoc *, enum mdoct, |
static int parse_rest(struct mdoc *, enum mdoct, |
int, int *, char *); |
int, int *, char *); |
static enum mdoct rew_alt(enum mdoct); |
static enum mdoct rew_alt(enum mdoct); |
Line 460 rew_elem(struct mdoc *mdoc, enum mdoct tok) |
|
Line 460 rew_elem(struct mdoc *mdoc, enum mdoct tok) |
|
} |
} |
|
|
/* |
/* |
* We are trying to close a block identified by tok, |
* We are trying to close the block *breaker, |
* but the child block *broken is still open. |
* but the child block *broken is still open. |
* Thus, postpone closing the tok block |
* Thus, postpone closing the *breaker |
* until the rew_pending() call closing *broken. |
* until the rew_pending() call closing *broken. |
*/ |
*/ |
static int |
static void |
make_pending(struct mdoc_node *broken, enum mdoct tok, |
make_pending(struct mdoc *mdoc, struct mdoc_node *breaker, |
struct mdoc *mdoc, int line, int ppos) |
struct mdoc_node *broken, int line, int ppos) |
{ |
{ |
struct mdoc_node *breaker; |
struct mdoc_node *n; |
|
|
|
mandoc_vmsg(MANDOCERR_BLK_NEST, mdoc->parse, line, ppos, |
|
"%s breaks %s", mdoc_macronames[breaker->tok], |
|
mdoc_macronames[broken->tok]); |
|
|
/* |
/* |
* Iterate backwards, searching for the block matching tok, |
* If the *broken block (Z) is already broken by a block (B) |
* that is, the block breaking the *broken block. |
* contained in the breaker (A), make the breaker pending |
|
* on that inner breaker (B). Graphically, |
|
* |
|
* breaker=[A! broken=n=[B!->A (old broken=)[Z->B B] A] Z] |
|
* |
|
* In these graphics, "->" indicates the "pending" pointer and |
|
* "!" indicates the MDOC_BREAK flag. Each of the cases gets |
|
* one additional pointer (B->A) and one additional flag (A!). |
*/ |
*/ |
for (breaker = broken->parent; breaker; breaker = breaker->parent) { |
|
|
|
/* |
for (n = broken->parent; ; n = n->parent) |
* If the *broken block (Z) is already broken and we |
if (n == broken->pending) |
* encounter its breaker (B), make the tok block (A) |
broken = n; |
* pending on that inner breaker (B). |
else if (n == breaker) |
* Graphically, [A breaker=[B! broken=[Z->B B] tok=A] Z] |
break; |
* becomes breaker=[A broken=[B! [Z->B B] tok=A] Z] |
|
* and finally [A! [B!->A [Z->B B] A] Z]. |
|
* In these graphics, "->" indicates the "pending" |
|
* pointer and "!" indicates the MDOC_BREAK flag. |
|
* Each of the cases gets one additional pointer (B->A) |
|
* and one additional flag (A!). |
|
*/ |
|
if (breaker == broken->pending) { |
|
broken = breaker; |
|
continue; |
|
} |
|
|
|
if (REWIND_THIS != rew_dohalt(tok, MDOC_BLOCK, breaker)) |
/* |
continue; |
* Found the breaker. |
if (MDOC_BODY == broken->type) |
* |
broken = broken->parent; |
* If another, outer breaker (X) is already pending on |
|
* the *broken block (B), we must not clobber the link |
|
* to the outer breaker, but make it pending on the new, |
|
* now inner breaker (A). Graphically, |
|
* |
|
* [X! n=breaker=[A!->X broken=[B(->X)->A X] A] B]. |
|
*/ |
|
|
/* |
if (broken->pending != NULL) { |
* Found the breaker. |
n = breaker; |
* If another, outer breaker (X) is already pending on |
|
* the *broken block (B), we must not clobber the link |
|
* to the outer breaker, but make it pending on the |
|
* new, now inner breaker (A). |
|
* Graphically, [X! breaker=[A broken=[B->X X] tok=A] B] |
|
* becomes [X! breaker=[A->X broken=[B X] tok=A] B] |
|
* and finally [X! [A!->X [B->A X] A] B]. |
|
*/ |
|
if (broken->pending) { |
|
struct mdoc_node *taker; |
|
|
|
/* |
|
* If the inner breaker (A) is already broken, |
|
* too, it cannot take on the outer breaker (X) |
|
* but must hand it on to its own breakers (Y): |
|
* [X! [Y! breaker=[A->Y Y] broken=[B->X X] tok=A] B] |
|
* [X! take=[Y!->X brea=[A->Y Y] brok=[B X] tok=A] B] |
|
* and finally [X! [Y!->X [A!->Y Y] [B->A X] A] B]. |
|
*/ |
|
taker = breaker; |
|
while (taker->pending) |
|
taker = taker->pending; |
|
taker->pending = broken->pending; |
|
} |
|
|
|
/* |
/* |
* Now we have reduced the situation to the simplest |
* If the inner breaker (A) is already broken, too, |
* case, which is just breaker=[A broken=[B tok=A] B] |
* it cannot take on the outer breaker (X) but must |
* and becomes [A! [B->A A] B]. |
* hand it on to its own breakers (Y). Graphically, |
|
* |
|
* [X! n=[Y!->X breaker=[A!->Y Y] broken=[B(->X)->A X] A] B] |
*/ |
*/ |
broken->pending = breaker; |
|
breaker->flags |= MDOC_BREAK; |
while (n->pending) |
if (breaker->body != NULL) |
n = n->pending; |
breaker->body->flags |= MDOC_BREAK; |
n->pending = broken->pending; |
mandoc_vmsg(MANDOCERR_BLK_NEST, mdoc->parse, line, ppos, |
|
"%s breaks %s", mdoc_macronames[tok], |
|
mdoc_macronames[broken->tok]); |
|
return(1); |
|
} |
} |
|
|
/* |
/* |
* Found no matching block for tok. |
* Now we have reduced the situation to the simplest case: |
* Are you trying to close a block that is not open? |
* breaker=[A! broken=[B->A A] B]. |
*/ |
*/ |
return(0); |
|
|
broken->pending = breaker; |
|
breaker->flags |= MDOC_BREAK; |
|
if (breaker->body != NULL) |
|
breaker->body->flags |= MDOC_BREAK; |
} |
} |
|
|
static void |
static void |
Line 769 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 752 blk_exp_close(MACRO_PROT_ARGS) |
|
* rew_pending() closing out the sub-block. |
* rew_pending() closing out the sub-block. |
*/ |
*/ |
|
|
make_pending(later, tok, mdoc, line, ppos); |
make_pending(mdoc, n, later, line, ppos); |
|
|
/* |
/* |
* Mark the place where the formatting - but not |
* Mark the place where the formatting - but not |
Line 1295 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1278 blk_part_imp(MACRO_PROT_ARGS) |
|
if (n->type == MDOC_BLOCK && |
if (n->type == MDOC_BLOCK && |
mdoc_macros[n->tok].flags & MDOC_EXPLICIT && |
mdoc_macros[n->tok].flags & MDOC_EXPLICIT && |
! (n->flags & MDOC_VALID)) { |
! (n->flags & MDOC_VALID)) { |
make_pending(n, tok, mdoc, line, ppos); |
make_pending(mdoc, blk, n, line, ppos); |
mdoc_endbody_alloc(mdoc, line, ppos, |
mdoc_endbody_alloc(mdoc, line, ppos, |
tok, body, ENDBODY_NOSPACE); |
tok, body, ENDBODY_NOSPACE); |
return; |
return; |
Line 1476 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1459 in_line_argn(MACRO_PROT_ARGS) |
|
static void |
static void |
in_line_eoln(MACRO_PROT_ARGS) |
in_line_eoln(MACRO_PROT_ARGS) |
{ |
{ |
struct mdoc_arg *arg; |
struct mdoc_node *n; |
|
struct mdoc_arg *arg; |
|
|
if (tok == MDOC_Pp) |
if ((tok == MDOC_Pp || tok == MDOC_Lp) && |
rew_sub(MDOC_BLOCK, mdoc, MDOC_Nm, line, ppos); |
! (mdoc->flags & MDOC_SYNOPSIS)) { |
|
n = mdoc->last; |
|
if (mdoc->next == MDOC_NEXT_SIBLING) |
|
n = n->parent; |
|
if (n->tok == MDOC_Nm) |
|
rew_last(mdoc, mdoc->last->parent); |
|
} |
|
|
mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
mdoc_elem_alloc(mdoc, line, ppos, tok, arg); |
mdoc_elem_alloc(mdoc, line, ppos, tok, arg); |