[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.27 and 1.28

version 1.27, 2009/07/12 16:55:11 version 1.28, 2009/07/12 17:25:07
Line 80  const int ttypes[TTYPE_NMAX] = {
Line 80  const int ttypes[TTYPE_NMAX] = {
         TERMP_BOLD              /* TTYPE_LIST */          TERMP_BOLD              /* TTYPE_LIST */
 };  };
   
 /* XXX - clean this up. */  /*
    * This is used to preserve a style of value across a macro, instead of
    * losing it while the body is processed.
    */
 struct  termpair {  struct  termpair {
         struct termpair  *ppair;          struct termpair  *ppair;
         int               type;  
 #define TERMPAIR_FLAG    (1 << 0)  
         int               flag;         /* Whether being used. */          int               flag;         /* Whether being used. */
         size_t            offset;       /* Left margin. */          size_t            offset;       /* Left margin. */
         size_t            rmargin;      /* Right margin. */          size_t            rmargin;      /* Right margin. */
         int               count;        /* Enum count. */          int               count;        /* Enum count. */
 };  };
   
 #define TERMPAIR_SETFLAG(termp, p, fl) \  
         do { \  
                 assert(! (TERMPAIR_FLAG & (p)->type)); \  
                 (termp)->flags |= (fl); \  
                 (p)->flag = (fl); \  
                 (p)->type |= TERMPAIR_FLAG; \  
         } while ( /* CONSTCOND */ 0)  
   
 #define DECL_ARGS \  #define DECL_ARGS \
         struct termp *p, struct termpair *pair, \          struct termp *p, struct termpair *pair, \
         const struct mdoc_meta *meta, \          const struct mdoc_meta *meta, \
Line 360  print_node(DECL_ARGS)
Line 352  print_node(DECL_ARGS)
   
         dochild = 1;          dochild = 1;
         npair.ppair = pair;          npair.ppair = pair;
         npair.type = 0;  
         npair.offset = npair.rmargin = 0;          npair.offset = npair.rmargin = 0;
         npair.flag = 0;          npair.flag = 0;
         npair.count = 0;          npair.count = 0;
Line 374  print_node(DECL_ARGS)
Line 365  print_node(DECL_ARGS)
   
         /* Children. */          /* Children. */
   
         if (TERMPAIR_FLAG & npair.type)          p->flags |= npair.flag;
                 p->flags |= npair.flag;  
   
         if (dochild && node->child)          if (dochild && node->child)
                 print_body(p, &npair, meta, node->child);                  print_body(p, &npair, meta, node->child);
   
         if (TERMPAIR_FLAG & npair.type)          p->flags &= ~npair.flag;
                 p->flags &= ~npair.flag;  
   
         /* Post-processing. */          /* Post-processing. */
   
Line 994  termp_nm_pre(DECL_ARGS)
Line 983  termp_nm_pre(DECL_ARGS)
         if (SEC_SYNOPSIS == node->sec)          if (SEC_SYNOPSIS == node->sec)
                 term_newln(p);                  term_newln(p);
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_PROG]);          pair->flag |= ttypes[TTYPE_PROG];
           p->flags |= ttypes[TTYPE_PROG];
   
         if (NULL == node->child)          if (NULL == node->child)
                 term_word(p, meta->name);                  term_word(p, meta->name);
   
Line 1007  static int
Line 998  static int
 termp_fl_pre(DECL_ARGS)  termp_fl_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CMD_FLAG]);          pair->flag |= ttypes[TTYPE_CMD_FLAG];
           p->flags |= ttypes[TTYPE_CMD_FLAG];
         term_word(p, "\\-");          term_word(p, "\\-");
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         return(1);          return(1);
Line 1019  static int
Line 1011  static int
 termp_ar_pre(DECL_ARGS)  termp_ar_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CMD_ARG]);          pair->flag |= ttypes[TTYPE_CMD_ARG];
         return(1);          return(1);
 }  }
   
