]>
git.cameronkatri.com Git - mandoc.git/blob - man_term.c
1 /* $Id: man_term.c,v 1.155 2014/10/28 17:36:19 schwarze Exp $ */
3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010-2014 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>
29 #include "mandoc_aux.h"
35 #define MAXMARGINS 64 /* maximum number of indented scopes */
39 #define MANT_LITERAL (1 << 0)
40 size_t lmargin
[MAXMARGINS
]; /* margins (incl. visible page) */
41 int lmargincur
; /* index of current margin */
42 int lmarginsz
; /* actual number of nested margins */
43 size_t offset
; /* default offset to visible page */
44 int pardist
; /* vert. space before par., unit: [v] */
47 #define DECL_ARGS struct termp *p, \
49 const struct man_node *n, \
50 const struct man_meta *meta
53 int (*pre
)(DECL_ARGS
);
54 void (*post
)(DECL_ARGS
);
56 #define MAN_NOTEXT (1 << 0) /* Never has text children. */
59 static int a2width(const struct termp
*, const char *);
60 static size_t a2height(const struct termp
*, const char *);
62 static void print_man_nodelist(DECL_ARGS
);
63 static void print_man_node(DECL_ARGS
);
64 static void print_man_head(struct termp
*, const void *);
65 static void print_man_foot(struct termp
*, const void *);
66 static void print_bvspace(struct termp
*,
67 const struct man_node
*, int);
69 static int pre_B(DECL_ARGS
);
70 static int pre_HP(DECL_ARGS
);
71 static int pre_I(DECL_ARGS
);
72 static int pre_IP(DECL_ARGS
);
73 static int pre_OP(DECL_ARGS
);
74 static int pre_PD(DECL_ARGS
);
75 static int pre_PP(DECL_ARGS
);
76 static int pre_RS(DECL_ARGS
);
77 static int pre_SH(DECL_ARGS
);
78 static int pre_SS(DECL_ARGS
);
79 static int pre_TP(DECL_ARGS
);
80 static int pre_UR(DECL_ARGS
);
81 static int pre_alternate(DECL_ARGS
);
82 static int pre_ft(DECL_ARGS
);
83 static int pre_ign(DECL_ARGS
);
84 static int pre_in(DECL_ARGS
);
85 static int pre_literal(DECL_ARGS
);
86 static int pre_ll(DECL_ARGS
);
87 static int pre_sp(DECL_ARGS
);
89 static void post_IP(DECL_ARGS
);
90 static void post_HP(DECL_ARGS
);
91 static void post_RS(DECL_ARGS
);
92 static void post_SH(DECL_ARGS
);
93 static void post_SS(DECL_ARGS
);
94 static void post_TP(DECL_ARGS
);
95 static void post_UR(DECL_ARGS
);
97 static const struct termact termacts
[MAN_MAX
] = {
98 { pre_sp
, NULL
, MAN_NOTEXT
}, /* br */
99 { NULL
, NULL
, 0 }, /* TH */
100 { pre_SH
, post_SH
, 0 }, /* SH */
101 { pre_SS
, post_SS
, 0 }, /* SS */
102 { pre_TP
, post_TP
, 0 }, /* TP */
103 { pre_PP
, NULL
, 0 }, /* LP */
104 { pre_PP
, NULL
, 0 }, /* PP */
105 { pre_PP
, NULL
, 0 }, /* P */
106 { pre_IP
, post_IP
, 0 }, /* IP */
107 { pre_HP
, post_HP
, 0 }, /* HP */
108 { NULL
, NULL
, 0 }, /* SM */
109 { pre_B
, NULL
, 0 }, /* SB */
110 { pre_alternate
, NULL
, 0 }, /* BI */
111 { pre_alternate
, NULL
, 0 }, /* IB */
112 { pre_alternate
, NULL
, 0 }, /* BR */
113 { pre_alternate
, NULL
, 0 }, /* RB */
114 { NULL
, NULL
, 0 }, /* R */
115 { pre_B
, NULL
, 0 }, /* B */
116 { pre_I
, NULL
, 0 }, /* I */
117 { pre_alternate
, NULL
, 0 }, /* IR */
118 { pre_alternate
, NULL
, 0 }, /* RI */
119 { pre_ign
, NULL
, MAN_NOTEXT
}, /* na */
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
, 0 }, /* 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 man_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
== MAN_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
);
189 a2height(const struct termp
*p
, const char *cp
)
193 if ( ! a2roffsu(cp
, &su
, SCALE_VS
))
194 SCALE_VS_INIT(&su
, atoi(cp
));
196 return(term_vspan(p
, &su
));
200 a2width(const struct termp
*p
, const char *cp
)
204 if ( ! a2roffsu(cp
, &su
, SCALE_BU
))
207 return((int)term_hspan(p
, &su
));
211 * Printing leading vertical space before a block.
212 * This is used for the paragraph macros.
213 * The rules are pretty simple, since there's very little nesting going
214 * on here. Basically, if we're the first within another block (SS/SH),
215 * then don't emit vertical space. If we are (RS), then do. If not the
219 print_bvspace(struct termp
*p
, const struct man_node
*n
, int pardist
)
225 if (n
->body
&& n
->body
->child
)
226 if (MAN_TBL
== n
->body
->child
->type
)
229 if (MAN_ROOT
== n
->parent
->type
|| MAN_RS
!= n
->parent
->tok
)
233 for (i
= 0; i
< pardist
; i
++)
249 term_setwidth(p
, n
->nchild
? n
->child
->string
: NULL
);
257 term_fontrepl(p
, TERMFONT_UNDER
);
262 pre_literal(DECL_ARGS
)
267 if (MAN_nf
== n
->tok
|| MAN_EX
== n
->tok
)
268 mt
->fl
|= MANT_LITERAL
;
270 mt
->fl
&= ~MANT_LITERAL
;
273 * Unlike .IP and .TP, .HP does not have a HEAD.
274 * So in case a second call to term_flushln() is needed,
275 * indentation has to be set up explicitly.
277 if (MAN_HP
== n
->parent
->tok
&& p
->rmargin
< p
->maxrmargin
) {
278 p
->offset
= p
->rmargin
;
279 p
->rmargin
= p
->maxrmargin
;
281 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
282 p
->flags
|= TERMP_NOSPACE
;
297 assert(MAN_TEXT
== n
->type
);
298 mt
->pardist
= atoi(n
->string
);
303 pre_alternate(DECL_ARGS
)
305 enum termfont font
[2];
306 const struct man_node
*nn
;
311 font
[0] = TERMFONT_NONE
;
312 font
[1] = TERMFONT_BOLD
;
315 font
[0] = TERMFONT_NONE
;
316 font
[1] = TERMFONT_UNDER
;
319 font
[0] = TERMFONT_BOLD
;
320 font
[1] = TERMFONT_NONE
;
323 font
[0] = TERMFONT_BOLD
;
324 font
[1] = TERMFONT_UNDER
;
327 font
[0] = TERMFONT_UNDER
;
328 font
[1] = TERMFONT_NONE
;
331 font
[0] = TERMFONT_UNDER
;
332 font
[1] = TERMFONT_BOLD
;
338 savelit
= MANT_LITERAL
& mt
->fl
;
339 mt
->fl
&= ~MANT_LITERAL
;
341 for (i
= 0, nn
= n
->child
; nn
; nn
= nn
->next
, i
= 1 - i
) {
342 term_fontrepl(p
, font
[i
]);
343 if (savelit
&& NULL
== nn
->next
)
344 mt
->fl
|= MANT_LITERAL
;
345 print_man_node(p
, mt
, nn
, meta
);
347 p
->flags
|= TERMP_NOSPACE
;
357 term_fontrepl(p
, TERMFONT_BOLD
);
366 p
->flags
|= TERMP_NOSPACE
;
368 if (NULL
!= (n
= n
->child
)) {
369 term_fontrepl(p
, TERMFONT_BOLD
);
370 term_word(p
, n
->string
);
372 if (NULL
!= n
&& NULL
!= n
->next
) {
373 term_fontrepl(p
, TERMFONT_UNDER
);
374 term_word(p
, n
->next
->string
);
377 term_fontrepl(p
, TERMFONT_NONE
);
378 p
->flags
|= TERMP_NOSPACE
;
388 if (NULL
== n
->child
) {
393 cp
= n
->child
->string
;
400 term_fontrepl(p
, TERMFONT_BOLD
);
405 term_fontrepl(p
, TERMFONT_UNDER
);
415 term_fontrepl(p
, TERMFONT_NONE
);
432 if (NULL
== n
->child
) {
433 p
->offset
= mt
->offset
;
437 cp
= n
->child
->string
;
447 if ((len
= a2width(p
, ++cp
)) < 0)
453 p
->offset
-= p
->offset
> v
? v
: p
->offset
;
459 /* Don't let this creep beyond the right margin. */
461 if (p
->offset
> p
->rmargin
)
462 p
->offset
= p
->rmargin
;
474 if ((NULL
== n
->prev
&& n
->parent
)) {
475 switch (n
->parent
->tok
) {
498 if (NULL
== n
->child
) {
502 s
= n
->child
->string
;
507 len
= a2height(p
, s
);
516 for (i
= 0; i
< len
; i
++)
527 const struct man_node
*nn
;
531 print_bvspace(p
, n
, mt
->pardist
);
539 if ( ! (MANT_LITERAL
& mt
->fl
)) {
540 p
->flags
|= TERMP_NOBREAK
| TERMP_BRIND
;
544 len
= mt
->lmargin
[mt
->lmargincur
];
547 /* Calculate offset. */
549 if (NULL
!= (nn
= n
->parent
->head
->child
))
550 if ((ival
= a2width(p
, nn
->string
)) >= 0)
553 one
= term_len(p
, 1);
557 p
->offset
= mt
->offset
;
558 p
->rmargin
= mt
->offset
+ len
;
561 mt
->lmargin
[mt
->lmargincur
] = (size_t)ival
;
573 p
->flags
&= ~(TERMP_NOBREAK
| TERMP_BRIND
);
575 p
->offset
= mt
->offset
;
576 p
->rmargin
= p
->maxrmargin
;
589 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
590 print_bvspace(p
, n
, mt
->pardist
);
593 p
->offset
= mt
->offset
;
597 return(MAN_HEAD
!= n
->type
);
603 const struct man_node
*nn
;
609 p
->flags
|= TERMP_NOSPACE
;
612 p
->flags
|= TERMP_NOBREAK
;
616 print_bvspace(p
, n
, mt
->pardist
);
622 len
= mt
->lmargin
[mt
->lmargincur
];
625 /* Calculate the offset from the optional second argument. */
626 if (NULL
!= (nn
= n
->parent
->head
->child
))
627 if (NULL
!= (nn
= nn
->next
))
628 if ((ival
= a2width(p
, nn
->string
)) >= 0)
633 /* Handle zero-width lengths. */
635 len
= term_len(p
, 1);
637 p
->offset
= mt
->offset
;
638 p
->rmargin
= mt
->offset
+ len
;
642 /* Set the saved left-margin. */
643 mt
->lmargin
[mt
->lmargincur
] = (size_t)ival
;
645 savelit
= MANT_LITERAL
& mt
->fl
;
646 mt
->fl
&= ~MANT_LITERAL
;
649 print_man_node(p
, mt
, n
->child
, meta
);
652 mt
->fl
|= MANT_LITERAL
;
656 p
->offset
= mt
->offset
+ len
;
657 p
->rmargin
= p
->maxrmargin
> p
->offset
?
658 p
->maxrmargin
: p
->offset
;
674 p
->flags
&= ~TERMP_NOBREAK
;
676 p
->rmargin
= p
->maxrmargin
;
680 p
->offset
= mt
->offset
;
690 const struct man_node
*nn
;
696 p
->flags
|= TERMP_NOBREAK
;
700 p
->flags
|= TERMP_NOSPACE
;
703 print_bvspace(p
, n
, mt
->pardist
);
709 len
= (size_t)mt
->lmargin
[mt
->lmargincur
];
712 /* Calculate offset. */
714 if (NULL
!= (nn
= n
->parent
->head
->child
))
715 if (nn
->string
&& 0 == (MAN_LINE
& nn
->flags
))
716 if ((ival
= a2width(p
, nn
->string
)) >= 0)
721 /* Handle zero-length properly. */
723 len
= term_len(p
, 1);
725 p
->offset
= mt
->offset
;
726 p
->rmargin
= mt
->offset
+ len
;
728 savelit
= MANT_LITERAL
& mt
->fl
;
729 mt
->fl
&= ~MANT_LITERAL
;
731 /* Don't print same-line elements. */
733 while (NULL
!= nn
&& 0 == (MAN_LINE
& nn
->flags
))
737 print_man_node(p
, mt
, nn
, meta
);
742 mt
->fl
|= MANT_LITERAL
;
744 mt
->lmargin
[mt
->lmargincur
] = (size_t)ival
;
748 p
->offset
= mt
->offset
+ len
;
749 p
->rmargin
= p
->maxrmargin
> p
->offset
?
750 p
->maxrmargin
: p
->offset
;
752 p
->flags
&= ~TERMP_NOBREAK
;
771 p
->offset
= mt
->offset
;
785 mt
->fl
&= ~MANT_LITERAL
;
786 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
787 mt
->offset
= term_len(p
, p
->defindent
);
788 /* If following a prior empty `SS', no vspace. */
789 if (n
->prev
&& MAN_SS
== n
->prev
->tok
)
790 if (NULL
== n
->prev
->body
->child
)
794 for (i
= 0; i
< mt
->pardist
; i
++)
798 term_fontrepl(p
, TERMFONT_BOLD
);
799 p
->offset
= term_len(p
, 3);
802 p
->offset
= mt
->offset
;
834 mt
->fl
&= ~MANT_LITERAL
;
835 mt
->lmargin
[mt
->lmargincur
] = term_len(p
, p
->defindent
);
836 mt
->offset
= term_len(p
, p
->defindent
);
837 /* If following a prior empty `SH', no vspace. */
838 if (n
->prev
&& MAN_SH
== n
->prev
->tok
)
839 if (NULL
== n
->prev
->body
->child
)
841 /* If the first macro, no vspae. */
844 for (i
= 0; i
< mt
->pardist
; i
++)
848 term_fontrepl(p
, TERMFONT_BOLD
);
852 p
->offset
= mt
->offset
;
893 sz
= term_len(p
, p
->defindent
);
895 if (NULL
!= (n
= n
->parent
->head
->child
))
896 if ((ival
= a2width(p
, n
->string
)) >= 0)
900 p
->offset
= mt
->offset
;
901 p
->rmargin
= p
->maxrmargin
> p
->offset
?
902 p
->maxrmargin
: p
->offset
;
904 if (++mt
->lmarginsz
< MAXMARGINS
)
905 mt
->lmargincur
= mt
->lmarginsz
;
907 mt
->lmargin
[mt
->lmargincur
] = mt
->lmargin
[mt
->lmargincur
- 1];
927 sz
= term_len(p
, p
->defindent
);
929 if (NULL
!= (n
= n
->parent
->head
->child
))
930 if ((ival
= a2width(p
, n
->string
)) >= 0)
933 mt
->offset
= mt
->offset
< sz
? 0 : mt
->offset
- sz
;
934 p
->offset
= mt
->offset
;
936 if (--mt
->lmarginsz
< MAXMARGINS
)
937 mt
->lmargincur
= mt
->lmarginsz
;
944 return (MAN_HEAD
!= n
->type
);
951 if (MAN_BLOCK
!= n
->type
)
955 p
->flags
|= TERMP_NOSPACE
;
957 if (NULL
!= n
->child
->child
)
958 print_man_node(p
, mt
, n
->child
->child
, meta
);
960 p
->flags
|= TERMP_NOSPACE
;
965 print_man_node(DECL_ARGS
)
973 * If we have a blank line, output a vertical space.
974 * If we have a space as the first character, break
975 * before printing the line's data.
977 if ('\0' == *n
->string
) {
980 } else if (' ' == *n
->string
&& MAN_LINE
& n
->flags
)
983 term_word(p
, n
->string
);
987 if ( ! (n
->flags
& MAN_LINE
))
988 p
->flags
|= TERMP_NOSPACE
;
990 if (n
->next
!= NULL
&& ! (n
->next
->flags
& MAN_LINE
))
991 p
->flags
|= TERMP_NOSPACE
;
995 * Tables are preceded by a newline. Then process a
996 * table line, which will cause line termination,
998 if (TBL_SPAN_FIRST
& n
->span
->flags
)
1000 term_tbl(p
, n
->span
);
1006 if ( ! (MAN_NOTEXT
& termacts
[n
->tok
].flags
))
1007 term_fontrepl(p
, TERMFONT_NONE
);
1010 if (termacts
[n
->tok
].pre
)
1011 c
= (*termacts
[n
->tok
].pre
)(p
, mt
, n
, meta
);
1014 print_man_nodelist(p
, mt
, n
->child
, meta
);
1016 if (termacts
[n
->tok
].post
)
1017 (*termacts
[n
->tok
].post
)(p
, mt
, n
, meta
);
1018 if ( ! (MAN_NOTEXT
& termacts
[n
->tok
].flags
))
1019 term_fontrepl(p
, TERMFONT_NONE
);
1023 * If we're in a literal context, make sure that words
1024 * together on the same line stay together. This is a
1025 * POST-printing call, so we check the NEXT word. Since
1026 * -man doesn't have nested macros, we don't need to be
1027 * more specific than this.
1029 if (MANT_LITERAL
& mt
->fl
&& ! (TERMP_NOBREAK
& p
->flags
) &&
1030 (NULL
== n
->next
|| MAN_LINE
& n
->next
->flags
)) {
1032 rmax
= p
->maxrmargin
;
1033 p
->rmargin
= p
->maxrmargin
= TERM_MAXMARGIN
;
1034 p
->flags
|= TERMP_NOSPACE
;
1035 if (NULL
!= n
->string
&& '\0' != *n
->string
)
1039 if (rm
< rmax
&& n
->parent
->tok
== MAN_HP
) {
1044 p
->maxrmargin
= rmax
;
1046 if (MAN_EOS
& n
->flags
)
1047 p
->flags
|= TERMP_SENTENCE
;
1052 print_man_nodelist(DECL_ARGS
)
1055 print_man_node(p
, mt
, n
, meta
);
1058 print_man_nodelist(p
, mt
, n
->next
, meta
);
1062 print_man_foot(struct termp
*p
, const void *arg
)
1064 const struct man_meta
*meta
;
1068 meta
= (const struct man_meta
*)arg
;
1069 assert(meta
->title
);
1073 term_fontrepl(p
, TERMFONT_NONE
);
1079 * Temporary, undocumented option to imitate mdoc(7) output.
1080 * In the bottom right corner, use the source instead of
1084 if ( ! p
->mdocstyle
) {
1085 if (meta
->hasbody
) {
1089 mandoc_asprintf(&title
, "%s(%s)",
1090 meta
->title
, meta
->msec
);
1091 } else if (meta
->source
) {
1092 title
= mandoc_strdup(meta
->source
);
1094 title
= mandoc_strdup("");
1096 datelen
= term_strlen(p
, meta
->date
);
1098 /* Bottom left corner: manual source. */
1100 p
->flags
|= TERMP_NOSPACE
| TERMP_NOBREAK
;
1103 p
->rmargin
= (p
->maxrmargin
- datelen
+ term_len(p
, 1)) / 2;
1106 term_word(p
, meta
->source
);
1109 /* At the bottom in the middle: manual date. */
1111 p
->flags
|= TERMP_NOSPACE
;
1112 p
->offset
= p
->rmargin
;
1113 p
->rmargin
= p
->maxrmargin
- term_strlen(p
, title
);
1114 if (p
->offset
+ datelen
>= p
->rmargin
)
1115 p
->rmargin
= p
->offset
+ datelen
;
1117 term_word(p
, meta
->date
);
1120 /* Bottom right corner: manual title and section. */
1122 p
->flags
&= ~TERMP_NOBREAK
;
1123 p
->flags
|= TERMP_NOSPACE
;
1125 p
->offset
= p
->rmargin
;
1126 p
->rmargin
= p
->maxrmargin
;
1128 term_word(p
, title
);
1134 print_man_head(struct termp
*p
, const void *arg
)
1136 const struct man_meta
*meta
;
1139 size_t vollen
, titlen
;
1141 meta
= (const struct man_meta
*)arg
;
1142 assert(meta
->title
);
1145 volume
= NULL
== meta
->vol
? "" : meta
->vol
;
1146 vollen
= term_strlen(p
, volume
);
1148 /* Top left corner: manual title and section. */
1150 mandoc_asprintf(&title
, "%s(%s)", meta
->title
, meta
->msec
);
1151 titlen
= term_strlen(p
, title
);
1153 p
->flags
|= TERMP_NOBREAK
| TERMP_NOSPACE
;
1156 p
->rmargin
= 2 * (titlen
+1) + vollen
< p
->maxrmargin
?
1157 (p
->maxrmargin
- vollen
+ term_len(p
, 1)) / 2 :
1158 p
->maxrmargin
- vollen
;
1160 term_word(p
, title
);
1163 /* At the top in the middle: manual volume. */
1165 p
->flags
|= TERMP_NOSPACE
;
1166 p
->offset
= p
->rmargin
;
1167 p
->rmargin
= p
->offset
+ vollen
+ titlen
< p
->maxrmargin
?
1168 p
->maxrmargin
- titlen
: p
->maxrmargin
;
1170 term_word(p
, volume
);
1173 /* Top right corner: title and section, again. */
1175 p
->flags
&= ~TERMP_NOBREAK
;
1177 if (p
->rmargin
+ titlen
<= p
->maxrmargin
) {
1178 p
->flags
|= TERMP_NOSPACE
;
1179 p
->offset
= p
->rmargin
;
1180 p
->rmargin
= p
->maxrmargin
;
1181 term_word(p
, title
);
1185 p
->flags
&= ~TERMP_NOSPACE
;
1187 p
->rmargin
= p
->maxrmargin
;
1190 * Groff prints three blank lines before the content.
1191 * Do the same, except in the temporary, undocumented
1192 * mode imitating mdoc(7) output.
1196 if ( ! p
->mdocstyle
) {