aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-04-13 09:57:41 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-04-13 09:57:41 +0000
commit9fe41268e363e1052d4d1a58f515b8cf8650ec55 (patch)
tree45707724e7b68d519fd2c61b3a13ff9aa7af1db9 /roff.c
parentd6a0b76fecae20088bd4d276cdd0eb2f041d59ec (diff)
downloadmandoc-9fe41268e363e1052d4d1a58f515b8cf8650ec55.tar.gz
mandoc-9fe41268e363e1052d4d1a58f515b8cf8650ec55.tar.zst
mandoc-9fe41268e363e1052d4d1a58f515b8cf8650ec55.zip
Remove TODO from prior commit of lifting warnings from `Sh', `Ss', `SH',
and `SS' bodies.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c59
1 files changed, 25 insertions, 34 deletions
diff --git a/roff.c b/roff.c
index 62633bde..11ed7435 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.131 2011/04/05 22:22:33 schwarze Exp $ */
+/* $Id: roff.c,v 1.132 2011/04/13 09:57:41 kristaps Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -277,10 +277,6 @@ roffnode_pop(struct roff *r)
assert(r->last);
p = r->last;
- if (ROFF_el == p->tok)
- if (r->rstackpos > -1)
- r->rstackpos--;
-
r->last = r->last->parent;
free(p->name);
free(p->end);
@@ -976,29 +972,20 @@ roff_cond(ROFF_ARGS)
int sv;
enum roffrule rule;
- /* Stack overflow! */
-
- if (ROFF_ie == tok && r->rstackpos == RSTACK_MAX - 1) {
- mandoc_msg(MANDOCERR_MEM, r->parse, ln, ppos, NULL);
- return(ROFF_ERR);
- }
-
- /* First, evaluate the conditional. */
+ /*
+ * An `.el' has no conditional body: it will consume the value
+ * of the current rstack entry set in prior `ie' calls or
+ * defaults to DENY.
+ *
+ * If we're not an `el', however, then evaluate the conditional.
+ */
- if (ROFF_el == tok) {
- /*
- * An `.el' will get the value of the current rstack
- * entry set in prior `ie' calls or defaults to DENY.
- */
- if (r->rstackpos < 0)
- rule = ROFFRULE_DENY;
- else
- rule = r->rstack[r->rstackpos];
- } else
- rule = roff_evalcond(*bufp, &pos);
+ rule = ROFF_el == tok ?
+ (r->rstackpos < 0 ?
+ ROFFRULE_DENY : r->rstack[r->rstackpos--]) :
+ roff_evalcond(*bufp, &pos);
sv = pos;
-
while (' ' == (*bufp)[pos])
pos++;
@@ -1018,16 +1005,20 @@ roff_cond(ROFF_ARGS)
r->last->rule = rule;
+ /*
+ * An if-else will put the NEGATION of the current evaluated
+ * conditional into the stack of rules.
+ */
+
if (ROFF_ie == tok) {
- /*
- * An if-else will put the NEGATION of the current
- * evaluated conditional into the stack.
- */
- r->rstackpos++;
- if (ROFFRULE_DENY == r->last->rule)
- r->rstack[r->rstackpos] = ROFFRULE_ALLOW;
- else
- r->rstack[r->rstackpos] = ROFFRULE_DENY;
+ if (r->rstackpos == RSTACK_MAX - 1) {
+ mandoc_msg(MANDOCERR_MEM,
+ r->parse, ln, ppos, NULL);
+ return(ROFF_ERR);
+ }
+ r->rstack[++r->rstackpos] =
+ ROFFRULE_DENY == r->last->rule ?
+ ROFFRULE_ALLOW : ROFFRULE_DENY;
}
/* If the parent has false as its rule, then so do we. */