[BACK]Return to mdoc_man.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/mdoc_man.c between version 1.90 and 1.94

version 1.90, 2015/04/02 22:48:17 version 1.94, 2015/10/06 18:32:19
Line 30 
Line 30 
 #include "out.h"  #include "out.h"
 #include "main.h"  #include "main.h"
   
 #define DECL_ARGS const struct mdoc_meta *meta, struct roff_node *n  #define DECL_ARGS const struct roff_meta *meta, struct roff_node *n
   
 struct  manact {  struct  manact {
         int             (*cond)(DECL_ARGS); /* DON'T run actions */          int             (*cond)(DECL_ARGS); /* DON'T run actions */
Line 532  print_count(int *count)
Line 532  print_count(int *count)
 }  }
   
 void  void
 man_man(void *arg, const struct man *man)  man_man(void *arg, const struct roff_man *man)
 {  {
   
         /*          /*
Line 545  man_man(void *arg, const struct man *man)
Line 545  man_man(void *arg, const struct man *man)
 }  }
   
 void  void
 man_mdoc(void *arg, const struct mdoc *mdoc)  man_mdoc(void *arg, const struct roff_man *mdoc)
 {  {
         const struct mdoc_meta *meta;  
         struct roff_node *n;          struct roff_node *n;
   
         meta = mdoc_meta(mdoc);  
         n = mdoc_node(mdoc)->child;  
   
         printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",          printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
             meta->title,              mdoc->meta.title,
             (meta->msec == NULL ? "" : meta->msec),              (mdoc->meta.msec == NULL ? "" : mdoc->meta.msec),
             meta->date, meta->os, meta->vol);              mdoc->meta.date, mdoc->meta.os, mdoc->meta.vol);
   
         /* Disable hyphenation and if nroff, disable justification. */          /* Disable hyphenation and if nroff, disable justification. */
         printf(".nh\n.if n .ad l");          printf(".nh\n.if n .ad l");
Line 567  man_mdoc(void *arg, const struct mdoc *mdoc)
Line 563  man_mdoc(void *arg, const struct mdoc *mdoc)
                 fontqueue.head = fontqueue.tail = mandoc_malloc(8);                  fontqueue.head = fontqueue.tail = mandoc_malloc(8);
                 *fontqueue.tail = 'R';                  *fontqueue.tail = 'R';
         }          }
         while (n != NULL) {          for (n = mdoc->first->child; n != NULL; n = n->next)
                 print_node(meta, n);                  print_node(&mdoc->meta, n);
                 n = n->next;  
         }  
         putchar('\n');          putchar('\n');
 }  }
   
Line 649  static int
Line 643  static int
 cond_head(DECL_ARGS)  cond_head(DECL_ARGS)
 {  {
   
         return(n->type == ROFFT_HEAD);          return n->type == ROFFT_HEAD;
 }  }
   
 static int  static int
 cond_body(DECL_ARGS)  cond_body(DECL_ARGS)
 {  {
   
         return(n->type == ROFFT_BODY);          return n->type == ROFFT_BODY;
 }  }
   
 static int  static int
Line 666  pre_enc(DECL_ARGS)
Line 660  pre_enc(DECL_ARGS)
   
         prefix = manacts[n->tok].prefix;          prefix = manacts[n->tok].prefix;
         if (NULL == prefix)          if (NULL == prefix)
                 return(1);                  return 1;
         print_word(prefix);          print_word(prefix);
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         return(1);          return 1;
 }  }
   
 static void  static void
Line 717  pre_ex(DECL_ARGS)
Line 711  pre_ex(DECL_ARGS)
   
         print_word("on success, and\\~>0 if an error occurs.");          print_word("on success, and\\~>0 if an error occurs.");
         outflags |= MMAN_nl;          outflags |= MMAN_nl;
         return(0);          return 0;
 }  }
   
 static void  static void
Line 755  pre__t(DECL_ARGS)
Line 749  pre__t(DECL_ARGS)
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
         } else          } else
                 font_push('I');                  font_push('I');
         return(1);          return 1;
 }  }
   
 static void  static void