Line 1196  termp_vt_pre(DECL_ARGS)
Line 1188  termp_vt_pre(DECL_ARGS)
 {  {
   
         /* FIXME: this can be "type name". */          /* FIXME: this can be "type name". */
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_VAR_DECL]);          pair->flag |= TTYPE_VAR_DECL;
         return(1);          return(1);
 }  }
   
Line 1216  static int
Line 1208  static int
 termp_fd_pre(DECL_ARGS)  termp_fd_pre(DECL_ARGS)
 {  {
   
         /*          pair->flag |= TTYPE_FUNC_DECL;
          * FIXME: this naming is bad.  This value is used, in general,  
          * for the #include header or other preprocessor statement.  
          */  
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FUNC_DECL]);  
         return(1);          return(1);
 }  }
   
Line 1246  termp_sh_pre(DECL_ARGS)
Line 1234  termp_sh_pre(DECL_ARGS)
         switch (node->type) {          switch (node->type) {
         case (MDOC_HEAD):          case (MDOC_HEAD):
                 term_vspace(p);                  term_vspace(p);
                 TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SECTION]);                  pair->flag |= ttypes[TTYPE_SECTION];
                 break;                  break;
         case (MDOC_BODY):          case (MDOC_BODY):
                 p->offset = INDENT;                  p->offset = INDENT;
Line 1399  termp_ft_pre(DECL_ARGS)
Line 1387  termp_ft_pre(DECL_ARGS)
         if (SEC_SYNOPSIS == node->sec)          if (SEC_SYNOPSIS == node->sec)
                 if (node->prev && MDOC_Fo == node->prev->tok)                  if (node->prev && MDOC_Fo == node->prev->tok)
                         term_vspace(p);                          term_vspace(p);
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FUNC_TYPE]);          pair->flag |= ttypes[TTYPE_FUNC_TYPE];
         return(1);          return(1);
 }  }
   
Line 1463  static int
Line 1451  static int
 termp_sx_pre(DECL_ARGS)  termp_sx_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK]);          pair->flag |= ttypes[TTYPE_LINK];
         return(1);          return(1);
 }  }
   
Line 1475  termp_fa_pre(DECL_ARGS)
Line 1463  termp_fa_pre(DECL_ARGS)
         struct mdoc_node *n;          struct mdoc_node *n;
   
         if (node->parent->tok != MDOC_Fo) {          if (node->parent->tok != MDOC_Fo) {
                 TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FUNC_ARG]);                  pair->flag |= ttypes[TTYPE_FUNC_ARG];
                 return(1);                  return(1);
         }          }
   
Line 1499  static int
Line 1487  static int
 termp_va_pre(DECL_ARGS)  termp_va_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_VAR_DECL]);          pair->flag |= ttypes[TTYPE_VAR_DECL];
         return(1);          return(1);
 }  }
   
Line 1736  termp_ss_pre(DECL_ARGS)
Line 1724  termp_ss_pre(DECL_ARGS)
                         term_vspace(p);                          term_vspace(p);
                 break;                  break;
         case (MDOC_HEAD):          case (MDOC_HEAD):
                 TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SSECTION]);                  pair->flag |= ttypes[TTYPE_SSECTION];
                 p->offset = HALFINDENT;                  p->offset = HALFINDENT;
                 break;                  break;
         default:          default:
Line 1768  static int
Line 1756  static int
 termp_pa_pre(DECL_ARGS)  termp_pa_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FILE]);          pair->flag |= ttypes[TTYPE_FILE];
         return(1);          return(1);
 }  }
   
Line 1778  static int
Line 1766  static int
 termp_em_pre(DECL_ARGS)  termp_em_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);          pair->flag |= ttypes[TTYPE_EMPH];
         return(1);          return(1);
 }  }
   
Line 1788  static int
Line 1776  static int
 termp_cd_pre(DECL_ARGS)  termp_cd_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CONFIG]);          pair->flag |= ttypes[TTYPE_CONFIG];
         term_newln(p);          term_newln(p);
         return(1);          return(1);
 }  }
