source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Implement the roff(7) .rr (remove register) request.
Date: Sat, 5 Apr 2014 16:34:58 -0400 (EDT)	[thread overview]
Message-ID: <201404052034.s35KYw7v013832@krisdoz.my.domain> (raw)

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        roff.7
        roff.c

Revision Data
-------------
Index: roff.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.7,v
retrieving revision 1.51
retrieving revision 1.52
diff -Lroff.7 -Lroff.7 -u -p -r1.51 -r1.52
--- roff.7
+++ roff.7
@@ -898,12 +898,6 @@ This line-scoped request is currently ig
 .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,
@@ -949,6 +943,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:
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.202
retrieving revision 1.203
diff -Lroff.c -Lroff.c -u -p -r1.202 -r1.203
--- roff.c
+++ roff.c
@@ -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
 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 },
@@ -1499,6 +1502,31 @@ roff_nr(ROFF_ARGS)
 
 	roff_setreg(r, key, iv, sign);
 
+	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);
 }
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-04-05 20:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201404052034.s35KYw7v013832@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).