tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* tbl(7) and preceding line boundaries
@ 2015-03-06  9:43 Kristaps Dzonsons
  2015-03-06 10:49 ` Ingo Schwarze
  0 siblings, 1 reply; 7+ messages in thread
From: Kristaps Dzonsons @ 2015-03-06  9:43 UTC (permalink / raw)
  To: tech

[-- Attachment #1: Type: text/plain, Size: 260 bytes --]

Hi,

I'm able to fool mandoc(1) into arbitrarily stretching its page boundary
by the enclosed graph.  In short, it seems that tbl(7) code directly
following free-form text causes a flush of the text after the right
margin is relieved.

Ideas?

Best,

Kristaps

[-- Attachment #2: foo.7 --]
[-- Type: text/plain, Size: 619 bytes --]

.Dd 2015-03-06
.Dt XYZZY 7
.Os
.Sh NAME
.Nm foo
.Nd bar
.Sh DESCRIPTION
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor
incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
.TS
l l l l.
Complex Numbers  Roots of Polynomials
Special Functions        Vectors and Matrices
.TE

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

* Re: tbl(7) and preceding line boundaries
  2015-03-06  9:43 tbl(7) and preceding line boundaries Kristaps Dzonsons
@ 2015-03-06 10:49 ` Ingo Schwarze
  2015-03-06 10:55   ` Kristaps Dzonsons
  2015-03-06 11:04   ` Kristaps Dzonsons
  0 siblings, 2 replies; 7+ messages in thread
From: Ingo Schwarze @ 2015-03-06 10:49 UTC (permalink / raw)
  To: tech

Hi Kristaps,

Kristaps Dzonsons wrote on Fri, Mar 06, 2015 at 10:43:43AM +0100:

> I'm able to fool mandoc(1) into arbitrarily stretching its page boundary
> by the enclosed graph.  In short, it seems that tbl(7) code directly
> following free-form text causes a flush of the text after the right
> margin is relieved.

Looking at the history of tbl_term.c, that seems to be broken since
basically forever, at least since 2011.

> Ideas?

Do you agree with the following simple fix?

It doesn't seem important enough to make the OpenBSD 5.7 release,
though.  If you agree, i would commit to bsd.lv now and to OpenBSD
after unlock.

Yours,
  Ingo


