version 1.41, 2009/01/17 20:10:36 |
version 1.42, 2009/01/19 17:02:58 |
Line 70 rewind_last(struct mdoc *mdoc, struct mdoc_node *to) |
|
Line 70 rewind_last(struct mdoc *mdoc, struct mdoc_node *to) |
|
|
|
assert(to); |
assert(to); |
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
if (mdoc->last == to) { |
|
|
while (mdoc->last != to) { |
if ( ! mdoc_valid_post(mdoc)) |
if ( ! mdoc_valid_post(mdoc)) |
return(0); |
return(0); |
if ( ! mdoc_action_post(mdoc)) |
if ( ! mdoc_action_post(mdoc)) |
return(0); |
return(0); |
return(1); |
|
} |
|
|
|
do { |
|
mdoc->last = mdoc->last->parent; |
mdoc->last = mdoc->last->parent; |
assert(mdoc->last); |
assert(mdoc->last); |
if ( ! mdoc_valid_post(mdoc)) |
} |
return(0); |
|
if ( ! mdoc_action_post(mdoc)) |
|
return(0); |
|
} while (mdoc->last != to); |
|
|
|
return(1); |
if ( ! mdoc_valid_post(mdoc)) |
|
return(0); |
|
return(mdoc_action_post(mdoc)); |
} |
} |
|
|
|
|
Line 139 rewind_dohalt(int tok, enum mdoc_type type, const stru |
|
Line 134 rewind_dohalt(int tok, enum mdoc_type type, const stru |
|
|
|
if (MDOC_ROOT == p->type) |
if (MDOC_ROOT == p->type) |
return(REWIND_HALT); |
return(REWIND_HALT); |
if (MDOC_TEXT == p->type) |
if (MDOC_VALID & p->flags) |
return(REWIND_NOHALT); |
return(REWIND_NOHALT); |
if (MDOC_ELEM == p->type) |
|
return(REWIND_NOHALT); |
|
|
|
switch (tok) { |
switch (tok) { |
/* One-liner implicit-scope. */ |
/* One-liner implicit-scope. */ |
Line 276 rewind_dobreak(int tok, const struct mdoc_node *p) |
|
Line 269 rewind_dobreak(int tok, const struct mdoc_node *p) |
|
return(1); |
return(1); |
if (MDOC_TEXT == p->type) |
if (MDOC_TEXT == p->type) |
return(1); |
return(1); |
|
if (MDOC_VALID & p->flags) |
|
return(1); |
|
|
switch (tok) { |
switch (tok) { |
/* Implicit rules. */ |
/* Implicit rules. */ |
Line 328 rewind_subblock(enum mdoc_type type, struct mdoc *mdoc |
|
Line 323 rewind_subblock(enum mdoc_type type, struct mdoc *mdoc |
|
struct mdoc_node *n; |
struct mdoc_node *n; |
int c; |
int c; |
|
|
c = rewind_dohalt(tok, type, mdoc->last); |
|
if (REWIND_HALT == c) |
|
return(1); |
|
if (REWIND_REWIND == c) |
|
return(rewind_last(mdoc, mdoc->last)); |
|
|
|
/* LINTED */ |
/* LINTED */ |
for (n = mdoc->last->parent; n; n = n->parent) { |
for (n = mdoc->last; n; n = n->parent) { |
c = rewind_dohalt(tok, type, n); |
c = rewind_dohalt(tok, type, n); |
if (REWIND_HALT == c) |
if (REWIND_HALT == c) |
return(1); |
return(1); |
Line 357 rewind_expblock(struct mdoc *mdoc, int tok, int line, |
|
Line 346 rewind_expblock(struct mdoc *mdoc, int tok, int line, |
|
struct mdoc_node *n; |
struct mdoc_node *n; |
int c; |
int c; |
|
|
c = rewind_dohalt(tok, MDOC_BLOCK, mdoc->last); |
|
if (REWIND_HALT == c) |
|
return(mdoc_perr(mdoc, line, ppos, "closing macro has no context")); |
|
if (REWIND_REWIND == c) |
|
return(rewind_last(mdoc, mdoc->last)); |
|
|
|
/* LINTED */ |
/* LINTED */ |
for (n = mdoc->last->parent; n; n = n->parent) { |
for (n = mdoc->last; n; n = n->parent) { |
c = rewind_dohalt(tok, MDOC_BLOCK, n); |
c = rewind_dohalt(tok, MDOC_BLOCK, n); |
if (REWIND_HALT == c) |
if (REWIND_HALT == c) |
return(mdoc_perr(mdoc, line, ppos, "closing macro has no context")); |
return(mdoc_perr(mdoc, line, ppos, "closing macro has no context")); |
Line 386 rewind_impblock(struct mdoc *mdoc, int tok, int line, |
|
Line 369 rewind_impblock(struct mdoc *mdoc, int tok, int line, |
|
struct mdoc_node *n; |
struct mdoc_node *n; |
int c; |
int c; |
|
|
c = rewind_dohalt(tok, MDOC_BLOCK, mdoc->last); |
|
if (REWIND_HALT == c) |
|
return(1); |
|
if (REWIND_REWIND == c) |
|
return(rewind_last(mdoc, mdoc->last)); |
|
|
|
/* LINTED */ |
/* LINTED */ |
for (n = mdoc->last->parent; n; n = n->parent) { |
for (n = mdoc->last; n; n = n->parent) { |
c = rewind_dohalt(tok, MDOC_BLOCK, n); |
c = rewind_dohalt(tok, MDOC_BLOCK, n); |
if (REWIND_HALT == c) |
if (REWIND_HALT == c) |
return(1); |
return(1); |
Line 435 append_delims(struct mdoc *mdoc, int line, int *pos, c |
|
Line 412 append_delims(struct mdoc *mdoc, int line, int *pos, c |
|
} |
} |
|
|
|
|
/* ARGSUSED */ |
|
int |
int |
macro_scoped_close(MACRO_PROT_ARGS) |
macro_scoped_close(MACRO_PROT_ARGS) |
{ |
{ |
Line 521 macro_scoped_close(MACRO_PROT_ARGS) |
|
Line 497 macro_scoped_close(MACRO_PROT_ARGS) |
|
} |
} |
|
|
|
|
/* |
|
* A general text domain macro. When invoked, this opens a scope that |
|
* accepts words until either end-of-line, only-punctuation, or a |
|
* callable macro. If the word is punctuation (not only-punctuation), |
|
* then the scope is closed out, the punctuation appended, then the |
|
* scope opened again. If any terminating conditions are met, the scope |
|
* is closed out. If this is the first macro in the line and |
|
* only-punctuation remains, this punctuation is flushed. |
|
*/ |
|
int |
int |
macro_text(MACRO_PROT_ARGS) |
macro_text(MACRO_PROT_ARGS) |
{ |
{ |
Line 636 macro_text(MACRO_PROT_ARGS) |
|
Line 603 macro_text(MACRO_PROT_ARGS) |
|
} |
} |
|
|
|
|
/* |
|
* Implicit- or explicit-end multi-line scoped macro. |
|
*/ |
|
int |
int |
macro_scoped(MACRO_PROT_ARGS) |
macro_scoped(MACRO_PROT_ARGS) |
{ |
{ |
Line 740 macro_scoped(MACRO_PROT_ARGS) |
|
Line 704 macro_scoped(MACRO_PROT_ARGS) |
|
} |
} |
|
|
|
|
/* |
|
* When scoped to a line, a macro encompasses all of the contents. This |
|
* differs from constants or text macros, where a new macro will |
|
* terminate the existing context. |
|
*/ |
|
int |
int |
macro_scoped_line(MACRO_PROT_ARGS) |
macro_scoped_line(MACRO_PROT_ARGS) |
{ |
{ |
Line 798 macro_scoped_line(MACRO_PROT_ARGS) |
|
Line 757 macro_scoped_line(MACRO_PROT_ARGS) |
|
} |
} |
|
|
|
|
/* |
|
* Constant-scope macros accept a fixed number of arguments and behave |
|
* like constant macros except that they're scoped across lines. |
|
*/ |
|
int |
int |
macro_constant_scoped(MACRO_PROT_ARGS) |
macro_constant_scoped(MACRO_PROT_ARGS) |
{ |
{ |
Line 901 macro_constant_scoped(MACRO_PROT_ARGS) |
|
Line 856 macro_constant_scoped(MACRO_PROT_ARGS) |
|
} |
} |
|
|
|
|
/* |
|
* Delimited macros are like text macros except that, should punctuation |
|
* be encountered, the macro isn't re-started with remaining tokens |
|
* (it's only emitted once). Delimited macros can have a maximum number |
|
* of arguments. |
|
*/ |
|
int |
int |
macro_constant_delimited(MACRO_PROT_ARGS) |
macro_constant_delimited(MACRO_PROT_ARGS) |
{ |
{ |
Line 1000 macro_constant_delimited(MACRO_PROT_ARGS) |
|
Line 949 macro_constant_delimited(MACRO_PROT_ARGS) |
|
mdoc->next = MDOC_NEXT_SIBLING; |
mdoc->next = MDOC_NEXT_SIBLING; |
} |
} |
|
|
if ( ! flushed && rewind_elem(mdoc, tok)) |
if ( ! flushed && ! rewind_elem(mdoc, tok)) |
return(0); |
return(0); |
|
|
if (ppos > 1) |
if (ppos > 1) |
Line 1009 macro_constant_delimited(MACRO_PROT_ARGS) |
|
Line 958 macro_constant_delimited(MACRO_PROT_ARGS) |
|
} |
} |
|
|
|
|
/* |
|
* Constant macros span an entire line: they constitute a macro and all |
|
* of its arguments and child data. |
|
*/ |
|
int |
int |
macro_constant(MACRO_PROT_ARGS) |
macro_constant(MACRO_PROT_ARGS) |
{ |
{ |
Line 1090 macro_obsolete(MACRO_PROT_ARGS) |
|
Line 1035 macro_obsolete(MACRO_PROT_ARGS) |
|
int |
int |
macro_end(struct mdoc *mdoc) |
macro_end(struct mdoc *mdoc) |
{ |
{ |
|
struct mdoc_node *n; |
|
|
assert(mdoc->first); |
assert(mdoc->first); |
assert(mdoc->last); |
assert(mdoc->last); |
|
|
|
/* Scan for open explicit scopes. */ |
|
|
|
n = MDOC_VALID & mdoc->last->flags ? |
|
mdoc->last->parent : mdoc->last; |
|
|
|
for ( ; n; n = n->parent) { |
|
if (MDOC_BLOCK != n->type) |
|
continue; |
|
if ( ! (MDOC_EXPLICIT & mdoc_macros[n->tok].flags)) |
|
continue; |
|
mdoc_nerr(mdoc, n, "macro scope still open on exit"); |
|
return(0); |
|
} |
|
|
return(rewind_last(mdoc, mdoc->first)); |
return(rewind_last(mdoc, mdoc->first)); |
} |
} |