[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.30 and 1.33

version 1.30, 2012/07/10 14:38:51 version 1.33, 2012/07/11 16:19:08
Line 100  static int   pre_ux(DECL_ARGS);
Line 100  static int   pre_ux(DECL_ARGS);
 static  int       pre_xr(DECL_ARGS);  static  int       pre_xr(DECL_ARGS);
 static  void      print_word(const char *);  static  void      print_word(const char *);
 static  void      print_offs(const char *);  static  void      print_offs(const char *);
 static  void      print_width(const char *);  static  void      print_width(const char *, const struct mdoc_node *);
 static  void      print_count(int *);  static  void      print_count(int *);
 static  void      print_node(DECL_ARGS);  static  void      print_node(DECL_ARGS);
   
Line 360  print_offs(const char *v)
Line 360  print_offs(const char *v)
 }  }
   
 void  void
 print_width(const char *v)  print_width(const char *v, const struct mdoc_node *child)
 {  {
         char              buf[24];          char              buf[24];
         struct roffsu     su;          struct roffsu     su;
         size_t            sz;          size_t            sz, chsz;
   
           /* XXX Rough estimation, might have multiple parts. */
           chsz = (NULL != child && MDOC_TEXT == child->type) ?
                           strlen(child->string) : 0;
   
         if (a2roffsu(v, &su, SCALE_MAX)) {          if (a2roffsu(v, &su, SCALE_MAX)) {
                 if (SCALE_EN == su.unit)                  if (SCALE_EN == su.unit)
                         sz = su.scale;                          sz = su.scale;
                 else {                  else {
                           if (chsz)
                                   print_word(".HP");
                           else
                                   print_word(".TP");
                         print_word(v);                          print_word(v);
                         return;                          return;
                 }                  }
         } else          } else
                 sz = strlen(v);                  sz = strlen(v);
   
           if (chsz > sz)
                   print_word(".HP");
           else
                   print_word(".TP");
         snprintf(buf, sizeof(buf), "%ldn", sz + 2);          snprintf(buf, sizeof(buf), "%ldn", sz + 2);
         print_word(buf);          print_word(buf);
 }  }
Line 742  post_bk(DECL_ARGS)
Line 754  post_bk(DECL_ARGS)
 static int  static int
 pre_bl(DECL_ARGS)  pre_bl(DECL_ARGS)
 {  {
           size_t           icol;
   
         if (LIST_enum == n->norm->Bl.type)          switch (n->norm->Bl.type) {
           case (LIST_enum):
                 n->norm->Bl.count = 0;                  n->norm->Bl.count = 0;
                   return(1);
           case (LIST_column):
                   break;
           default:
                   return(1);
           }
   
           outflags |= MMAN_nl;
           print_word(".TS");
           outflags |= MMAN_nl;
           for (icol = 0; icol < n->norm->Bl.ncols; icol++)
                   print_word("l");
           print_word(".");
         return(1);          return(1);
 }  }
   
Line 752  static void
Line 779  static void
 post_bl(DECL_ARGS)  post_bl(DECL_ARGS)
 {  {
   
         if (LIST_enum == n->norm->Bl.type)          switch (n->norm->Bl.type) {
           case (LIST_enum):
                 n->norm->Bl.count = 0;                  n->norm->Bl.count = 0;
                   break;
           case (LIST_column):
                   outflags |= MMAN_nl;
                   print_word(".TE");
                   break;
           default:
                   break;
           }
           outflags |= MMAN_br;
 }  }
   
 static int  static int
Line 1027  pre_it(DECL_ARGS)
Line 1064  pre_it(DECL_ARGS)
                 case (LIST_dash):                  case (LIST_dash):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (LIST_hyphen):                  case (LIST_hyphen):
                         print_word(".TP");                          print_width(bln->norm->Bl.width, NULL);
                         print_width(bln->norm->Bl.width);  
                         outflags |= MMAN_nl;                          outflags |= MMAN_nl;
                         font_push('B');                          font_push('B');
                         if (LIST_bullet == bln->norm->Bl.type)                          if (LIST_bullet == bln->norm->Bl.type)
Line 1038  pre_it(DECL_ARGS)
Line 1074  pre_it(DECL_ARGS)
                         font_pop();                          font_pop();
                         break;                          break;
                 case (LIST_enum):                  case (LIST_enum):
                         print_word(".TP");                          print_width(bln->norm->Bl.width, NULL);
                         print_width(bln->norm->Bl.width);  
                         outflags |= MMAN_nl;                          outflags |= MMAN_nl;
                         print_count(&bln->norm->Bl.count);                          print_count(&bln->norm->Bl.count);
                         outflags |= MMAN_nl;  
                         break;                          break;
                 default:                  case (LIST_hang):
                         if (bln->norm->Bl.width)                          print_width(bln->norm->Bl.width, n->child);
                                 print_width(bln->norm->Bl.width);  
                         break;                          break;
                   case (LIST_tag):
                           print_width(bln->norm->Bl.width, NULL);
                           break;
                   default:
                           return(1);
                 }                  }
                 outflags |= MMAN_nl;                  outflags |= MMAN_nl;
         default:          default:
Line 1061  post_it(DECL_ARGS)
Line 1099  post_it(DECL_ARGS)
 {  {
         const struct mdoc_node *bln;          const struct mdoc_node *bln;
   
         if (MDOC_HEAD == n->type) {          bln = n->parent->parent;
                 bln = n->parent->parent;  
           switch (n->type) {
           case (MDOC_HEAD):
                 switch (bln->norm->Bl.type) {                  switch (bln->norm->Bl.type) {
                 case (LIST_diag):                  case (LIST_diag):
                         outflags &= ~MMAN_spc;                          outflags &= ~MMAN_spc;
Line 1074  post_it(DECL_ARGS)
Line 1114  post_it(DECL_ARGS)
                 default:                  default:
                         break;                          break;
                 }                  }
                   break;
           case (MDOC_BODY):
                   if (LIST_column == bln->norm->Bl.type &&
                       NULL != n->next) {
                           putchar('\t');
                           outflags &= ~MMAN_spc;
                   }
                   break;
           default:
                   break;
         }          }
 }  }
   

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.33

CVSweb