[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.47 and 1.52

version 1.47, 2009/07/19 08:24:16 version 1.52, 2009/07/21 13:45:04
Line 27 
Line 27 
 #include "mdoc.h"  #include "mdoc.h"
   
 /* FIXME: macro arguments can be escaped. */  /* FIXME: macro arguments can be escaped. */
 /* FIXME: support more offset/width tokens. */  
   
 #define TTYPE_PROG        0  #define TTYPE_PROG        0
 #define TTYPE_CMD_FLAG    1  #define TTYPE_CMD_FLAG    1
Line 66  const int ttypes[TTYPE_NMAX] = {
Line 65  const int ttypes[TTYPE_NMAX] = {
         TERMP_UNDER,            /* TTYPE_FUNC_ARG */          TERMP_UNDER,            /* TTYPE_FUNC_ARG */
         TERMP_UNDER,            /* TTYPE_LINK */          TERMP_UNDER,            /* TTYPE_LINK */
         TERMP_BOLD,             /* TTYPE_SSECTION */          TERMP_BOLD,             /* TTYPE_SSECTION */
         TERMP_UNDER,            /* TTYPE_FILE */          0,                      /* TTYPE_FILE */
         TERMP_UNDER,            /* TTYPE_EMPH */          TERMP_UNDER,            /* TTYPE_EMPH */
         TERMP_BOLD,             /* TTYPE_CONFIG */          TERMP_BOLD,             /* TTYPE_CONFIG */
         TERMP_BOLD,             /* TTYPE_CMD */          TERMP_BOLD,             /* TTYPE_CMD */
Line 155  static int   termp_nd_pre(DECL_ARGS);
Line 154  static int   termp_nd_pre(DECL_ARGS);
 static  int       termp_nm_pre(DECL_ARGS);  static  int       termp_nm_pre(DECL_ARGS);
 static  int       termp_ns_pre(DECL_ARGS);  static  int       termp_ns_pre(DECL_ARGS);
 static  int       termp_op_pre(DECL_ARGS);  static  int       termp_op_pre(DECL_ARGS);
 static  int       termp_pa_pre(DECL_ARGS);  
 static  int       termp_pf_pre(DECL_ARGS);  static  int       termp_pf_pre(DECL_ARGS);
 static  int       termp_pp_pre(DECL_ARGS);  static  int       termp_pp_pre(DECL_ARGS);
 static  int       termp_pq_pre(DECL_ARGS);  static  int       termp_pq_pre(DECL_ARGS);
Line 211  static const struct termact termacts[MDOC_MAX] = {
Line 209  static const struct termact termacts[MDOC_MAX] = {
         { termp_nm_pre, NULL }, /* Nm */          { termp_nm_pre, NULL }, /* Nm */
         { termp_op_pre, termp_op_post }, /* Op */          { termp_op_pre, termp_op_post }, /* Op */
         { NULL, NULL }, /* Ot */          { NULL, NULL }, /* Ot */
         { termp_pa_pre, NULL }, /* Pa */          { NULL, NULL }, /* Pa */
         { termp_rv_pre, NULL }, /* Rv */          { termp_rv_pre, NULL }, /* Rv */
         { NULL, NULL }, /* St */          { NULL, NULL }, /* St */
         { termp_va_pre, NULL }, /* Va */          { termp_va_pre, NULL }, /* Va */
Line 672  fmt_block_vspace(struct termp *p, 
Line 670  fmt_block_vspace(struct termp *p, 
   
         if (arg_hasattr(MDOC_Compact, bl))          if (arg_hasattr(MDOC_Compact, bl))
                 return(1);                  return(1);
           /* XXX - not documented! */
           else if (arg_hasattr(MDOC_Column, bl))
                   return(1);
   
         for (n = node; n; n = n->parent) {          for (n = node; n; n = n->parent) {
                 if (MDOC_BLOCK != n->type)                  if (MDOC_BLOCK != n->type)
Line 795  termp_it_pre(DECL_ARGS)
Line 796  termp_it_pre(DECL_ARGS)
                 if (0 == width)                  if (0 == width)
                         width = 8;                          width = 8;
                 break;                  break;
           case (MDOC_Column):
                   /* FALLTHROUGH */
         case (MDOC_Tag):          case (MDOC_Tag):
                 if (0 == width)                  if (0 == width)
                         width = 10;                          width = 10;
Line 808  termp_it_pre(DECL_ARGS)
Line 811  termp_it_pre(DECL_ARGS)
          * while diagonal bodies need two.           * while diagonal bodies need two.
          */           */
   
           p->flags |= TERMP_NOSPACE;
   
         switch (type) {          switch (type) {
           case (MDOC_Diag):
                   term_word(p, "\\ \\ ");
                   break;
         case (MDOC_Inset):          case (MDOC_Inset):
                 if (MDOC_BODY == node->type)                  if (MDOC_BODY == node->type)
                         p->flags &= ~TERMP_NOSPACE;                          term_word(p, "\\ ");
                 else  
                         p->flags |= TERMP_NOSPACE;  
                 break;                  break;
         default:          default:
                 p->flags |= TERMP_NOSPACE;  
                 break;                  break;
         }          }
   
           p->flags |= TERMP_NOSPACE;
   
         /*          /*
          * Style flags.  Diagnostic heads need TTYPE_DIAG.           * Style flags.  Diagnostic heads need TTYPE_DIAG.
          */           */
Line 865  termp_it_pre(DECL_ARGS)
Line 872  termp_it_pre(DECL_ARGS)
                 break;                  break;
         case (MDOC_Tag):          case (MDOC_Tag):
                 if (MDOC_HEAD == node->type)                  if (MDOC_HEAD == node->type)
                         p->flags |= TERMP_NOBREAK;                          p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE;
                 else                  else
                         p->flags |= TERMP_NOLPAD;                          p->flags |= TERMP_NOLPAD;
   
Line 913  termp_it_pre(DECL_ARGS)
Line 920  termp_it_pre(DECL_ARGS)
         case (MDOC_Hang):          case (MDOC_Hang):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Tag):          case (MDOC_Tag):
                   assert(width);
                 if (MDOC_HEAD == node->type)                  if (MDOC_HEAD == node->type)
                         p->rmargin = p->offset + width;                          p->rmargin = p->offset + width;
                 else                  else
                         p->offset += width;                          p->offset += width;
                 break;                  break;
         case (MDOC_Column):          case (MDOC_Column):
                   assert(width);
                 p->rmargin = p->offset + width;                  p->rmargin = p->offset + width;
                   /*
                    * XXX - this behaviour is not documented: the
                    * right-most column is filled to the right margin.
                    */
                   if (MDOC_HEAD == node->type &&
                                   MDOC_BODY == node->next->type)
                           p->rmargin = p->maxrmargin;
                 break;                  break;
         default:          default:
                 break;                  break;
Line 996  termp_it_post(DECL_ARGS)
Line 1012  termp_it_post(DECL_ARGS)
         assert(-1 != type);          assert(-1 != type);
   
         switch (type) {          switch (type) {
         case (MDOC_Diag):  
                 term_word(p, "\\ ");  
                 /* FALLTHROUGH */  
         case (MDOC_Item):          case (MDOC_Item):
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         case (MDOC_Inset):          case (MDOC_Inset):
Line 1742  termp_ss_post(DECL_ARGS)
Line 1755  termp_ss_post(DECL_ARGS)
   
         if (MDOC_HEAD == node->type)          if (MDOC_HEAD == node->type)
                 term_newln(p);                  term_newln(p);
 }  
   
   
 /* ARGSUSED */  
 static int  
 termp_pa_pre(DECL_ARGS)  
 {  
   
         pair->flag |= ttypes[TTYPE_FILE];  
         return(1);  
 }  }
   
   

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.52

CVSweb