diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2011-01-16 04:00:34 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2011-01-16 04:00:34 +0000 |
commit | 1ca4ada58f22986d7f95e7c5e06036d223771182 (patch) | |
tree | 8e561305321128bd573321ad57cfe9b1d201de20 | |
parent | fa547cebe06d42ee136cd3db4c7459b4d8d5d733 (diff) | |
download | mandoc-1ca4ada58f22986d7f95e7c5e06036d223771182.tar.gz mandoc-1ca4ada58f22986d7f95e7c5e06036d223771182.tar.zst mandoc-1ca4ada58f22986d7f95e7c5e06036d223771182.zip |
Implement the roff .rm request (remove macro).
Using the new roff_getname() function, this is really simple.
Breaks mandoc of the habit of reporting an error in each pod2man(1) preamble.
Reminded by a report from brad@; ok kristaps@.
-rw-r--r-- | roff.c | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.121 2011/01/11 00:11:45 schwarze Exp $ */ +/* $Id: roff.c,v 1.122 2011/01/16 04:00:34 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -138,10 +138,10 @@ static char *roff_getname(struct roff *, char **, int, int); static const char *roff_getstrn(const struct roff *, const char *, size_t); static enum rofferr roff_line_ignore(ROFF_ARGS); -static enum rofferr roff_line_error(ROFF_ARGS); static enum rofferr roff_nr(ROFF_ARGS); static int roff_res(struct roff *, char **, size_t *, int); +static enum rofferr roff_rm(ROFF_ARGS); static void roff_setstr(struct roff *, const char *, const char *, int); static enum rofferr roff_so(ROFF_ARGS); @@ -175,7 +175,7 @@ static struct roffmac roffs[ROFF_MAX] = { { "ne", roff_line_ignore, NULL, NULL, 0, NULL }, { "nh", roff_line_ignore, NULL, NULL, 0, NULL }, { "nr", roff_nr, NULL, NULL, 0, NULL }, - { "rm", roff_line_error, NULL, NULL, 0, NULL }, + { "rm", roff_rm, NULL, NULL, 0, NULL }, { "so", roff_so, NULL, NULL, 0, NULL }, { "tr", roff_line_ignore, NULL, NULL, 0, NULL }, { "TS", roff_TS, NULL, NULL, 0, NULL }, @@ -940,15 +940,6 @@ roff_line_ignore(ROFF_ARGS) /* ARGSUSED */ static enum rofferr -roff_line_error(ROFF_ARGS) -{ - - (*r->msg)(MANDOCERR_REQUEST, r->data, ln, ppos, roffs[tok].name); - return(ROFF_IGN); -} - -/* ARGSUSED */ -static enum rofferr roff_cond(ROFF_ARGS) { int sv; @@ -1095,6 +1086,22 @@ roff_nr(ROFF_ARGS) /* ARGSUSED */ static enum rofferr +roff_rm(ROFF_ARGS) +{ + const char *name; + char *cp; + + cp = *bufp + pos; + while ('\0' != *cp) { + name = roff_getname(r, &cp, ln, cp - *bufp); + if ('\0' != *name) + roff_setstr(r, name, NULL, 0); + } + return(ROFF_IGN); +} + +/* ARGSUSED */ +static enum rofferr roff_TE(ROFF_ARGS) { |