From: Ingo Schwarze <schwarze@usta.de>
To: Thomas Klausner <wiz@netbsd.org>
Cc: discuss@mdocml.bsd.lv
Subject: Re: groff-1.19.2 difference: indent
Date: Tue, 20 Sep 2011 11:12:07 +0200 [thread overview]
Message-ID: <20110920091207.GA13269@iris.usta.de> (raw)
In-Reply-To: <20110919133533.GT10245@danbala.tuwien.ac.at>
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
prev parent reply other threads:[~2011-09-20 9:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-18 16:24 Thomas Klausner
2011-09-18 16:32 ` Ingo Schwarze
2011-09-19 13:35 ` Thomas Klausner
2011-09-20 9:12 ` Ingo Schwarze [this message]
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=20110920091207.GA13269@iris.usta.de \
--to=schwarze@usta.de \
--cc=discuss@mdocml.bsd.lv \
--cc=wiz@netbsd.org \
/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).