Print this page
9718 update mandoc to 1.14.4

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mandoc/mdoc_man.c
          +++ new/usr/src/cmd/mandoc/mdoc_man.c
   1      -/*      $Id: mdoc_man.c,v 1.122 2017/06/14 22:51:25 schwarze Exp $ */
        1 +/*      $Id: mdoc_man.c,v 1.126 2018/04/11 17:11:13 schwarze Exp $ */
   2    2  /*
   3      - * Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
        3 + * Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org>
   4    4   *
   5    5   * Permission to use, copy, modify, and distribute this software for any
   6    6   * purpose with or without fee is hereby granted, provided that the above
   7    7   * copyright notice and this permission notice appear in all copies.
   8    8   *
   9    9   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10   10   * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11   11   * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12   12   * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13   13   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
↓ open down ↓ 181 lines elided ↑ open up ↑
 195  195          { cond_body, pre_aq, post_aq, NULL, NULL }, /* Aq */
 196  196          { NULL, NULL, NULL, NULL, NULL }, /* At */
 197  197          { NULL, NULL, NULL, NULL, NULL }, /* Bc */
 198  198          { NULL, pre_bf, post_bf, NULL, NULL }, /* Bf */
 199  199          { cond_body, pre_enc, post_enc, "[", "]" }, /* Bo */
 200  200          { cond_body, pre_enc, post_enc, "[", "]" }, /* Bq */
 201  201          { NULL, pre_bk, post_bk, NULL, NULL }, /* Bsx */
 202  202          { NULL, pre_bk, post_bk, NULL, NULL }, /* Bx */
 203  203          { NULL, pre_skip, NULL, NULL, NULL }, /* Db */
 204  204          { NULL, NULL, NULL, NULL, NULL }, /* Dc */
 205      -        { cond_body, pre_enc, post_enc, "\\(Lq", "\\(Rq" }, /* Do */
 206      -        { cond_body, pre_enc, post_enc, "\\(Lq", "\\(Rq" }, /* Dq */
      205 +        { cond_body, pre_enc, post_enc, "\\(lq", "\\(rq" }, /* Do */
      206 +        { cond_body, pre_enc, post_enc, "\\(lq", "\\(rq" }, /* Dq */
 207  207          { NULL, NULL, NULL, NULL, NULL }, /* Ec */
 208  208          { NULL, NULL, NULL, NULL, NULL }, /* Ef */
 209  209          { NULL, pre_em, post_font, NULL, NULL }, /* Em */
 210  210          { cond_body, pre_eo, post_eo, NULL, NULL }, /* Eo */
 211  211          { NULL, pre_bk, post_bk, NULL, NULL }, /* Fx */
 212  212          { NULL, pre_sy, post_font, NULL, NULL }, /* Ms */
 213  213          { NULL, pre_no, NULL, NULL, NULL }, /* No */
 214  214          { NULL, pre_ns, NULL, NULL, NULL }, /* Ns */
 215  215          { NULL, pre_bk, post_bk, NULL, NULL }, /* Nx */
 216  216          { NULL, pre_bk, post_bk, NULL, NULL }, /* Ox */
