[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.132 and 1.142

version 1.132, 2010/05/29 18:47:54 version 1.142, 2010/06/06 22:08:15
Line 82  static void   termp_dq_post(DECL_ARGS);
Line 82  static void   termp_dq_post(DECL_ARGS);
 static  void      termp_fd_post(DECL_ARGS);  static  void      termp_fd_post(DECL_ARGS);
 static  void      termp_fn_post(DECL_ARGS);  static  void      termp_fn_post(DECL_ARGS);
 static  void      termp_fo_post(DECL_ARGS);  static  void      termp_fo_post(DECL_ARGS);
 static  void      termp_ft_post(DECL_ARGS);  
 static  void      termp_in_post(DECL_ARGS);  static  void      termp_in_post(DECL_ARGS);
 static  void      termp_it_post(DECL_ARGS);  static  void      termp_it_post(DECL_ARGS);
 static  void      termp_lb_post(DECL_ARGS);  static  void      termp_lb_post(DECL_ARGS);
Line 166  static const struct termact termacts[MDOC_MAX] = {
Line 165  static const struct termact termacts[MDOC_MAX] = {
         { termp_bold_pre, termp_fd_post }, /* Fd */          { termp_bold_pre, termp_fd_post }, /* Fd */
         { termp_fl_pre, NULL }, /* Fl */          { termp_fl_pre, NULL }, /* Fl */
         { termp_fn_pre, termp_fn_post }, /* Fn */          { termp_fn_pre, termp_fn_post }, /* Fn */
         { termp_ft_pre, termp_ft_post }, /* Ft */          { termp_ft_pre, NULL }, /* 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 */
         { termp_li_pre, NULL }, /* Li */          { termp_li_pre, NULL }, /* Li */
Line 260  static const struct termact termacts[MDOC_MAX] = {
Line 259  static const struct termact termacts[MDOC_MAX] = {
         { termp_sp_pre, NULL }, /* br */          { termp_sp_pre, NULL }, /* br */
         { termp_sp_pre, NULL }, /* sp */          { termp_sp_pre, NULL }, /* sp */
         { termp_under_pre, termp____post }, /* %U */          { termp_under_pre, termp____post }, /* %U */
           { NULL, NULL }, /* Ta */
 };  };
   
   
Line 700  termp_it_pre(DECL_ARGS)
Line 700  termp_it_pre(DECL_ARGS)
   
         switch (type) {          switch (type) {
         case (LIST_column):          case (LIST_column):
                 if (MDOC_BODY == n->type)                  if (MDOC_HEAD == n->type)
                         break;                          break;
                 /*                  /*
                  * Imitate groff's column handling:                   * Imitate groff's column handling:
Line 715  termp_it_pre(DECL_ARGS)
Line 715  termp_it_pre(DECL_ARGS)
                 /* LINTED */                  /* LINTED */
                 dcol = ncols < 5 ? 4 : ncols == 5 ? 3 : 1;                  dcol = ncols < 5 ? 4 : ncols == 5 ? 3 : 1;
   
                   /*
                    * Calculate the offset by applying all prior MDOC_BODY,
                    * so we stop at the MDOC_HEAD (NULL == nn->prev).
                    */
   
                 for (i = 0, nn = n->prev;                  for (i = 0, nn = n->prev;
                                 nn && i < (int)ncols;                                  nn->prev && i < (int)ncols;
                                 nn = nn->prev, i++)                                  nn = nn->prev, i++)
                         offset += dcol + a2width                          offset += dcol + a2width
                                 (&bl->args->argv[vals[2]], i);                                  (&bl->args->argv[vals[2]], i);
Line 869  termp_it_pre(DECL_ARGS)
Line 874  termp_it_pre(DECL_ARGS)
                         p->flags |= TERMP_DANGLE;                          p->flags |= TERMP_DANGLE;
                 break;                  break;
         case (LIST_column):          case (LIST_column):
                 if (MDOC_HEAD == n->type) {                  if (MDOC_HEAD == n->type)
                         assert(n->next);                          break;
                         if (MDOC_BODY == n->next->type)  
                                 p->flags &= ~TERMP_NOBREAK;                  if (NULL == n->next)
                         else                          p->flags &= ~TERMP_NOBREAK;
                                 p->flags |= TERMP_NOBREAK;                  else
                         if (n->prev)                          p->flags |= TERMP_NOBREAK;
                                 p->flags |= TERMP_NOLPAD;  
                 }                  assert(n->prev);
                   if (MDOC_BODY == n->prev->type)
                           p->flags |= TERMP_NOLPAD;
   
                 break;                  break;
         case (LIST_diag):          case (LIST_diag):
                 if (MDOC_HEAD == n->type)                  if (MDOC_HEAD == n->type)
Line 929  termp_it_pre(DECL_ARGS)
Line 937  termp_it_pre(DECL_ARGS)
                  * XXX - this behaviour is not documented: the                   * XXX - this behaviour is not documented: the
                  * right-most column is filled to the right margin.                   * right-most column is filled to the right margin.
                  */                   */
                 if (MDOC_HEAD == n->type &&                  if (MDOC_HEAD == n->type)
                                 MDOC_BODY == n->next->type &&                          break;
                                 p->rmargin < p->maxrmargin)                  if (NULL == n->next && p->rmargin < p->maxrmargin)
                         p->rmargin = p->maxrmargin;                          p->rmargin = p->maxrmargin;
                 break;                  break;
         default:          default:
Line 985  termp_it_pre(DECL_ARGS)
Line 993  termp_it_pre(DECL_ARGS)
                         return(0);                          return(0);
                 break;                  break;
         case (LIST_column):          case (LIST_column):
                 if (MDOC_BODY == n->type)                  if (MDOC_HEAD == n->type)
                         return(0);                          return(0);
                 break;                  break;
         default:          default:
Line 1017  termp_it_post(DECL_ARGS)
Line 1025  termp_it_post(DECL_ARGS)
                         term_newln(p);                          term_newln(p);
                 break;                  break;
         case (LIST_column):          case (LIST_column):
                 if (MDOC_HEAD == n->type)                  if (MDOC_BODY == n->type)
                         term_flushln(p);                          term_flushln(p);
                 break;                  break;
         default:          default:
Line 1349  static void
Line 1357  static void
 termp_fd_post(DECL_ARGS)  termp_fd_post(DECL_ARGS)
 {  {
   
         if (n->sec != SEC_SYNOPSIS || ! (MDOC_LINE & n->flags))  
                 return;  
   
         term_newln(p);          term_newln(p);
         if (n->next && MDOC_Fd != n->next->tok)  
                 term_vspace(p);  
 }  }
   
   
Line 1507  static int
Line 1510  static int
 termp_ft_pre(DECL_ARGS)  termp_ft_pre(DECL_ARGS)
 {  {
   
         if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)          /* NB: MDOC_LINE does not effect this! */
                 if (n->prev && MDOC_Fo == n->prev->tok)          if (SEC_SYNOPSIS == n->sec && n->prev)
                         term_vspace(p);                  term_vspace(p);
   
         term_fontpush(p, TERMFONT_UNDER);          term_fontpush(p, TERMFONT_UNDER);
         return(1);          return(1);
Line 1517  termp_ft_pre(DECL_ARGS)
Line 1520  termp_ft_pre(DECL_ARGS)
   
   
 /* ARGSUSED */  /* ARGSUSED */
 static void  
 termp_ft_post(DECL_ARGS)  
 {  
   
         if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)  
                 term_newln(p);  
 }  
   
   
 /* ARGSUSED */  
 static int  static int
 termp_fn_pre(DECL_ARGS)  termp_fn_pre(DECL_ARGS)
 {  {
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
   
           /* NB: MDOC_LINE has no effect on this macro! */
           if (SEC_SYNOPSIS == n->sec) {
                   if (n->prev && MDOC_Ft == n->prev->tok)
                           term_newln(p);
                   else if (n->prev)
                           term_vspace(p);
           }
   
         term_fontpush(p, TERMFONT_BOLD);          term_fontpush(p, TERMFONT_BOLD);
         term_word(p, n->child->string);          term_word(p, n->child->string);
         term_fontpop(p);          term_fontpop(p);
Line 1562  static void
Line 1563  static void
 termp_fn_post(DECL_ARGS)  termp_fn_post(DECL_ARGS)
 {  {
   
         if (n->sec == SEC_SYNOPSIS && n->next && MDOC_LINE & n->flags)          /* NB: MDOC_LINE has no effect on this macro! */
                 term_vspace(p);          if (SEC_SYNOPSIS == n->sec)
                   term_newln(p);
 }  }
   
   
Line 1843  static int
Line 1845  static int
 termp_in_pre(DECL_ARGS)  termp_in_pre(DECL_ARGS)
 {  {
   
         term_fontpush(p, TERMFONT_BOLD);          if (SEC_SYNOPSIS == n->sec && n->prev && MDOC_In != n->prev->tok)
         if (SEC_SYNOPSIS == n->sec)                  term_vspace(p);
   
           if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
                   term_fontpush(p, TERMFONT_BOLD);
                 term_word(p, "#include");                  term_word(p, "#include");
                   term_word(p, "<");
           } else {
                   term_word(p, "<");
                   term_fontpush(p, TERMFONT_UNDER);
           }
   
         term_word(p, "<");  
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         return(1);          return(1);
 }  }
Line 1858  static void
Line 1867  static void
 termp_in_post(DECL_ARGS)  termp_in_post(DECL_ARGS)
 {  {
   
         term_fontpush(p, TERMFONT_BOLD);          if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
                   term_fontpush(p, TERMFONT_BOLD);
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         term_word(p, ">");          term_word(p, ">");
         term_fontpop(p);  
   
         if (SEC_SYNOPSIS != n->sec && ! (MDOC_LINE & n->flags))          if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
                 return;                  term_fontpop(p);
                   term_newln(p);
         term_newln(p);          }
         /*  
          * XXX Not entirely correct.  If `.In foo bar' is specified in  
          * the SYNOPSIS section, then it produces a single break after  
          * the <foo>; mandoc asserts a vertical space.  Since this  
          * construction is rarely used, I think it's fine.  
          */  
         if (n->next && MDOC_In != n->next->tok)  
                 term_vspace(p);  
 }  }
   
   
Line 1983  termp_pq_post(DECL_ARGS)
Line 1985  termp_pq_post(DECL_ARGS)
 static int  static int
 termp_fo_pre(DECL_ARGS)  termp_fo_pre(DECL_ARGS)
 {  {
         const struct mdoc_node *nn;  
   
         if (MDOC_BODY == n->type) {          if (MDOC_BLOCK == n->type) {
                   /* NB: MDOC_LINE has no effect on this macro! */
                   if (SEC_SYNOPSIS != n->sec)
                           return(1);
                   if (n->prev && MDOC_Ft == n->prev->tok)
                           term_newln(p);
                   else if (n->prev)
                           term_vspace(p);
                   return(1);
           } else if (MDOC_BODY == n->type) {
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
                 term_word(p, "(");                  term_word(p, "(");
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
                 return(1);                  return(1);
         } else if (MDOC_HEAD != n->type)          }
                 return(1);  
   
         term_fontpush(p, TERMFONT_BOLD);          /* XXX: we drop non-initial arguments as per groff. */
         for (nn = n->child; nn; nn = nn->next) {  
                 assert(MDOC_TEXT == nn->type);  
                 term_word(p, nn->string);  
         }  
         term_fontpop(p);  
   
           assert(n->child);
           assert(n->child->string);
           term_fontpush(p, TERMFONT_BOLD);
           term_word(p, n->child->string);
         return(0);          return(0);
 }  }
   
Line 2009  static void
Line 2017  static void
 termp_fo_post(DECL_ARGS)  termp_fo_post(DECL_ARGS)
 {  {
   
         if (MDOC_BODY != n->type)          if (MDOC_BLOCK == n->type) {
                 return;                  /* NB: MDOC_LINE has no effect on this macro! */
         p->flags |= TERMP_NOSPACE;                  if (SEC_SYNOPSIS == n->sec)
         term_word(p, ")");                          term_newln(p);
         p->flags |= TERMP_NOSPACE;          } else if (MDOC_BODY == n->type) {
         term_word(p, ";");                  p->flags |= TERMP_NOSPACE;
         term_newln(p);                  term_word(p, ")");
                   if (SEC_SYNOPSIS == n->sec) {
                           p->flags |= TERMP_NOSPACE;
                           term_word(p, ";");
                   }
           }
 }  }
   
   
Line 2098  termp_li_pre(DECL_ARGS)
Line 2111  termp_li_pre(DECL_ARGS)
 {  {
   
         term_fontpush(p, TERMFONT_NONE);          term_fontpush(p, TERMFONT_NONE);
         if (NULL == n->child)  
                 term_word(p, "");  
         return(1);          return(1);
 }  }
   

Legend:
Removed from v.1.132  
changed lines
  Added in v.1.142

CVSweb