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 o7KM4ARF014191 for ; Fri, 20 Aug 2010 18:04:13 -0400 (EDT) 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 1OmZh0-00038p-Ue; Sat, 21 Aug 2010 00:04:08 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.71) (envelope-from ) id 1OmZh0-00043D-TS; Sat, 21 Aug 2010 00:04:06 +0200 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.69) (envelope-from ) id 1OmZh0-0008Ha-S9; Sat, 21 Aug 2010 00:04:06 +0200 Received: from schwarze by usta.de with local (Exim 4.71) (envelope-from ) id 1OmZh0-0004Rt-Ke; Sat, 21 Aug 2010 00:04:06 +0200 Date: Sat, 21 Aug 2010 00:04:06 +0200 From: Ingo Schwarze To: Mark Kettenis Cc: jmc@openbsd.org, tech@mdocml.bsd.lv Subject: Re: sysctl(3) man page rendering Message-ID: <20100820220406.GC31562@iris.usta.de> References: <201008181950.o7IJojvu008258@glazunov.sibelius.xs4all.nl> <20100820142346.GB2203@iris.usta.de> 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: <20100820142346.GB2203@iris.usta.de> User-Agent: Mutt/1.5.20 (2009-06-14) Hi, Ingo Schwarze wrote on Fri, Aug 20, 2010 at 04:23:46PM +0200: > Mark Kettenis wrote on Wed, Aug 18, 2010 at 09:50:45PM +0200: >> Could you guys take a look at the sysctl(3) man page? >> The tables that list the "names" are rendered badly; >> the columns aren't lined up properly. > The following patch seems to fix the issue. > I need to test it more before committing, > but i have to leave now. > Index: term.c > =================================================================== > RCS file: /cvs/src/usr.bin/mandoc/term.c,v > retrieving revision 1.47 > diff -u -p -r1.47 term.c > --- term.c 20 Aug 2010 00:53:35 -0000 1.47 > +++ term.c 20 Aug 2010 14:19:16 -0000 > @@ -271,6 +271,12 @@ term_flushln(struct termp *p) > vis = vend; > } > > + /* > + * If there was trailing white space, it was not printed; > + * so reset the cursor position accordingly. > + */ > + vis -= vbl; > + > p->col = 0; > p->overstep = 0; After more systematic testing with both .Bl -column and .Bl -tag, it turns out this patch is indeed correct, so i shall commit it soon. While scrutinizing term_flushln() once again for logical errors (in sharp contrast to Kristaps, i like hacking in here ;-) and not finding any other errors in vis/vbl handling, i noticed that handling of leading tabs can be simplified, making the code much easier to understand, see the patch below (no functional change). I'll put that one in soon, too. Finally, i noticed that viscol handling is slightly broken, it counts the width of underlined and bold characters three times. Fortunately, viscol is so far only used in boolean context, so the exact value is not yet relevant, and i can postpone fixing that issue for now. But it must be fixed before we start using viscol for anything serious. Yours, Ingo Index: term.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/term.c,v retrieving revision 1.47 diff -u -p -r1.47 term.c --- term.c 20 Aug 2010 00:53:35 -0000 1.47 +++ term.c 20 Aug 2010 21:47:31 -0000 @@ -165,12 +165,11 @@ term_flushln(struct termp *p) * Handle literal tab characters: collapse all * subsequent tabs into a single huge set of spaces. */ - for (j = i; j < (int)p->col; j++) { - if ('\t' != p->buf[j]) - break; + while (i < (int)p->col && '\t' == p->buf[i]) { vend = (vis / p->tabwidth + 1) * p->tabwidth; vbl += vend - vis; vis = vend; + i++; } /* @@ -181,7 +180,7 @@ term_flushln(struct termp *p) */ /* LINTED */ - for (jhy = 0; j < (int)p->col; j++) { + for (j = i, jhy = 0; j < (int)p->col; j++) { if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j]) break; @@ -224,12 +223,6 @@ term_flushln(struct termp *p) p->overstep = 0; } - /* - * Skip leading tabs, they were handled above. - */ - while (i < (int)p->col && '\t' == p->buf[i]) - i++; - /* Write out the [remaining] word. */ for ( ; i < (int)p->col; i++) { if (vend > bp && jhy > 0 && i > jhy) -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv