diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-04-05 20:33:39 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-04-05 20:33:39 +0000 |
commit | e338fced38feb2bdd0f5a2adcf97ecf0936e02ee (patch) | |
tree | c2e46114e96382dfcd3f64f89ff9012567087ded /usr.bin | |
parent | 19161018813038fd466d9743673d9e9b14006270 (diff) |
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 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/roff.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 0084569fb7d..8e4e8727a2d 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.75 2014/03/21 22:52:21 schwarze Exp $ */ +/* $Id: roff.c,v 1.76 2014/04/05 20:33:38 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -58,6 +58,7 @@ enum rofft { ROFF_ns, ROFF_ps, ROFF_rm, + ROFF_rr, ROFF_so, ROFF_ta, ROFF_tr, @@ -198,6 +199,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 *, @@ -247,6 +249,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 }, @@ -1498,6 +1501,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) |