Print this page
9718 update mandoc to 1.14.4

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mandoc/mdoc_term.c
          +++ new/usr/src/cmd/mandoc/mdoc_term.c
   1      -/*      $Id: mdoc_term.c,v 1.364 2017/06/14 17:51:15 schwarze Exp $ */
        1 +/*      $Id: mdoc_term.c,v 1.367 2018/04/11 17:11:13 schwarze Exp $ */
   2    2  /*
   3    3   * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
   4      - * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
        4 + * Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
   5    5   * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
   6    6   *
   7    7   * Permission to use, copy, modify, and distribute this software for any
   8    8   * purpose with or without fee is hereby granted, provided that the above
   9    9   * copyright notice and this permission notice appear in all copies.
  10   10   *
  11   11   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  12   12   * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13   13   * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  14   14   * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
↓ open down ↓ 261 lines elided ↑ open up ↑
 276  276                                  break;
 277  277                          }
 278  278                          n = n->next;
 279  279                  }
 280  280          } else {
 281  281                  save_defindent = p->defindent;
 282  282                  if (p->defindent == 0)
 283  283                          p->defindent = 5;
 284  284                  term_begin(p, print_mdoc_head, print_mdoc_foot,
 285  285                      &mdoc->meta);
 286      -                while (n != NULL && n->flags & NODE_NOPRT)
      286 +                while (n != NULL &&
      287 +                    (n->type == ROFFT_COMMENT ||
      288 +                     n->flags & NODE_NOPRT))
 287  289                          n = n->next;
 288  290                  if (n != NULL) {
 289  291                          if (n->tok != MDOC_Sh)
 290  292                                  term_vspace(p);
 291  293                          print_mdoc_nodelist(p, NULL, &mdoc->meta, n);
 292  294                  }
 293  295                  term_end(p);
 294  296                  p->defindent = save_defindent;
 295  297          }
 296  298  }
↓ open down ↓ 8 lines elided ↑ open up ↑
 305  307          }
 306  308  }
 307  309  
 308  310  static void
 309  311  print_mdoc_node(DECL_ARGS)
 310  312  {
 311  313          int              chld;
 312  314          struct termpair  npair;
 313  315          size_t           offset, rmargin;
 314  316  
 315      -        if (n->flags & NODE_NOPRT)
      317 +        if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT)
 316  318                  return;
 317  319  
 318  320          chld = 1;
 319  321          offset = p->tcol->offset;
 320  322          rmargin = p->tcol->rmargin;
 321  323          n->flags &= ~NODE_ENDED;
 322  324          n->prev_font = p->fonti;
 323  325  
 324  326          memset(&npair, 0, sizeof(struct termpair));
 325  327          npair.ppair = pair;
↓ open down ↓ 234 lines elided ↑ open up ↑
 560  562          term_newln(p);
 561  563  
 562  564          if (MDOC_Bd == bl->tok && bl->norm->Bd.comp)
 563  565                  return;
 564  566          if (MDOC_Bl == bl->tok && bl->norm->Bl.comp)
 565  567                  return;
 566  568  
 567  569          /* Do not vspace directly after Ss/Sh. */
 568  570  
 569  571          nn = n;
 570      -        while (nn->prev != NULL && nn->prev->flags & NODE_NOPRT)
      572 +        while (nn->prev != NULL &&
      573 +            (nn->prev->type == ROFFT_COMMENT ||
      574 +             nn->prev->flags & NODE_NOPRT))
 571  575                  nn = nn->prev;
 572  576          while (nn->prev == NULL) {
 573  577                  do {
 574  578                          nn = nn->parent;
 575  579                          if (nn->type == ROFFT_ROOT)
 576  580                                  return;
 577  581                  } while (nn->type != ROFFT_BLOCK);
 578  582                  if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss)
 579  583                          return;
 580  584                  if (nn->tok == MDOC_It &&
↓ open down ↓ 962 lines elided ↑ open up ↑
1543 1547  
1544 1548  static int
1545 1549  termp_ss_pre(DECL_ARGS)
1546 1550  {
1547 1551          struct roff_node *nn;
1548 1552  
1549 1553          switch (n->type) {
1550 1554          case ROFFT_BLOCK:
1551 1555                  term_newln(p);
1552 1556                  for (nn = n->prev; nn != NULL; nn = nn->prev)
1553      -                        if ((nn->flags & NODE_NOPRT) == 0)
     1557 +                        if (nn->type != ROFFT_COMMENT &&
     1558 +                            (nn->flags & NODE_NOPRT) == 0)
1554 1559                                  break;
1555 1560                  if (nn != NULL)
1556 1561                          term_vspace(p);
1557 1562                  break;
1558 1563          case ROFFT_HEAD:
1559 1564                  term_fontpush(p, TERMFONT_BOLD);
1560 1565                  p->tcol->offset = term_len(p, (p->defindent+1)/2);
1561 1566                  break;
1562 1567          case ROFFT_BODY:
1563 1568                  p->tcol->offset = term_len(p, p->defindent);
↓ open down ↓ 93 lines elided ↑ open up ↑
1657 1662          case MDOC_Oo:
1658 1663          case MDOC_Op:
1659 1664          case MDOC_Bo:
1660 1665          case MDOC_Bq:
1661 1666                  term_word(p, "[");
1662 1667                  break;
1663 1668          case MDOC__T:
1664 1669                  /* FALLTHROUGH */
1665 1670          case MDOC_Do:
1666 1671          case MDOC_Dq:
1667      -                term_word(p, "\\(Lq");
     1672 +                term_word(p, "\\(lq");
1668 1673                  break;
1669 1674          case MDOC_En:
1670 1675                  if (NULL == n->norm->Es ||
1671 1676                      NULL == n->norm->Es->child)
1672 1677                          return 1;
1673 1678                  term_word(p, n->norm->Es->child->string);
1674 1679                  break;
1675 1680          case MDOC_Po:
1676 1681          case MDOC_Pq:
1677 1682                  term_word(p, "(");
↓ open down ↓ 37 lines elided ↑ open up ↑
1715 1720          case MDOC_Oo:
1716 1721          case MDOC_Op:
1717 1722          case MDOC_Bo:
1718 1723          case MDOC_Bq:
1719 1724                  term_word(p, "]");
1720 1725                  break;
1721 1726          case MDOC__T:
1722 1727                  /* FALLTHROUGH */
1723 1728          case MDOC_Do:
1724 1729          case MDOC_Dq:
1725      -                term_word(p, "\\(Rq");
     1730 +                term_word(p, "\\(rq");
1726 1731                  break;
1727 1732          case MDOC_En:
1728 1733                  if (n->norm->Es == NULL ||
1729 1734                      n->norm->Es->child == NULL ||
1730 1735                      n->norm->Es->child->next == NULL)
1731 1736                          p->flags &= ~TERMP_NOSPACE;
1732 1737                  else
1733 1738                          term_word(p, n->norm->Es->child->next->string);
1734 1739                  break;
1735 1740          case MDOC_Po:
↓ open down ↓ 197 lines elided ↑ open up ↑
1933 1938  
1934 1939          termp_tag_pre(p, pair, meta, n);
1935 1940          term_fontpush(p, TERMFONT_NONE);
1936 1941          return 1;
1937 1942  }
1938 1943  
1939 1944  static int
1940 1945  termp_lk_pre(DECL_ARGS)
1941 1946  {
1942 1947          const struct roff_node *link, *descr, *punct;
1943      -        int display;
1944 1948  
1945 1949          if ((link = n->child) == NULL)
1946 1950                  return 0;
1947 1951  
1948 1952          /* Find beginning of trailing punctuation. */
1949 1953          punct = n->last;
1950 1954          while (punct != link && punct->flags & NODE_DELIMC)
1951 1955                  punct = punct->prev;
1952 1956          punct = punct->next;
1953 1957  
↓ open down ↓ 5 lines elided ↑ open up ↑
1959 1963                                  p->flags |= TERMP_NOSPACE;
1960 1964                          term_word(p, descr->string);
1961 1965                          descr = descr->next;
1962 1966                  }
1963 1967                  term_fontpop(p);
1964 1968                  p->flags |= TERMP_NOSPACE;
1965 1969                  term_word(p, ":");
1966 1970          }
1967 1971  
1968 1972          /* Link target. */
1969      -        display = term_strlen(p, link->string) >= 26;
1970      -        if (display) {
1971      -                term_newln(p);
1972      -                p->tcol->offset += term_len(p, p->defindent + 1);
1973      -        }
1974 1973          term_fontpush(p, TERMFONT_BOLD);
1975 1974          term_word(p, link->string);
1976 1975          term_fontpop(p);
1977 1976  
1978 1977          /* Trailing punctuation. */
1979 1978          while (punct != NULL) {
1980 1979                  p->flags |= TERMP_NOSPACE;
1981 1980                  term_word(p, punct->string);
1982 1981                  punct = punct->next;
1983 1982          }
1984      -        if (display)
1985      -                term_newln(p);
1986 1983          return 0;
1987 1984  }
1988 1985  
1989 1986  static int
1990 1987  termp_bk_pre(DECL_ARGS)
1991 1988  {
1992 1989  
1993 1990          switch (n->type) {
1994 1991          case ROFFT_BLOCK:
1995 1992                  break;
↓ open down ↓ 108 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX