From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.rz.uni-karlsruhe.de (Debian-exim@smtp1.rz.uni-karlsruhe.de [129.13.185.217]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p0ANfXVF024196 for ; Mon, 10 Jan 2011 18:41:34 -0500 (EST) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by smtp1.rz.uni-karlsruhe.de with esmtp (Exim 4.63 #1) id 1PcRMi-0001Gv-6Z; Tue, 11 Jan 2011 00:41:32 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1PcRMi-0001bg-5M for tech@mdocml.bsd.lv; Tue, 11 Jan 2011 00:41:32 +0100 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.69) (envelope-from ) id 1PcRMi-0007of-4H for tech@mdocml.bsd.lv; Tue, 11 Jan 2011 00:41:32 +0100 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1PcRMh-0000Wp-QM for tech@mdocml.bsd.lv; Tue, 11 Jan 2011 00:41:31 +0100 Date: Tue, 11 Jan 2011 00:41:31 +0100 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: [PATCH] implement .rm Message-ID: <20110110234131.GB4964@iris.usta.de> References: <20110110225213.GA4964@iris.usta.de> <4D2B91DA.3000607@bsd.lv> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D2B91DA.3000607@bsd.lv> User-Agent: Mutt/1.5.21 (2010-09-15) 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