discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
* groff-1.19.2 difference: indent
@ 2011-09-18 16:24 Thomas Klausner
  2011-09-18 16:32 ` Ingo Schwarze
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Klausner @ 2011-09-18 16:24 UTC (permalink / raw)
  To: discuss

Nicolas Joly reports a few differences between groff 1.19.2 and
1.11.1.

I've verified against 1.11.7, only one of them is still there:

----- Forwarded message from Nicolas Joly <njoly@pasteur.fr> -----

2) In SYNOPSIS, functions with big prototypes are not indented after
   line wrap, which can occur between argument type and name. Check
   wborder(3).

20,21c20,21
<      wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs,
<          chtype tl, chtype tr, chtype bl, chtype br);
---
>      wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype
>      tl, chtype tr, chtype bl, chtype br);

----- End forwarded message -----

Additionally, I've also noticed on this example that "chtype" and "tl"
are split across lines. The source for this is:
.Fa "chtype tl"
I wonder why it's split and not handled as one item?

Cheers,
 Thomas
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

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

* Re: groff-1.19.2 difference: indent
  2011-09-18 16:24 groff-1.19.2 difference: indent Thomas Klausner
@ 2011-09-18 16:32 ` Ingo Schwarze
  2011-09-19 13:35   ` Thomas Klausner
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Schwarze @ 2011-09-18 16:32 UTC (permalink / raw)
  To: Thomas Klausner; +Cc: discuss

Hi Thomas,

thanks for reporting.
I have updated the TODO entry, see below.

I think you are right, both aspects should be improved in mandoc.

Yours,
  Ingo


Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.120
diff -u -r1.120 TODO
--- TODO	28 Jul 2011 14:37:39 -0000	1.120
+++ TODO	18 Sep 2011 16:38:44 -0000
@@ -264,6 +266,9 @@
 - When .Fn arguments exceed one output line, all but the first
   should be indented, see e.g. rpc(3);
   reported by jmc@ on discuss@  Fri, 29 Oct 2010 13:48:33 +0100
+  reported again by Nicolas Joly via wiz@  Sun, 18 Sep 2011 18:24:40 +0200
+  Also, we don't want to break the line within the argument of:
+  .Fa "chtype tl"
 
 - .Ns should work when called at the end of an input line, see
   the following code in vi(1):


Thomas Klausner wrote on Sun, Sep 18, 2011 at 06:24:40PM +0200:

> Nicolas Joly reports a few differences between groff 1.19.2 and
> 1.11.1.
> 
> I've verified against 1.11.7, only one of them is still there:
> 
> ----- Forwarded message from Nicolas Joly <njoly@pasteur.fr> -----
> 
> 2) In SYNOPSIS, functions with big prototypes are not indented after
>    line wrap, which can occur between argument type and name. Check
>    wborder(3).
> 
> 20,21c20,21
> <      wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs,
> <          chtype tl, chtype tr, chtype bl, chtype br);
> ---
> >      wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype
> >      tl, chtype tr, chtype bl, chtype br);
> 
> ----- End forwarded message -----
> 
> Additionally, I've also noticed on this example that "chtype" and "tl"
> are split across lines. The source for this is:
> .Fa "chtype tl"
> I wonder why it's split and not handled as one item?
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

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

* Re: groff-1.19.2 difference: indent
  2011-09-18 16:32 ` Ingo Schwarze
@ 2011-09-19 13:35   ` Thomas Klausner
  2011-09-20  9:12     ` Ingo Schwarze
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Klausner @ 2011-09-19 13:35 UTC (permalink / raw)
  To: discuss

On Sun, Sep 18, 2011 at 06:32:25PM +0200, Ingo Schwarze wrote:
> thanks for reporting.
> I have updated the TODO entry, see below.

Thanks.

I tested one of the issues Nicolas found incorrectly, so here's another unfixed one:

1) For long names, you end up with 3 lines (mandoc) instead of one
   (nroff). By example curses_default_colors(3)
< CURSES_DEFAULT_COLOR... NetBSD Library Functions ManualCURSES_DEFAULT_COLOR...
---
> CURSES_DEFAULT_COLORS(3)
>                         NetBSD Library Functions Manual
>                                                       CURSES_DEFAULT_COLORS(3)


I can't say I like the "..." but three lines is worse in my eyes...

Cheers,
 Thomas
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

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

* Re: groff-1.19.2 difference: indent
  2011-09-19 13:35   ` Thomas Klausner
@ 2011-09-20  9:12     ` Ingo Schwarze
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Schwarze @ 2011-09-20  9:12 UTC (permalink / raw)
  To: Thomas Klausner; +Cc: discuss

Hi Thomas,

Thomas Klausner wrote on Mon, Sep 19, 2011 at 03:35:33PM +0200:

> I tested one of the issues Nicolas found incorrectly,
> so here's another unfixed one:
> 
> 1) For long names, you end up with 3 lines (mandoc) instead of one
>    (nroff). By example curses_default_colors(3)
> < CURSES_DEFAULT_COLOR... NetBSD Library Functions ManualCURSES_DEFAULT_COLOR...
> ---
> > CURSES_DEFAULT_COLORS(3)
> >                         NetBSD Library Functions Manual
> >                                                       CURSES_DEFAULT_COLORS(3)
> 
> I can't say I like the "..." but three lines is worse in my eyes...

