* fix man(7) font alternating blocks in literal mode
@ 2010-10-28 10:52 Ingo Schwarze
2010-10-28 10:55 ` Ingo Schwarze
2010-10-28 11:56 ` Kristaps Dzonsons
0 siblings, 2 replies; 4+ messages in thread
From: Ingo Schwarze @ 2010-10-28 10:52 UTC (permalink / raw)
To: tech
OK to commit to bsd.lv, too?
----- Forwarded message from Ingo Schwarze <schwarze@cvs.openbsd.org> -----
From: Ingo Schwarze <schwarze@cvs.openbsd.org>
Date: Thu, 28 Oct 2010 04:42:39 -0600 (MDT)
To: source-changes@cvs.openbsd.org
CVSROOT: /cvs
Module name: src
Changes by: schwarze@cvs.openbsd.org 2010/10/28 04:42:39
Modified files:
usr.bin/mandoc : man_term.c
Log message:
Font alternating blocks like .RB must not break the line between children
in literal mode. Fixing a bug found by naddy@ in the gettext(3) SYNOPSIS.
This required a bit of refactoring:
* consolidate pre_RB(), pre_RI(), and pre_BI() into pre_alternate()
* save the MANT_LITERAL mode before descending into children
* restore MANT_LITERAL mode before printing the last child
----- End forwarded message -----
Index: man_term.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/man_term.c,v
retrieving revision 1.50
diff -u -p -r1.50 man_term.c
--- man_term.c 16 Oct 2010 20:49:37 -0000 1.50
+++ man_term.c 28 Oct 2010 10:40:48 -0000
@@ -77,14 +77,12 @@ static void print_man_foot(struct ter
static void print_bvspace(struct termp *,
const struct man_node *);
+static int pre_alternate(DECL_ARGS);
static int pre_B(DECL_ARGS);
-static int pre_BI(DECL_ARGS);
static int pre_HP(DECL_ARGS);
static int pre_I(DECL_ARGS);
static int pre_IP(DECL_ARGS);
static int pre_PP(DECL_ARGS);
-static int pre_RB(DECL_ARGS);
-static int pre_RI(DECL_ARGS);
static int pre_RS(DECL_ARGS);
static int pre_SH(DECL_ARGS);
static int pre_SS(DECL_ARGS);
@@ -115,15 +113,15 @@ static const struct termact termacts[MAN
{ pre_HP, post_HP, 0 }, /* HP */
{ NULL, NULL, 0 }, /* SM */
{ pre_B, NULL, 0 }, /* SB */
- { pre_BI, NULL, 0 }, /* BI */
- { pre_BI, NULL, 0 }, /* IB */
- { pre_RB, NULL, 0 }, /* BR */
- { pre_RB, NULL, 0 }, /* RB */
+ { pre_alternate, NULL, 0 }, /* BI */
+ { pre_alternate, NULL, 0 }, /* IB */
+ { pre_alternate, NULL, 0 }, /* BR */
+ { pre_alternate, NULL, 0 }, /* RB */
{ NULL, NULL, 0 }, /* R */
{ pre_B, NULL, 0 }, /* B */
{ pre_I, NULL, 0 }, /* I */
- { pre_RI, NULL, 0 }, /* IR */
- { pre_RI, NULL, 0 }, /* RI */
+ { pre_alternate, NULL, 0 }, /* IR */
+ { pre_alternate, NULL, 0 }, /* RI */
{ NULL, NULL, MAN_NOTEXT }, /* na */
{ pre_I, NULL, 0 }, /* i */
{ pre_sp, NULL, MAN_NOTEXT }, /* sp */
@@ -268,77 +266,55 @@ pre_literal(DECL_ARGS)
}
-
/* ARGSUSED */
static int
-pre_RB(DECL_ARGS)
+pre_alternate(DECL_ARGS)
{
- const struct man_node *nn;
- int i;
-
- for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
- if (i % 2 && MAN_RB == n->tok)
- term_fontrepl(p, TERMFONT_BOLD);
- else if ( ! (i % 2) && MAN_RB != n->tok)
- term_fontrepl(p, TERMFONT_BOLD);
- else
- term_fontrepl(p, TERMFONT_NONE);
-
- if (i > 0)
- p->flags |= TERMP_NOSPACE;
+ enum termfont font[2];
+ const struct man_node *nn;
+ int savelit, i;
- print_man_node(p, mt, nn, m);
+ switch (n->tok) {
+ case (MAN_RB):
+ font[0] = TERMFONT_NONE;
+ font[1] = TERMFONT_BOLD;
+ break;
+ case (MAN_RI):
+ font[0] = TERMFONT_NONE;
+ font[1] = TERMFONT_UNDER;
+ break;
+ case (MAN_BR):
+ font[0] = TERMFONT_BOLD;
+ font[1] = TERMFONT_NONE;
+ break;
+ case (MAN_BI):
+ font[0] = TERMFONT_BOLD;
+ font[1] = TERMFONT_UNDER;
+ break;
+ case (MAN_IR):
+ font[0] = TERMFONT_UNDER;
+ font[1] = TERMFONT_NONE;
+ break;
+ case (MAN_IB):
+ font[0] = TERMFONT_UNDER;
+ font[1] = TERMFONT_BOLD;
+ break;
+ default:
+ abort();
}
- return(0);
-}
+ savelit = MANT_LITERAL & mt->fl;
+ mt->fl &= ~MANT_LITERAL;
-/* ARGSUSED */
-static int
-pre_RI(DECL_ARGS)
-{
- const struct man_node *nn;
- int i;
-
- for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
- if (i % 2 && MAN_RI == n->tok)
- term_fontrepl(p, TERMFONT_UNDER);
- else if ( ! (i % 2) && MAN_RI != n->tok)
- term_fontrepl(p, TERMFONT_UNDER);
- else
- term_fontrepl(p, TERMFONT_NONE);
-
- if (i > 0)
- p->flags |= TERMP_NOSPACE;
-
+ for (i = 0, nn = n->child; nn; nn = nn->next, i = 1 - i) {
+ term_fontrepl(p, font[i]);
+ if (savelit && NULL == nn->next)
+ mt->fl |= MANT_LITERAL;
print_man_node(p, mt, nn, m);
- }
- return(0);
-}
-
-
-/* ARGSUSED */
-static int
-pre_BI(DECL_ARGS)
-{
- const struct man_node *nn;
- int i;
-
- for (i = 0, nn = n->child; nn; nn = nn->next, i++) {
- if (i % 2 && MAN_BI == n->tok)
- term_fontrepl(p, TERMFONT_UNDER);
- else if (i % 2)
- term_fontrepl(p, TERMFONT_BOLD);
- else if (MAN_BI == n->tok)
- term_fontrepl(p, TERMFONT_BOLD);
- else
- term_fontrepl(p, TERMFONT_UNDER);
-
- if (i)
+ if (nn->next)
p->flags |= TERMP_NOSPACE;
-
- print_man_node(p, mt, nn, m);
}
+
return(0);
}
--
To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fix man(7) font alternating blocks in literal mode
2010-10-28 10:52 fix man(7) font alternating blocks in literal mode Ingo Schwarze
@ 2010-10-28 10:55 ` Ingo Schwarze
2010-10-28 11:56 ` Kristaps Dzonsons
1 sibling, 0 replies; 4+ messages in thread
From: Ingo Schwarze @ 2010-10-28 10:55 UTC (permalink / raw)
To: tech
> OK to commit to bsd.lv, too?
Oh, and here ist a testfile...
.TH alternate 1 "October 28, 2010"
.SH NAME
alternate \- RB, RI, and BI blocks
.SH DESCRIPTION
regular
text
.RB roman bold roman
regular
text
.RI roman under roman
regular
text
.BR bold roman bold
regular
text
.BI bold under bold
regular
text
.IR under roman under
regular
text
.IB under bold under
regular
text
.nf
literal
text
.RB roman bold roman
literal
text
.RI roman under roman
literal
text
.BR bold roman bold
literal
text
.BI bold under bold
literal
text
.IR under roman under
literal
text
.IB under bold under
literal
text
--
To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fix man(7) font alternating blocks in literal mode
2010-10-28 10:52 fix man(7) font alternating blocks in literal mode Ingo Schwarze
2010-10-28 10:55 ` Ingo Schwarze
@ 2010-10-28 11:56 ` Kristaps Dzonsons
2010-10-28 14:18 ` Ingo Schwarze
1 sibling, 1 reply; 4+ messages in thread
From: Kristaps Dzonsons @ 2010-10-28 11:56 UTC (permalink / raw)
To: tech
Ingo, give me a little time to get up to speed before giving Ok's for
BSD.lv... I've a few loose ends to tie up before I can divert to mdocml
code, which is growing an ever-larger backlog!
Thanks,
Kristaps
--
To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: fix man(7) font alternating blocks in literal mode
2010-10-28 11:56 ` Kristaps Dzonsons
@ 2010-10-28 14:18 ` Ingo Schwarze
0 siblings, 0 replies; 4+ messages in thread
From: Ingo Schwarze @ 2010-10-28 14:18 UTC (permalink / raw)
To: tech
Hi Kristpas,
> Ingo, give me a little time to get up to speed before giving Ok's
> for BSD.lv... I've a few loose ends to tie up before I can divert to
> mdocml code,
No problem, just take the time you need to tie up those loose ends!
> which is growing an ever-larger backlog!
Well, i shall continue prodding along and drop patches on tech@,
such that we have all in one place when sorting it out later.
Yours,
Ingo
--
To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-28 14:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-28 10:52 fix man(7) font alternating blocks in literal mode Ingo Schwarze
2010-10-28 10:55 ` Ingo Schwarze
2010-10-28 11:56 ` Kristaps Dzonsons
2010-10-28 14:18 ` 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).