↓ open down ↓ 386 lines elided ↑ open up ↑
 603  603           */
 604  604          fputs(mparse_getkeep(man_mparse(man)), stdout);
 605  605          fflush(stdout);
 606  606  }
 607  607  
 608  608  void
 609  609  man_mdoc(void *arg, const struct roff_man *mdoc)
 610  610  {
 611  611          struct roff_node *n;
 612  612  
      613 +        printf(".\\\" Automatically generated from an mdoc input file."
      614 +            "  Do not edit.\n");
      615 +        for (n = mdoc->first->child; n != NULL; n = n->next) {
      616 +                if (n->type != ROFFT_COMMENT)
      617 +                        break;
      618 +                printf(".\\\"%s\n", n->string);
      619 +        }
      620 +
 613  621          printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
 614  622              mdoc->meta.title,
 615  623              (mdoc->meta.msec == NULL ? "" : mdoc->meta.msec),
 616  624              mdoc->meta.date, mdoc->meta.os, mdoc->meta.vol);
 617  625  
 618  626          /* Disable hyphenation and if nroff, disable justification. */
 619  627          printf(".nh\n.if n .ad l");
 620  628  
 621  629          outflags = MMAN_nl | MMAN_Sm;
 622  630          if (0 == fontqueue.size) {
 623  631                  fontqueue.size = 8;
 624  632                  fontqueue.head = fontqueue.tail = mandoc_malloc(8);
 625  633                  *fontqueue.tail = 'R';
 626  634          }
 627      -        for (n = mdoc->first->child; n != NULL; n = n->next)
      635 +        for (; n != NULL; n = n->next)
 628  636                  print_node(&mdoc->meta, n);
 629  637          putchar('\n');
 630  638  }
 631  639  
 632  640  static void
 633  641  print_node(DECL_ARGS)
 634  642  {
 635  643          const struct manact     *act;
 636  644          struct roff_node        *sub;
 637  645          int                      cond, do_sub;
↓ open down ↓ 763 lines elided ↑ open up ↑
1401 1409                  outflags &= ~MMAN_br;
1402 1410                  switch (bln->norm->Bl.type) {
1403 1411                  case LIST_item:
1404 1412                          return 0;
1405 1413                  case LIST_inset:
1406 1414                  case LIST_diag:
1407 1415                  case LIST_ohang:
1408 1416                          if (bln->norm->Bl.type == LIST_diag)
1409 1417                                  print_line(".B \"", 0);
1410 1418                          else
1411      -                                print_line(".R \"", 0);
     1419 +                                print_line(".BR \\& \"", 0);
1412 1420                          outflags &= ~MMAN_spc;
1413 1421                          return 1;
1414 1422                  case LIST_bullet:
1415 1423                  case LIST_dash:
1416 1424                  case LIST_hyphen:
1417 1425                          print_width(&bln->norm->Bl, NULL);
1418 1426                          TPremain = 0;
1419 1427                          outflags |= MMAN_nl;
1420 1428                          font_push('B');
1421 1429                          if (LIST_bullet == bln->norm->Bl.type)
↓ open down ↓ 118 lines elided ↑ open up ↑
1540 1548  {
1541 1549  
1542 1550          if (SEC_LIBRARY == n->sec)
1543 1551                  outflags |= MMAN_br;
1544 1552  }
1545 1553  
1546 1554  static int
1547 1555  pre_lk(DECL_ARGS)
1548 1556  {
1549 1557          const struct roff_node *link, *descr, *punct;
1550      -        int display;
1551 1558  
1552 1559          if ((link = n->child) == NULL)
1553 1560                  return 0;
1554 1561  
1555 1562          /* Find beginning of trailing punctuation. */
1556 1563          punct = n->last;
1557 1564          while (punct != link && punct->flags & NODE_DELIMC)
1558 1565                  punct = punct->prev;
1559 1566          punct = punct->next;
1560 1567  
↓ open down ↓ 2 lines elided ↑ open up ↑
1563 1570                  font_push('I');
1564 1571                  while (descr != punct) {
1565 1572                          print_word(descr->string);
1566 1573                          descr = descr->next;
1567 1574                  }
1568 1575                  font_pop();
1569 1576                  print_word(":");
1570 1577          }
1571 1578  
1572 1579          /* Link target. */
1573      -        display = man_strlen(link->string) >= 26;
1574      -        if (display) {
1575      -                print_line(".RS", MMAN_Bk_susp);
1576      -                print_word("6n");
1577      -                outflags |= MMAN_nl;
1578      -        }
1579 1580          font_push('B');
1580 1581          print_word(link->string);
1581 1582          font_pop();
1582 1583  
1583 1584          /* Trailing punctuation. */
1584 1585          while (punct != NULL) {
1585 1586                  print_word(punct->string);
1586 1587                  punct = punct->next;
1587 1588          }
1588      -        if (display)
1589      -                print_line(".RE", MMAN_nl);
1590 1589          return 0;
1591 1590  }
1592 1591  
1593 1592  static void
1594 1593  pre_onearg(DECL_ARGS)
1595 1594  {
1596 1595          outflags |= MMAN_nl;
1597 1596          print_word(".");
1598 1597          outflags &= ~MMAN_spc;
1599 1598          print_word(roff_name[n->tok]);
↓ open down ↓ 205 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX