diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-06-14 14:02:39 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-06-14 14:02:39 +0000 |
commit | f47c24ce5479036f4e05569d948d51dbebcb1f9d (patch) | |
tree | bd0d1c73aad4e3919635064f8a112b2b14ff9297 /roff.c | |
parent | 57f77c200a922cb0605b19e4b87d3c8931dd568a (diff) | |
download | mandoc-f47c24ce5479036f4e05569d948d51dbebcb1f9d.tar.gz |
implement the roff(7) d (macro or string defined) conditional
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -2065,7 +2065,7 @@ roff_evalcond(struct roff *r, int ln, char *v, int *pos) { char *cp, *name; size_t sz; - int number, savepos, wanttrue; + int number, savepos, istrue, wanttrue; if ('!' == v[*pos]) { wanttrue = 0; @@ -2081,17 +2081,23 @@ roff_evalcond(struct roff *r, int ln, char *v, int *pos) (*pos)++; return wanttrue; case 'c': - case 'd': case 'e': case 't': case 'v': (*pos)++; return !wanttrue; + case 'd': case 'r': - cp = name = v + ++*pos; - sz = roff_getname(r, &cp, ln, *pos); + cp = v + *pos + 1; + while (*cp == ' ') + cp++; + name = cp; + sz = roff_getname(r, &cp, ln, cp - v); + istrue = sz && (v[*pos] == 'r' ? roff_hasregn(r, name, sz) : + (roff_getstrn(r, name, sz) != NULL || + roff_getrenn(r, name, sz) != NULL)); *pos = cp - v; - return (sz && roff_hasregn(r, name, sz)) == wanttrue; + return istrue == wanttrue; default: break; } |