discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: discuss@mdocml.bsd.lv
Subject: Re: genassym.sh(8) SYNOPSIS oops
Date: Wed, 22 Sep 2010 22:38:04 +0200	[thread overview]
Message-ID: <20100922203804.GB15325@iris.usta.de> (raw)
In-Reply-To: <20100922135020.GA11871@bramka.kerhand.co.uk>

Hi Jason,

Jason McIntyre wrote on Wed, Sep 22, 2010 at 02:49:56PM +0059:

> source:
> 
> 	.Sh SYNOPSIS
> 	.Nm sh genassym.sh
> 	.Op Fl c
> 	.Ar C compiler invocation
> 
> groff:
> 
> 	SYNOPSIS
> 	     sh genassym.sh [-c] C compiler invocation

Gah.  When .Nm has more than one head argument in block mode,
groff uses only one of the arguments to calculate the indentation,
then uses -hang mode indeed to accomodate the fact that the head
is actually wider than the chosen indentation.

Old groff 1.15 uses the width of the *last* argument as the
indentation, which usually looks ugly.  New groff 1.20.1
uses the width of the *first* argument instead, which clearly
looks better, because the second, indented line aligns with the
second word of the .Nm.

I suggest to follow groff 1.20.1 behaviour, so we need -hang
mode if and only if the .Nm block head has more than one child.

See below for an updated patch.
The test(1) and vi(1) pages still look fine as well.

> mandoc:
> 
> 	sh genassym.sh
> 	        [-c] C compiler invocation
> 
> this is with ingo's last patch (the one that made vi work).
> some regression?

Indeed, good catch, thanks!

Yours,
  Ingo


Index: mdoc_term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mdoc_term.c,v
retrieving revision 1.104
diff -u -p -r1.104 mdoc_term.c
--- mdoc_term.c	20 Sep 2010 20:02:27 -0000	1.104
+++ mdoc_term.c	22 Sep 2010 20:33:26 -0000
@@ -1027,12 +1027,18 @@ termp_nm_pre(DECL_ARGS)
 		synopsis_pre(p, n->parent);
 
 	if (MDOC_HEAD == n->type && n->next->child) {
-		p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_HANG;
-		p->rmargin = p->offset + term_len(p, 1) +
-		    (NULL == n->child ? term_strlen(p, m->name) :
-		     MDOC_TEXT == n->child->type ?
-			term_strlen(p, n->child->string) :
-		     term_len(p, 5));
+		p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
+		p->rmargin = p->offset + term_len(p, 1);
+		if (NULL == n->child) {
+			p->rmargin += term_strlen(p, m->name);
+		} else if (MDOC_TEXT == n->child->type) {
+			p->rmargin += term_strlen(p, n->child->string);
+			if (n->child->next)
+				p->flags |= TERMP_HANG;
+		} else {
+			p->rmargin += term_len(p, 5);
+			p->flags |= TERMP_HANG;
+		}
 	}
 
 	term_fontpush(p, TERMFONT_BOLD);
Index: term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/term.c,v
retrieving revision 1.50
diff -u -p -r1.50 term.c
--- term.c	21 Sep 2010 22:33:41 -0000	1.50
+++ term.c	22 Sep 2010 20:33:28 -0000
@@ -1,4 +1,4 @@
-/*	$Id: term.c,v 1.50 2010/09/21 22:33:41 schwarze Exp $ */
+/*	$Id: term.c,v 1.49 2010/08/20 23:34:00 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -130,6 +130,7 @@ term_flushln(struct termp *p)
 	size_t		 vbl;   /* number of blanks to prepend to output */
 	size_t		 vend;	/* end of word visual position on output */
 	size_t		 bp;    /* visual right border position */
+	size_t		 dv;    /* temporary for visual pos calculations */
 	int		 j;     /* temporary loop index for p->buf */
 	int		 jhy;	/* last hyph before overflow w/r/t j */
 	size_t		 maxvis; /* output position of visible boundary */
@@ -233,7 +234,9 @@ term_flushln(struct termp *p)
 				j = i;
 				while (' ' == p->buf[i])
 					i++;
-				vbl += (i - j) * (*p->width)(p, ' ');
+				dv = (i - j) * (*p->width)(p, ' ');
+				vbl += dv;
+				vend += dv;
 				break;
 			}
 			if (ASCII_NBRSP == p->buf[i]) {
@@ -260,7 +263,6 @@ term_flushln(struct termp *p)
 				p->viscol += (*p->width)(p, p->buf[i]);
 			}
 		}
-		vend += vbl;
 		vis = vend;
 	}
 
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

  reply	other threads:[~2010-09-22 20:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22 13:50 Jason McIntyre
2010-09-22 20:38 ` Ingo Schwarze [this message]
2010-09-23 13:48   ` Jason McIntyre

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=20100922203804.GB15325@iris.usta.de \
    --to=schwarze@usta.de \
    --cc=discuss@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).