tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: jmc@openbsd.org, tech@mdocml.bsd.lv
Subject: Re: sysctl(3) man page rendering
Date: Sat, 21 Aug 2010 00:04:06 +0200	[thread overview]
Message-ID: <20100820220406.GC31562@iris.usta.de> (raw)
In-Reply-To: <20100820142346.GB2203@iris.usta.de>

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

  reply	other threads:[~2010-08-20 22:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201008181950.o7IJojvu008258@glazunov.sibelius.xs4all.nl>
2010-08-20 14:23 ` Ingo Schwarze
2010-08-20 22:04   ` Ingo Schwarze [this message]
2010-08-21 17:34     ` 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=20100820220406.GC31562@iris.usta.de \
    --to=schwarze@usta.de \
    --cc=jmc@openbsd.org \
    --cc=mark.kettenis@xs4all.nl \
    --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).