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

Diff for /mandoc/mdoc_term.c between version 1.101 and 1.102

version 1.101, 2009/11/10 11:45:57 version 1.102, 2009/11/12 05:50:12
Line 59  static int   arg_listtype(const struct mdoc_node *);
Line 59  static int   arg_listtype(const struct mdoc_node *);
 static  void      print_bvspace(struct termp *,  static  void      print_bvspace(struct termp *,
                         const struct mdoc_node *,                          const struct mdoc_node *,
                         const struct mdoc_node *);                          const struct mdoc_node *);
 static  void      print_node(DECL_ARGS);  static  void      print_mdoc_node(DECL_ARGS);
 static  void      print_head(DECL_ARGS);  static  void      print_mdoc_head(DECL_ARGS);
 static  void      print_body(DECL_ARGS);  static  void      print_mdoc_nodelist(DECL_ARGS);
 static  void      print_foot(DECL_ARGS);  static  void      print_foot(DECL_ARGS);
   
 #ifdef __linux__  #ifdef __linux__
Line 116  static int   termp_fo_pre(DECL_ARGS);
Line 116  static int   termp_fo_pre(DECL_ARGS);
 static  int       termp_ft_pre(DECL_ARGS);  static  int       termp_ft_pre(DECL_ARGS);
 static  int       termp_in_pre(DECL_ARGS);  static  int       termp_in_pre(DECL_ARGS);
 static  int       termp_it_pre(DECL_ARGS);  static  int       termp_it_pre(DECL_ARGS);
   static  int       termp_li_pre(DECL_ARGS);
 static  int       termp_lk_pre(DECL_ARGS);  static  int       termp_lk_pre(DECL_ARGS);
 static  int       termp_nd_pre(DECL_ARGS);  static  int       termp_nd_pre(DECL_ARGS);
 static  int       termp_nm_pre(DECL_ARGS);  static  int       termp_nm_pre(DECL_ARGS);
Line 167  static const struct termact termacts[MDOC_MAX] = {
Line 168  static const struct termact termacts[MDOC_MAX] = {
         { termp_ft_pre, termp_ft_post }, /* Ft */          { termp_ft_pre, termp_ft_post }, /* Ft */
         { termp_bold_pre, NULL }, /* Ic */          { termp_bold_pre, NULL }, /* Ic */
         { termp_in_pre, termp_in_post }, /* In */          { termp_in_pre, termp_in_post }, /* In */
         { NULL, NULL }, /* Li */          { termp_li_pre, NULL }, /* Li */
         { termp_nd_pre, NULL }, /* Nd */          { termp_nd_pre, NULL }, /* Nd */
         { termp_nm_pre, NULL }, /* Nm */          { termp_nm_pre, NULL }, /* Nm */
         { termp_op_pre, termp_op_post }, /* Op */          { termp_op_pre, termp_op_post }, /* Op */
Line 283  terminal_mdoc(void *arg, const struct mdoc *mdoc)
Line 284  terminal_mdoc(void *arg, const struct mdoc *mdoc)
         n = mdoc_node(mdoc);          n = mdoc_node(mdoc);
         m = mdoc_meta(mdoc);          m = mdoc_meta(mdoc);
   
         print_head(p, NULL, m, n);          print_mdoc_head(p, NULL, m, n);
         if (n->child)          if (n->child)
                 print_body(p, NULL, m, n->child);                  print_mdoc_nodelist(p, NULL, m, n->child);
         print_foot(p, NULL, m, n);          print_foot(p, NULL, m, n);
 }  }
   
   
 static void  static void
 print_body(DECL_ARGS)  print_mdoc_nodelist(DECL_ARGS)
 {  {
   
         print_node(p, pair, m, n);          print_mdoc_node(p, pair, m, n);
         if (n->next)          if (n->next)
                 print_body(p, pair, m, n->next);                  print_mdoc_nodelist(p, pair, m, n->next);
 }  }
   
   
 /* ARGSUSED */  /* ARGSUSED */
 static void  static void
 print_node(DECL_ARGS)  print_mdoc_node(DECL_ARGS)
 {  {
         int              chld, bold, under;          int              chld;
           const void      *font;
         struct termpair  npair;          struct termpair  npair;
         size_t           offset, rmargin;          size_t           offset, rmargin;
   
         chld = 1;          chld = 1;
         offset = p->offset;          offset = p->offset;
         rmargin = p->rmargin;          rmargin = p->rmargin;
         bold = p->bold;          font = term_fontq(p);
         under = p->under;  
   
         memset(&npair, 0, sizeof(struct termpair));          memset(&npair, 0, sizeof(struct termpair));
         npair.ppair = pair;          npair.ppair = pair;
Line 322  print_node(DECL_ARGS)
Line 323  print_node(DECL_ARGS)
                         chld = (*termacts[n->tok].pre)(p, &npair, m, n);                          chld = (*termacts[n->tok].pre)(p, &npair, m, n);
         } else          } else
                 term_word(p, n->string);                  term_word(p, n->string);
   
         if (chld && n->child)          if (chld && n->child)
                 print_body(p, &npair, m, n->child);                  print_mdoc_nodelist(p, &npair, m, n->child);
   
         /*          term_fontpopq(p, font);
          * XXX - if bold/under were to span scopes, this wouldn't be  
          * possible, but because decoration is always in-scope, we can  
          * get away with this.  
          */  
   
         p->bold = bold;  
         p->under = under;  
   
         if (MDOC_TEXT != n->type)          if (MDOC_TEXT != n->type)
                 if (termacts[n->tok].post)                  if (termacts[n->tok].post)
                         (*termacts[n->tok].post)(p, &npair, m, n);                          (*termacts[n->tok].post)(p, &npair, m, n);
