man_term.c (710eed94) | man_term.c (d1982c71) |
---|---|
1/* $OpenBSD: man_term.c,v 1.123 2015/03/15 16:51:34 schwarze Exp $ */ | 1/* $OpenBSD: man_term.c,v 1.124 2015/04/02 21:03:18 schwarze Exp $ */ |
2/* 3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> 4 * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> 5 * 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. 9 * | 2/* 3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> 4 * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> 5 * 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. 9 * |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 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. 17 */ 18#include <sys/types.h> 19 20#include <assert.h> 21#include <ctype.h> 22#include <limits.h> 23#include <stdio.h> 24#include <stdlib.h> 25#include <string.h> 26 | 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. 17 */ 18#include <sys/types.h> 19 20#include <assert.h> 21#include <ctype.h> 22#include <limits.h> 23#include <stdio.h> 24#include <stdlib.h> 25#include <string.h> 26 |
27#include "mandoc.h" | |
28#include "mandoc_aux.h" | 27#include "mandoc_aux.h" |
29#include "out.h" | 28#include "mandoc.h" 29#include "roff.h" |
30#include "man.h" | 30#include "man.h" |
31#include "out.h" |
|
31#include "term.h" 32#include "main.h" 33 34#define MAXMARGINS 64 /* maximum number of indented scopes */ 35 36struct mtermp { 37 int fl; 38#define MANT_LITERAL (1 << 0) --- 114 unchanged lines hidden (view full) --- 153 154 mt.lmargin[mt.lmargincur] = term_len(p, p->defindent); 155 mt.offset = term_len(p, p->defindent); 156 mt.pardist = 1; 157 158 if (p->synopsisonly) { 159 while (n != NULL) { 160 if (n->tok == MAN_SH && | 32#include "term.h" 33#include "main.h" 34 35#define MAXMARGINS 64 /* maximum number of indented scopes */ 36 37struct mtermp { 38 int fl; 39#define MANT_LITERAL (1 << 0) --- 114 unchanged lines hidden (view full) --- 154 155 mt.lmargin[mt.lmargincur] = term_len(p, p->defindent); 156 mt.offset = term_len(p, p->defindent); 157 mt.pardist = 1; 158 159 if (p->synopsisonly) { 160 while (n != NULL) { 161 if (n->tok == MAN_SH && |
161 n->child->child->type == MAN_TEXT && | 162 n->child->child->type == ROFFT_TEXT && |
162 !strcmp(n->child->child->string, "SYNOPSIS")) { 163 if (n->child->next->child != NULL) 164 print_man_nodelist(p, &mt, 165 n->child->next->child, meta); 166 term_newln(p); 167 break; 168 } 169 n = n->next; --- 20 unchanged lines hidden (view full) --- 190static void 191print_bvspace(struct termp *p, const struct man_node *n, int pardist) 192{ 193 int i; 194 195 term_newln(p); 196 197 if (n->body && n->body->child) | 163 !strcmp(n->child->child->string, "SYNOPSIS")) { 164 if (n->child->next->child != NULL) 165 print_man_nodelist(p, &mt, 166 n->child->next->child, meta); 167 term_newln(p); 168 break; 169 } 170 n = n->next; --- 20 unchanged lines hidden (view full) --- 191static void 192print_bvspace(struct termp *p, const struct man_node *n, int pardist) 193{ 194 int i; 195 196 term_newln(p); 197 198 if (n->body && n->body->child) |
198 if (MAN_TBL == n->body->child->type) | 199 if (n->body->child->type == ROFFT_TBL) |
199 return; 200 | 200 return; 201 |
201 if (MAN_ROOT == n->parent->type || MAN_RS != n->parent->tok) | 202 if (n->parent->type == ROFFT_ROOT || n->parent->tok != MAN_RS) |
202 if (NULL == n->prev) 203 return; 204 205 for (i = 0; i < pardist; i++) 206 term_vspace(p); 207} 208 209 --- 52 unchanged lines hidden (view full) --- 262{ 263 struct roffsu su; 264 265 n = n->child; 266 if (n == NULL) { 267 mt->pardist = 1; 268 return(0); 269 } | 203 if (NULL == n->prev) 204 return; 205 206 for (i = 0; i < pardist; i++) 207 term_vspace(p); 208} 209 210 --- 52 unchanged lines hidden (view full) --- 263{ 264 struct roffsu su; 265 266 n = n->child; 267 if (n == NULL) { 268 mt->pardist = 1; 269 return(0); 270 } |
270 assert(MAN_TEXT == n->type); | 271 assert(n->type == ROFFT_TEXT); |
271 if (a2roffsu(n->string, &su, SCALE_VS)) 272 mt->pardist = term_vspan(p, &su); 273 return(0); 274} 275 276static int 277pre_alternate(DECL_ARGS) 278{ --- 205 unchanged lines hidden (view full) --- 484static int 485pre_HP(DECL_ARGS) 486{ 487 struct roffsu su; 488 const struct man_node *nn; 489 int len; 490 491 switch (n->type) { | 272 if (a2roffsu(n->string, &su, SCALE_VS)) 273 mt->pardist = term_vspan(p, &su); 274 return(0); 275} 276 277static int 278pre_alternate(DECL_ARGS) 279{ --- 205 unchanged lines hidden (view full) --- 485static int 486pre_HP(DECL_ARGS) 487{ 488 struct roffsu su; 489 const struct man_node *nn; 490 int len; 491 492 switch (n->type) { |
492 case MAN_BLOCK: | 493 case ROFFT_BLOCK: |
493 print_bvspace(p, n, mt->pardist); 494 return(1); | 494 print_bvspace(p, n, mt->pardist); 495 return(1); |
495 case MAN_BODY: | 496 case ROFFT_BODY: |
496 break; 497 default: 498 return(0); 499 } 500 501 if ( ! (MANT_LITERAL & mt->fl)) { 502 p->flags |= TERMP_NOBREAK | TERMP_BRIND; 503 p->trailspace = 2; --- 17 unchanged lines hidden (view full) --- 521 return(1); 522} 523 524static void 525post_HP(DECL_ARGS) 526{ 527 528 switch (n->type) { | 497 break; 498 default: 499 return(0); 500 } 501 502 if ( ! (MANT_LITERAL & mt->fl)) { 503 p->flags |= TERMP_NOBREAK | TERMP_BRIND; 504 p->trailspace = 2; --- 17 unchanged lines hidden (view full) --- 522 return(1); 523} 524 525static void 526post_HP(DECL_ARGS) 527{ 528 529 switch (n->type) { |
529 case MAN_BODY: | 530 case ROFFT_BODY: |
530 term_newln(p); 531 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 532 p->trailspace = 0; 533 p->offset = mt->offset; 534 p->rmargin = p->maxrmargin; 535 break; 536 default: 537 break; 538 } 539} 540 541static int 542pre_PP(DECL_ARGS) 543{ 544 545 switch (n->type) { | 531 term_newln(p); 532 p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); 533 p->trailspace = 0; 534 p->offset = mt->offset; 535 p->rmargin = p->maxrmargin; 536 break; 537 default: 538 break; 539 } 540} 541 542static int 543pre_PP(DECL_ARGS) 544{ 545 546 switch (n->type) { |
546 case MAN_BLOCK: | 547 case ROFFT_BLOCK: |
547 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 548 print_bvspace(p, n, mt->pardist); 549 break; 550 default: 551 p->offset = mt->offset; 552 break; 553 } 554 | 548 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 549 print_bvspace(p, n, mt->pardist); 550 break; 551 default: 552 p->offset = mt->offset; 553 break; 554 } 555 |
555 return(MAN_HEAD != n->type); | 556 return(n->type != ROFFT_HEAD); |
556} 557 558static int 559pre_IP(DECL_ARGS) 560{ 561 struct roffsu su; 562 const struct man_node *nn; 563 int len, savelit; 564 565 switch (n->type) { | 557} 558 559static int 560pre_IP(DECL_ARGS) 561{ 562 struct roffsu su; 563 const struct man_node *nn; 564 int len, savelit; 565 566 switch (n->type) { |
566 case MAN_BODY: | 567 case ROFFT_BODY: |
567 p->flags |= TERMP_NOSPACE; 568 break; | 568 p->flags |= TERMP_NOSPACE; 569 break; |
569 case MAN_HEAD: | 570 case ROFFT_HEAD: |
570 p->flags |= TERMP_NOBREAK; 571 p->trailspace = 1; 572 break; | 571 p->flags |= TERMP_NOBREAK; 572 p->trailspace = 1; 573 break; |
573 case MAN_BLOCK: | 574 case ROFFT_BLOCK: |
574 print_bvspace(p, n, mt->pardist); 575 /* FALLTHROUGH */ 576 default: 577 return(1); 578 } 579 580 /* Calculate the offset from the optional second argument. */ 581 if ((nn = n->parent->head->child) != NULL && --- 4 unchanged lines hidden (view full) --- 586 len = -mt->offset; 587 else if (len > SHRT_MAX) 588 len = term_len(p, p->defindent); 589 mt->lmargin[mt->lmargincur] = len; 590 } else 591 len = mt->lmargin[mt->lmargincur]; 592 593 switch (n->type) { | 575 print_bvspace(p, n, mt->pardist); 576 /* FALLTHROUGH */ 577 default: 578 return(1); 579 } 580 581 /* Calculate the offset from the optional second argument. */ 582 if ((nn = n->parent->head->child) != NULL && --- 4 unchanged lines hidden (view full) --- 587 len = -mt->offset; 588 else if (len > SHRT_MAX) 589 len = term_len(p, p->defindent); 590 mt->lmargin[mt->lmargincur] = len; 591 } else 592 len = mt->lmargin[mt->lmargincur]; 593 594 switch (n->type) { |
594 case MAN_HEAD: | 595 case ROFFT_HEAD: |
595 p->offset = mt->offset; 596 p->rmargin = mt->offset + len; 597 598 savelit = MANT_LITERAL & mt->fl; 599 mt->fl &= ~MANT_LITERAL; 600 601 if (n->child) 602 print_man_node(p, mt, n->child, meta); 603 604 if (savelit) 605 mt->fl |= MANT_LITERAL; 606 607 return(0); | 596 p->offset = mt->offset; 597 p->rmargin = mt->offset + len; 598 599 savelit = MANT_LITERAL & mt->fl; 600 mt->fl &= ~MANT_LITERAL; 601 602 if (n->child) 603 print_man_node(p, mt, n->child, meta); 604 605 if (savelit) 606 mt->fl |= MANT_LITERAL; 607 608 return(0); |
608 case MAN_BODY: | 609 case ROFFT_BODY: |
609 p->offset = mt->offset + len; 610 p->rmargin = p->maxrmargin; 611 break; 612 default: 613 break; 614 } 615 616 return(1); 617} 618 619static void 620post_IP(DECL_ARGS) 621{ 622 623 switch (n->type) { | 610 p->offset = mt->offset + len; 611 p->rmargin = p->maxrmargin; 612 break; 613 default: 614 break; 615 } 616 617 return(1); 618} 619 620static void 621post_IP(DECL_ARGS) 622{ 623 624 switch (n->type) { |
624 case MAN_HEAD: | 625 case ROFFT_HEAD: |
625 term_flushln(p); 626 p->flags &= ~TERMP_NOBREAK; 627 p->trailspace = 0; 628 p->rmargin = p->maxrmargin; 629 break; | 626 term_flushln(p); 627 p->flags &= ~TERMP_NOBREAK; 628 p->trailspace = 0; 629 p->rmargin = p->maxrmargin; 630 break; |
630 case MAN_BODY: | 631 case ROFFT_BODY: |
631 term_newln(p); 632 p->offset = mt->offset; 633 break; 634 default: 635 break; 636 } 637} 638 639static int 640pre_TP(DECL_ARGS) 641{ 642 struct roffsu su; 643 struct man_node *nn; 644 int len, savelit; 645 646 switch (n->type) { | 632 term_newln(p); 633 p->offset = mt->offset; 634 break; 635 default: 636 break; 637 } 638} 639 640static int 641pre_TP(DECL_ARGS) 642{ 643 struct roffsu su; 644 struct man_node *nn; 645 int len, savelit; 646 647 switch (n->type) { |
647 case MAN_HEAD: | 648 case ROFFT_HEAD: |
648 p->flags |= TERMP_NOBREAK; 649 p->trailspace = 1; 650 break; | 649 p->flags |= TERMP_NOBREAK; 650 p->trailspace = 1; 651 break; |
651 case MAN_BODY: | 652 case ROFFT_BODY: |
652 p->flags |= TERMP_NOSPACE; 653 break; | 653 p->flags |= TERMP_NOSPACE; 654 break; |
654 case MAN_BLOCK: | 655 case ROFFT_BLOCK: |
655 print_bvspace(p, n, mt->pardist); 656 /* FALLTHROUGH */ 657 default: 658 return(1); 659 } 660 661 /* Calculate offset. */ 662 --- 5 unchanged lines hidden (view full) --- 668 len = -mt->offset; 669 else if (len > SHRT_MAX) 670 len = term_len(p, p->defindent); 671 mt->lmargin[mt->lmargincur] = len; 672 } else 673 len = mt->lmargin[mt->lmargincur]; 674 675 switch (n->type) { | 656 print_bvspace(p, n, mt->pardist); 657 /* FALLTHROUGH */ 658 default: 659 return(1); 660 } 661 662 /* Calculate offset. */ 663 --- 5 unchanged lines hidden (view full) --- 669 len = -mt->offset; 670 else if (len > SHRT_MAX) 671 len = term_len(p, p->defindent); 672 mt->lmargin[mt->lmargincur] = len; 673 } else 674 len = mt->lmargin[mt->lmargincur]; 675 676 switch (n->type) { |
676 case MAN_HEAD: | 677 case ROFFT_HEAD: |
677 p->offset = mt->offset; 678 p->rmargin = mt->offset + len; 679 680 savelit = MANT_LITERAL & mt->fl; 681 mt->fl &= ~MANT_LITERAL; 682 683 /* Don't print same-line elements. */ 684 nn = n->child; 685 while (NULL != nn && 0 == (MAN_LINE & nn->flags)) 686 nn = nn->next; 687 688 while (NULL != nn) { 689 print_man_node(p, mt, nn, meta); 690 nn = nn->next; 691 } 692 693 if (savelit) 694 mt->fl |= MANT_LITERAL; 695 return(0); | 678 p->offset = mt->offset; 679 p->rmargin = mt->offset + len; 680 681 savelit = MANT_LITERAL & mt->fl; 682 mt->fl &= ~MANT_LITERAL; 683 684 /* Don't print same-line elements. */ 685 nn = n->child; 686 while (NULL != nn && 0 == (MAN_LINE & nn->flags)) 687 nn = nn->next; 688 689 while (NULL != nn) { 690 print_man_node(p, mt, nn, meta); 691 nn = nn->next; 692 } 693 694 if (savelit) 695 mt->fl |= MANT_LITERAL; 696 return(0); |
696 case MAN_BODY: | 697 case ROFFT_BODY: |
697 p->offset = mt->offset + len; 698 p->rmargin = p->maxrmargin; 699 p->trailspace = 0; 700 p->flags &= ~TERMP_NOBREAK; 701 break; 702 default: 703 break; 704 } 705 706 return(1); 707} 708 709static void 710post_TP(DECL_ARGS) 711{ 712 713 switch (n->type) { | 698 p->offset = mt->offset + len; 699 p->rmargin = p->maxrmargin; 700 p->trailspace = 0; 701 p->flags &= ~TERMP_NOBREAK; 702 break; 703 default: 704 break; 705 } 706 707 return(1); 708} 709 710static void 711post_TP(DECL_ARGS) 712{ 713 714 switch (n->type) { |
714 case MAN_HEAD: | 715 case ROFFT_HEAD: |
715 term_flushln(p); 716 break; | 716 term_flushln(p); 717 break; |
717 case MAN_BODY: | 718 case ROFFT_BODY: |
718 term_newln(p); 719 p->offset = mt->offset; 720 break; 721 default: 722 break; 723 } 724} 725 726static int 727pre_SS(DECL_ARGS) 728{ 729 int i; 730 731 switch (n->type) { | 719 term_newln(p); 720 p->offset = mt->offset; 721 break; 722 default: 723 break; 724 } 725} 726 727static int 728pre_SS(DECL_ARGS) 729{ 730 int i; 731 732 switch (n->type) { |
732 case MAN_BLOCK: | 733 case ROFFT_BLOCK: |
733 mt->fl &= ~MANT_LITERAL; 734 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 735 mt->offset = term_len(p, p->defindent); 736 737 /* 738 * No vertical space before the first subsection 739 * and after an empty subsection. 740 */ 741 742 do { 743 n = n->prev; 744 } while (n != NULL && n->tok != MAN_MAX && 745 termacts[n->tok].flags & MAN_NOTEXT); 746 if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) 747 break; 748 749 for (i = 0; i < mt->pardist; i++) 750 term_vspace(p); 751 break; | 734 mt->fl &= ~MANT_LITERAL; 735 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 736 mt->offset = term_len(p, p->defindent); 737 738 /* 739 * No vertical space before the first subsection 740 * and after an empty subsection. 741 */ 742 743 do { 744 n = n->prev; 745 } while (n != NULL && n->tok != MAN_MAX && 746 termacts[n->tok].flags & MAN_NOTEXT); 747 if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) 748 break; 749 750 for (i = 0; i < mt->pardist; i++) 751 term_vspace(p); 752 break; |
752 case MAN_HEAD: | 753 case ROFFT_HEAD: |
753 term_fontrepl(p, TERMFONT_BOLD); 754 p->offset = term_len(p, 3); 755 break; | 754 term_fontrepl(p, TERMFONT_BOLD); 755 p->offset = term_len(p, 3); 756 break; |
756 case MAN_BODY: | 757 case ROFFT_BODY: |
757 p->offset = mt->offset; 758 break; 759 default: 760 break; 761 } 762 763 return(1); 764} 765 766static void 767post_SS(DECL_ARGS) 768{ 769 770 switch (n->type) { | 758 p->offset = mt->offset; 759 break; 760 default: 761 break; 762 } 763 764 return(1); 765} 766 767static void 768post_SS(DECL_ARGS) 769{ 770 771 switch (n->type) { |
771 case MAN_HEAD: | 772 case ROFFT_HEAD: |
772 term_newln(p); 773 break; | 773 term_newln(p); 774 break; |
774 case MAN_BODY: | 775 case ROFFT_BODY: |
775 term_newln(p); 776 break; 777 default: 778 break; 779 } 780} 781 782static int 783pre_SH(DECL_ARGS) 784{ 785 int i; 786 787 switch (n->type) { | 776 term_newln(p); 777 break; 778 default: 779 break; 780 } 781} 782 783static int 784pre_SH(DECL_ARGS) 785{ 786 int i; 787 788 switch (n->type) { |
788 case MAN_BLOCK: | 789 case ROFFT_BLOCK: |
789 mt->fl &= ~MANT_LITERAL; 790 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 791 mt->offset = term_len(p, p->defindent); 792 793 /* 794 * No vertical space before the first section 795 * and after an empty section. 796 */ 797 798 do { 799 n = n->prev; 800 } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT); 801 if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL)) 802 break; 803 804 for (i = 0; i < mt->pardist; i++) 805 term_vspace(p); 806 break; | 790 mt->fl &= ~MANT_LITERAL; 791 mt->lmargin[mt->lmargincur] = term_len(p, p->defindent); 792 mt->offset = term_len(p, p->defindent); 793 794 /* 795 * No vertical space before the first section 796 * and after an empty section. 797 */ 798 799 do { 800 n = n->prev; 801 } while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT); 802 if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL)) 803 break; 804 805 for (i = 0; i < mt->pardist; i++) 806 term_vspace(p); 807 break; |
807 case MAN_HEAD: | 808 case ROFFT_HEAD: |
808 term_fontrepl(p, TERMFONT_BOLD); 809 p->offset = 0; 810 break; | 809 term_fontrepl(p, TERMFONT_BOLD); 810 p->offset = 0; 811 break; |
811 case MAN_BODY: | 812 case ROFFT_BODY: |
812 p->offset = mt->offset; 813 break; 814 default: 815 break; 816 } 817 818 return(1); 819} 820 821static void 822post_SH(DECL_ARGS) 823{ 824 825 switch (n->type) { | 813 p->offset = mt->offset; 814 break; 815 default: 816 break; 817 } 818 819 return(1); 820} 821 822static void 823post_SH(DECL_ARGS) 824{ 825 826 switch (n->type) { |
826 case MAN_HEAD: | 827 case ROFFT_HEAD: |
827 term_newln(p); 828 break; | 828 term_newln(p); 829 break; |
829 case MAN_BODY: | 830 case ROFFT_BODY: |
830 term_newln(p); 831 break; 832 default: 833 break; 834 } 835} 836 837static int 838pre_RS(DECL_ARGS) 839{ 840 struct roffsu su; 841 842 switch (n->type) { | 831 term_newln(p); 832 break; 833 default: 834 break; 835 } 836} 837 838static int 839pre_RS(DECL_ARGS) 840{ 841 struct roffsu su; 842 843 switch (n->type) { |
843 case MAN_BLOCK: | 844 case ROFFT_BLOCK: |
844 term_newln(p); 845 return(1); | 845 term_newln(p); 846 return(1); |
846 case MAN_HEAD: | 847 case ROFFT_HEAD: |
847 return(0); 848 default: 849 break; 850 } 851 852 n = n->parent->head; 853 n->aux = SHRT_MAX + 1; 854 if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EN)) --- 14 unchanged lines hidden (view full) --- 869 return(1); 870} 871 872static void 873post_RS(DECL_ARGS) 874{ 875 876 switch (n->type) { | 848 return(0); 849 default: 850 break; 851 } 852 853 n = n->parent->head; 854 n->aux = SHRT_MAX + 1; 855 if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EN)) --- 14 unchanged lines hidden (view full) --- 870 return(1); 871} 872 873static void 874post_RS(DECL_ARGS) 875{ 876 877 switch (n->type) { |
877 case MAN_BLOCK: | 878 case ROFFT_BLOCK: |
878 return; | 879 return; |
879 case MAN_HEAD: | 880 case ROFFT_HEAD: |
880 return; 881 default: 882 term_newln(p); 883 break; 884 } 885 886 mt->offset -= n->parent->head->aux; 887 p->offset = mt->offset; 888 889 if (--mt->lmarginsz < MAXMARGINS) 890 mt->lmargincur = mt->lmarginsz; 891} 892 893static int 894pre_UR(DECL_ARGS) 895{ 896 | 881 return; 882 default: 883 term_newln(p); 884 break; 885 } 886 887 mt->offset -= n->parent->head->aux; 888 p->offset = mt->offset; 889 890 if (--mt->lmarginsz < MAXMARGINS) 891 mt->lmargincur = mt->lmarginsz; 892} 893 894static int 895pre_UR(DECL_ARGS) 896{ 897 |
897 return (MAN_HEAD != n->type); | 898 return (n->type != ROFFT_HEAD); |
898} 899 900static void 901post_UR(DECL_ARGS) 902{ 903 | 899} 900 901static void 902post_UR(DECL_ARGS) 903{ 904 |
904 if (MAN_BLOCK != n->type) | 905 if (n->type != ROFFT_BLOCK) |
905 return; 906 907 term_word(p, "<"); 908 p->flags |= TERMP_NOSPACE; 909 910 if (NULL != n->child->child) 911 print_man_node(p, mt, n->child->child, meta); 912 913 p->flags |= TERMP_NOSPACE; 914 term_word(p, ">"); 915} 916 917static void 918print_man_node(DECL_ARGS) 919{ 920 size_t rm, rmax; 921 int c; 922 923 switch (n->type) { | 906 return; 907 908 term_word(p, "<"); 909 p->flags |= TERMP_NOSPACE; 910 911 if (NULL != n->child->child) 912 print_man_node(p, mt, n->child->child, meta); 913 914 p->flags |= TERMP_NOSPACE; 915 term_word(p, ">"); 916} 917 918static void 919print_man_node(DECL_ARGS) 920{ 921 size_t rm, rmax; 922 int c; 923 924 switch (n->type) { |
924 case MAN_TEXT: | 925 case ROFFT_TEXT: |
925 /* 926 * If we have a blank line, output a vertical space. 927 * If we have a space as the first character, break 928 * before printing the line's data. 929 */ 930 if ('\0' == *n->string) { 931 term_vspace(p); 932 return; 933 } else if (' ' == *n->string && MAN_LINE & n->flags) 934 term_newln(p); 935 936 term_word(p, n->string); 937 goto out; 938 | 926 /* 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. 930 */ 931 if ('\0' == *n->string) { 932 term_vspace(p); 933 return; 934 } else if (' ' == *n->string && MAN_LINE & n->flags) 935 term_newln(p); 936 937 term_word(p, n->string); 938 goto out; 939 |
939 case MAN_EQN: | 940 case ROFFT_EQN: |
940 if ( ! (n->flags & MAN_LINE)) 941 p->flags |= TERMP_NOSPACE; 942 term_eqn(p, n->eqn); 943 if (n->next != NULL && ! (n->next->flags & MAN_LINE)) 944 p->flags |= TERMP_NOSPACE; 945 return; | 941 if ( ! (n->flags & MAN_LINE)) 942 p->flags |= TERMP_NOSPACE; 943 term_eqn(p, n->eqn); 944 if (n->next != NULL && ! (n->next->flags & MAN_LINE)) 945 p->flags |= TERMP_NOSPACE; 946 return; |
946 case MAN_TBL: | 947 case ROFFT_TBL: |
947 if (p->tbl.cols == NULL) 948 term_vspace(p); 949 term_tbl(p, n->span); 950 return; 951 default: 952 break; 953 } 954 --- 197 unchanged lines hidden --- | 948 if (p->tbl.cols == NULL) 949 term_vspace(p); 950 term_tbl(p, n->span); 951 return; 952 default: 953 break; 954 } 955 --- 197 unchanged lines hidden --- |