Index: tbl_term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/tbl_term.c,v
retrieving revision 1.26
diff -u -p -r1.26 tbl_term.c
--- tbl_term.c	31 Jan 2015 00:11:52 -0000	1.26
+++ tbl_term.c	6 Mar 2015 10:46:19 -0000
@@ -64,6 +64,9 @@ term_tbl(struct termp *tp, const struct 
 	size_t			 rmargin, maxrmargin, tsz;
 	int			 ic, horiz, spans, vert;
 
+	if (tp->tbl.cols == NULL)
+		term_flushln(tp);
+
 	rmargin = tp->rmargin;
 	maxrmargin = tp->maxrmargin;
 
@@ -80,8 +83,6 @@ term_tbl(struct termp *tp, const struct 
 	 */
 
 	if (tp->tbl.cols == NULL) {
-		term_flushln(tp);
-
 		tp->tbl.len = term_tbl_len;
 		tp->tbl.slen = term_tbl_strlen;
 		tp->tbl.arg = tp;
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

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

* Re: tbl(7) and preceding line boundaries
  2015-03-06 10:49 ` Ingo Schwarze
@ 2015-03-06 10:55   ` Kristaps Dzonsons
  2015-03-06 22:24     ` Ingo Schwarze
  2015-03-06 11:04   ` Kristaps Dzonsons
  1 sibling, 1 reply; 7+ messages in thread
From: Kristaps Dzonsons @ 2015-03-06 10:55 UTC (permalink / raw)
  To: tech

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

>> I'm able to fool mandoc(1) into arbitrarily stretching its page 
>> boundary by the enclosed graph.  In short, it seems that tbl(7) 
>> code directly following free-form text causes a flush of the
>> text after the right margin is relieved.
> 
> Looking at the history of tbl_term.c, that seems to be broken since
> basically forever, at least since 2011.
> 
>> Ideas?
> 
> Do you agree with the following simple fix?
> 
> It doesn't seem important enough to make the OpenBSD 5.7 release, 
> though.  If you agree, i would commit to bsd.lv now and to OpenBSD
>  after unlock.

Ingo,

That fixes the issue, thanks!  I don't think it's important at all--I
only noticed it when running texi2mdoc(1) on the GSL manual.  (Texinfo
manuals seem to (ab)use the @multitable command a lot, which maps to
TS/TE.  So it exercises the tbl(7) functionality quite a lot.)

One thing I'm still not sure about is whether it's possible to affect
multiline columns in tbl(7), but that's a different story.

Best,

Kristaps
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQIcBAEBCgAGBQJU+YefAAoJEMT2SUY9XBES9lcP/A1loZMbM4GSw5zrOUVAKOqO
eUkDa5gBRqeUa81UlVeRyLZ69M1igk0vFkLhBTDmw/7V7Y3q9wy5GgNfq41LnaXM
un0+Exak8SXNfSTLZgyJwo5l/kpciCz6mUekb2GCPbsPjulRZT0stFmE9CcGsje+
Xf6SUnZ6qGlKceWGrChytI1ULsoegI4mQDrtwgw+jl34a8r0D5/3KY4k5SeVZGuJ
gZtGIlz9rCmhmPLCvpbP5HNAxS2TKKqbu3eFDWKC/vzp6GKvQDqWYoHsoolnnIWj
iKnrY4eKdix1tQQw8YDBFuM73sZXVBO/CCnNS2c18Xz92btoqa2EXOrAE/bUAefL
SqBfz2weEdA0TxoZ8HY8GyN4Gtl9CpN/oaBsnHfWgqggvkxdC50DpXJFjSLekEH2
9/bSxgLDMhXLJ4ubz5XXtWYLvVJHHDvYVn8odHk44f9j0z43u4t9O3VuoHpRPzoJ
Y93L6kvABZ6FCPq3YnJ4dGYFuEJot3ucWbA4abkHLtDEmBuU5be/raNiOdLgCYAo
5VkCLF8hAEXAdwcQMXPmYwYoUcZL3NrHM0+Gm6HD3iSbbdsb7c6qy54vcVJJMu6g
tYTlU3SXbvt1ZeBUAEmotFihB/PFd7wITkun+6tSBWM5aqz2hyhYo0eh3T5z4Zm2
KuKz5wtsFqwF9VKHSKpb
=0snA
-----END PGP SIGNATURE-----
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

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

* Re: tbl(7) and preceding line boundaries
  2015-03-06 10:49 ` Ingo Schwarze
  2015-03-06 10:55   ` Kristaps Dzonsons
@ 2015-03-06 11:04   ` Kristaps Dzonsons
  2015-03-06 13:43     ` Ingo Schwarze
  1 sibling, 1 reply; 7+ messages in thread
From: Kristaps Dzonsons @ 2015-03-06 11:04 UTC (permalink / raw)
  To: tech

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Ingo,

Actually, a new problem has arisen.  If I now put a `Pp' in front of
the `TS', it effects a double newline in mandoc(1) output instead of
the expected single newline.

Best,

Kristaps
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQIcBAEBCgAGBQJU+YnEAAoJEMT2SUY9XBES8FwQAKREfb8yI5lyLutesco2hree
+CASIzLFuPa6VbJvqeule+yPu7SfX6nD+67Nm77ohxFLldBipu1pbvgWTD4S2iKw
3tcpaq3a0wu4rOWMgwNJlIFpYUrFlaU/ApRhoL5Mf307EEht84dksSTt/m9s2aHg
wpZpQ+5NPMgR0j9ObkUQLuUiFG8NF+cVAqUEyfUFIvWebgFyWZK8NdQId8p815vu
gXaOFJ2cDxqcdy6vTbicTLemdylgrkYclZ4kbmEky3JsfRn19fPnDv5NyMvX63+t
Swa38fdyE5fzBk/cdieheaqOjc03SBfpORzaqQ0DIQsRTLdZEHzQPrhaRDtVXKFr
WrfrmFPoAHkHi4XtfaV1bXeQdSfUq/C+qrYDVJOx38Nspaps7FwLIY9obD8w6moZ
GLomWwi+O0MFcVtZ1kXl67F9K/g4yXPdOwLzWG0kDKtZel/4JQ/L5CY8QplEOL/B
cZW8ar/KYhUULo0iNMjzrng+JQTcb17+COn6IoSlgOHlpxaO6mqPfHHuiBdxZo1M
fcEnmA7CzcA9VtfYn8FfPDyFPyXOuVnPTjhkqYscM73DLXEhAGnqPdOJVUdQC5B0
RoeJ6RKtW/8/pyptq1D10kyLX1hzLCf8WRAg/FhYypTrMlqTuVPQbXBOZqw1RCRq
2wMFkVFbLfu5vAg7H72S
=71Nz
-----END PGP SIGNATURE-----
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

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

* Re: tbl(7) and preceding line boundaries
  2015-03-06 11:04   ` Kristaps Dzonsons
@ 2015-03-06 13:43     ` Ingo Schwarze
  2015-03-06 15:02       ` Kristaps Dzonsons
  0 siblings, 1 reply; 7+ messages in thread
From: Ingo Schwarze @ 2015-03-06 13:43 UTC (permalink / raw)
  To: tech

Hi Kristaps,

Kristaps Dzonsons wrote on Fri, Mar 06, 2015 at 12:04:36PM +0100:

> Actually, a new problem has arisen.  If I now put a `Pp' in front of
> the `TS', it effects a double newline in mandoc(1) output instead of
> the expected single newline.

That didn't change with my previous commit, it is an unrelated bug -
except that it affects the same line of code.  Sometimes, it's
amzing how many bugs can feed on how little code.  Almost as if
one byte of code could nurture up to eight unrelated bugs...

Actually, mdoc(7) and man(7) treat vertical spacing before tables
differently.  mdoc(7) only breaks the line; if you want vertcal
spacing, you need an explicit .Pp.  man(7), on the other hand,
always prints a blank line before a table.  Consequently, to
fix *this* bug, vertical space handling cannot remain in the
table formatter but must be moved to the macro formatters,
which the following patch does.

Note that the existing comment in the man(7) formatter contradicts
both the behaviour of the existing code and the desirable
behavour, somewhat like this:

	i += 2;  /* To decrement i, we have to add one. */

The old code was indeed non-obvious because vertical spacing
was manipulated in both print_man_node() and term_tbl().
The new code is obvious enough and can speak for itself;
it really doesn't need a comment like

	term_vspace(p);  /* Assure a blank line before the table. */

OK?
  Ingo


Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.168
diff -u -p -r1.168 man_term.c
--- man_term.c	30 Jan 2015 22:04:44 -0000	1.168
+++ man_term.c	6 Mar 2015 13:16:39 -0000
@@ -945,12 +945,8 @@ print_man_node(DECL_ARGS)
 			p->flags |= TERMP_NOSPACE;
 		return;
 	case MAN_TBL:
-		/*
-		 * Tables are preceded by a newline.  Then process a
-		 * table line, which will cause line termination,
-		 */
-		if (n->span->prev == NULL)
-			term_newln(p);
+		if (p->tbl.cols == NULL)
+			term_vspace(p);
 		term_tbl(p, n->span);
 		return;
 	default:
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.312
diff -u -p -r1.312 mdoc_term.c
--- mdoc_term.c	6 Mar 2015 13:09:07 -0000	1.312
+++ mdoc_term.c	6 Mar 2015 13:16:39 -0000
@@ -348,6 +348,8 @@ print_mdoc_node(DECL_ARGS)
 			p->flags |= TERMP_NOSPACE;
 		break;
 	case MDOC_TBL:
+		if (p->tbl.cols == NULL)
+			term_newln(p);
 		term_tbl(p, n->span);
 		break;
 	default:
Index: tbl_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tbl_term.c,v
retrieving revision 1.39
diff -u -p -r1.39 tbl_term.c
--- tbl_term.c	6 Mar 2015 11:03:03 -0000	1.39
+++ tbl_term.c	6 Mar 2015 13:16:39 -0000
@@ -66,9 +66,6 @@ term_tbl(struct termp *tp, const struct 
 	size_t			 rmargin, maxrmargin, tsz;
 	int			 ic, horiz, spans, vert;
 
-	if (tp->tbl.cols == NULL)
-		term_flushln(tp);
-
 	rmargin = tp->rmargin;
 	maxrmargin = tp->maxrmargin;
 
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

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

* Re: tbl(7) and preceding line boundaries
  2015-03-06 13:43     ` Ingo Schwarze
@ 2015-03-06 15:02       ` Kristaps Dzonsons
  0 siblings, 0 replies; 7+ messages in thread
From: Kristaps Dzonsons @ 2015-03-06 15:02 UTC (permalink / raw)
  To: tech

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Ingo,

I didn't verify the man(7) behaviour but can see that it fixes
rendering in mdoc(7), both with and without the preceding `Pp'.  Thank
you!

Best,

Kristaps
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQIcBAEBCgAGBQJU+cGQAAoJEMT2SUY9XBESA54P/2Wwsww7MzzxzSknScCvPRZ5
rvSlgt1EdkDvC1f83yKdIo+un13HjI/8wbDTkRjuQOzBQhTrYyYljwTobW8neId1
fiKgeW814/q0NmouaZ8h349xBheWMyAyjEXTqdMkOY7QXn9VqFqgLEjABDXfsclm
e5zMyKeNeSgb0WGpFn4/gxd6PrN30tOYHJkgru3NHyh+gw6b+chFV6B1MVVQsAoy
EYszoirC6GClzxKfq2L0GY553oyKMvQT9MAVU8F8BEfh2O4LVuxLQjKu3XmBbSxB
MFDSPExDINTP0+kbDevDjZnB0CeVgJzsazbM2i6CA5MZfsUWr6YgZUmTkKrbjcxe
BMUxtkJKK2kInrxZyjy6IzALLUCfNOt7pfLmyIg+IQTpbSAbcjHgLAFasm9Qj/5B
0iHVPZIiC7aMRAtpVE719kbjWnLpX9FBpS7clA16TrYDJYFDu3j1MGCKCtN71c8J
CibFkHgynhAK/H1t6t3mpWM3kYyzf9hYTRA9vkTSQp3gVi77aZjkkckUdF8el8tO
TqtUr3mX13tMrBO89m2KQNSEJ/w7DYZXjz/iaskRPX9jhT1kAFkdfdhDaQ/wf/lQ
XsK9ECI+7qPAwmnePN1B/QmdCzb4yx/4vUW6snBb5N223O4qgok2mKDc0cTaZjCT
F1S+AiUAGYZBilhqb43b
=OR8B
-----END PGP SIGNATURE-----
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

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

* Re: tbl(7) and preceding line boundaries
  2015-03-06 10:55   ` Kristaps Dzonsons
@ 2015-03-06 22:24     ` Ingo Schwarze
  0 siblings, 0 replies; 7+ messages in thread
From: Ingo Schwarze @ 2015-03-06 22:24 UTC (permalink / raw)
  To: tech

Hi Kristaps,

Kristaps Dzonsons wrote on Fri, Mar 06, 2015 at 11:55:27AM +0100:

> One thing I'm still not sure about is whether it's possible to affect
> multiline columns in tbl(7), but that's a different story.

You mean,

.Dd March 6, 2015
.Dt TEST 1
.Os
.Sh NAME
.Nm test
.Nd spans
.Sh DESCRIPTION
.TS
tab(:) box;
c s|c
c c|^
c|c|^
^|c ^
^|c s.
horiz:vert
_:_:
vert:X:
:_:_
:horiz
.TE

Rendering is clearly far from perfect, but it could be improved
if needed.

Yours,
  Ingo
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

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

end of thread, other threads:[~2015-03-06 22:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-06  9:43 tbl(7) and preceding line boundaries Kristaps Dzonsons
2015-03-06 10:49 ` Ingo Schwarze
2015-03-06 10:55   ` Kristaps Dzonsons
2015-03-06 22:24     ` Ingo Schwarze
2015-03-06 11:04   ` Kristaps Dzonsons
2015-03-06 13:43     ` Ingo Schwarze
2015-03-06 15:02       ` 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).