tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: tech@mdocml.bsd.lv
Subject: Re: tbl(7) and preceding line boundaries
Date: Fri, 6 Mar 2015 14:43:59 +0100	[thread overview]
Message-ID: <20150306134359.GB12226@athene.usta.de> (raw)
In-Reply-To: <54F989C4.20304@bsd.lv>

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

  reply	other threads:[~2015-03-06 13:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06  9:43 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 [this message]
2015-03-06 15:02       ` 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=20150306134359.GB12226@athene.usta.de \
    --to=schwarze@usta.de \
    --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).