=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/roff.c,v retrieving revision 1.45 retrieving revision 1.46 diff -c -r1.45 -r1.46 *** src/usr.bin/mandoc/roff.c 2011/10/24 21:38:56 1.45 --- src/usr.bin/mandoc/roff.c 2012/05/31 01:36:56 1.46 *************** *** 1,7 **** ! /* $Id: roff.c,v 1.45 2011/10/24 21:38:56 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons ! * Copyright (c) 2010, 2011 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above --- 1,7 ---- ! /* $Id: roff.c,v 1.46 2012/05/31 01:36:56 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons ! * Copyright (c) 2010, 2011, 2012 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above *************** *** 774,780 **** { while (r->last) { ! if (--r->last->endspan < 0) break; roffnode_pop(r); } --- 774,780 ---- { while (r->last) { ! if (--r->last->endspan != 0) break; roffnode_pop(r); } *************** *** 1094,1102 **** static enum rofferr 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 --- 1094,1102 ---- static enum rofferr roff_cond(ROFF_ARGS) { + roffnode_push(r, tok, NULL, ln, ppos); + /* * An `.el' has no conditional body: it will consume the value * of the current rstack entry set in prior `ie' calls or *************** *** 1105,1136 **** * If we're not an `el', however, then evaluate the conditional. */ ! rule = ROFF_el == tok ? (r->rstackpos < 0 ? ROFFRULE_DENY : r->rstack[r->rstackpos--]) : roff_evalcond(*bufp, &pos); - sv = pos; - while (' ' == (*bufp)[pos]) - pos++; - /* - * Roff is weird. If we have just white-space after the - * conditional, it's considered the BODY and we exit without - * really doing anything. Warn about this. It's probably - * wrong. - */ - - if ('\0' == (*bufp)[pos] && sv != pos) { - mandoc_msg(MANDOCERR_NOARGS, r->parse, ln, ppos, NULL); - return(ROFF_IGN); - } - - roffnode_push(r, tok, NULL, ln, ppos); - - r->last->rule = rule; - - /* * An if-else will put the NEGATION of the current evaluated * conditional into the stack of rules. */ --- 1105,1116 ---- * If we're not an `el', however, then evaluate the conditional. */ ! r->last->rule = ROFF_el == tok ? (r->rstackpos < 0 ? ROFFRULE_DENY : r->rstack[r->rstackpos--]) : roff_evalcond(*bufp, &pos); /* * An if-else will put the NEGATION of the current evaluated * conditional into the stack of rules. */ *************** *** 1152,1179 **** r->last->rule = ROFFRULE_DENY; /* ! * Determine scope. If we're invoked with "\{" trailing the ! * conditional, then we're in a multiline scope. Else our scope ! * expires on the next line. */ ! r->last->endspan = 1; if ('\\' == (*bufp)[pos] && '{' == (*bufp)[pos + 1]) { r->last->endspan = -1; pos += 2; } /* ! * If there are no arguments on the line, the next-line scope is ! * assumed. */ if ('\0' == (*bufp)[pos]) ! return(ROFF_IGN); ! /* Otherwise re-run the roff parser after recalculating. */ *offs = pos; return(ROFF_RERUN); } --- 1132,1170 ---- r->last->rule = ROFFRULE_DENY; /* ! * Determine scope. ! * If there is nothing on the line after the conditional, ! * not even whitespace, use next-line scope. */ ! if ('\0' == (*bufp)[pos]) { ! r->last->endspan = 2; ! goto out; ! } + while (' ' == (*bufp)[pos]) + pos++; + + /* An opening brace requests multiline scope. */ + if ('\\' == (*bufp)[pos] && '{' == (*bufp)[pos + 1]) { r->last->endspan = -1; pos += 2; + goto out; } /* ! * Anything else following the conditional causes ! * single-line scope. Warn if the scope contains ! * nothing but trailing whitespace. */ if ('\0' == (*bufp)[pos]) ! mandoc_msg(MANDOCERR_NOARGS, r->parse, ln, ppos, NULL); ! r->last->endspan = 1; + out: *offs = pos; return(ROFF_RERUN); }