]>
git.cameronkatri.com Git - mandoc.git/blob - man_term.c
1 /* $Id: man_term.c,v 1.168 2015/01/30 22:04:44 schwarze Exp $ */
3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <sys/types.h>
30 #include "mandoc_aux.h"
36 #define MAXMARGINS 64 /* maximum number of indented scopes */
40 #define MANT_LITERAL (1 << 0)
41 int lmargin
[MAXMARGINS
]; /* margins (incl. vis. page) */
42 int lmargincur
; /* index of current margin */
43 int lmarginsz
; /* actual number of nested margins */
44 size_t offset
; /* default offset to visible page */
45 int pardist
; /* vert. space before par., unit: [v] */
48 #define DECL_ARGS struct termp *p, \
51 const struct man_meta *meta
54 int (*pre
)(DECL_ARGS
);
55 void (*post
)(DECL_ARGS
);
57 #define MAN_NOTEXT (1 << 0) /* Never has text children. */
60 static void print_man_nodelist(DECL_ARGS
);
61 static void print_man_node(DECL_ARGS
);
62 static void print_man_head(struct termp
*, const void *);
63 static void print_man_foot(struct termp
*, const void *);
64 static void print_bvspace(struct termp
*,
65 const struct man_node
*, int);
67 static int pre_B(DECL_ARGS
);
68 static int pre_HP(DECL_ARGS
);
69 static int pre_I(DECL_ARGS
);
70 static int pre_IP(DECL_ARGS
);
71 static int pre_OP(DECL_ARGS
);
72 static int pre_PD(DECL_ARGS
);
73 static int pre_PP(DECL_ARGS
);
74 static int pre_RS(DECL_ARGS
);
75 static int pre_SH(DECL_ARGS
);
76 static int pre_SS(DECL_ARGS
);
77 static int pre_TP(DECL_ARGS
);
78 static int pre_UR(DECL_ARGS
);
79 static int pre_alternate(DECL_ARGS
);
80 static int pre_ft(DECL_ARGS
);
81 static int pre_ign(DECL_ARGS
);
82 static int pre_in(DECL_ARGS
);
83 static int pre_literal(DECL_ARGS
);
84 static int pre_ll(DECL_ARGS
);
85 static int pre_sp(DECL_ARGS
);
87 static void post_IP(DECL_ARGS
);
88 static void post_HP(DECL_ARGS
);
89 static void post_RS(DECL_ARGS
);
90 static void post_SH(DECL_ARGS
);
91 static void post_SS(DECL_ARGS
);
92 static void post_TP(DECL_ARGS
);
93 static void post_UR(DECL_ARGS
);
95 static const struct termact termacts
[MAN_MAX
] = {
96 { pre_sp
, NULL
, MAN_NOTEXT
}, /* br */
97 { NULL
, NULL
, 0 }, /* TH */
98 { pre_SH
, post_SH
, 0 }, /* SH */
99 { pre_SS
, post_SS
, 0 }, /* SS */
100 { pre_TP
, post_TP
, 0 }, /* TP */
101 { pre_PP
, NULL
, 0 }, /* LP */
102 { pre_PP
, NULL
, 0 }, /* PP */
103 { pre_PP
, NULL
, 0 }, /* P */
104 { pre_IP
, post_IP
, 0 }, /* IP */
105 { pre_HP
, post_HP
, 0 }, /* HP */
106 { NULL
, NULL
, 0 }, /* SM */
107 { pre_B
, NULL
, 0 }, /* SB */
108 { pre_alternate
, NULL
, 0 }, /* BI */
109 { pre_alternate
, NULL
, 0 }, /* IB */
110 { pre_alternate
, NULL
, 0 }, /* BR */
111 { pre_alternate
, NULL
, 0 }, /* RB */
112 { NULL
, NULL
, 0 }, /* R */
113 { pre_B
, NULL
, 0 }, /* B */
114 { pre_I
, NULL
, 0 }, /* I */
115 { pre_alternate
, NULL
, 0 }, /* IR */
116 { pre_alternate
, NULL
, 0 }, /* RI */
117 { pre_sp
, NULL
, MAN_NOTEXT
}, /* sp */
118 { pre_literal
, NULL
, 0 }, /* nf */
119 { pre_literal
, NULL
, 0 }, /* fi */
120 { NULL
, NULL
, 0 }, /* RE */
121 { pre_RS
, post_RS
, 0 }, /* RS */
122 { pre_ign
, NULL
, 0 }, /* DT */
123 { pre_ign
, NULL
, MAN_NOTEXT
}, /* UC */
124 { pre_PD
, NULL
, MAN_NOTEXT
}, /* PD */
125 { pre_ign
, NULL
, 0 }, /* AT */
126 { pre_in
, NULL
, MAN_NOTEXT
}, /* in */
127 { pre_ft
, NULL
, MAN_NOTEXT
}, /* ft */
128 { pre_OP
, NULL
, 0 }, /* OP */
129 { pre_literal
, NULL
, 0 }, /* EX */
130 { pre_literal
, NULL
, 0 }, /* EE */
131 { pre_UR
, post_UR
, 0 }, /* UR */
132 { NULL
, NULL
, 0 }, /* UE */
133 { pre_ll
, NULL
, MAN_NOTEXT
}, /* ll */
138 terminal_man(void *arg
, const struct man
*man
)
141 const struct man_meta
*meta
;
145 p
= (struct termp
*)arg
;
148 p
->rmargin
= p
->maxrmargin
= p
->defrmargin
;
149 p
->tabwidth
= term_len(p
, 5);
151 n
= man_node(man
)->child
;
152 meta
= man_meta(man
);
154 memset(&mt
, 0, sizeof(struct mtermp
));
156 mt
.lmargin
[mt
.lmargincur
] = term_len(p
, p
->defindent
);
157 mt
.offset
= term_len(p
, p
->defindent
);
160 if (p
->synopsisonly
) {
162 if (n
->tok
== MAN_SH
&&
163 n
->child
->child
->type
== MAN_TEXT
&&
164 !strcmp(n
->child
->child
->string
, "SYNOPSIS")) {
165 if (n
->child
->next
->child
!= NULL
)
166 print_man_nodelist(p
, &mt
,
167 n
->child
->next
->child
, meta
);
174 if (p
->defindent
== 0)
176 term_begin(p
, print_man_head
, print_man_foot
, meta
);
177 p
->flags
|= TERMP_NOSPACE
;
179 print_man_nodelist(p
, &mt
, n
, meta
);
185 * Printing leading vertical space before a block.
186 * This is used for the paragraph macros.
187 * The rules are pretty simple, since there's very little nesting going
188 * on here. Basically, if we're the first within another block (SS/SH),
189 * then don't emit vertical space. If we are (RS), then do. If not the
193 print_bvspace(struct termp
*p
, const struct man_node
*n
, int pardist
)
199 if (n
->body
&& n
->body
->child
)
200 if (MAN_TBL
== n
->body
->child
->type
)
203 if (MAN_ROOT
== n
->parent
->type
|| MAN_RS
!= n
->parent
->tok
)
207 for (i
= 0; i
< pardist
; i
++)
223 term_setwidth(p
, n
->nchild
? n
->child
->string
: NULL
);
231 term_fontrepl(p
, TERMFONT_UNDER
);
236 pre_literal(DECL_ARGS
)
241 if (MAN_nf
== n
->tok
|| MAN_EX
== n
->tok
)
242 mt
->fl
|= MANT_LITERAL
;
244 mt
->fl
&= ~MANT_LITERAL
;
247 * Unlike .IP and .TP, .HP does not have a HEAD.
248 * So in case a second call to term_flushln() is needed,
249 * indentation has to be set up explicitly.
251 if (MAN_HP
== n
->parent
->tok
&& p
->rmargin
< p
->maxrmargin
) {
252 p
->offset
= p
->rmargin
;
253 p
->rmargin
= p
->maxrmargin
;
255 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
256 p
->flags
|= TERMP_NOSPACE
;
272 assert(MAN_TEXT
== n
->type
);
273 if (a2roffsu(n
->string
, &su
, SCALE_VS
))
274 mt
->pardist
= term_vspan(p
, &su
);
279 pre_alternate(DECL_ARGS
)
281 enum termfont font
[2];
287 font
[0] = TERMFONT_NONE
;
288 font
[1] = TERMFONT_BOLD
;
291 font
[0] = TERMFONT_NONE
;
292 font
[1] = TERMFONT_UNDER
;
295 font
[0] = TERMFONT_BOLD
;
296 font
[1] = TERMFONT_NONE
;
299 font
[0] = TERMFONT_BOLD
;
300 font
[1] = TERMFONT_UNDER
;
303 font
[0] = TERMFONT_UNDER
;
304 font
[1] = TERMFONT_NONE
;
307 font
[0] = TERMFONT_UNDER
;
308 font
[1] = TERMFONT_BOLD
;
314 savelit
= MANT_LITERAL
& mt
->fl
;
315 mt
->fl
&= ~MANT_LITERAL
;
317 for (i
= 0, nn
= n
->child
; nn
; nn
= nn
->next
, i
= 1 - i
) {
318 term_fontrepl(p
, font
[i
]);
319 if (savelit
&& NULL
== nn
->next
)
320 mt
->fl
|= MANT_LITERAL
;
321 print_man_node(p
, mt
, nn
, meta
);
323 p
->flags
|= TERMP_NOSPACE
;
333 term_fontrepl(p
, TERMFONT_BOLD
);
342 p
->flags
|= TERMP_NOSPACE
;
344 if (NULL
!= (n
= n
->child
)) {
345 term_fontrepl(p
, TERMFONT_BOLD
);
346 term_word(p
, n
->string
);
348 if (NULL
!= n
&& NULL
!= n
->next
) {
349 term_fontrepl(p
, TERMFONT_UNDER
);
350 term_word(p
, n
->next
->string
);
353 term_fontrepl(p
, TERMFONT_NONE
);
354 p
->flags
|= TERMP_NOSPACE
;
364 if (NULL
== n
->child
) {
369 cp
= n
->child
->string
;
376 term_fontrepl(p
, TERMFONT_BOLD
);
381 term_fontrepl(p
, TERMFONT_UNDER
);
391 term_fontrepl(p
, TERMFONT_NONE
);
409 if (NULL
== n
->child
) {
410 p
->offset
= mt
->offset
;
414 cp
= n
->child
->string
;
424 if ( ! a2roffsu(++cp
, &su
, SCALE_EN
))
427 v
= term_hspan(p
, &su
);
430 p
->offset
-= p
->offset
> v
? v
: p
->offset
;
435 if (p
->offset
> SHRT_MAX
)
436 p
->offset
= term_len(p
, p
->defindent
);
447 if ((NULL
== n
->prev
&& n
->parent
)) {
448 switch (n
->parent
->tok
) {
465 if (n
->tok
== MAN_br
)
467 else if (n
->child
== NULL
)
470 if ( ! a2roffsu(n
->child
->string
, &su
, SCALE_VS
))
472 len
= term_vspan(p
, &su
);
480 for (i
= 0; i
< len
; i
++)
490 const struct man_node
*nn
;
495 print_bvspace(p
, n
, mt
->pardist
);
503 if ( ! (MANT_LITERAL
& mt
->fl
)) {
504 p
->flags
|= TERMP_NOBREAK
| TERMP_BRIND
;
508 /* Calculate offset. */
510 if ((nn
= n
->parent
->head
->child
) != NULL
&&
511 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
512 len
= term_hspan(p
, &su
);
513 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
515 else if (len
> SHRT_MAX
)
516 len
= term_len(p
, p
->defindent
);
517 mt
->lmargin
[mt
->lmargincur
] = len
;
519 len
= mt
->lmargin
[mt
->lmargincur
];
521 p
->offset
= mt
->offset
;
522 p
->rmargin
= mt
->offset
+ len
;
533 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
535 p
->offset
= mt
->offset
;
536 p
->rmargin
= p
->maxrmargin
;
549 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
550 print_bvspace(p
, n
, mt
->pardist
);
553 p
->offset
= mt
->offset
;
557 return(MAN_HEAD
!= n
->type
);
564 const struct man_node
*nn
;
569 p
->flags
|= TERMP_NOSPACE
;
572 p
->flags
|= TERMP_NOBREAK
;
576 print_bvspace(p
, n
, mt
->pardist
);
582 /* Calculate the offset from the optional second argument. */
583 if ((nn
= n
->parent
->head
->child
) != NULL
&&
584 (nn
= nn
->next
) != NULL
&&
585 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
586 len
= term_hspan(p
, &su
);
587 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
589 else if (len
> SHRT_MAX
)
590 len
= term_len(p
, p
->defindent
);
591 mt
->lmargin
[mt
->lmargincur
] = len
;
593 len
= mt
->lmargin
[mt
->lmargincur
];
597 p
->offset
= mt
->offset
;
598 p
->rmargin
= mt
->offset
+ len
;
600 savelit
= MANT_LITERAL
& mt
->fl
;
601 mt
->fl
&= ~MANT_LITERAL
;
604 print_man_node(p
, mt
, n
->child
, meta
);
607 mt
->fl
|= MANT_LITERAL
;
611 p
->offset
= mt
->offset
+ len
;
612 p
->rmargin
= p
->maxrmargin
;
628 p
->flags
&= ~TERMP_NOBREAK
;
630 p
->rmargin
= p
->maxrmargin
;
634 p
->offset
= mt
->offset
;
650 p
->flags
|= TERMP_NOBREAK
;
654 p
->flags
|= TERMP_NOSPACE
;
657 print_bvspace(p
, n
, mt
->pardist
);
663 /* Calculate offset. */
665 if ((nn
= n
->parent
->head
->child
) != NULL
&&
666 nn
->string
!= NULL
&& ! (MAN_LINE
& nn
->flags
) &&
667 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
668 len
= term_hspan(p
, &su
);
669 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
671 else if (len
> SHRT_MAX
)
672 len
= term_len(p
, p
->defindent
);
673 mt
->lmargin
[mt
->lmargincur
] = len
;
675 len
= mt
->lmargin
[mt
->lmargincur
];
679 p
->offset
= mt
->offset
;
680 p
->rmargin
= mt
->offset
+ len
;
682 savelit
= MANT_LITERAL
& mt
->fl
;
683 mt
->fl
&= ~MANT_LITERAL
;
685 /* Don't print same-line elements. */
687 while (NULL
!= nn
&& 0 == (MAN_LINE
& nn
->flags
))
691 print_man_node(p
, mt
, nn
, meta
);
696 mt
->fl
|= MANT_LITERAL
;
699 p
->offset
= mt
->offset
+ len
;
700 p
->rmargin
= p
->maxrmargin
;
702 p
->flags
&= ~TERMP_NOBREAK
;
721 p
->offset
= mt
->offset
;
735 mt
->fl
&= ~MANT_LITERAL
;
736 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
737 mt
->offset
= term_len(p
, p
->defindent
);
740 * No vertical space before the first subsection
741 * and after an empty subsection.
746 } while (n
!= NULL
&& termacts
[n
->tok
].flags
& MAN_NOTEXT
);
747 if (n
== NULL
|| (n
->tok
== MAN_SS
&& n
->body
->child
== NULL
))
750 for (i
= 0; i
< mt
->pardist
; i
++)
754 term_fontrepl(p
, TERMFONT_BOLD
);
755 p
->offset
= term_len(p
, 3);
758 p
->offset
= mt
->offset
;
790 mt
->fl
&= ~MANT_LITERAL
;
791 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
792 mt
->offset
= term_len(p
, p
->defindent
);
795 * No vertical space before the first section
796 * and after an empty section.
801 } while (n
!= NULL
&& termacts
[n
->tok
].flags
& MAN_NOTEXT
);
802 if (n
== NULL
|| (n
->tok
== MAN_SH
&& n
->body
->child
== NULL
))
805 for (i
= 0; i
< mt
->pardist
; i
++)
809 term_fontrepl(p
, TERMFONT_BOLD
);
813 p
->offset
= mt
->offset
;
854 n
->aux
= SHRT_MAX
+ 1;
855 if (n
->child
!= NULL
&& a2roffsu(n
->child
->string
, &su
, SCALE_EN
))
856 n
->aux
= term_hspan(p
, &su
);
857 if (n
->aux
< 0 && (size_t)(-n
->aux
) > mt
->offset
)
858 n
->aux
= -mt
->offset
;
859 else if (n
->aux
> SHRT_MAX
)
860 n
->aux
= term_len(p
, p
->defindent
);
862 mt
->offset
+= n
->aux
;
863 p
->offset
= mt
->offset
;
864 p
->rmargin
= p
->maxrmargin
;
866 if (++mt
->lmarginsz
< MAXMARGINS
)
867 mt
->lmargincur
= mt
->lmarginsz
;
869 mt
->lmargin
[mt
->lmargincur
] = mt
->lmargin
[mt
->lmargincur
- 1];
887 mt
->offset
-= n
->parent
->head
->aux
;
888 p
->offset
= mt
->offset
;
890 if (--mt
->lmarginsz
< MAXMARGINS
)
891 mt
->lmargincur
= mt
->lmarginsz
;
898 return (MAN_HEAD
!= n
->type
);
905 if (MAN_BLOCK
!= n
->type
)
909 p
->flags
|= TERMP_NOSPACE
;
911 if (NULL
!= n
->child
->child
)
912 print_man_node(p
, mt
, n
->child
->child
, meta
);
914 p
->flags
|= TERMP_NOSPACE
;
919 print_man_node(DECL_ARGS
)
927 * If we have a blank line, output a vertical space.
928 * If we have a space as the first character, break
929 * before printing the line's data.
931 if ('\0' == *n
->string
) {
934 } else if (' ' == *n
->string
&& MAN_LINE
& n
->flags
)
937 term_word(p
, n
->string
);
941 if ( ! (n
->flags
& MAN_LINE
))
942 p
->flags
|= TERMP_NOSPACE
;
944 if (n
->next
!= NULL
&& ! (n
->next
->flags
& MAN_LINE
))
945 p
->flags
|= TERMP_NOSPACE
;
949 * Tables are preceded by a newline. Then process a
950 * table line, which will cause line termination,
952 if (n
->span
->prev
== NULL
)
954 term_tbl(p
, n
->span
);
960 if ( ! (MAN_NOTEXT
& termacts
[n
->tok
].flags
))
961 term_fontrepl(p
, TERMFONT_NONE
);
964 if (termacts
[n
->tok
].pre
)
965 c
= (*termacts
[n
->tok
].pre
)(p
, mt
, n
, meta
);
968 print_man_nodelist(p
, mt
, n
->child
, meta
);
970 if (termacts
[n
->tok
].post
)
971 (*termacts
[n
->tok
].post
)(p
, mt
, n
, meta
);
972 if ( ! (MAN_NOTEXT
& termacts
[n
->tok
].flags
))
973 term_fontrepl(p
, TERMFONT_NONE
);
977 * If we're in a literal context, make sure that words
978 * together on the same line stay together. This is a
979 * POST-printing call, so we check the NEXT word. Since
980 * -man doesn't have nested macros, we don't need to be
981 * more specific than this.
983 if (mt
->fl
& MANT_LITERAL
&&
984 ! (p
->flags
& (TERMP_NOBREAK
| TERMP_NONEWLINE
)) &&
985 (n
->next
== NULL
|| n
->next
->flags
& MAN_LINE
)) {
987 rmax
= p
->maxrmargin
;
988 p
->rmargin
= p
->maxrmargin
= TERM_MAXMARGIN
;
989 p
->flags
|= TERMP_NOSPACE
;
990 if (n
->string
!= NULL
&& *n
->string
!= '\0')
994 if (rm
< rmax
&& n
->parent
->tok
== MAN_HP
) {
999 p
->maxrmargin
= rmax
;
1001 if (MAN_EOS
& n
->flags
)
1002 p
->flags
|= TERMP_SENTENCE
;
1007 print_man_nodelist(DECL_ARGS
)
1011 print_man_node(p
, mt
, n
, meta
);
1017 print_man_foot(struct termp
*p
, const void *arg
)
1019 const struct man_meta
*meta
;
1021 size_t datelen
, titlen
;
1023 meta
= (const struct man_meta
*)arg
;
1024 assert(meta
->title
);
1028 term_fontrepl(p
, TERMFONT_NONE
);
1034 * Temporary, undocumented option to imitate mdoc(7) output.
1035 * In the bottom right corner, use the source instead of
1039 if ( ! p
->mdocstyle
) {
1040 if (meta
->hasbody
) {
1044 mandoc_asprintf(&title
, "%s(%s)",
1045 meta
->title
, meta
->msec
);
1046 } else if (meta
->source
) {
1047 title
= mandoc_strdup(meta
->source
);
1049 title
= mandoc_strdup("");
1051 datelen
= term_strlen(p
, meta
->date
);
1053 /* Bottom left corner: manual source. */
1055 p
->flags
|= TERMP_NOSPACE
| TERMP_NOBREAK
;
1058 p
->rmargin
= p
->maxrmargin
> datelen
?
1059 (p
->maxrmargin
+ term_len(p
, 1) - datelen
) / 2 : 0;
1062 term_word(p
, meta
->source
);
1065 /* At the bottom in the middle: manual date. */
1067 p
->offset
= p
->rmargin
;
1068 titlen
= term_strlen(p
, title
);
1069 p
->rmargin
= p
->maxrmargin
> titlen
? p
->maxrmargin
- titlen
: 0;
1070 p
->flags
|= TERMP_NOSPACE
;
1072 term_word(p
, meta
->date
);
1075 /* Bottom right corner: manual title and section. */
1077 p
->flags
&= ~TERMP_NOBREAK
;
1078 p
->flags
|= TERMP_NOSPACE
;
1080 p
->offset
= p
->rmargin
;
1081 p
->rmargin
= p
->maxrmargin
;
1083 term_word(p
, title
);
1089 print_man_head(struct termp
*p
, const void *arg
)
1091 const struct man_meta
*meta
;
1094 size_t vollen
, titlen
;
1096 meta
= (const struct man_meta
*)arg
;
1097 assert(meta
->title
);
1100 volume
= NULL
== meta
->vol
? "" : meta
->vol
;
1101 vollen
= term_strlen(p
, volume
);
1103 /* Top left corner: manual title and section. */
1105 mandoc_asprintf(&title
, "%s(%s)", meta
->title
, meta
->msec
);
1106 titlen
= term_strlen(p
, title
);
1108 p
->flags
|= TERMP_NOBREAK
| TERMP_NOSPACE
;
1111 p
->rmargin
= 2 * (titlen
+1) + vollen
< p
->maxrmargin
?
1112 (p
->maxrmargin
- vollen
+ term_len(p
, 1)) / 2 :
1113 vollen
< p
->maxrmargin
? p
->maxrmargin
- vollen
: 0;
1115 term_word(p
, title
);
1118 /* At the top in the middle: manual volume. */
1120 p
->flags
|= TERMP_NOSPACE
;
1121 p
->offset
= p
->rmargin
;
1122 p
->rmargin
= p
->offset
+ vollen
+ titlen
< p
->maxrmargin
?
1123 p
->maxrmargin
- titlen
: p
->maxrmargin
;
1125 term_word(p
, volume
);
1128 /* Top right corner: title and section, again. */
1130 p
->flags
&= ~TERMP_NOBREAK
;
1132 if (p
->rmargin
+ titlen
<= p
->maxrmargin
) {
1133 p
->flags
|= TERMP_NOSPACE
;
1134 p
->offset
= p
->rmargin
;
1135 p
->rmargin
= p
->maxrmargin
;
1136 term_word(p
, title
);
1140 p
->flags
&= ~TERMP_NOSPACE
;
1142 p
->rmargin
= p
->maxrmargin
;
1145 * Groff prints three blank lines before the content.
1146 * Do the same, except in the temporary, undocumented
1147 * mode imitating mdoc(7) output.
1151 if ( ! p
->mdocstyle
) {