Indeed, dropping content just to slavishly adhere to a format where
the content won't fit is stupid, so we decided a long time ago that
we won't follow groff in this respect.

But what mandoc(1) does with mdoc(7) is not nice either; i have now
committed a patch to both OpenBSD and bsd.lv to use the same format
for mdoc(7) that we had chosen for man(7) - when the title gets too
long, it now does this:

CURSES_DEFAULT_COLORS(3)                       NetBSD Library Functions Manual

NAME
     curses_default_colors, assume_default_colors, use_default_colors - curses
     default colors setting routines


Thanks for the reminder,
  Ingo


Log Message:
-----------
Sync print_mdoc_head to print_man_head;                    
this was forgotten after man_term.c rev. 1.25 on March 2, 2010.
The benefit is a sane page header line when .Dt is very long.
Reminded by Thomas Klausner <wiz at NetBSD>, thanks.

Modified Files:
--------------
    mdocml:
        man_term.c
        mdoc_term.c

Revision Data
-------------
Index: man_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -Lman_term.c -Lman_term.c -u -p -r1.117 -r1.118
--- man_term.c
+++ man_term.c
@@ -1007,9 +1007,9 @@ print_man_head(struct termp *p, const vo
 	 * point we did so here.
 	 */
 
+	p->offset = 0;
 	p->rmargin = p->maxrmargin;
 
-	p->offset = 0;
 	buf[0] = title[0] = '\0';
 
 	if (m->vol)
@@ -1019,12 +1019,12 @@ print_man_head(struct termp *p, const vo
 	snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec);
 	titlen = term_strlen(p, title);
 
+	p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
 	p->offset = 0;
 	p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ?
 	    (p->maxrmargin - 
 	     term_strlen(p, buf) + term_len(p, 1)) / 2 :
 	    p->maxrmargin - buflen;
-	p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
 
 	term_word(p, title);
 	term_flushln(p);
@@ -1046,9 +1046,9 @@ print_man_head(struct termp *p, const vo
 		term_flushln(p);
 	}
 
-	p->rmargin = p->maxrmargin;
-	p->offset = 0;
 	p->flags &= ~TERMP_NOSPACE;
+	p->offset = 0;
+	p->rmargin = p->maxrmargin;
 
 	/* 
 	 * Groff likes to have some leading spaces before content.  Well
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.234
retrieving revision 1.235
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.234 -r1.235
--- mdoc_term.c
+++ mdoc_term.c
@@ -458,13 +458,11 @@ static void
 print_mdoc_head(struct termp *p, const void *arg)
 {
 	char		buf[BUFSIZ], title[BUFSIZ];
+	size_t		buflen, titlen;
 	const struct mdoc_meta *m;
 
 	m = (const struct mdoc_meta *)arg;
 
-	p->rmargin = p->maxrmargin;
-	p->offset = 0;
-
 	/*
 	 * The header is strange.  It has three components, which are
 	 * really two with the first duplicated.  It goes like this:
@@ -478,8 +476,12 @@ print_mdoc_head(struct termp *p, const v
 	 * switches on the manual section.
 	 */
 
+	p->offset = 0;
+	p->rmargin = p->maxrmargin;
+
 	assert(m->vol);
 	strlcpy(buf, m->vol, BUFSIZ);
+	buflen = term_strlen(p, buf);
 
 	if (m->arch) {
 		strlcat(buf, " (", BUFSIZ);
@@ -488,33 +490,38 @@ print_mdoc_head(struct termp *p, const v
 	}
 
 	snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec);
+	titlen = term_strlen(p, title);
 
-	p->offset = 0;
-	p->rmargin = (p->maxrmargin - 
-			term_strlen(p, buf) + term_len(p, 1)) / 2;
 	p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
+	p->offset = 0;
+	p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ?
+	    (p->maxrmargin -
+	     term_strlen(p, buf) + term_len(p, 1)) / 2 :
+	    p->maxrmargin - buflen;
 
 	term_word(p, title);
 	term_flushln(p);
 
-	p->offset = p->rmargin;
-	p->rmargin = p->maxrmargin - term_strlen(p, title);
 	p->flags |= TERMP_NOSPACE;
+	p->offset = p->rmargin;
+	p->rmargin = p->offset + buflen + titlen < p->maxrmargin ?
+	    p->maxrmargin - titlen : p->maxrmargin;
 
 	term_word(p, buf);
 	term_flushln(p);
 
-	p->offset = p->rmargin;
-	p->rmargin = p->maxrmargin;
 	p->flags &= ~TERMP_NOBREAK;
-	p->flags |= TERMP_NOSPACE;
-
-	term_word(p, title);
-	term_flushln(p);
+	if (p->rmargin + titlen <= p->maxrmargin) {
+		p->flags |= TERMP_NOSPACE;
+		p->offset = p->rmargin;
+		p->rmargin = p->maxrmargin;
+		term_word(p, title);
+		term_flushln(p);
+	}
 
+	p->flags &= ~TERMP_NOSPACE;
 	p->offset = 0;
 	p->rmargin = p->maxrmargin;
-	p->flags &= ~TERMP_NOSPACE;
 }
 
 
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

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

end of thread, other threads:[~2011-09-20  9:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-18 16:24 groff-1.19.2 difference: indent Thomas Klausner
2011-09-18 16:32 ` Ingo Schwarze
2011-09-19 13:35   ` Thomas Klausner
2011-09-20  9:12     ` Ingo Schwarze

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