Line 1799  static int
Line 1787  static int
 termp_cm_pre(DECL_ARGS)  termp_cm_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CMD_FLAG]);          pair->flag |= ttypes[TTYPE_CMD_FLAG];
         return(1);          return(1);
 }  }
   
Line 1809  static int
Line 1797  static int
 termp_ic_pre(DECL_ARGS)  termp_ic_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CMD]);          pair->flag |= ttypes[TTYPE_CMD];
         return(1);          return(1);
 }  }
   
Line 1819  static int
Line 1807  static int
 termp_in_pre(DECL_ARGS)  termp_in_pre(DECL_ARGS)
 {  {
   
         /* XXX This conforms to new-groff style. */          pair->flag |= ttypes[TTYPE_INCLUDE];
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_INCLUDE]);          p->flags |= ttypes[TTYPE_INCLUDE];
   
         if (SEC_SYNOPSIS == node->sec)          if (SEC_SYNOPSIS == node->sec)
                 term_word(p, "#include");                  term_word(p, "#include");
Line 1993  termp_bf_pre(DECL_ARGS)
Line 1981  termp_bf_pre(DECL_ARGS)
 {  {
         const struct mdoc_node  *n;          const struct mdoc_node  *n;
   
         if (MDOC_HEAD == node->type) {          if (MDOC_HEAD == node->type)
                 return(0);                  return(0);
         } else if (MDOC_BLOCK != node->type)          else if (MDOC_BLOCK != node->type)
                 return(1);                  return(1);
   
         if (NULL == (n = node->head->child)) {          if (NULL == (n = node->head->child)) {
                 if (arg_hasattr(MDOC_Emphasis, node))                  if (arg_hasattr(MDOC_Emphasis, node))
                         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);                          pair->flag |= ttypes[TTYPE_EMPH];
                 else if (arg_hasattr(MDOC_Symbolic, node))                  else if (arg_hasattr(MDOC_Symbolic, node))
                         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SYMB]);                          pair->flag |= ttypes[TTYPE_SYMB];
   
                 return(1);                  return(1);
         }          }
   
         assert(MDOC_TEXT == n->type);          assert(MDOC_TEXT == n->type);
         if (0 == strcmp("Em", n->string))          if (0 == strcmp("Em", n->string))
                 TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);                  pair->flag |= ttypes[TTYPE_EMPH];
         else if (0 == strcmp("Sy", n->string))          else if (0 == strcmp("Sy", n->string))
                 TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);                  pair->flag |= ttypes[TTYPE_SYMB];
   
         return(1);          return(1);
 }  }
Line 2022  static int
Line 2010  static int
 termp_sy_pre(DECL_ARGS)  termp_sy_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SYMB]);          pair->flag |= ttypes[TTYPE_SYMB];
         return(1);          return(1);
 }  }
   
Line 2032  static int
Line 2020  static int
 termp_ms_pre(DECL_ARGS)  termp_ms_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SYMBOL]);          pair->flag |= ttypes[TTYPE_SYMBOL];
         return(1);          return(1);
 }  }
   
Line 2071  static int
Line 2059  static int
 termp__j_pre(DECL_ARGS)  termp__j_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_REF_JOURNAL]);          pair->flag |= ttypes[TTYPE_REF_JOURNAL];
         return(1);          return(1);
 }  }
   
Line 2118  termp_lk_pre(DECL_ARGS)
Line 2106  termp_lk_pre(DECL_ARGS)
         n = node->child;          n = node->child;
   
         if (NULL == n->next) {          if (NULL == n->next) {
                 TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK_ANCHOR]);                  pair->flag |= ttypes[TTYPE_LINK_ANCHOR];
                 return(1);                  return(1);
         }          }
   
Line 2142  static int
Line 2130  static int
 termp_mt_pre(DECL_ARGS)  termp_mt_pre(DECL_ARGS)
 {  {
   
         TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK_ANCHOR]);          pair->flag |= ttypes[TTYPE_LINK_ANCHOR];
         return(1);          return(1);
 }  }
   

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

CVSweb