tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: tech@mdocml.bsd.lv
Subject: [PATCH] implement .rm
Date: Tue, 11 Jan 2011 00:41:31 +0100	[thread overview]
Message-ID: <20110110234131.GB4964@iris.usta.de> (raw)
In-Reply-To: <4D2B91DA.3000607@bsd.lv>

Hi Kristaps,

Kristaps Dzonsons wrote on Tue, Jan 11, 2011 at 12:10:18AM +0100:
> On 10/01/2011 23:52, Ingo Schwarze wrote:

>> i just started to implement .rm (remove macro) in libroff,
>> then realized that i would be introducing the third place
>> where names (that is, to be precise, roff macro and string names)
>> get parsed.

Having roff_getname(), this is now really easy.

> Ingo, I'm fine with this.

Thanks for looking, i'm putting that into both trees right now.

> Let me know when your changes into libroff are finished---

After the patch appended below.  ;-)

> I want to
> hash setstr() stuff, as there are a lot of pod2man and man pages
> with lots of requests, and we can probably make a measurably impact
> on performance.

Hmm, last time i did an optimization in libroff, it gave us
2% speedup on ksh(1).  Yes, that was measurable, though the
measurement was somewhat non-trivial.  :)

Thus, i will believe this gives us a measureable improvement
when i see the measurement!

Using hash tables (or RB-trees?) probably makes sense, but please
try to not hack up a third (or fourth?  i have lost count)
independent hash table implementation in mandoc.  ;-)

Yours,
  Ingo


diff -Napur mandoc.getname/roff.c mandoc/roff.c
--- mandoc.getname/roff.c	Mon Jan 10 15:24:03 2011
+++ mandoc/roff.c	Mon Jan 10 16:25:48 2011
@@ -134,10 +134,10 @@ static	char		*roff_getname(struct roff *, char **, 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);
@@ -171,7 +171,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 },
@@ -936,15 +936,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;
@@ -1086,6 +1077,22 @@ roff_nr(ROFF_ARGS)
 			rg[(int)REG_nS].v.u = 0;
 	}
 
+	return(ROFF_IGN);
+}
+
+/* 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);
 }
 
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

  reply	other threads:[~2011-01-10 23:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 22:52 [PATCH] uniform parsing of names in libroff Ingo Schwarze
2011-01-10 23:10 ` Kristaps Dzonsons
2011-01-10 23:41   ` Ingo Schwarze [this message]
2011-01-10 23:47     ` [PATCH] implement .rm Kristaps Dzonsons

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=20110110234131.GB4964@iris.usta.de \
    --to=schwarze@usta.de \
    --cc=tech@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).