Line 349  print_foot(DECL_ARGS)
Line 344  print_foot(DECL_ARGS)
 {  {
         char            buf[DATESIZ], os[BUFSIZ];          char            buf[DATESIZ], os[BUFSIZ];
   
         /* Disable meta-fonts. */          term_fontrepl(p, TERMFONT_NONE);
         p->metafont = 0;  
   
         /*          /*
          * Output the footer in new-groff style, that is, three columns           * Output the footer in new-groff style, that is, three columns
Line 393  print_foot(DECL_ARGS)
Line 387  print_foot(DECL_ARGS)
 }  }
   
   
 /* FIXME: put in utility library. */  
 /* ARGSUSED */  /* ARGSUSED */
 static void  static void
 print_head(DECL_ARGS)  print_mdoc_head(DECL_ARGS)
 {  {
         char            buf[BUFSIZ], title[BUFSIZ];          char            buf[BUFSIZ], title[BUFSIZ];
   
Line 782  termp_it_pre(DECL_ARGS)
Line 775  termp_it_pre(DECL_ARGS)
         switch (type) {          switch (type) {
         case (MDOC_Diag):          case (MDOC_Diag):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
                         p->bold++;                          term_fontpush(p, TERMFONT_BOLD);
                 break;                  break;
         default:          default:
                 break;                  break;
Line 920  termp_it_pre(DECL_ARGS)
Line 913  termp_it_pre(DECL_ARGS)
         if (MDOC_HEAD == n->type)          if (MDOC_HEAD == n->type)
                 switch (type) {                  switch (type) {
                 case (MDOC_Bullet):                  case (MDOC_Bullet):
                         p->bold++;                          term_fontpush(p, TERMFONT_BOLD);
                         term_word(p, "\\[bu]");                          term_word(p, "\\[bu]");
                         p->bold--;                          term_fontpop(p);
                         break;                          break;
                 case (MDOC_Dash):                  case (MDOC_Dash):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (MDOC_Hyphen):                  case (MDOC_Hyphen):
                         p->bold++;                          term_fontpush(p, TERMFONT_BOLD);
                         term_word(p, "\\(hy");                          term_word(p, "\\(hy");
                         p->bold--;                          term_fontpop(p);
                         break;                          break;
                 case (MDOC_Enum):                  case (MDOC_Enum):
                         (pair->ppair->ppair->count)++;                          (pair->ppair->ppair->count)++;
Line 1011  termp_nm_pre(DECL_ARGS)
Line 1004  termp_nm_pre(DECL_ARGS)
   
         if (SEC_SYNOPSIS == n->sec)          if (SEC_SYNOPSIS == n->sec)
                 term_newln(p);                  term_newln(p);
         p->bold++;  
           term_fontpush(p, TERMFONT_BOLD);
   
         if (NULL == n->child)          if (NULL == n->child)
                 term_word(p, m->name);                  term_word(p, m->name);
         return(1);          return(1);
Line 1023  static int
Line 1018  static int
 termp_fl_pre(DECL_ARGS)  termp_fl_pre(DECL_ARGS)
 {  {
   
         p->bold++;          term_fontpush(p, TERMFONT_BOLD);
         term_word(p, "\\-");          term_word(p, "\\-");
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         return(1);          return(1);
Line 1121  termp_rv_pre(DECL_ARGS)
Line 1116  termp_rv_pre(DECL_ARGS)
         term_word(p, "The");          term_word(p, "The");
   
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 p->bold++;                  term_fontpush(p, TERMFONT_BOLD);
                 term_word(p, nn->string);                  term_word(p, nn->string);
                 p->bold--;                  term_fontpop(p);
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
                 if (nn->next && NULL == nn->next->next)                  if (nn->next && NULL == nn->next->next)
                         term_word(p, "(), and");                          term_word(p, "(), and");
Line 1141  termp_rv_pre(DECL_ARGS)
Line 1136  termp_rv_pre(DECL_ARGS)
         term_word(p, "the value 0 if successful; otherwise the value "          term_word(p, "the value 0 if successful; otherwise the value "
                         "-1 is returned and the global variable");                          "-1 is returned and the global variable");
   
         p->under++;          term_fontpush(p, TERMFONT_UNDER);
         term_word(p, "errno");          term_word(p, "errno");
         p->under--;          term_fontpop(p);
   
         term_word(p, "is set to indicate the error.");          term_word(p, "is set to indicate the error.");
   
Line 1160  termp_ex_pre(DECL_ARGS)
Line 1155  termp_ex_pre(DECL_ARGS)
         term_word(p, "The");          term_word(p, "The");
   
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 p->bold++;                  term_fontpush(p, TERMFONT_BOLD);
                 term_word(p, nn->string);                  term_word(p, nn->string);
                 p->bold--;                  term_fontpop(p);
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
                 if (nn->next && NULL == nn->next->next)                  if (nn->next && NULL == nn->next->next)
                         term_word(p, ", and");                          term_word(p, ", and");
Line 1264  static int
Line 1259  static int
 termp_bold_pre(DECL_ARGS)  termp_bold_pre(DECL_ARGS)
 {  {
   
         p->bold++;          term_fontpush(p, TERMFONT_BOLD);
         return(1);          return(1);
 }  }
   
Line 1298  termp_sh_pre(DECL_ARGS)
Line 1293  termp_sh_pre(DECL_ARGS)
                 term_vspace(p);                  term_vspace(p);
                 break;                  break;
         case (MDOC_HEAD):          case (MDOC_HEAD):
                 p->bold++;                  term_fontpush(p, TERMFONT_BOLD);
                 break;                  break;
         case (MDOC_BODY):          case (MDOC_BODY):
                 p->offset = INDENT;                  p->offset = INDENT;
Line 1433  termp_ft_pre(DECL_ARGS)
Line 1428  termp_ft_pre(DECL_ARGS)
         if (SEC_SYNOPSIS == n->sec)          if (SEC_SYNOPSIS == n->sec)
                 if (n->prev && MDOC_Fo == n->prev->tok)                  if (n->prev && MDOC_Fo == n->prev->tok)
                         term_vspace(p);                          term_vspace(p);
         p->under++;  
           term_fontpush(p, TERMFONT_UNDER);
         return(1);          return(1);
 }  }
   
Line 1454  termp_fn_pre(DECL_ARGS)
Line 1450  termp_fn_pre(DECL_ARGS)
 {  {
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
   
         p->bold++;          term_fontpush(p, TERMFONT_BOLD);
         term_word(p, n->child->string);          term_word(p, n->child->string);
         p->bold--;          term_fontpop(p);
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         term_word(p, "(");          term_word(p, "(");
   
         for (nn = n->child->next; nn; nn = nn->next) {          for (nn = n->child->next; nn; nn = nn->next) {
                 p->under++;                  term_fontpush(p, TERMFONT_UNDER);
                 term_word(p, nn->string);                  term_word(p, nn->string);
                 p->under--;                  term_fontpop(p);
   
                 if (nn->next)                  if (nn->next)
                         term_word(p, ",");                          term_word(p, ",");
         }          }
Line 1495  termp_fa_pre(DECL_ARGS)
Line 1492  termp_fa_pre(DECL_ARGS)
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
   
         if (n->parent->tok != MDOC_Fo) {          if (n->parent->tok != MDOC_Fo) {
                 p->under++;                  term_fontpush(p, TERMFONT_UNDER);
                 return(1);                  return(1);
         }          }
   
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 p->under++;                  term_fontpush(p, TERMFONT_UNDER);
                 term_word(p, nn->string);                  term_word(p, nn->string);
                 p->under--;                  term_fontpop(p);
   
                 if (nn->next)                  if (nn->next)
                         term_word(p, ",");                          term_word(p, ",");
         }          }
Line 1564  termp_bd_pre(DECL_ARGS)
Line 1562  termp_bd_pre(DECL_ARGS)
   
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
                 print_node(p, pair, m, nn);                  print_mdoc_node(p, pair, m, nn);
                 if (NULL == nn->next)                  if (NULL == nn->next)
                         continue;                          continue;
                 if (nn->prev && nn->prev->line < nn->line)                  if (nn->prev && nn->prev->line < nn->line)
Line 1718  termp_ss_pre(DECL_ARGS)
Line 1716  termp_ss_pre(DECL_ARGS)
                         term_vspace(p);                          term_vspace(p);
                 break;                  break;
         case (MDOC_HEAD):          case (MDOC_HEAD):
                 p->bold++;                  term_fontpush(p, TERMFONT_BOLD);
                 p->offset = HALFINDENT;                  p->offset = HALFINDENT;
                 break;                  break;
         default:          default:
Line 1744  static int
Line 1742  static int
 termp_cd_pre(DECL_ARGS)  termp_cd_pre(DECL_ARGS)
 {  {
   
         p->bold++;          term_fontpush(p, TERMFONT_BOLD);
         term_newln(p);          term_newln(p);
         return(1);          return(1);
 }  }
Line 1755  static int
Line 1753  static int
 termp_in_pre(DECL_ARGS)  termp_in_pre(DECL_ARGS)
 {  {
   
         p->bold++;          term_fontpush(p, TERMFONT_BOLD);
         if (SEC_SYNOPSIS == n->sec)          if (SEC_SYNOPSIS == n->sec)
                 term_word(p, "#include");                  term_word(p, "#include");
   
Line 1770  static void
Line 1768  static void
 termp_in_post(DECL_ARGS)  termp_in_post(DECL_ARGS)
 {  {
   
         p->bold++;          term_fontpush(p, TERMFONT_BOLD);
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         term_word(p, ">");          term_word(p, ">");
         p->bold--;          term_fontpop(p);
   
         if (SEC_SYNOPSIS != n->sec)          if (SEC_SYNOPSIS != n->sec)
                 return;                  return;
Line 1905  termp_fo_pre(DECL_ARGS)
Line 1903  termp_fo_pre(DECL_ARGS)
         } else if (MDOC_HEAD != n->type)          } else if (MDOC_HEAD != n->type)
                 return(1);                  return(1);
   
         p->bold++;          term_fontpush(p, TERMFONT_BOLD);
         for (nn = n->child; nn; nn = nn->next) {          for (nn = n->child; nn; nn = nn->next) {
                 assert(MDOC_TEXT == nn->type);                  assert(MDOC_TEXT == nn->type);
                 term_word(p, nn->string);                  term_word(p, nn->string);
         }          }
         p->bold--;          term_fontpop(p);
   
         return(0);          return(0);
 }  }
Line 1944  termp_bf_pre(DECL_ARGS)
Line 1942  termp_bf_pre(DECL_ARGS)
   
         if (NULL == (nn = n->head->child)) {          if (NULL == (nn = n->head->child)) {
                 if (arg_hasattr(MDOC_Emphasis, n))                  if (arg_hasattr(MDOC_Emphasis, n))
                         p->under++;                          term_fontpush(p, TERMFONT_UNDER);
                 else if (arg_hasattr(MDOC_Symbolic, n))                  else if (arg_hasattr(MDOC_Symbolic, n))
                         p->bold++;                          term_fontpush(p, TERMFONT_BOLD);
                   else
                           term_fontpush(p, TERMFONT_NONE);
   
                 return(1);                  return(1);
         }          }
   
         assert(MDOC_TEXT == nn->type);          assert(MDOC_TEXT == nn->type);
         if (0 == strcmp("Em", nn->string))          if (0 == strcmp("Em", nn->string))
                 p->under++;                  term_fontpush(p, TERMFONT_UNDER);
         else if (0 == strcmp("Sy", nn->string))          else if (0 == strcmp("Sy", nn->string))
                 p->bold++;                  term_fontpush(p, TERMFONT_BOLD);
           else
                   term_fontpush(p, TERMFONT_NONE);
   
         return(1);          return(1);
 }  }
Line 2011  termp____post(DECL_ARGS)
Line 2013  termp____post(DECL_ARGS)
   
 /* ARGSUSED */  /* ARGSUSED */
 static int  static int
   termp_li_pre(DECL_ARGS)
   {
   
           term_fontpush(p, TERMFONT_NONE);
           return(1);
   }
   
   
   /* ARGSUSED */
   static int
 termp_lk_pre(DECL_ARGS)  termp_lk_pre(DECL_ARGS)
 {  {
         const struct mdoc_node *nn;          const struct mdoc_node *nn;
   
         p->under++;          term_fontpush(p, TERMFONT_UNDER);
         nn = n->child;          nn = n->child;
   
         if (NULL == nn->next)          if (NULL == nn->next)
                 return(1);                  return(1);
   
         term_word(p, nn->string);          term_word(p, nn->string);
         p->under--;          term_fontpop(p);
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         term_word(p, ":");          term_word(p, ":");
   
         p->bold++;          term_fontpush(p, TERMFONT_BOLD);
         for (nn = nn->next; nn; nn = nn->next)          for (nn = nn->next; nn; nn = nn->next)
                 term_word(p, nn->string);                  term_word(p, nn->string);
         p->bold--;          term_fontpop(p);
   
         return(0);          return(0);
 }  }
Line 2041  static int
Line 2053  static int
 termp_under_pre(DECL_ARGS)  termp_under_pre(DECL_ARGS)
 {  {
   
         p->under++;          term_fontpush(p, TERMFONT_UNDER);
         return(1);          return(1);
 }  }
   

Legend:
Removed from v.1.101  
changed lines
  Added in v.1.102

CVSweb