tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* Re: sysctl(3) man page rendering
       [not found] <201008181950.o7IJojvu008258@glazunov.sibelius.xs4all.nl>
@ 2010-08-20 14:23 ` Ingo Schwarze
  2010-08-20 22:04   ` Ingo Schwarze
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Schwarze @ 2010-08-20 14:23 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: jmc, tech

Hi Mark,

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.

Thanks for reporting!
  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 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;
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sysctl(3) man page rendering
  2010-08-20 14:23 ` sysctl(3) man page rendering Ingo Schwarze
@ 2010-08-20 22:04   ` Ingo Schwarze
  2010-08-21 17:34     ` Kristaps Dzonsons
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Schwarze @ 2010-08-20 22:04 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: jmc, tech

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: sysctl(3) man page rendering
  2010-08-20 22:04   ` Ingo Schwarze
@ 2010-08-21 17:34     ` Kristaps Dzonsons
  0 siblings, 0 replies; 3+ messages in thread
From: Kristaps Dzonsons @ 2010-08-21 17:34 UTC (permalink / raw)
  To: tech; +Cc: Mark Kettenis, jmc

>>> 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.

Incidentally, these look alright to me; I can't spot any logic errors,
but I didn't look too hard given my time constraints.  So a retroactive
"ok" by me.

Kristaps
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-21 17:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <201008181950.o7IJojvu008258@glazunov.sibelius.xs4all.nl>
2010-08-20 14:23 ` sysctl(3) man page rendering Ingo Schwarze
2010-08-20 22:04   ` Ingo Schwarze
2010-08-21 17:34     ` Kristaps Dzonsons

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).