version 1.46, 2010/03/30 08:24:01 |
version 1.48, 2010/03/31 07:42:04 |
Line 42 static int blk_exp_close(MACRO_PROT_ARGS); |
|
Line 42 static int blk_exp_close(MACRO_PROT_ARGS); |
|
static int blk_part_imp(MACRO_PROT_ARGS); |
static int blk_part_imp(MACRO_PROT_ARGS); |
|
|
static int phrase(struct mdoc *, int, int, char *); |
static int phrase(struct mdoc *, int, int, char *); |
static int rew_dohalt(int, enum mdoc_type, |
static int rew_dohalt(enum mdoct, enum mdoc_type, |
const struct mdoc_node *); |
const struct mdoc_node *); |
static int rew_alt(int); |
static enum mdoct rew_alt(enum mdoct); |
static int rew_dobreak(int, const struct mdoc_node *); |
static int rew_dobreak(enum mdoct, const struct mdoc_node *); |
static int rew_elem(struct mdoc *, int); |
static int rew_elem(struct mdoc *, enum mdoct); |
static int rew_sub(enum mdoc_type, struct mdoc *, |
static int rew_sub(enum mdoc_type, struct mdoc *, |
int, int, int); |
enum mdoct, int, int); |
static int rew_last(struct mdoc *, |
static int rew_last(struct mdoc *, |
const struct mdoc_node *); |
const struct mdoc_node *); |
static int append_delims(struct mdoc *, int, int *, char *); |
static int append_delims(struct mdoc *, int, int *, char *); |
Line 318 rew_last(struct mdoc *mdoc, const struct mdoc_node *to |
|
Line 318 rew_last(struct mdoc *mdoc, const struct mdoc_node *to |
|
* Return the opening macro of a closing one, e.g., `Ec' has `Eo' as its |
* Return the opening macro of a closing one, e.g., `Ec' has `Eo' as its |
* matching pair. |
* matching pair. |
*/ |
*/ |
static int |
static enum mdoct |
rew_alt(int tok) |
rew_alt(enum mdoct tok) |
{ |
{ |
switch (tok) { |
switch (tok) { |
case (MDOC_Ac): |
case (MDOC_Ac): |
Line 369 rew_alt(int tok) |
|
Line 369 rew_alt(int tok) |
|
* The scope-closing and so on occurs in the various rew_* routines. |
* The scope-closing and so on occurs in the various rew_* routines. |
*/ |
*/ |
static int |
static int |
rew_dohalt(int tok, enum mdoc_type type, const struct mdoc_node *p) |
rew_dohalt(enum mdoct tok, enum mdoc_type type, |
|
const struct mdoc_node *p) |
{ |
{ |
|
|
if (MDOC_ROOT == p->type) |
if (MDOC_ROOT == p->type) |
Line 508 rew_dohalt(int tok, enum mdoc_type type, const struct |
|
Line 509 rew_dohalt(int tok, enum mdoc_type type, const struct |
|
* REWIND_NOHALT). |
* REWIND_NOHALT). |
*/ |
*/ |
static int |
static int |
rew_dobreak(int tok, const struct mdoc_node *p) |
rew_dobreak(enum mdoct tok, const struct mdoc_node *p) |
{ |
{ |
|
|
assert(MDOC_ROOT != p->type); |
assert(MDOC_ROOT != p->type); |
Line 537 rew_dobreak(int tok, const struct mdoc_node *p) |
|
Line 538 rew_dobreak(int tok, const struct mdoc_node *p) |
|
return(1); |
return(1); |
break; |
break; |
case (MDOC_Oc): |
case (MDOC_Oc): |
/* XXX - experimental! */ |
|
if (MDOC_Op == p->tok) |
if (MDOC_Op == p->tok) |
return(1); |
return(1); |
break; |
break; |
Line 555 rew_dobreak(int tok, const struct mdoc_node *p) |
|
Line 555 rew_dobreak(int tok, const struct mdoc_node *p) |
|
|
|
|
|
static int |
static int |
rew_elem(struct mdoc *mdoc, int tok) |
rew_elem(struct mdoc *mdoc, enum mdoct tok) |
{ |
{ |
struct mdoc_node *n; |
struct mdoc_node *n; |
|
|
Line 571 rew_elem(struct mdoc *mdoc, int tok) |
|
Line 571 rew_elem(struct mdoc *mdoc, int tok) |
|
|
|
static int |
static int |
rew_sub(enum mdoc_type t, struct mdoc *m, |
rew_sub(enum mdoc_type t, struct mdoc *m, |
int tok, int line, int ppos) |
enum mdoct tok, int line, int ppos) |
{ |
{ |
struct mdoc_node *n; |
struct mdoc_node *n; |
int c; |
int c; |
Line 595 rew_sub(enum mdoc_type t, struct mdoc *m, |
|
Line 595 rew_sub(enum mdoc_type t, struct mdoc *m, |
|
} |
} |
|
|
assert(n); |
assert(n); |
return(rew_last(m, n)); |
if ( ! rew_last(m, n)) |
|
return(0); |
|
|
|
#ifdef UGLY |
|
/* |
|
* The current block extends an enclosing block beyond a line |
|
* break. Now that the current block ends, close the enclosing |
|
* block, too. |
|
*/ |
|
if (NULL != (n = n->pending)) { |
|
assert(MDOC_HEAD == n->type); |
|
if ( ! rew_last(m, n)) |
|
return(0); |
|
if ( ! mdoc_body_alloc(m, n->line, n->pos, n->tok)) |
|
return(0); |
|
} |
|
#endif |
|
|
|
return(1); |
} |
} |
|
|
|
|
Line 861 blk_full(MACRO_PROT_ARGS) |
|
Line 879 blk_full(MACRO_PROT_ARGS) |
|
int c, la; |
int c, la; |
struct mdoc_arg *arg; |
struct mdoc_arg *arg; |
struct mdoc_node *head; /* save of head macro */ |
struct mdoc_node *head; /* save of head macro */ |
|
#ifdef UGLY |
|
struct mdoc_node *n; |
|
#endif |
char *p; |
char *p; |
|
|
/* Close out prior implicit scope. */ |
/* Close out prior implicit scope. */ |
Line 978 blk_full(MACRO_PROT_ARGS) |
|
Line 999 blk_full(MACRO_PROT_ARGS) |
|
if (MDOC_Nd == tok) |
if (MDOC_Nd == tok) |
return(1); |
return(1); |
|
|
|
#ifdef UGLY |
|
/* |
|
* If there is an open sub-block requiring explicit close-out, |
|
* postpone switching the current block from head to body until |
|
* the rew_sub() call closing out that sub-block. |
|
*/ |
|
for (n = m->last; n && n != head; n = n->parent) { |
|
if (MDOC_EXPLICIT & mdoc_macros[n->tok].flags && |
|
MDOC_BLOCK == n->type) { |
|
n->pending = head; |
|
return(1); |
|
} |
|
} |
|
#endif |
|
|
/* Close out scopes to remain in a consistent state. */ |
/* Close out scopes to remain in a consistent state. */ |
|
|
if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) |
if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) |
Line 1070 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1106 blk_part_imp(MACRO_PROT_ARGS) |
|
* If we can't rewind to our body, then our scope has already |
* If we can't rewind to our body, then our scope has already |
* been closed by another macro (like `Oc' closing `Op'). This |
* been closed by another macro (like `Oc' closing `Op'). This |
* is ugly behaviour nodding its head to OpenBSD's overwhelming |
* is ugly behaviour nodding its head to OpenBSD's overwhelming |
* crufty use of `Op' breakage. XXX: DEPRECATE. |
* crufty use of `Op' breakage. |
*/ |
*/ |
|
|
for (n = m->last; n; n = n->parent) |
for (n = m->last; n; n = n->parent) |
if (body == n) |
if (body == n) |
break; |
break; |