version 1.83, 2010/05/24 22:25:58 |
version 1.84, 2010/05/24 23:54:18 |
Line 575 roff_cond_sub(ROFF_ARGS) |
|
Line 575 roff_cond_sub(ROFF_ARGS) |
|
ppos = pos; |
ppos = pos; |
rr = r->last->rule; |
rr = r->last->rule; |
|
|
roffnode_cleanscope(r); |
roff_cond_text(r, tok, bufp, szp, ln, ppos, pos, offs); |
|
|
if (ROFF_MAX == (t = roff_parse(*bufp, &pos))) |
if (ROFF_MAX == (t = roff_parse(*bufp, &pos))) |
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); |
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); |
Line 616 roff_cond_text(ROFF_ARGS) |
|
Line 616 roff_cond_text(ROFF_ARGS) |
|
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); |
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); |
} |
} |
|
|
if (ep > st && '\\' != *(ep - 1)) |
if (ep > st && '\\' != *(ep - 1)) { |
|
ep = '\0'; |
roffnode_pop(r); |
roffnode_pop(r); |
|
} |
|
|
roffnode_cleanscope(r); |
roffnode_cleanscope(r); |
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); |
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); |
Line 628 roff_cond_text(ROFF_ARGS) |
|
Line 630 roff_cond_text(ROFF_ARGS) |
|
static enum rofferr |
static enum rofferr |
roff_cond(ROFF_ARGS) |
roff_cond(ROFF_ARGS) |
{ |
{ |
|
int cpos; /* position of the condition */ |
int sv; |
int sv; |
|
|
/* Stack overflow! */ |
/* Stack overflow! */ |
Line 637 roff_cond(ROFF_ARGS) |
|
Line 640 roff_cond(ROFF_ARGS) |
|
return(ROFF_ERR); |
return(ROFF_ERR); |
} |
} |
|
|
|
cpos = pos; |
|
|
if (ROFF_if == tok || ROFF_ie == tok) { |
if (ROFF_if == tok || ROFF_ie == tok) { |
/* |
/* |
* Read ahead past the conditional. FIXME: this does |
* Read ahead past the conditional. FIXME: this does |
Line 667 roff_cond(ROFF_ARGS) |
|
Line 672 roff_cond(ROFF_ARGS) |
|
if ( ! roffnode_push(r, tok, ln, ppos)) |
if ( ! roffnode_push(r, tok, ln, ppos)) |
return(ROFF_ERR); |
return(ROFF_ERR); |
|
|
/* TODO: here we would evaluate the conditional. */ |
/* XXX: Implement more conditionals. */ |
|
|
if (ROFF_el == tok) { |
if (ROFF_if == tok || ROFF_ie == tok) |
|
r->last->rule = 'n' == (*bufp)[cpos] ? |
|
ROFFRULE_ALLOW : ROFFRULE_DENY; |
|
else if (ROFF_el == tok) { |
/* |
/* |
* An `.el' will get the value of the current rstack |
* An `.el' will get the value of the current rstack |
* entry set in prior `ie' calls or defaults to DENY. |
* entry set in prior `ie' calls or defaults to DENY. |
Line 678 roff_cond(ROFF_ARGS) |
|
Line 686 roff_cond(ROFF_ARGS) |
|
r->last->rule = ROFFRULE_DENY; |
r->last->rule = ROFFRULE_DENY; |
else |
else |
r->last->rule = r->rstack[r->rstackpos]; |
r->last->rule = r->rstack[r->rstackpos]; |
} else if (ROFF_ie == tok) { |
} |
|
if (ROFF_ie == tok) { |
/* |
/* |
* An if-else will put the NEGATION of the current |
* An if-else will put the NEGATION of the current |
* evaluated conditional into the stack. |
* evaluated conditional into the stack. |
Line 689 roff_cond(ROFF_ARGS) |
|
Line 698 roff_cond(ROFF_ARGS) |
|
else |
else |
r->rstack[r->rstackpos] = ROFFRULE_DENY; |
r->rstack[r->rstackpos] = ROFFRULE_DENY; |
} |
} |
|
if (r->last->parent && ROFFRULE_DENY == r->last->parent->rule) |
|
r->last->rule = ROFFRULE_DENY; |
|
|
r->last->endspan = 1; |
r->last->endspan = 1; |
|
|