From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p8K92Ndg013595 for ; Tue, 20 Sep 2011 05:02:23 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id p8K92Nc9029689; Tue, 20 Sep 2011 05:02:23 -0400 (EDT) Date: Tue, 20 Sep 2011 05:02:23 -0400 (EDT) Message-Id: <201109200902.p8K92Nc9029689@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Sync print_mdoc_head to print_man_head; this X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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 , 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 source+unsubscribe@mdocml.bsd.lv