[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.82 and 1.87

version 1.82, 2015/01/23 14:21:01 version 1.87, 2015/02/12 12:24:33
Line 29 
Line 29 
 #include "mdoc.h"  #include "mdoc.h"
 #include "main.h"  #include "main.h"
   
 #define DECL_ARGS const struct mdoc_meta *meta, \  #define DECL_ARGS const struct mdoc_meta *meta, struct mdoc_node *n
                   const struct mdoc_node *n  
   
 struct  manact {  struct  manact {
         int             (*cond)(DECL_ARGS); /* DON'T run actions */          int             (*cond)(DECL_ARGS); /* DON'T run actions */
Line 548  void
Line 547  void
 man_mdoc(void *arg, const struct mdoc *mdoc)  man_mdoc(void *arg, const struct mdoc *mdoc)
 {  {
         const struct mdoc_meta *meta;          const struct mdoc_meta *meta;
         const struct mdoc_node *n;          struct mdoc_node *n;
   
         meta = mdoc_meta(mdoc);          meta = mdoc_meta(mdoc);
         n = mdoc_node(mdoc);          n = mdoc_node(mdoc)->child;
   
         printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",          printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
             meta->title,              meta->title,
Line 567  man_mdoc(void *arg, const struct mdoc *mdoc)
Line 566  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';
         }          }
         print_node(meta, n);          while (n != NULL) {
                   print_node(meta, n);
                   n = n->next;
           }
         putchar('\n');          putchar('\n');
 }  }
   
 static void  static void
 print_node(DECL_ARGS)  print_node(DECL_ARGS)
 {  {
         const struct mdoc_node  *sub;  
         const struct manact     *act;          const struct manact     *act;
           struct mdoc_node        *sub;
         int                      cond, do_sub;          int                      cond, do_sub;
   
         /*          /*
Line 588  print_node(DECL_ARGS)
Line 590  print_node(DECL_ARGS)
         act = NULL;          act = NULL;
         cond = 0;          cond = 0;
         do_sub = 1;          do_sub = 1;
           n->flags &= ~MDOC_ENDED;
   
         if (MDOC_TEXT == n->type) {          if (MDOC_TEXT == n->type) {
                 /*                  /*
Line 635  print_node(DECL_ARGS)
Line 638  print_node(DECL_ARGS)
                 (*act->post)(meta, n);                  (*act->post)(meta, n);
   
         if (ENDBODY_NOT != n->end)          if (ENDBODY_NOT != n->end)
                 n->pending->flags |= MDOC_ENDED;                  n->body->flags |= MDOC_ENDED;
   
         if (ENDBODY_NOSPACE == n->end)          if (ENDBODY_NOSPACE == n->end)
                 outflags &= ~(MMAN_spc | MMAN_nl);                  outflags &= ~(MMAN_spc | MMAN_nl);
Line 1006  pre_bl(DECL_ARGS)
Line 1009  pre_bl(DECL_ARGS)
                 return(1);                  return(1);
         }          }
   
         print_line(".TS", MMAN_nl);          if (n->nchild) {
         for (icol = 0; icol < n->norm->Bl.ncols; icol++)                  print_line(".TS", MMAN_nl);
                 print_word("l");                  for (icol = 0; icol < n->norm->Bl.ncols; icol++)
         print_word(".");                          print_word("l");
                   print_word(".");
           }
         outflags |= MMAN_nl;          outflags |= MMAN_nl;
         return(1);          return(1);
 }  }
Line 1020  post_bl(DECL_ARGS)
Line 1025  post_bl(DECL_ARGS)
   
         switch (n->norm->Bl.type) {          switch (n->norm->Bl.type) {
         case LIST_column:          case LIST_column:
                 print_line(".TE", 0);                  if (n->nchild)
                           print_line(".TE", 0);
                 break;                  break;
         case LIST_enum:          case LIST_enum:
                 n->norm->Bl.count = 0;                  n->norm->Bl.count = 0;
Line 1131  static int
Line 1137  static int
 pre_eo(DECL_ARGS)  pre_eo(DECL_ARGS)
 {  {
   
         outflags &= ~(MMAN_spc | MMAN_nl);          if (n->end == ENDBODY_NOT &&
               n->parent->head->child == NULL &&
               n->child != NULL &&
               n->child->end != ENDBODY_NOT)
                   print_word("\\&");
           else if (n->end != ENDBODY_NOT ? n->child != NULL :
               n->parent->head->child != NULL && (n->child != NULL ||
               (n->parent->tail != NULL && n->parent->tail->child != NULL)))
                   outflags &= ~(MMAN_spc | MMAN_nl);
         return(1);          return(1);
 }  }
   
 static void  static void
 post_eo(DECL_ARGS)  post_eo(DECL_ARGS)
 {  {
           int      body, tail;
   
         if (n->end != ENDBODY_SPACE)          if (n->end != ENDBODY_NOT) {
                   outflags |= MMAN_spc;
                   return;
           }
   
           body = n->child != NULL || n->parent->head->child != NULL;
           tail = n->parent->tail != NULL && n->parent->tail->child != NULL;
   
           if (body && tail)
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
           else if ( ! (body || tail))
                   print_word("\\&");
           else if ( ! tail)
                   outflags |= MMAN_spc;
 }  }
   
 static int  static int
Line 1259  pre_fo(DECL_ARGS)
Line 1286  pre_fo(DECL_ARGS)
                 pre_syn(n);                  pre_syn(n);
                 break;                  break;
         case MDOC_HEAD:          case MDOC_HEAD:
                   if (n->child == NULL)
                           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');
                 break;                  break;
         case MDOC_BODY:          case MDOC_BODY:
                 outflags &= ~MMAN_spc;                  outflags &= ~(MMAN_spc | MMAN_nl);
                 print_word("(");                  print_word("(");
                 outflags &= ~MMAN_spc;                  outflags &= ~MMAN_spc;
                 break;                  break;
Line 1280  post_fo(DECL_ARGS)
Line 1309  post_fo(DECL_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case MDOC_HEAD:          case MDOC_HEAD:
                 font_pop();                  if (n->child != NULL)
                           font_pop();
                 break;                  break;
         case MDOC_BODY:          case MDOC_BODY:
                 post_fn(meta, n);                  post_fn(meta, n);

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.87

CVSweb