=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.251 retrieving revision 1.255 diff -u -p -r1.251 -r1.255 --- mandoc/roff.c 2015/01/20 21:16:51 1.251 +++ mandoc/roff.c 2015/01/23 20:18:40 1.255 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.251 2015/01/20 21:16:51 schwarze Exp $ */ +/* $Id: roff.c,v 1.255 2015/01/23 20:18:40 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -608,7 +608,7 @@ static struct roffmac roffs[ROFF_MAX] = { { "po", roff_line_ignore, NULL, NULL, 0, NULL }, { "ps", roff_line_ignore, NULL, NULL, 0, NULL }, { "psbb", roff_unsupp, NULL, NULL, 0, NULL }, - { "pshape", roff_line_ignore, NULL, NULL, 0, NULL }, + { "pshape", roff_unsupp, NULL, NULL, 0, NULL }, { "pso", roff_insec, NULL, NULL, 0, NULL }, { "ptr", roff_line_ignore, NULL, NULL, 0, NULL }, { "pvs", roff_line_ignore, NULL, NULL, 0, NULL }, @@ -640,11 +640,11 @@ static struct roffmac roffs[ROFF_MAX] = { { "sv", roff_line_ignore, NULL, NULL, 0, NULL }, { "sy", roff_insec, NULL, NULL, 0, NULL }, { "T&", roff_T_, NULL, NULL, 0, NULL }, - { "ta", roff_line_ignore, NULL, NULL, 0, NULL }, + { "ta", roff_unsupp, NULL, NULL, 0, NULL }, { "tc", roff_unsupp, NULL, NULL, 0, NULL }, { "TE", roff_TE, NULL, NULL, 0, NULL }, { "TH", roff_TH, NULL, NULL, 0, NULL }, - { "ti", roff_line_ignore, NULL, NULL, 0, NULL }, + { "ti", roff_unsupp, NULL, NULL, 0, NULL }, { "tkf", roff_line_ignore, NULL, NULL, 0, NULL }, { "tl", roff_unsupp, NULL, NULL, 0, NULL }, { "tm", roff_line_ignore, NULL, NULL, 0, NULL }, @@ -1004,8 +1004,9 @@ roff_res(struct roff *r, struct buf *buf, int ln, int /* Advance to the end of the name. */ + naml = 0; arg_complete = 1; - for (naml = 0; maxl == 0 || naml < maxl; naml++, cp++) { + while (maxl == 0 || naml < maxl) { if (*cp == '\0') { mandoc_msg(MANDOCERR_ESC_BAD, r->parse, ln, (int)(stesc - buf->buf), stesc); @@ -1016,6 +1017,23 @@ roff_res(struct roff *r, struct buf *buf, int ln, int cp++; break; } + if (*cp++ != '\\' || stesc[1] != 'w') { + naml++; + continue; + } + switch (mandoc_escape(&cp, NULL, NULL)) { + case ESCAPE_SPECIAL: + /* FALLTHROUGH */ + case ESCAPE_UNICODE: + /* FALLTHROUGH */ + case ESCAPE_NUMBERED: + /* FALLTHROUGH */ + case ESCAPE_OVERSTRIKE: + naml++; + break; + default: + break; + } } /* @@ -1166,13 +1184,13 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, /* * First, if a scope is open and we're not a macro, pass the - * text through the macro's filter. If a scope isn't open and - * we're not a macro, just let it through. - * Finally, if there's an equation scope open, divert it into it - * no matter our state. + * text through the macro's filter. + * Equations process all content themselves. + * Tables process almost all content themselves, but we want + * to warn about macros before passing it there. */ - if (r->last && ! ctl) { + if (r->last != NULL && ! ctl) { t = r->last->tok; assert(roffs[t].text); e = (*roffs[t].text)(r, t, buf, ln, pos, pos, offs); @@ -1180,13 +1198,12 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, if (e != ROFF_CONT) return(e); } - if (r->eqn) + if (r->eqn != NULL) return(eqn_read(&r->eqn, ln, buf->buf, ppos, offs)); - if ( ! ctl) { - if (r->tbl) - return(tbl_read(r->tbl, ln, buf->buf, pos)); + if (r->tbl != NULL && ( ! ctl || buf->buf[pos] == '\0')) + return(tbl_read(r->tbl, ln, buf->buf, pos)); + if ( ! ctl) return(roff_parsetext(buf, pos, offs)); - } /* Skip empty request lines. */ @@ -1624,8 +1641,46 @@ roff_getnum(const char *v, int *pos, int *res) if (n) *res = -*res; - *pos = p; - return 1; + /* Each number may be followed by one optional scaling unit. */ + + switch (v[p]) { + case 'f': + *res *= 65536; + break; + case 'i': + *res *= 240; + break; + case 'c': + *res *= 240; + *res /= 2.54; + break; + case 'v': + /* FALLTROUGH */ + case 'P': + *res *= 40; + break; + case 'm': + /* FALLTROUGH */ + case 'n': + *res *= 24; + break; + case 'p': + *res *= 10; + *res /= 3; + break; + case 'u': + break; + case 'M': + *res *= 6; + *res /= 25; + break; + default: + p--; + break; + } + + *pos = p + 1; + return(1); } /*