Lines Matching +full:bl +full:- +full:data +full:- +full:offset
3 * Copyright (c) 2010, 2012-2020, 2022 Ingo Schwarze <schwarze@openbsd.org>
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 * for ASCII, UTF-8, PostScript, and PDF output.
123 static const struct mdoc_term_act mdoc_term_acts[MDOC_MAX - MDOC_Dd] = {
134 { termp_bl_pre, termp_bl_post }, /* Bl */
255 p->tcol->rmargin = p->maxrmargin = p->defrmargin; in terminal_mdoc()
260 n = mdoc->first->child; in terminal_mdoc()
261 if (p->synopsisonly) { in terminal_mdoc()
262 for (nn = NULL; n != NULL; n = n->next) { in terminal_mdoc()
263 if (n->tok != MDOC_Sh) in terminal_mdoc()
265 if (n->sec == SEC_SYNOPSIS) in terminal_mdoc()
267 if (nn == NULL && n->sec == SEC_NAME) in terminal_mdoc()
272 p->flags |= TERMP_NOSPACE; in terminal_mdoc()
273 if (n != NULL && (n = n->child->next->child) != NULL) in terminal_mdoc()
279 (n->type == ROFFT_COMMENT || in terminal_mdoc()
280 n->flags & NODE_NOPRT)) in terminal_mdoc()
281 n = n->next; in terminal_mdoc()
283 if (n->tok != MDOC_Sh) in terminal_mdoc()
296 n = n->next; in print_mdoc_nodelist()
305 size_t offset, rmargin; in print_mdoc_node() local
309 * In no-fill mode, break the output line at the beginning in print_mdoc_node()
313 if (n->flags & NODE_NOFILL) { in print_mdoc_node()
314 if (n->flags & NODE_LINE && in print_mdoc_node()
315 (p->flags & TERMP_NONEWLINE) == 0) in print_mdoc_node()
317 p->flags |= TERMP_BRNEVER; in print_mdoc_node()
319 if (n->flags & NODE_LINE) in print_mdoc_node()
321 p->flags &= ~TERMP_BRNEVER; in print_mdoc_node()
324 if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT) in print_mdoc_node()
328 offset = p->tcol->offset; in print_mdoc_node()
329 rmargin = p->tcol->rmargin; in print_mdoc_node()
330 n->flags &= ~NODE_ENDED; in print_mdoc_node()
331 n->prev_font = p->fonti; in print_mdoc_node()
336 if (n->flags & NODE_ID && n->tok != MDOC_Pp && in print_mdoc_node()
337 (n->tok != MDOC_It || n->type != ROFFT_BLOCK)) in print_mdoc_node()
338 term_tag_write(n, p->line); in print_mdoc_node()
345 if (p->flags & TERMP_KEEP && n->flags & NODE_LINE) { in print_mdoc_node()
346 p->flags &= ~TERMP_KEEP; in print_mdoc_node()
347 p->flags |= TERMP_PREKEEP; in print_mdoc_node()
352 * produce output. Note that some pre-handlers do so. in print_mdoc_node()
356 switch (n->type) { in print_mdoc_node()
358 if (n->flags & NODE_LINE) { in print_mdoc_node()
359 switch (*n->string) { in print_mdoc_node()
361 if (p->flags & TERMP_NONEWLINE) in print_mdoc_node()
367 if ((p->flags & TERMP_NONEWLINE) == 0) in print_mdoc_node()
374 if (NODE_DELIMC & n->flags) in print_mdoc_node()
375 p->flags |= TERMP_NOSPACE; in print_mdoc_node()
376 term_word(p, n->string); in print_mdoc_node()
377 if (NODE_DELIMO & n->flags) in print_mdoc_node()
378 p->flags |= TERMP_NOSPACE; in print_mdoc_node()
381 if ( ! (n->flags & NODE_LINE)) in print_mdoc_node()
382 p->flags |= TERMP_NOSPACE; in print_mdoc_node()
383 term_eqn(p, n->eqn); in print_mdoc_node()
384 if (n->next != NULL && ! (n->next->flags & NODE_LINE)) in print_mdoc_node()
385 p->flags |= TERMP_NOSPACE; in print_mdoc_node()
388 if (p->tbl.cols == NULL) in print_mdoc_node()
390 term_tbl(p, n->span); in print_mdoc_node()
393 if (n->tok < ROFF_MAX) { in print_mdoc_node()
397 assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX); in print_mdoc_node()
398 act = mdoc_term_acts + (n->tok - MDOC_Dd); in print_mdoc_node()
399 if (act->pre != NULL && in print_mdoc_node()
400 (n->end == ENDBODY_NOT || n->child != NULL)) in print_mdoc_node()
401 chld = (*act->pre)(p, &npair, meta, n); in print_mdoc_node()
405 if (chld && n->child) in print_mdoc_node()
406 print_mdoc_nodelist(p, &npair, meta, n->child); in print_mdoc_node()
409 (ENDBODY_NOT == n->end ? n : n->body)->prev_font); in print_mdoc_node()
411 switch (n->type) { in print_mdoc_node()
419 if (act->post == NULL || n->flags & NODE_ENDED) in print_mdoc_node()
421 (void)(*act->post)(p, &npair, meta, n); in print_mdoc_node()
428 if (ENDBODY_NOT != n->end) in print_mdoc_node()
429 n->body->flags |= NODE_ENDED; in print_mdoc_node()
433 if (NODE_EOS & n->flags) in print_mdoc_node()
434 p->flags |= TERMP_SENTENCE; in print_mdoc_node()
436 if (n->type != ROFFT_TEXT) in print_mdoc_node()
437 p->tcol->offset = offset; in print_mdoc_node()
438 p->tcol->rmargin = rmargin; in print_mdoc_node()
449 * Output the footer in new-groff style, that is, three columns in print_mdoc_foot()
458 p->tcol->offset = 0; in print_mdoc_foot()
459 sz = term_strlen(p, meta->date); in print_mdoc_foot()
460 p->tcol->rmargin = p->maxrmargin > sz ? in print_mdoc_foot()
461 (p->maxrmargin + term_len(p, 1) - sz) / 2 : 0; in print_mdoc_foot()
462 p->trailspace = 1; in print_mdoc_foot()
463 p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; in print_mdoc_foot()
465 term_word(p, meta->os); in print_mdoc_foot()
468 p->tcol->offset = p->tcol->rmargin; in print_mdoc_foot()
469 sz = term_strlen(p, meta->os); in print_mdoc_foot()
470 p->tcol->rmargin = p->maxrmargin > sz ? p->maxrmargin - sz : 0; in print_mdoc_foot()
471 p->flags |= TERMP_NOSPACE; in print_mdoc_foot()
473 term_word(p, meta->date); in print_mdoc_foot()
476 p->tcol->offset = p->tcol->rmargin; in print_mdoc_foot()
477 p->tcol->rmargin = p->maxrmargin; in print_mdoc_foot()
478 p->trailspace = 0; in print_mdoc_foot()
479 p->flags &= ~TERMP_NOBREAK; in print_mdoc_foot()
480 p->flags |= TERMP_NOSPACE; in print_mdoc_foot()
482 term_word(p, meta->os); in print_mdoc_foot()
485 p->tcol->offset = 0; in print_mdoc_foot()
486 p->tcol->rmargin = p->maxrmargin; in print_mdoc_foot()
487 p->flags = 0; in print_mdoc_foot()
502 * The IDENTIFIER is NAME(SECTION), which is the command-name in print_mdoc_head()
504 * section. These are given in `Dt'. The TITLE is a free-form in print_mdoc_head()
509 assert(meta->vol); in print_mdoc_head()
510 if (NULL == meta->arch) in print_mdoc_head()
511 volume = mandoc_strdup(meta->vol); in print_mdoc_head()
514 meta->vol, meta->arch); in print_mdoc_head()
517 if (NULL == meta->msec) in print_mdoc_head()
518 title = mandoc_strdup(meta->title); in print_mdoc_head()
521 meta->title, meta->msec); in print_mdoc_head()
524 p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; in print_mdoc_head()
525 p->trailspace = 1; in print_mdoc_head()
526 p->tcol->offset = 0; in print_mdoc_head()
527 p->tcol->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? in print_mdoc_head()
528 (p->maxrmargin - vollen + term_len(p, 1)) / 2 : in print_mdoc_head()
529 vollen < p->maxrmargin ? p->maxrmargin - vollen : 0; in print_mdoc_head()
534 p->flags |= TERMP_NOSPACE; in print_mdoc_head()
535 p->tcol->offset = p->tcol->rmargin; in print_mdoc_head()
536 p->tcol->rmargin = p->tcol->offset + vollen + titlen < in print_mdoc_head()
537 p->maxrmargin ? p->maxrmargin - titlen : p->maxrmargin; in print_mdoc_head()
542 p->flags &= ~TERMP_NOBREAK; in print_mdoc_head()
543 p->trailspace = 0; in print_mdoc_head()
544 if (p->tcol->rmargin + titlen <= p->maxrmargin) { in print_mdoc_head()
545 p->flags |= TERMP_NOSPACE; in print_mdoc_head()
546 p->tcol->offset = p->tcol->rmargin; in print_mdoc_head()
547 p->tcol->rmargin = p->maxrmargin; in print_mdoc_head()
552 p->flags &= ~TERMP_NOSPACE; in print_mdoc_head()
553 p->tcol->offset = 0; in print_mdoc_head()
554 p->tcol->rmargin = p->maxrmargin; in print_mdoc_head()
575 * (and thus `Bl') and `Bd'. And then go ahead and print that space,
579 print_bvspace(struct termp *p, struct roff_node *bl, struct roff_node *n) in print_bvspace() argument
585 if ((bl->tok == MDOC_Bd && bl->norm->Bd.comp) || in print_bvspace()
586 (bl->tok == MDOC_Bl && bl->norm->Bl.comp)) in print_bvspace()
594 nn = nn->parent; in print_bvspace()
595 if (nn->type == ROFFT_ROOT) in print_bvspace()
597 } while (nn->type != ROFFT_BLOCK); in print_bvspace()
598 if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss) in print_bvspace()
600 if (nn->tok == MDOC_It && in print_bvspace()
601 nn->parent->parent->norm->Bl.type != LIST_item) in print_bvspace()
607 * items in .Bl -column in print_bvspace()
608 * items without a body in .Bl -diag in print_bvspace()
611 if (bl->tok != MDOC_Bl || in print_bvspace()
612 n->prev == NULL || n->prev->tok != MDOC_It || in print_bvspace()
613 (bl->norm->Bl.type != LIST_column && in print_bvspace()
614 (bl->norm->Bl.type != LIST_diag || in print_bvspace()
615 n->prev->body->child != NULL))) in print_bvspace()
625 const struct roff_node *bl, *nn; in termp_it_pre() local
627 int i, offset, width; in termp_it_pre() local
630 if (n->type == ROFFT_BLOCK) { in termp_it_pre()
631 print_bvspace(p, n->parent->parent, n); in termp_it_pre()
632 if (n->flags & NODE_ID) in termp_it_pre()
633 term_tag_write(n, p->line); in termp_it_pre()
637 bl = n->parent->parent->parent; in termp_it_pre()
638 type = bl->norm->Bl.type; in termp_it_pre()
662 offset = 0; in termp_it_pre()
665 * First calculate width and offset. This is pretty easy unless in termp_it_pre()
666 * we're a -column list, in which case all prior columns must in termp_it_pre()
670 if (bl->norm->Bl.offs != NULL) { in termp_it_pre()
671 offset = a2width(p, bl->norm->Bl.offs); in termp_it_pre()
672 if (offset < 0 && (size_t)(-offset) > p->tcol->offset) in termp_it_pre()
673 offset = -p->tcol->offset; in termp_it_pre()
674 else if (offset > SHRT_MAX) in termp_it_pre()
675 offset = 0; in termp_it_pre()
680 if (n->type == ROFFT_HEAD) in termp_it_pre()
685 * - For each earlier column, add its width. in termp_it_pre()
686 * - For less than 5 columns, add four more blanks per in termp_it_pre()
688 * - For exactly 5 columns, add three more blank per in termp_it_pre()
690 * - For more than 5 columns, add only one column. in termp_it_pre()
692 ncols = bl->norm->Bl.ncols; in termp_it_pre()
697 * Calculate the offset by applying all prior ROFFT_BODY, in termp_it_pre()
698 * so we stop at the ROFFT_HEAD (nn->prev == NULL). in termp_it_pre()
701 for (i = 0, nn = n->prev; in termp_it_pre()
702 nn->prev && i < (int)ncols; in termp_it_pre()
703 nn = nn->prev, i++) { in termp_it_pre()
705 su.scale = term_strlen(p, bl->norm->Bl.cols[i]) / in termp_it_pre()
707 offset += term_hen(p, &su) + dcol; in termp_it_pre()
724 su.scale = term_strlen(p, bl->norm->Bl.cols[i]) / in termp_it_pre()
729 if (NULL == bl->norm->Bl.width) in termp_it_pre()
737 width = a2width(p, bl->norm->Bl.width) + term_len(p, 2); in termp_it_pre()
738 if (width < 0 && (size_t)(-width) > p->tcol->offset) in termp_it_pre()
739 width = -p->tcol->offset; in termp_it_pre()
750 p->flags |= TERMP_NOSPACE; in termp_it_pre()
754 if (n->type == ROFFT_BODY) in termp_it_pre()
758 if (n->type == ROFFT_BODY && n->parent->head->child != NULL) in termp_it_pre()
765 p->flags |= TERMP_NOSPACE; in termp_it_pre()
769 if (n->type == ROFFT_HEAD) in termp_it_pre()
788 if (n->type == ROFFT_HEAD) { in termp_it_pre()
789 p->flags |= TERMP_NOBREAK | TERMP_HANG; in termp_it_pre()
790 p->trailspace = 1; in termp_it_pre()
792 p->flags |= TERMP_NOPAD; in termp_it_pre()
795 if (n->type != ROFFT_HEAD) in termp_it_pre()
797 p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG; in termp_it_pre()
798 p->trailspace = 1; in termp_it_pre()
801 if (n->type != ROFFT_HEAD) in termp_it_pre()
804 p->flags |= TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND; in termp_it_pre()
805 p->trailspace = 2; in termp_it_pre()
807 if (NULL == n->next || NULL == n->next->child) in termp_it_pre()
808 p->flags |= TERMP_HANG; in termp_it_pre()
811 if (n->type == ROFFT_HEAD) in termp_it_pre()
814 if (NULL == n->next) { in termp_it_pre()
815 p->flags &= ~TERMP_NOBREAK; in termp_it_pre()
816 p->trailspace = 0; in termp_it_pre()
818 p->flags |= TERMP_NOBREAK; in termp_it_pre()
819 p->trailspace = 1; in termp_it_pre()
824 if (n->type != ROFFT_HEAD) in termp_it_pre()
826 p->flags |= TERMP_NOBREAK | TERMP_BRIND; in termp_it_pre()
827 p->trailspace = 1; in termp_it_pre()
834 * Margin control. Set-head-width lists have their right in termp_it_pre()
835 * margins shortened. The body for these lists has the offset in termp_it_pre()
836 * necessarily lengthened. Everybody gets the offset. in termp_it_pre()
839 p->tcol->offset += offset; in termp_it_pre()
848 if (n->type == ROFFT_HEAD) in termp_it_pre()
849 p->tcol->rmargin = p->tcol->offset + width; in termp_it_pre()
851 p->tcol->offset += width; in termp_it_pre()
855 p->tcol->rmargin = p->tcol->offset + width; in termp_it_pre()
857 * XXX - this behaviour is not documented: the in termp_it_pre()
858 * right-most column is filled to the right margin. in termp_it_pre()
860 if (n->type == ROFFT_HEAD) in termp_it_pre()
862 if (n->next == NULL && p->tcol->rmargin < p->maxrmargin) in termp_it_pre()
863 p->tcol->rmargin = p->maxrmargin; in termp_it_pre()
874 if (n->type == ROFFT_HEAD) in termp_it_pre()
884 term_word(p, "-"); in termp_it_pre()
888 (pair->ppair->ppair->count)++; in termp_it_pre()
890 pair->ppair->ppair->count); in termp_it_pre()
907 if (n->type == ROFFT_HEAD) in termp_it_pre()
911 if (n->type == ROFFT_HEAD) in termp_it_pre()
913 p->minbl = 0; in termp_it_pre()
927 if (n->type == ROFFT_BLOCK) in termp_it_post()
930 type = n->parent->parent->parent->norm->Bl.type; in termp_it_post()
936 if (n->type == ROFFT_BODY) in termp_it_post()
940 if (n->type == ROFFT_BODY) in termp_it_post()
954 p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND | TERMP_HANG); in termp_it_post()
955 p->trailspace = 0; in termp_it_post()
963 if (n->type == ROFFT_BLOCK) { in termp_nm_pre()
964 p->flags |= TERMP_PREKEEP; in termp_nm_pre()
968 if (n->type == ROFFT_BODY) { in termp_nm_pre()
969 if (n->child == NULL) in termp_nm_pre()
971 p->flags |= TERMP_NOSPACE; in termp_nm_pre()
973 if (n->prev->child != NULL) in termp_nm_pre()
974 cp = n->prev->child->string; in termp_nm_pre()
976 cp = meta->name; in termp_nm_pre()
978 p->tcol->offset += term_len(p, 6); in termp_nm_pre()
980 p->tcol->offset += term_len(p, 1) + in termp_nm_pre()
985 if (n->child == NULL) in termp_nm_pre()
988 if (n->type == ROFFT_HEAD) in termp_nm_pre()
989 synopsis_pre(p, n->parent); in termp_nm_pre()
991 if (n->type == ROFFT_HEAD && in termp_nm_pre()
992 n->next != NULL && n->next->child != NULL) { in termp_nm_pre()
993 p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND; in termp_nm_pre()
994 p->trailspace = 1; in termp_nm_pre()
995 p->tcol->rmargin = p->tcol->offset + term_len(p, 1); in termp_nm_pre()
996 if (n->child == NULL) in termp_nm_pre()
997 p->tcol->rmargin += term_strlen(p, meta->name); in termp_nm_pre()
998 else if (n->child->type == ROFFT_TEXT) { in termp_nm_pre()
999 p->tcol->rmargin += term_strlen(p, n->child->string); in termp_nm_pre()
1000 if (n->child->next != NULL) in termp_nm_pre()
1001 p->flags |= TERMP_HANG; in termp_nm_pre()
1003 p->tcol->rmargin += term_len(p, 5); in termp_nm_pre()
1004 p->flags |= TERMP_HANG; in termp_nm_pre()
1013 switch (n->type) { in termp_nm_post()
1015 p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); in termp_nm_post()
1018 if (n->next == NULL || n->next->child == NULL) in termp_nm_post()
1021 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG); in termp_nm_post()
1022 p->trailspace = 0; in termp_nm_post()
1025 if (n->child != NULL) in termp_nm_post()
1039 term_word(p, "\\-"); in termp_fl_pre()
1041 if (n->child != NULL || in termp_fl_pre()
1043 nn->type != ROFFT_TEXT && in termp_fl_pre()
1044 (nn->flags & NODE_LINE) == 0)) in termp_fl_pre()
1045 p->flags |= TERMP_NOSPACE; in termp_fl_pre()
1055 if ((nn = roff_node_prev(n)) != NULL && nn->tok == MDOC__A && in termp__a_pre()
1056 ((nn = roff_node_next(n)) == NULL || nn->tok != MDOC__A)) in termp__a_pre()
1066 if (n->norm->An.auth == AUTH_split) { in termp_an_pre()
1067 p->flags &= ~TERMP_NOSPLIT; in termp_an_pre()
1068 p->flags |= TERMP_SPLIT; in termp_an_pre()
1071 if (n->norm->An.auth == AUTH_nosplit) { in termp_an_pre()
1072 p->flags &= ~TERMP_SPLIT; in termp_an_pre()
1073 p->flags |= TERMP_NOSPLIT; in termp_an_pre()
1077 if (p->flags & TERMP_SPLIT) in termp_an_pre()
1080 if (n->sec == SEC_AUTHORS && ! (p->flags & TERMP_NOSPLIT)) in termp_an_pre()
1081 p->flags |= TERMP_SPLIT; in termp_an_pre()
1090 if ( ! (NODE_LINE & n->flags)) in termp_ns_pre()
1091 p->flags |= TERMP_NOSPACE; in termp_ns_pre()
1098 if (SEC_SEE_ALSO != n->sec) in termp_rs_pre()
1100 if (n->type == ROFFT_BLOCK && roff_node_prev(n) != NULL) in termp_rs_pre()
1115 if (n->type == ROFFT_BODY) in termp_nd_pre()
1123 switch (n->type) { in termp_bl_pre()
1137 if (n->type != ROFFT_BLOCK) in termp_bl_post()
1140 if (n->tok != MDOC_Bl || n->norm->Bl.type != LIST_column) in termp_bl_post()
1150 if (NULL == (n = n->child)) in termp_xr_pre()
1153 assert(n->type == ROFFT_TEXT); in termp_xr_pre()
1154 term_word(p, n->string); in termp_xr_pre()
1156 if (NULL == (n = n->next)) in termp_xr_pre()
1159 p->flags |= TERMP_NOSPACE; in termp_xr_pre()
1161 p->flags |= TERMP_NOSPACE; in termp_xr_pre()
1163 assert(n->type == ROFFT_TEXT); in termp_xr_pre()
1164 term_word(p, n->string); in termp_xr_pre()
1166 p->flags |= TERMP_NOSPACE; in termp_xr_pre()
1182 if ((n->flags & NODE_SYNPRETTY) == 0 || in synopsis_pre()
1191 if (np->tok == n->tok && in synopsis_pre()
1192 MDOC_Ft != n->tok && in synopsis_pre()
1193 MDOC_Fo != n->tok && in synopsis_pre()
1194 MDOC_Fn != n->tok) { in synopsis_pre()
1200 * If we're one of the SYNOPSIS set and non-like pair-wise after in synopsis_pre()
1204 switch (np->tok) { in synopsis_pre()
1213 if (n->tok != MDOC_Fn && n->tok != MDOC_Fo) { in synopsis_pre()
1227 switch (n->type) { in termp_vt_pre()
1265 switch (n->type) { in termp_sh_pre()
1272 np->tok != MDOC_Sh || in termp_sh_pre()
1273 (np->body != NULL && np->body->child != NULL)) in termp_sh_pre()
1279 p->tcol->offset = term_len(p, p->defindent); in termp_sh_pre()
1283 if (n->sec == SEC_AUTHORS) in termp_sh_pre()
1284 p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT); in termp_sh_pre()
1295 switch (n->type) { in termp_sh_post()
1301 p->tcol->offset = 0; in termp_sh_post()
1311 if (n->sec == SEC_LIBRARY && n->flags & NODE_LINE) in termp_lb_post()
1318 if (n->type != ROFFT_BLOCK) in termp_d1_pre()
1321 p->tcol->offset += term_len(p, p->defindent + 1); in termp_d1_pre()
1342 pretty = n->flags & NODE_SYNPRETTY; in termp_fn_pre()
1343 if ((n = n->child) == NULL) in termp_fn_pre()
1347 rmargin = p->tcol->rmargin; in termp_fn_pre()
1348 p->tcol->rmargin = p->tcol->offset + term_len(p, 4); in termp_fn_pre()
1349 p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG; in termp_fn_pre()
1352 assert(n->type == ROFFT_TEXT); in termp_fn_pre()
1354 term_word(p, n->string); in termp_fn_pre()
1359 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG); in termp_fn_pre()
1360 p->flags |= TERMP_NOPAD; in termp_fn_pre()
1361 p->tcol->offset = p->tcol->rmargin; in termp_fn_pre()
1362 p->tcol->rmargin = rmargin; in termp_fn_pre()
1365 p->flags |= TERMP_NOSPACE; in termp_fn_pre()
1367 p->flags |= TERMP_NOSPACE; in termp_fn_pre()
1369 for (n = n->next; n; n = n->next) { in termp_fn_pre()
1370 assert(n->type == ROFFT_TEXT); in termp_fn_pre()
1373 p->flags |= TERMP_NBRWORD; in termp_fn_pre()
1374 term_word(p, n->string); in termp_fn_pre()
1377 if (n->next) { in termp_fn_pre()
1378 p->flags |= TERMP_NOSPACE; in termp_fn_pre()
1383 p->flags |= TERMP_NOSPACE; in termp_fn_pre()
1387 p->flags |= TERMP_NOSPACE; in termp_fn_pre()
1399 if (n->parent->tok != MDOC_Fo) in termp_fa_pre()
1402 for (nn = n->child; nn != NULL; nn = nn->next) { in termp_fa_pre()
1404 p->flags |= TERMP_NBRWORD; in termp_fa_pre()
1405 term_word(p, nn->string); in termp_fa_pre()
1407 if (nn->next != NULL) { in termp_fa_pre()
1408 p->flags |= TERMP_NOSPACE; in termp_fa_pre()
1412 if (n->child != NULL && in termp_fa_pre()
1414 nn->tok == MDOC_Fa) { in termp_fa_pre()
1415 p->flags |= TERMP_NOSPACE; in termp_fa_pre()
1424 int offset; in termp_bd_pre() local
1426 if (n->type == ROFFT_BLOCK) { in termp_bd_pre()
1429 } else if (n->type == ROFFT_HEAD) in termp_bd_pre()
1432 /* Handle the -offset argument. */ in termp_bd_pre()
1434 if (n->norm->Bd.offs == NULL || in termp_bd_pre()
1435 ! strcmp(n->norm->Bd.offs, "left")) in termp_bd_pre()
1437 else if ( ! strcmp(n->norm->Bd.offs, "indent")) in termp_bd_pre()
1438 p->tcol->offset += term_len(p, p->defindent + 1); in termp_bd_pre()
1439 else if ( ! strcmp(n->norm->Bd.offs, "indent-two")) in termp_bd_pre()
1440 p->tcol->offset += term_len(p, (p->defindent + 1) * 2); in termp_bd_pre()
1442 offset = a2width(p, n->norm->Bd.offs); in termp_bd_pre()
1443 if (offset < 0 && (size_t)(-offset) > p->tcol->offset) in termp_bd_pre()
1444 p->tcol->offset = 0; in termp_bd_pre()
1445 else if (offset < SHRT_MAX) in termp_bd_pre()
1446 p->tcol->offset += offset; in termp_bd_pre()
1449 switch (n->norm->Bd.type) { in termp_bd_pre()
1456 p->flags |= TERMP_CENTER; in termp_bd_pre()
1467 if (n->type != ROFFT_BODY) in termp_bd_post()
1469 if (n->norm->Bd.type == DISP_unfilled || in termp_bd_post()
1470 n->norm->Bd.type == DISP_literal) in termp_bd_post()
1471 p->flags |= TERMP_BRNEVER; in termp_bd_post()
1472 p->flags |= TERMP_NOSPACE; in termp_bd_post()
1474 p->flags &= ~TERMP_BRNEVER; in termp_bd_post()
1475 if (n->norm->Bd.type == DISP_centered) in termp_bd_post()
1476 p->flags &= ~TERMP_CENTER; in termp_bd_post()
1482 if ((n->aux = p->flags & TERMP_PREKEEP) == 0) in termp_xx_pre()
1483 p->flags |= TERMP_PREKEEP; in termp_xx_pre()
1490 if (n->aux == 0) in termp_xx_post()
1491 p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); in termp_xx_post()
1497 if (n->next != NULL && (n->next->flags & NODE_LINE) == 0) in termp_pf_post()
1498 p->flags |= TERMP_NOSPACE; in termp_pf_post()
1504 switch (n->type) { in termp_ss_pre()
1512 p->tcol->offset = term_len(p, (p->defindent+1)/2); in termp_ss_pre()
1515 p->tcol->offset = term_len(p, p->defindent); in termp_ss_pre()
1529 if (n->type == ROFFT_HEAD || n->type == ROFFT_BODY) in termp_ss_post()
1537 if (n->flags & NODE_SYNPRETTY && n->flags & NODE_LINE) { in termp_in_pre()
1545 p->flags |= TERMP_NOSPACE; in termp_in_pre()
1552 if (n->flags & NODE_SYNPRETTY) in termp_in_post()
1554 p->flags |= TERMP_NOSPACE; in termp_in_post()
1556 if (n->flags & NODE_SYNPRETTY) in termp_in_post()
1564 if (n->flags & NODE_ID) in termp_pp_pre()
1565 term_tag_write(n, p->line); in termp_pp_pre()
1578 if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM) in termp_quote_pre()
1581 switch (n->tok) { in termp_quote_pre()
1584 term_word(p, n->child != NULL && n->child->next == NULL && in termp_quote_pre()
1585 n->child->tok == MDOC_Mt ? "<" : "\\(la"); in termp_quote_pre()
1604 if (NULL == n->norm->Es || in termp_quote_pre()
1605 NULL == n->norm->Es->child) in termp_quote_pre()
1607 term_word(p, n->norm->Es->child->string); in termp_quote_pre()
1626 p->flags |= TERMP_NOSPACE; in termp_quote_pre()
1634 if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM) in termp_quote_post()
1637 p->flags |= TERMP_NOSPACE; in termp_quote_post()
1639 switch (n->tok) { in termp_quote_post()
1642 term_word(p, n->child != NULL && n->child->next == NULL && in termp_quote_post()
1643 n->child->tok == MDOC_Mt ? ">" : "\\(ra"); in termp_quote_post()
1662 if (n->norm->Es == NULL || in termp_quote_post()
1663 n->norm->Es->child == NULL || in termp_quote_post()
1664 n->norm->Es->child->next == NULL) in termp_quote_post()
1665 p->flags &= ~TERMP_NOSPACE; in termp_quote_post()
1667 term_word(p, n->norm->Es->child->next->string); in termp_quote_post()
1691 if (n->type != ROFFT_BODY) in termp_eo_pre()
1694 if (n->end == ENDBODY_NOT && in termp_eo_pre()
1695 n->parent->head->child == NULL && in termp_eo_pre()
1696 n->child != NULL && in termp_eo_pre()
1697 n->child->end != ENDBODY_NOT) in termp_eo_pre()
1699 else if (n->end != ENDBODY_NOT ? n->child != NULL : in termp_eo_pre()
1700 n->parent->head->child != NULL && (n->child != NULL || in termp_eo_pre()
1701 (n->parent->tail != NULL && n->parent->tail->child != NULL))) in termp_eo_pre()
1702 p->flags |= TERMP_NOSPACE; in termp_eo_pre()
1712 if (n->type != ROFFT_BODY) in termp_eo_post()
1715 if (n->end != ENDBODY_NOT) { in termp_eo_post()
1716 p->flags &= ~TERMP_NOSPACE; in termp_eo_post()
1720 body = n->child != NULL || n->parent->head->child != NULL; in termp_eo_post()
1721 tail = n->parent->tail != NULL && n->parent->tail->child != NULL; in termp_eo_post()
1724 p->flags |= TERMP_NOSPACE; in termp_eo_post()
1728 p->flags &= ~TERMP_NOSPACE; in termp_eo_post()
1736 switch (n->type) { in termp_fo_pre()
1741 rmargin = p->tcol->rmargin; in termp_fo_pre()
1742 if (n->flags & NODE_SYNPRETTY) { in termp_fo_pre()
1743 p->tcol->rmargin = p->tcol->offset + term_len(p, 4); in termp_fo_pre()
1744 p->flags |= TERMP_NOBREAK | TERMP_BRIND | in termp_fo_pre()
1747 p->flags |= TERMP_NOSPACE; in termp_fo_pre()
1749 p->flags |= TERMP_NOSPACE; in termp_fo_pre()
1750 if (n->flags & NODE_SYNPRETTY) { in termp_fo_pre()
1752 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | in termp_fo_pre()
1754 p->flags |= TERMP_NOPAD; in termp_fo_pre()
1755 p->tcol->offset = p->tcol->rmargin; in termp_fo_pre()
1756 p->tcol->rmargin = rmargin; in termp_fo_pre()
1767 if (n->type != ROFFT_BODY) in termp_fo_post()
1770 p->flags |= TERMP_NOSPACE; in termp_fo_post()
1773 if (n->flags & NODE_SYNPRETTY) { in termp_fo_post()
1774 p->flags |= TERMP_NOSPACE; in termp_fo_post()
1783 switch (n->type) { in termp_bf_pre()
1791 switch (n->norm->Bf.font) { in termp_bf_pre()
1804 if (n->child == NULL) in termp_sm_pre()
1805 p->flags ^= TERMP_NONOSPACE; in termp_sm_pre()
1806 else if (strcmp(n->child->string, "on") == 0) in termp_sm_pre()
1807 p->flags &= ~TERMP_NONOSPACE; in termp_sm_pre()
1809 p->flags |= TERMP_NONOSPACE; in termp_sm_pre()
1811 if (p->col && ! (TERMP_NONOSPACE & p->flags)) in termp_sm_pre()
1812 p->flags &= ~TERMP_NOSPACE; in termp_sm_pre()
1820 p->flags |= TERMP_NOSPACE; in termp_ap_pre()
1822 p->flags |= TERMP_NOSPACE; in termp_ap_pre()
1836 if (n->tok == MDOC__A && in termp____post()
1837 (nn = roff_node_next(n)) != NULL && nn->tok == MDOC__A && in termp____post()
1838 ((nn = roff_node_next(nn)) == NULL || nn->tok != MDOC__A) && in termp____post()
1839 ((nn = roff_node_prev(n)) == NULL || nn->tok != MDOC__A)) in termp____post()
1844 if (n->parent == NULL || n->parent->tok != MDOC_Rs) in termp____post()
1847 p->flags |= TERMP_NOSPACE; in termp____post()
1850 p->flags |= TERMP_SENTENCE; in termp____post()
1867 if ((link = n->child) == NULL) in termp_lk_pre()
1871 punct = n->last; in termp_lk_pre()
1872 while (punct != link && punct->flags & NODE_DELIMC) in termp_lk_pre()
1873 punct = punct->prev; in termp_lk_pre()
1874 punct = punct->next; in termp_lk_pre()
1877 if ((descr = link->next) != NULL && descr != punct) { in termp_lk_pre()
1880 if (descr->flags & (NODE_DELIMC | NODE_DELIMO)) in termp_lk_pre()
1881 p->flags |= TERMP_NOSPACE; in termp_lk_pre()
1882 term_word(p, descr->string); in termp_lk_pre()
1883 descr = descr->next; in termp_lk_pre()
1886 p->flags |= TERMP_NOSPACE; in termp_lk_pre()
1892 term_word(p, link->string); in termp_lk_pre()
1897 p->flags |= TERMP_NOSPACE; in termp_lk_pre()
1898 term_word(p, punct->string); in termp_lk_pre()
1899 punct = punct->next; in termp_lk_pre()
1907 switch (n->type) { in termp_bk_pre()
1913 if (n->parent->args != NULL || n->prev->child == NULL) in termp_bk_pre()
1914 p->flags |= TERMP_PREKEEP; in termp_bk_pre()
1925 if (n->type == ROFFT_BODY) in termp_bk_post()
1926 p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); in termp_bk_post()
1936 if (n->parent != NULL && n->parent->tok == MDOC_Rs && in termp__t_post()
1937 n->parent->norm->Rs.quote_T) in termp__t_post()
1945 if (n->parent != NULL && n->parent->tok == MDOC_Rs && in termp__t_pre()
1946 n->parent->norm->Rs.quote_T) in termp__t_pre()