]>
git.cameronkatri.com Git - mandoc.git/blob - man_term.c
1 /* $Id: man_term.c,v 1.173 2015/04/02 23:48:19 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 AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS 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>
29 #include "mandoc_aux.h"
37 #define MAXMARGINS 64 /* maximum number of indented scopes */
41 #define MANT_LITERAL (1 << 0)
42 int lmargin
[MAXMARGINS
]; /* margins (incl. vis. page) */
43 int lmargincur
; /* index of current margin */
44 int lmarginsz
; /* actual number of nested margins */
45 size_t offset
; /* default offset to visible page */
46 int pardist
; /* vert. space before par., unit: [v] */
49 #define DECL_ARGS struct termp *p, \
51 struct roff_node *n, \
52 const struct roff_meta *meta
55 int (*pre
)(DECL_ARGS
);
56 void (*post
)(DECL_ARGS
);
58 #define MAN_NOTEXT (1 << 0) /* Never has text children. */
61 static void print_man_nodelist(DECL_ARGS
);
62 static void print_man_node(DECL_ARGS
);
63 static void print_man_head(struct termp
*,
64 const struct roff_meta
*);
65 static void print_man_foot(struct termp
*,
66 const struct roff_meta
*);
67 static void print_bvspace(struct termp
*,
68 const struct roff_node
*, int);
70 static int pre_B(DECL_ARGS
);
71 static int pre_HP(DECL_ARGS
);
72 static int pre_I(DECL_ARGS
);
73 static int pre_IP(DECL_ARGS
);
74 static int pre_OP(DECL_ARGS
);
75 static int pre_PD(DECL_ARGS
);
76 static int pre_PP(DECL_ARGS
);
77 static int pre_RS(DECL_ARGS
);
78 static int pre_SH(DECL_ARGS
);
79 static int pre_SS(DECL_ARGS
);
80 static int pre_TP(DECL_ARGS
);
81 static int pre_UR(DECL_ARGS
);
82 static int pre_alternate(DECL_ARGS
);
83 static int pre_ft(DECL_ARGS
);
84 static int pre_ign(DECL_ARGS
);
85 static int pre_in(DECL_ARGS
);
86 static int pre_literal(DECL_ARGS
);
87 static int pre_ll(DECL_ARGS
);
88 static int pre_sp(DECL_ARGS
);
90 static void post_IP(DECL_ARGS
);
91 static void post_HP(DECL_ARGS
);
92 static void post_RS(DECL_ARGS
);
93 static void post_SH(DECL_ARGS
);
94 static void post_SS(DECL_ARGS
);
95 static void post_TP(DECL_ARGS
);
96 static void post_UR(DECL_ARGS
);
98 static const struct termact termacts
[MAN_MAX
] = {
99 { pre_sp
, NULL
, MAN_NOTEXT
}, /* br */
100 { NULL
, NULL
, 0 }, /* TH */
101 { pre_SH
, post_SH
, 0 }, /* SH */
102 { pre_SS
, post_SS
, 0 }, /* SS */
103 { pre_TP
, post_TP
, 0 }, /* TP */
104 { pre_PP
, NULL
, 0 }, /* LP */
105 { pre_PP
, NULL
, 0 }, /* PP */
106 { pre_PP
, NULL
, 0 }, /* P */
107 { pre_IP
, post_IP
, 0 }, /* IP */
108 { pre_HP
, post_HP
, 0 }, /* HP */
109 { NULL
, NULL
, 0 }, /* SM */
110 { pre_B
, NULL
, 0 }, /* SB */
111 { pre_alternate
, NULL
, 0 }, /* BI */
112 { pre_alternate
, NULL
, 0 }, /* IB */
113 { pre_alternate
, NULL
, 0 }, /* BR */
114 { pre_alternate
, NULL
, 0 }, /* RB */
115 { NULL
, NULL
, 0 }, /* R */
116 { pre_B
, NULL
, 0 }, /* B */
117 { pre_I
, NULL
, 0 }, /* I */
118 { pre_alternate
, NULL
, 0 }, /* IR */
119 { pre_alternate
, NULL
, 0 }, /* RI */
120 { pre_sp
, NULL
, MAN_NOTEXT
}, /* sp */
121 { pre_literal
, NULL
, 0 }, /* nf */
122 { pre_literal
, NULL
, 0 }, /* fi */
123 { NULL
, NULL
, 0 }, /* RE */
124 { pre_RS
, post_RS
, 0 }, /* RS */
125 { pre_ign
, NULL
, 0 }, /* DT */
126 { pre_ign
, NULL
, MAN_NOTEXT
}, /* UC */
127 { pre_PD
, NULL
, MAN_NOTEXT
}, /* PD */
128 { pre_ign
, NULL
, 0 }, /* AT */
129 { pre_in
, NULL
, MAN_NOTEXT
}, /* in */
130 { pre_ft
, NULL
, MAN_NOTEXT
}, /* ft */
131 { pre_OP
, NULL
, 0 }, /* OP */
132 { pre_literal
, NULL
, 0 }, /* EX */
133 { pre_literal
, NULL
, 0 }, /* EE */
134 { pre_UR
, post_UR
, 0 }, /* UR */
135 { NULL
, NULL
, 0 }, /* UE */
136 { pre_ll
, NULL
, MAN_NOTEXT
}, /* ll */
141 terminal_man(void *arg
, const struct man
*man
)
144 const struct roff_meta
*meta
;
148 p
= (struct termp
*)arg
;
151 p
->rmargin
= p
->maxrmargin
= p
->defrmargin
;
152 p
->tabwidth
= term_len(p
, 5);
154 n
= man_node(man
)->child
;
155 meta
= man_meta(man
);
157 memset(&mt
, 0, sizeof(struct mtermp
));
159 mt
.lmargin
[mt
.lmargincur
] = term_len(p
, p
->defindent
);
160 mt
.offset
= term_len(p
, p
->defindent
);
163 if (p
->synopsisonly
) {
165 if (n
->tok
== MAN_SH
&&
166 n
->child
->child
->type
== ROFFT_TEXT
&&
167 !strcmp(n
->child
->child
->string
, "SYNOPSIS")) {
168 if (n
->child
->next
->child
!= NULL
)
169 print_man_nodelist(p
, &mt
,
170 n
->child
->next
->child
, meta
);
177 if (p
->defindent
== 0)
179 term_begin(p
, print_man_head
, print_man_foot
, meta
);
180 p
->flags
|= TERMP_NOSPACE
;
182 print_man_nodelist(p
, &mt
, n
, meta
);
188 * Printing leading vertical space before a block.
189 * This is used for the paragraph macros.
190 * The rules are pretty simple, since there's very little nesting going
191 * on here. Basically, if we're the first within another block (SS/SH),
192 * then don't emit vertical space. If we are (RS), then do. If not the
196 print_bvspace(struct termp
*p
, const struct roff_node
*n
, int pardist
)
202 if (n
->body
&& n
->body
->child
)
203 if (n
->body
->child
->type
== ROFFT_TBL
)
206 if (n
->parent
->type
== ROFFT_ROOT
|| n
->parent
->tok
!= MAN_RS
)
210 for (i
= 0; i
< pardist
; i
++)
226 term_setwidth(p
, n
->nchild
? n
->child
->string
: NULL
);
234 term_fontrepl(p
, TERMFONT_UNDER
);
239 pre_literal(DECL_ARGS
)
244 if (MAN_nf
== n
->tok
|| MAN_EX
== n
->tok
)
245 mt
->fl
|= MANT_LITERAL
;
247 mt
->fl
&= ~MANT_LITERAL
;
250 * Unlike .IP and .TP, .HP does not have a HEAD.
251 * So in case a second call to term_flushln() is needed,
252 * indentation has to be set up explicitly.
254 if (MAN_HP
== n
->parent
->tok
&& p
->rmargin
< p
->maxrmargin
) {
255 p
->offset
= p
->rmargin
;
256 p
->rmargin
= p
->maxrmargin
;
258 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
259 p
->flags
|= TERMP_NOSPACE
;
275 assert(n
->type
== ROFFT_TEXT
);
276 if (a2roffsu(n
->string
, &su
, SCALE_VS
))
277 mt
->pardist
= term_vspan(p
, &su
);
282 pre_alternate(DECL_ARGS
)
284 enum termfont font
[2];
285 struct roff_node
*nn
;
290 font
[0] = TERMFONT_NONE
;
291 font
[1] = TERMFONT_BOLD
;
294 font
[0] = TERMFONT_NONE
;
295 font
[1] = TERMFONT_UNDER
;
298 font
[0] = TERMFONT_BOLD
;
299 font
[1] = TERMFONT_NONE
;
302 font
[0] = TERMFONT_BOLD
;
303 font
[1] = TERMFONT_UNDER
;
306 font
[0] = TERMFONT_UNDER
;
307 font
[1] = TERMFONT_NONE
;
310 font
[0] = TERMFONT_UNDER
;
311 font
[1] = TERMFONT_BOLD
;
317 savelit
= MANT_LITERAL
& mt
->fl
;
318 mt
->fl
&= ~MANT_LITERAL
;
320 for (i
= 0, nn
= n
->child
; nn
; nn
= nn
->next
, i
= 1 - i
) {
321 term_fontrepl(p
, font
[i
]);
322 if (savelit
&& NULL
== nn
->next
)
323 mt
->fl
|= MANT_LITERAL
;
324 print_man_node(p
, mt
, nn
, meta
);
326 p
->flags
|= TERMP_NOSPACE
;
336 term_fontrepl(p
, TERMFONT_BOLD
);
345 p
->flags
|= TERMP_NOSPACE
;
347 if (NULL
!= (n
= n
->child
)) {
348 term_fontrepl(p
, TERMFONT_BOLD
);
349 term_word(p
, n
->string
);
351 if (NULL
!= n
&& NULL
!= n
->next
) {
352 term_fontrepl(p
, TERMFONT_UNDER
);
353 term_word(p
, n
->next
->string
);
356 term_fontrepl(p
, TERMFONT_NONE
);
357 p
->flags
|= TERMP_NOSPACE
;
367 if (NULL
== n
->child
) {
372 cp
= n
->child
->string
;
379 term_fontrepl(p
, TERMFONT_BOLD
);
384 term_fontrepl(p
, TERMFONT_UNDER
);
394 term_fontrepl(p
, TERMFONT_NONE
);
412 if (NULL
== n
->child
) {
413 p
->offset
= mt
->offset
;
417 cp
= n
->child
->string
;
427 if ( ! a2roffsu(++cp
, &su
, SCALE_EN
))
430 v
= term_hspan(p
, &su
);
433 p
->offset
-= p
->offset
> v
? v
: p
->offset
;
438 if (p
->offset
> SHRT_MAX
)
439 p
->offset
= term_len(p
, p
->defindent
);
450 if ((NULL
== n
->prev
&& n
->parent
)) {
451 switch (n
->parent
->tok
) {
468 if (n
->tok
== MAN_br
)
470 else if (n
->child
== NULL
)
473 if ( ! a2roffsu(n
->child
->string
, &su
, SCALE_VS
))
475 len
= term_vspan(p
, &su
);
483 for (i
= 0; i
< len
; i
++)
493 const struct roff_node
*nn
;
498 print_bvspace(p
, n
, mt
->pardist
);
506 if ( ! (MANT_LITERAL
& mt
->fl
)) {
507 p
->flags
|= TERMP_NOBREAK
| TERMP_BRIND
;
511 /* Calculate offset. */
513 if ((nn
= n
->parent
->head
->child
) != NULL
&&
514 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
515 len
= term_hspan(p
, &su
);
516 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
518 else if (len
> SHRT_MAX
)
519 len
= term_len(p
, p
->defindent
);
520 mt
->lmargin
[mt
->lmargincur
] = len
;
522 len
= mt
->lmargin
[mt
->lmargincur
];
524 p
->offset
= mt
->offset
;
525 p
->rmargin
= mt
->offset
+ len
;
536 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
538 p
->offset
= mt
->offset
;
539 p
->rmargin
= p
->maxrmargin
;
552 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
553 print_bvspace(p
, n
, mt
->pardist
);
556 p
->offset
= mt
->offset
;
560 return(n
->type
!= ROFFT_HEAD
);
567 const struct roff_node
*nn
;
572 p
->flags
|= TERMP_NOSPACE
;
575 p
->flags
|= TERMP_NOBREAK
;
579 print_bvspace(p
, n
, mt
->pardist
);
585 /* Calculate the offset from the optional second argument. */
586 if ((nn
= n
->parent
->head
->child
) != NULL
&&
587 (nn
= nn
->next
) != NULL
&&
588 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
589 len
= term_hspan(p
, &su
);
590 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
592 else if (len
> SHRT_MAX
)
593 len
= term_len(p
, p
->defindent
);
594 mt
->lmargin
[mt
->lmargincur
] = len
;
596 len
= mt
->lmargin
[mt
->lmargincur
];
600 p
->offset
= mt
->offset
;
601 p
->rmargin
= mt
->offset
+ len
;
603 savelit
= MANT_LITERAL
& mt
->fl
;
604 mt
->fl
&= ~MANT_LITERAL
;
607 print_man_node(p
, mt
, n
->child
, meta
);
610 mt
->fl
|= MANT_LITERAL
;
614 p
->offset
= mt
->offset
+ len
;
615 p
->rmargin
= p
->maxrmargin
;
631 p
->flags
&= ~TERMP_NOBREAK
;
633 p
->rmargin
= p
->maxrmargin
;
637 p
->offset
= mt
->offset
;
648 struct roff_node
*nn
;
653 p
->flags
|= TERMP_NOBREAK
;
657 p
->flags
|= TERMP_NOSPACE
;
660 print_bvspace(p
, n
, mt
->pardist
);
666 /* Calculate offset. */
668 if ((nn
= n
->parent
->head
->child
) != NULL
&&
669 nn
->string
!= NULL
&& ! (MAN_LINE
& nn
->flags
) &&
670 a2roffsu(nn
->string
, &su
, SCALE_EN
)) {
671 len
= term_hspan(p
, &su
);
672 if (len
< 0 && (size_t)(-len
) > mt
->offset
)
674 else if (len
> SHRT_MAX
)
675 len
= term_len(p
, p
->defindent
);
676 mt
->lmargin
[mt
->lmargincur
] = len
;
678 len
= mt
->lmargin
[mt
->lmargincur
];
682 p
->offset
= mt
->offset
;
683 p
->rmargin
= mt
->offset
+ len
;
685 savelit
= MANT_LITERAL
& mt
->fl
;
686 mt
->fl
&= ~MANT_LITERAL
;
688 /* Don't print same-line elements. */
690 while (NULL
!= nn
&& 0 == (MAN_LINE
& nn
->flags
))
694 print_man_node(p
, mt
, nn
, meta
);
699 mt
->fl
|= MANT_LITERAL
;
702 p
->offset
= mt
->offset
+ len
;
703 p
->rmargin
= p
->maxrmargin
;
705 p
->flags
&= ~TERMP_NOBREAK
;
724 p
->offset
= mt
->offset
;
738 mt
->fl
&= ~MANT_LITERAL
;
739 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
740 mt
->offset
= term_len(p
, p
->defindent
);
743 * No vertical space before the first subsection
744 * and after an empty subsection.
749 } while (n
!= NULL
&& n
->tok
!= MAN_MAX
&&
750 termacts
[n
->tok
].flags
& MAN_NOTEXT
);
751 if (n
== NULL
|| (n
->tok
== MAN_SS
&& n
->body
->child
== NULL
))
754 for (i
= 0; i
< mt
->pardist
; i
++)
758 term_fontrepl(p
, TERMFONT_BOLD
);
759 p
->offset
= term_len(p
, 3);
762 p
->offset
= mt
->offset
;
794 mt
->fl
&= ~MANT_LITERAL
;
795 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
796 mt
->offset
= term_len(p
, p
->defindent
);
799 * No vertical space before the first section
800 * and after an empty section.
805 } while (n
!= NULL
&& termacts
[n
->tok
].flags
& MAN_NOTEXT
);
806 if (n
== NULL
|| (n
->tok
== MAN_SH
&& n
->body
->child
== NULL
))
809 for (i
= 0; i
< mt
->pardist
; i
++)
813 term_fontrepl(p
, TERMFONT_BOLD
);
817 p
->offset
= mt
->offset
;
858 n
->aux
= SHRT_MAX
+ 1;
859 if (n
->child
!= NULL
&& a2roffsu(n
->child
->string
, &su
, SCALE_EN
))
860 n
->aux
= term_hspan(p
, &su
);
861 if (n
->aux
< 0 && (size_t)(-n
->aux
) > mt
->offset
)
862 n
->aux
= -mt
->offset
;
863 else if (n
->aux
> SHRT_MAX
)
864 n
->aux
= term_len(p
, p
->defindent
);
866 mt
->offset
+= n
->aux
;
867 p
->offset
= mt
->offset
;
868 p
->rmargin
= p
->maxrmargin
;
870 if (++mt
->lmarginsz
< MAXMARGINS
)
871 mt
->lmargincur
= mt
->lmarginsz
;
873 mt
->lmargin
[mt
->lmargincur
] = mt
->lmargin
[mt
->lmargincur
- 1];
891 mt
->offset
-= n
->parent
->head
->aux
;
892 p
->offset
= mt
->offset
;
894 if (--mt
->lmarginsz
< MAXMARGINS
)
895 mt
->lmargincur
= mt
->lmarginsz
;
902 return (n
->type
!= ROFFT_HEAD
);
909 if (n
->type
!= ROFFT_BLOCK
)
913 p
->flags
|= TERMP_NOSPACE
;
915 if (NULL
!= n
->child
->child
)
916 print_man_node(p
, mt
, n
->child
->child
, meta
);
918 p
->flags
|= TERMP_NOSPACE
;
923 print_man_node(DECL_ARGS
)
931 * If we have a blank line, output a vertical space.
932 * If we have a space as the first character, break
933 * before printing the line's data.
935 if ('\0' == *n
->string
) {
938 } else if (' ' == *n
->string
&& MAN_LINE
& n
->flags
)
941 term_word(p
, n
->string
);
945 if ( ! (n
->flags
& MAN_LINE
))
946 p
->flags
|= TERMP_NOSPACE
;
948 if (n
->next
!= NULL
&& ! (n
->next
->flags
& MAN_LINE
))
949 p
->flags
|= TERMP_NOSPACE
;
952 if (p
->tbl
.cols
== 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 struct roff_meta
*meta
)
1020 size_t datelen
, titlen
;
1022 assert(meta
->title
);
1026 term_fontrepl(p
, TERMFONT_NONE
);
1032 * Temporary, undocumented option to imitate mdoc(7) output.
1033 * In the bottom right corner, use the operating system
1034 * instead of the title.
1037 if ( ! p
->mdocstyle
) {
1038 if (meta
->hasbody
) {
1042 mandoc_asprintf(&title
, "%s(%s)",
1043 meta
->title
, meta
->msec
);
1044 } else if (meta
->os
) {
1045 title
= mandoc_strdup(meta
->os
);
1047 title
= mandoc_strdup("");
1049 datelen
= term_strlen(p
, meta
->date
);
1051 /* Bottom left corner: operating system. */
1053 p
->flags
|= TERMP_NOSPACE
| TERMP_NOBREAK
;
1056 p
->rmargin
= p
->maxrmargin
> datelen
?
1057 (p
->maxrmargin
+ term_len(p
, 1) - datelen
) / 2 : 0;
1060 term_word(p
, meta
->os
);
1063 /* At the bottom in the middle: manual date. */
1065 p
->offset
= p
->rmargin
;
1066 titlen
= term_strlen(p
, title
);
1067 p
->rmargin
= p
->maxrmargin
> titlen
? p
->maxrmargin
- titlen
: 0;
1068 p
->flags
|= TERMP_NOSPACE
;
1070 term_word(p
, meta
->date
);
1073 /* Bottom right corner: manual title and section. */
1075 p
->flags
&= ~TERMP_NOBREAK
;
1076 p
->flags
|= TERMP_NOSPACE
;
1078 p
->offset
= p
->rmargin
;
1079 p
->rmargin
= p
->maxrmargin
;
1081 term_word(p
, title
);
1087 print_man_head(struct termp
*p
, const struct roff_meta
*meta
)
1091 size_t vollen
, titlen
;
1093 assert(meta
->title
);
1096 volume
= NULL
== meta
->vol
? "" : meta
->vol
;
1097 vollen
= term_strlen(p
, volume
);
1099 /* Top left corner: manual title and section. */
1101 mandoc_asprintf(&title
, "%s(%s)", meta
->title
, meta
->msec
);
1102 titlen
= term_strlen(p
, title
);
1104 p
->flags
|= TERMP_NOBREAK
| TERMP_NOSPACE
;
1107 p
->rmargin
= 2 * (titlen
+1) + vollen
< p
->maxrmargin
?
1108 (p
->maxrmargin
- vollen
+ term_len(p
, 1)) / 2 :
1109 vollen
< p
->maxrmargin
? p
->maxrmargin
- vollen
: 0;
1111 term_word(p
, title
);
1114 /* At the top in the middle: manual volume. */
1116 p
->flags
|= TERMP_NOSPACE
;
1117 p
->offset
= p
->rmargin
;
1118 p
->rmargin
= p
->offset
+ vollen
+ titlen
< p
->maxrmargin
?
1119 p
->maxrmargin
- titlen
: p
->maxrmargin
;
1121 term_word(p
, volume
);
1124 /* Top right corner: title and section, again. */
1126 p
->flags
&= ~TERMP_NOBREAK
;
1128 if (p
->rmargin
+ titlen
<= p
->maxrmargin
) {
1129 p
->flags
|= TERMP_NOSPACE
;
1130 p
->offset
= p
->rmargin
;
1131 p
->rmargin
= p
->maxrmargin
;
1132 term_word(p
, title
);
1136 p
->flags
&= ~TERMP_NOSPACE
;
1138 p
->rmargin
= p
->maxrmargin
;
1141 * Groff prints three blank lines before the content.
1142 * Do the same, except in the temporary, undocumented
1143 * mode imitating mdoc(7) output.
1147 if ( ! p
->mdocstyle
) {