From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Back out commit to roff.c that needs to go in on its own.
Date: Wed, 13 Apr 2011 06:01:27 -0400 (EDT) [thread overview]
Message-ID: <201104131001.p3DA1RuM029367@krisdoz.my.domain> (raw)
Log Message:
-----------
Back out commit to roff.c that needs to go in on its own.
Modified Files:
--------------
mdocml:
roff.c
Revision Data
-------------
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -Lroff.c -Lroff.c -u -p -r1.132 -r1.133
--- roff.c
+++ roff.c
@@ -277,6 +277,10 @@ 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);
@@ -972,20 +976,29 @@ roff_cond(ROFF_ARGS)
int sv;
enum roffrule rule;
- /*
- * 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.
- */
+ /* Stack overflow! */
- rule = ROFF_el == tok ?
- (r->rstackpos < 0 ?
- ROFFRULE_DENY : r->rstack[r->rstackpos--]) :
- roff_evalcond(*bufp, &pos);
+ 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. */
+
+ 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);
sv = pos;
+
while (' ' == (*bufp)[pos])
pos++;
@@ -1005,20 +1018,16 @@ 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) {
- 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;
+ /*
+ * 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 the parent has false as its rule, then so do we. */
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2011-04-13 10:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201104131001.p3DA1RuM029367@krisdoz.my.domain \
--to=kristaps@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).