=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/roff.c,v retrieving revision 1.67 retrieving revision 1.68 diff -c -r1.67 -r1.68 *** src/usr.bin/mandoc/roff.c 2014/02/14 23:24:17 1.67 --- src/usr.bin/mandoc/roff.c 2014/03/07 02:21:55 1.68 *************** *** 1,4 **** ! /* $Id: roff.c,v 1.67 2014/02/14 23:24:17 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze --- 1,4 ---- ! /* $Id: roff.c,v 1.68 2014/03/07 02:21:55 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze *************** *** 68,74 **** ROFF_EQ, ROFF_EN, ROFF_cblock, - ROFF_ccond, ROFF_USERDEF, ROFF_MAX }; --- 68,73 ---- *************** *** 176,182 **** static enum rofferr roff_block_sub(ROFF_ARGS); static enum rofferr roff_cblock(ROFF_ARGS); static enum rofferr roff_cc(ROFF_ARGS); ! static enum rofferr roff_ccond(ROFF_ARGS); static enum rofferr roff_cond(ROFF_ARGS); static enum rofferr roff_cond_text(ROFF_ARGS); static enum rofferr roff_cond_sub(ROFF_ARGS); --- 175,181 ---- static enum rofferr roff_block_sub(ROFF_ARGS); static enum rofferr roff_cblock(ROFF_ARGS); static enum rofferr roff_cc(ROFF_ARGS); ! static void roff_ccond(struct roff *, int, int); static enum rofferr roff_cond(ROFF_ARGS); static enum rofferr roff_cond_text(ROFF_ARGS); static enum rofferr roff_cond_sub(ROFF_ARGS); *************** *** 263,269 **** { "EQ", roff_EQ, NULL, NULL, 0, NULL }, { "EN", roff_EN, NULL, NULL, 0, NULL }, { ".", roff_cblock, NULL, NULL, 0, NULL }, - { "\\}", roff_ccond, NULL, NULL, 0, NULL }, { NULL, roff_userdef, NULL, NULL, 0, NULL }, }; --- 262,267 ---- *************** *** 786,799 **** '\t' == buf[*pos] || ' ' == buf[*pos]) return(ROFF_MAX); ! /* ! * We stop the macro parse at an escape, tab, space, or nil. ! * However, `\}' is also a valid macro, so make sure we don't ! * clobber it by seeing the `\' as the end of token. ! */ mac = buf + *pos; ! maclen = strcspn(mac + 1, " \\\t\0") + 1; t = (r->current_string = roff_getstrn(r, mac, maclen)) ? ROFF_USERDEF : roffhash_find(mac, maclen); --- 784,793 ---- '\t' == buf[*pos] || ' ' == buf[*pos]) return(ROFF_MAX); ! /* We stop the macro parse at an escape, tab, space, or nil. */ mac = buf + *pos; ! maclen = strcspn(mac, " \\\t\0"); t = (r->current_string = roff_getstrn(r, mac, maclen)) ? ROFF_USERDEF : roffhash_find(mac, maclen); *************** *** 862,875 **** } ! /* ARGSUSED */ ! static enum rofferr ! roff_ccond(ROFF_ARGS) { if (NULL == r->last) { mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL); ! return(ROFF_IGN); } switch (r->last->tok) { --- 856,868 ---- } ! static void ! roff_ccond(struct roff *r, int ln, int ppos) { if (NULL == r->last) { mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL); ! return; } switch (r->last->tok) { *************** *** 881,900 **** break; default: mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL); ! return(ROFF_IGN); } if (r->last->endspan > -1) { mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL); ! return(ROFF_IGN); } - if ((*bufp)[pos]) - mandoc_msg(MANDOCERR_ARGSLOST, r->parse, ln, pos, NULL); - roffnode_pop(r); roffnode_cleanscope(r); ! return(ROFF_IGN); } --- 874,890 ---- break; default: mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL); ! return; } if (r->last->endspan > -1) { mandoc_msg(MANDOCERR_NOSCOPE, r->parse, ln, ppos, NULL); ! return; } roffnode_pop(r); roffnode_cleanscope(r); ! return; } *************** *** 1069,1075 **** */ if ((ROFF_MAX != t) && ! (ROFF_ccond == t || ROFFRULE_ALLOW == rr || ROFFMAC_STRUCT & roffs[t].flags)) { assert(roffs[t].proc); return((*roffs[t].proc)(r, t, bufp, szp, --- 1059,1065 ---- */ if ((ROFF_MAX != t) && ! (ROFFRULE_ALLOW == rr || ROFFMAC_STRUCT & roffs[t].flags)) { assert(roffs[t].proc); return((*roffs[t].proc)(r, t, bufp, szp, *************** *** 1095,1103 **** } else *(ep - 1) = *ep = ' '; ! roff_ccond(r, ROFF_ccond, bufp, szp, ! ln, pos, pos + 2, offs); ! break; } return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); } --- 1085,1091 ---- } else *(ep - 1) = *ep = ' '; ! roff_ccond(r, ln, pos); } return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); } *************** *** 1118,1125 **** if ('}' != *ep) continue; *ep = '&'; ! roff_ccond(r, ROFF_ccond, bufp, szp, ! ln, pos, pos + 2, offs); } return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); } --- 1106,1112 ---- if ('}' != *ep) continue; *ep = '&'; ! roff_ccond(r, ln, pos); } return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); }