summaryrefslogtreecommitdiffstats
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-06-14 14:02:39 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-06-14 14:02:39 +0000
commitf47c24ce5479036f4e05569d948d51dbebcb1f9d (patch)
treebd0d1c73aad4e3919635064f8a112b2b14ff9297 /roff.c
parent57f77c200a922cb0605b19e4b87d3c8931dd568a (diff)
downloadmandoc-f47c24ce5479036f4e05569d948d51dbebcb1f9d.tar.gz
implement the roff(7) d (macro or string defined) conditional
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/roff.c b/roff.c
index fe53be97..2983c1d1 100644
--- a/roff.c
+++ b/roff.c
@@ -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;
}