summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/mandoc/roff/nr/Makefile4
-rw-r--r--regress/usr.bin/mandoc/roff/nr/rr.in15
-rw-r--r--regress/usr.bin/mandoc/roff/nr/rr.out_ascii14
-rw-r--r--share/man/man7/roff.720
-rw-r--r--usr.bin/mandoc/roff.c30
5 files changed, 72 insertions, 11 deletions
diff --git a/regress/usr.bin/mandoc/roff/nr/Makefile b/regress/usr.bin/mandoc/roff/nr/Makefile
index 03327299fef..19e66eb2ae0 100644
--- a/regress/usr.bin/mandoc/roff/nr/Makefile
+++ b/regress/usr.bin/mandoc/roff/nr/Makefile
@@ -1,5 +1,5 @@
-# $OpenBSD: Makefile,v 1.3 2014/02/14 22:27:32 schwarze Exp $
+# $OpenBSD: Makefile,v 1.4 2014/04/05 20:33:38 schwarze Exp $
-REGRESS_TARGETS = int argc predef
+REGRESS_TARGETS = int argc predef rr
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/roff/nr/rr.in b/regress/usr.bin/mandoc/roff/nr/rr.in
new file mode 100644
index 00000000000..06ccdf6422c
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/nr/rr.in
@@ -0,0 +1,15 @@
+.TH NR-RR 1 "April 5, 2014" OpenBSD
+.SH NAME
+nr-rr \- defining and undefining number registers
+.SH DESCRIPTION
+.nr key1 1
+.nr key2 2
+.nr key3 3
+.nr key4 4
+.nr key5 5
+.rr key1
+.rr key3
+.rr key5
+non-null values: \n[key2] \n[key4]
+.br
+unset values: \n[key1] \n[key3] \n[key5]
diff --git a/regress/usr.bin/mandoc/roff/nr/rr.out_ascii b/regress/usr.bin/mandoc/roff/nr/rr.out_ascii
new file mode 100644
index 00000000000..fe554d60199
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/nr/rr.out_ascii
@@ -0,0 +1,14 @@
+NR-RR(1) OpenBSD Reference Manual NR-RR(1)
+
+
+
+NNAAMMEE
+ nr-rr - defining and undefining number registers
+
+DDEESSCCRRIIPPTTIIOONN
+ non-null values: 2 4
+ unset values: 0 0 0
+
+
+
+OpenBSD April 5, 2014 NR-RR(1)
diff --git a/share/man/man7/roff.7 b/share/man/man7/roff.7
index 79f1748a074..79123050938 100644
--- a/share/man/man7/roff.7
+++ b/share/man/man7/roff.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: roff.7,v 1.30 2014/03/30 21:27:59 schwarze Exp $
+.\" $OpenBSD: roff.7,v 1.31 2014/04/05 20:33:38 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010, 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 30 2014 $
+.Dd $Mdocdate: April 5 2014 $
.Dt ROFF 7
.Os
.Sh NAME
@@ -896,12 +896,6 @@ This line-scoped request is currently ignored.
.Ss \&nh
Turn off automatic hyphenation mode.
This line-scoped request is currently ignored.
-.Ss \&rm
-Remove a request, macro or string.
-This request is intended to have one argument,
-the name of the request, macro or string to be undefined.
-Currently, it is ignored including its arguments,
-and the number of arguments is not checked.
.Ss \&nr
Define or change a register.
A register is an arbitrary string value that defines some sort of state,
@@ -947,6 +941,16 @@ Change point size.
This line-scoped request is intended to take one numerical argument.
Currently, it is ignored including its arguments,
and the number of arguments is not checked.
+.Ss \&rm
+Remove a request, macro or string.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Cm \&rm Ar name
+.Ss \&rr
+Remove a register.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Cm \&rr Ar name
.Ss \&so
Include a source file.
Its syntax is as follows:
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 = &reg->next;
+ }
+ if (NULL != reg) {
+ *prev = reg->next;
+ free(reg->key.p);
+ free(reg);
+ }
+ return(ROFF_IGN);
+}
+
/* ARGSUSED */
static enum rofferr
roff_rm(ROFF_ARGS)