diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-05 20:34:57 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-05 20:34:57 +0000 |
commit | a6e0e907b41152b48f9766f3cfd1adfdfa28963c (patch) | |
tree | 7d03fd452e1839de32f2fa511b81fd60cdee4c43 /roff.c | |
parent | 76f8a389bc9591897fd727d6aff216d42cc17798 (diff) | |
download | mandoc-a6e0e907b41152b48f9766f3cfd1adfdfa28963c.tar.gz |
Implement the roff(7) .rr (remove register) request.
As reported by sthen@, the perl-5.18 pod2man(1) preamble
thinks cool kids use that in manuals. I hope *you* know better.
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -62,6 +62,7 @@ enum rofft { ROFF_ns, ROFF_ps, ROFF_rm, + ROFF_rr, ROFF_so, ROFF_ta, ROFF_tr, @@ -202,6 +203,7 @@ static enum rofferr roff_parsetext(char **, size_t *, int, int *); static enum rofferr roff_res(struct roff *, char **, size_t *, int, int); static enum rofferr roff_rm(ROFF_ARGS); +static enum rofferr roff_rr(ROFF_ARGS); static void roff_setstr(struct roff *, const char *, const char *, int); static void roff_setstrn(struct roffkv **, const char *, @@ -251,6 +253,7 @@ static struct roffmac roffs[ROFF_MAX] = { { "ns", roff_line_ignore, NULL, NULL, 0, NULL }, { "ps", roff_line_ignore, NULL, NULL, 0, NULL }, { "rm", roff_rm, NULL, NULL, 0, NULL }, + { "rr", roff_rr, NULL, NULL, 0, NULL }, { "so", roff_so, NULL, NULL, 0, NULL }, { "ta", roff_line_ignore, NULL, NULL, 0, NULL }, { "tr", roff_tr, NULL, NULL, 0, NULL }, @@ -1502,6 +1505,31 @@ roff_nr(ROFF_ARGS) return(ROFF_IGN); } +static enum rofferr +roff_rr(ROFF_ARGS) +{ + struct roffreg *reg, **prev; + const char *name; + char *cp; + + cp = *bufp + pos; + name = roff_getname(r, &cp, ln, pos); + + prev = &r->regtab; + while (1) { + reg = *prev; + if (NULL == reg || !strcmp(name, reg->key.p)) + break; + prev = ®->next; + } + if (NULL != reg) { + *prev = reg->next; + free(reg->key.p); + free(reg); + } + return(ROFF_IGN); +} + /* ARGSUSED */ static enum rofferr roff_rm(ROFF_ARGS) |