Line 786  pre_sect(DECL_ARGS)
Line 780  pre_sect(DECL_ARGS)
                 putchar('\"');                  putchar('\"');
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
         }          }
         return(1);          return 1;
 }  }
   
 /*  /*
Line 854  pre_an(DECL_ARGS)
Line 848  pre_an(DECL_ARGS)
         case AUTH_split:          case AUTH_split:
                 outflags &= ~MMAN_An_nosplit;                  outflags &= ~MMAN_An_nosplit;
                 outflags |= MMAN_An_split;                  outflags |= MMAN_An_split;
                 return(0);                  return 0;
         case AUTH_nosplit:          case AUTH_nosplit:
                 outflags &= ~MMAN_An_split;                  outflags &= ~MMAN_An_split;
                 outflags |= MMAN_An_nosplit;                  outflags |= MMAN_An_nosplit;
                 return(0);                  return 0;
         default:          default:
                 if (MMAN_An_split & outflags)                  if (MMAN_An_split & outflags)
                         outflags |= MMAN_br;                          outflags |= MMAN_br;
                 else if (SEC_AUTHORS == n->sec &&                  else if (SEC_AUTHORS == n->sec &&
                     ! (MMAN_An_nosplit & outflags))                      ! (MMAN_An_nosplit & outflags))
                         outflags |= MMAN_An_split;                          outflags |= MMAN_An_split;
                 return(1);                  return 1;
         }          }
 }  }
   
Line 876  pre_ap(DECL_ARGS)
Line 870  pre_ap(DECL_ARGS)
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word("'");          print_word("'");
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         return(0);          return 0;
 }  }
   
 static int  static int
Line 886  pre_aq(DECL_ARGS)
Line 880  pre_aq(DECL_ARGS)
         print_word(n->nchild == 1 &&          print_word(n->nchild == 1 &&
             n->child->tok == MDOC_Mt ?  "<" : "\\(la");              n->child->tok == MDOC_Mt ?  "<" : "\\(la");
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         return(1);          return 1;
 }  }
   
 static void  static void
Line 910  pre_bd(DECL_ARGS)
Line 904  pre_bd(DECL_ARGS)
         if (0 == n->norm->Bd.comp && NULL != n->parent->prev)          if (0 == n->norm->Bd.comp && NULL != n->parent->prev)
                 outflags |= MMAN_sp;                  outflags |= MMAN_sp;
         print_offs(n->norm->Bd.offs, 1);          print_offs(n->norm->Bd.offs, 1);
         return(1);          return 1;
 }  }
   
 static void  static void
Line 934  pre_bf(DECL_ARGS)
Line 928  pre_bf(DECL_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case ROFFT_BLOCK:          case ROFFT_BLOCK:
                 return(1);                  return 1;
         case ROFFT_BODY:          case ROFFT_BODY:
                 break;                  break;
         default:          default:
                 return(0);                  return 0;
         }          }
         switch (n->norm->Bf.font) {          switch (n->norm->Bf.font) {
         case FONT_Em:          case FONT_Em:
Line 951  pre_bf(DECL_ARGS)
Line 945  pre_bf(DECL_ARGS)
                 font_push('R');                  font_push('R');
                 break;                  break;
         }          }
         return(1);          return 1;
 }  }
   
 static void  static void
Line 968  pre_bk(DECL_ARGS)
Line 962  pre_bk(DECL_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case ROFFT_BLOCK:          case ROFFT_BLOCK:
                 return(1);                  return 1;
         case ROFFT_BODY:          case ROFFT_BODY:
                 outflags |= MMAN_Bk;                  outflags |= MMAN_Bk;
                 return(1);                  return 1;
         default:          default:
                 return(0);                  return 0;
         }          }
 }  }
   
Line 1003  pre_bl(DECL_ARGS)
Line 997  pre_bl(DECL_ARGS)
         switch (n->norm->Bl.type) {          switch (n->norm->Bl.type) {
         case LIST_enum:          case LIST_enum:
                 n->norm->Bl.count = 0;                  n->norm->Bl.count = 0;
                 return(1);                  return 1;
         case LIST_column:          case LIST_column:
                 break;                  break;
         default:          default:
                 return(1);                  return 1;
         }          }
   
         if (n->nchild) {          if (n->nchild) {
Line 1017  pre_bl(DECL_ARGS)
Line 1011  pre_bl(DECL_ARGS)
                 print_word(".");                  print_word(".");
         }          }
         outflags |= MMAN_nl;          outflags |= MMAN_nl;
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1057  pre_br(DECL_ARGS)
Line 1051  pre_br(DECL_ARGS)
 {  {
   
         outflags |= MMAN_br;          outflags |= MMAN_br;
         return(0);          return 0;
 }  }
   
 static int  static int
Line 1072  pre_bx(DECL_ARGS)
Line 1066  pre_bx(DECL_ARGS)
         }          }
         print_word("BSD");          print_word("BSD");
         if (NULL == n)          if (NULL == n)
                 return(0);                  return 0;
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word("-");          print_word("-");
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word(n->string);          print_word(n->string);
         return(0);          return 0;
 }  }
   
 static int  static int
Line 1085  pre_dl(DECL_ARGS)
Line 1079  pre_dl(DECL_ARGS)
 {  {
   
         print_offs("6n", 0);          print_offs("6n", 0);
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1104  pre_em(DECL_ARGS)
Line 1098  pre_em(DECL_ARGS)
 {  {
   
         font_push('I');          font_push('I');
         return(1);          return 1;
 }  }
   
 static int  static int
Line 1113  pre_en(DECL_ARGS)
Line 1107  pre_en(DECL_ARGS)
   
         if (NULL == n->norm->Es ||          if (NULL == n->norm->Es ||
             NULL == n->norm->Es->child)              NULL == n->norm->Es->child)
                 return(1);                  return 1;
   
         print_word(n->norm->Es->child->string);          print_word(n->norm->Es->child->string);
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1147  pre_eo(DECL_ARGS)
Line 1141  pre_eo(DECL_ARGS)
             n->parent->head->child != NULL && (n->child != NULL ||              n->parent->head->child != NULL && (n->child != NULL ||
             (n->parent->tail != NULL && n->parent->tail->child != NULL)))              (n->parent->tail != NULL && n->parent->tail->child != NULL)))
                 outflags &= ~(MMAN_spc | MMAN_nl);                  outflags &= ~(MMAN_spc | MMAN_nl);
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1190  pre_fa(DECL_ARGS)
Line 1184  pre_fa(DECL_ARGS)
                 if (NULL != (n = n->next))                  if (NULL != (n = n->next))
                         print_word(",");                          print_word(",");
         }          }
         return(0);          return 0;
 }  }
   
 static void  static void
Line 1207  pre_fd(DECL_ARGS)
Line 1201  pre_fd(DECL_ARGS)
   
         pre_syn(n);          pre_syn(n);
         font_push('B');          font_push('B');
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1226  pre_fl(DECL_ARGS)
Line 1220  pre_fl(DECL_ARGS)
         print_word("\\-");          print_word("\\-");
         if (n->nchild)          if (n->nchild)
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1249  pre_fn(DECL_ARGS)
Line 1243  pre_fn(DECL_ARGS)
   
         n = n->child;          n = n->child;
         if (NULL == n)          if (NULL == n)
                 return(0);                  return 0;
   
         if (MDOC_SYNPRETTY & n->flags)          if (MDOC_SYNPRETTY & n->flags)
                 print_block(".HP 4n", MMAN_nl);                  print_block(".HP 4n", MMAN_nl);
Line 1264  pre_fn(DECL_ARGS)
Line 1258  pre_fn(DECL_ARGS)
         n = n->next;          n = n->next;
         if (NULL != n)          if (NULL != n)
                 pre_fa(meta, n);                  pre_fa(meta, n);
         return(0);          return 0;
 }  }
   
 static void  static void
Line 1288  pre_fo(DECL_ARGS)
Line 1282  pre_fo(DECL_ARGS)
                 break;                  break;
         case ROFFT_HEAD:          case ROFFT_HEAD:
                 if (n->child == NULL)                  if (n->child == NULL)
                         return(0);                          return 0;
                 if (MDOC_SYNPRETTY & n->flags)                  if (MDOC_SYNPRETTY & n->flags)
                         print_block(".HP 4n", MMAN_nl);                          print_block(".HP 4n", MMAN_nl);
                 font_push('B');                  font_push('B');
Line 1301  pre_fo(DECL_ARGS)
Line 1295  pre_fo(DECL_ARGS)
         default:          default:
                 break;                  break;
         }          }
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1327  pre_ft(DECL_ARGS)
Line 1321  pre_ft(DECL_ARGS)
   
         pre_syn(n);          pre_syn(n);
         font_push('I');          font_push('I');
         return(1);          return 1;
 }  }
   
 static int  static int
Line 1344  pre_in(DECL_ARGS)
Line 1338  pre_in(DECL_ARGS)
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
                 font_push('I');                  font_push('I');
         }          }
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1379  pre_it(DECL_ARGS)
Line 1373  pre_it(DECL_ARGS)
                 outflags &= ~MMAN_br;                  outflags &= ~MMAN_br;
                 switch (bln->norm->Bl.type) {                  switch (bln->norm->Bl.type) {
                 case LIST_item:                  case LIST_item:
                         return(0);                          return 0;
                 case LIST_inset:                  case LIST_inset:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case LIST_diag:                  case LIST_diag:
Line 1390  pre_it(DECL_ARGS)
Line 1384  pre_it(DECL_ARGS)
                         else                          else
                                 print_line(".R \"", 0);                                  print_line(".R \"", 0);
                         outflags &= ~MMAN_spc;                          outflags &= ~MMAN_spc;
                         return(1);                          return 1;
                 case LIST_bullet:                  case LIST_bullet:
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case LIST_dash:                  case LIST_dash:
Line 1406  pre_it(DECL_ARGS)
Line 1400  pre_it(DECL_ARGS)
                                 print_word("-");                                  print_word("-");
                         font_pop();                          font_pop();
                         outflags |= MMAN_nl;                          outflags |= MMAN_nl;
                         return(0);                          return 0;
                 case LIST_enum:                  case LIST_enum:
                         print_width(&bln->norm->Bl, NULL);                          print_width(&bln->norm->Bl, NULL);
                         TPremain = 0;                          TPremain = 0;
                         outflags |= MMAN_nl;                          outflags |= MMAN_nl;
                         print_count(&bln->norm->Bl.count);                          print_count(&bln->norm->Bl.count);
                         outflags |= MMAN_nl;                          outflags |= MMAN_nl;
                         return(0);                          return 0;
                 case LIST_hang:                  case LIST_hang:
                         print_width(&bln->norm->Bl, n->child);                          print_width(&bln->norm->Bl, n->child);
                         TPremain = 0;                          TPremain = 0;
                         outflags |= MMAN_nl;                          outflags |= MMAN_nl;
                         return(1);                          return 1;
                 case LIST_tag:                  case LIST_tag:
                         print_width(&bln->norm->Bl, n->child);                          print_width(&bln->norm->Bl, n->child);
                         putchar('\n');                          putchar('\n');
                         outflags &= ~MMAN_spc;                          outflags &= ~MMAN_spc;
                         return(1);                          return 1;
                 default:                  default:
                         return(1);                          return 1;
                 }                  }
         default:          default:
                 break;                  break;
         }          }
         return(1);          return 1;
 }  }
   
 /*  /*
Line 1536  pre_lk(DECL_ARGS)
Line 1530  pre_lk(DECL_ARGS)
         const struct roff_node *link, *descr;          const struct roff_node *link, *descr;
   
         if (NULL == (link = n->child))          if (NULL == (link = n->child))
                 return(0);                  return 0;
   
         if (NULL != (descr = link->next)) {          if (NULL != (descr = link->next)) {
                 font_push('I');                  font_push('I');
Line 1551  pre_lk(DECL_ARGS)
Line 1545  pre_lk(DECL_ARGS)
         font_push('B');          font_push('B');
         print_word(link->string);          print_word(link->string);
         font_pop();          font_pop();
         return(0);          return 0;
 }  }
   
 static int  static int
Line 1559  pre_ll(DECL_ARGS)
Line 1553  pre_ll(DECL_ARGS)
 {  {
   
         print_line(".ll", 0);          print_line(".ll", 0);
         return(1);          return 1;
 }  }
   
 static int  static int
Line 1567  pre_li(DECL_ARGS)
Line 1561  pre_li(DECL_ARGS)
 {  {
   
         font_push('R');          font_push('R');
         return(1);          return 1;
 }  }
   
 static int  static int
Line 1580  pre_nm(DECL_ARGS)
Line 1574  pre_nm(DECL_ARGS)
                 pre_syn(n);                  pre_syn(n);
         }          }
         if (n->type != ROFFT_ELEM && n->type != ROFFT_HEAD)          if (n->type != ROFFT_ELEM && n->type != ROFFT_HEAD)
                 return(1);                  return 1;
         name = n->child ? n->child->string : meta->name;          name = n->child ? n->child->string : meta->name;
         if (NULL == name)          if (NULL == name)
                 return(0);                  return 0;
         if (n->type == ROFFT_HEAD) {          if (n->type == ROFFT_HEAD) {
                 if (NULL == n->parent->prev)                  if (NULL == n->parent->prev)
                         outflags |= MMAN_sp;                          outflags |= MMAN_sp;
Line 1594  pre_nm(DECL_ARGS)
Line 1588  pre_nm(DECL_ARGS)
         font_push('B');          font_push('B');
         if (NULL == n->child)          if (NULL == n->child)
                 print_word(meta->name);                  print_word(meta->name);
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1621  pre_no(DECL_ARGS)
Line 1615  pre_no(DECL_ARGS)
 {  {
   
         outflags |= MMAN_spc_force;          outflags |= MMAN_spc_force;
         return(1);          return 1;
 }  }
   
 static int  static int
Line 1629  pre_ns(DECL_ARGS)
Line 1623  pre_ns(DECL_ARGS)
 {  {
   
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         return(0);          return 0;
 }  }
   
 static void  static void
Line 1648  pre_pp(DECL_ARGS)
Line 1642  pre_pp(DECL_ARGS)
                 outflags |= MMAN_PP;                  outflags |= MMAN_PP;
         outflags |= MMAN_sp | MMAN_nl;          outflags |= MMAN_sp | MMAN_nl;
         outflags &= ~MMAN_br;          outflags &= ~MMAN_br;
         return(0);          return 0;
 }  }
   
 static int  static int
Line 1659  pre_rs(DECL_ARGS)
Line 1653  pre_rs(DECL_ARGS)
                 outflags |= MMAN_PP | MMAN_sp | MMAN_nl;                  outflags |= MMAN_PP | MMAN_sp | MMAN_nl;
                 outflags &= ~MMAN_br;                  outflags &= ~MMAN_br;
         }          }
         return(1);          return 1;
 }  }
   
 static int  static int
Line 1711  pre_rv(DECL_ARGS)
Line 1705  pre_rv(DECL_ARGS)
   
         print_word("is set to indicate the error.");          print_word("is set to indicate the error.");
         outflags |= MMAN_nl;          outflags |= MMAN_nl;
         return(0);          return 0;
 }  }
   
 static int  static int
 pre_skip(DECL_ARGS)  pre_skip(DECL_ARGS)
 {  {
   
         return(0);          return 0;
 }  }
   
 static int  static int
Line 1735  pre_sm(DECL_ARGS)
Line 1729  pre_sm(DECL_ARGS)
         if (MMAN_Sm & outflags)          if (MMAN_Sm & outflags)
                 outflags |= MMAN_spc;                  outflags |= MMAN_spc;
   
         return(0);          return 0;
 }  }
   
 static int  static int
Line 1747  pre_sp(DECL_ARGS)
Line 1741  pre_sp(DECL_ARGS)
                 print_line(".PP", 0);                  print_line(".PP", 0);
         } else          } else
                 print_line(".sp", 0);                  print_line(".sp", 0);
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1762  pre_sy(DECL_ARGS)
Line 1756  pre_sy(DECL_ARGS)
 {  {
   
         font_push('B');          font_push('B');
         return(1);          return 1;
 }  }
   
 static int  static int
Line 1773  pre_vt(DECL_ARGS)
Line 1767  pre_vt(DECL_ARGS)
                 switch (n->type) {                  switch (n->type) {
                 case ROFFT_BLOCK:                  case ROFFT_BLOCK:
                         pre_syn(n);                          pre_syn(n);
                         return(1);                          return 1;
                 case ROFFT_BODY:                  case ROFFT_BODY:
                         break;                          break;
                 default:                  default:
                         return(0);                          return 0;
                 }                  }
         }          }
         font_push('I');          font_push('I');
         return(1);          return 1;
 }  }
   
 static void  static void
Line 1799  pre_xr(DECL_ARGS)
Line 1793  pre_xr(DECL_ARGS)
   
         n = n->child;          n = n->child;
         if (NULL == n)          if (NULL == n)
                 return(0);                  return 0;
         print_node(meta, n);          print_node(meta, n);
         n = n->next;          n = n->next;
         if (NULL == n)          if (NULL == n)
                 return(0);                  return 0;
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word("(");          print_word("(");
         print_node(meta, n);          print_node(meta, n);
         print_word(")");          print_word(")");
         return(0);          return 0;
 }  }
   
 static int  static int
Line 1817  pre_ux(DECL_ARGS)
Line 1811  pre_ux(DECL_ARGS)
   
         print_word(manacts[n->tok].prefix);          print_word(manacts[n->tok].prefix);
         if (NULL == n->child)          if (NULL == n->child)
                 return(0);                  return 0;
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         print_word("\\ ");          print_word("\\ ");
         outflags &= ~MMAN_spc;          outflags &= ~MMAN_spc;
         return(1);          return 1;
 }  }

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.94

CVSweb