[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.117 and 1.118

version 1.117, 2010/04/08 08:17:55 version 1.118, 2010/05/09 16:05:13
Line 22 
Line 22 
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
   #include <stdint.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
Line 58  static int   arg_hasattr(int, const struct mdoc_node *
Line 59  static int   arg_hasattr(int, const struct mdoc_node *
 static  int       arg_getattrs(const int *, int *, size_t,  static  int       arg_getattrs(const int *, int *, size_t,
                         const struct mdoc_node *);                          const struct mdoc_node *);
 static  int       arg_getattr(int, const struct mdoc_node *);  static  int       arg_getattr(int, const struct mdoc_node *);
   static  int       arg_disptype(const struct mdoc_node *);
 static  int       arg_listtype(const struct mdoc_node *);  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 *,
Line 478  a2width(const struct mdoc_argv *arg, int pos)
Line 480  a2width(const struct mdoc_argv *arg, int pos)
   
   
 static int  static int
   arg_disptype(const struct mdoc_node *n)
   {
           int              i, len;
   
           assert(MDOC_BLOCK == n->type);
   
           len = (int)(n->args ? n->args->argc : 0);
   
           for (i = 0; i < len; i++)
                   switch (n->args->argv[i].arg) {
                   case (MDOC_Centred):
                           /* FALLTHROUGH */
                   case (MDOC_Ragged):
                           /* FALLTHROUGH */
                   case (MDOC_Filled):
                           /* FALLTHROUGH */
                   case (MDOC_Unfilled):
                           /* FALLTHROUGH */
                   case (MDOC_Literal):
                           return(n->args->argv[i].arg);
                   default:
                           break;
                   }
   
           return(-1);
   }
   
   
   static int
 arg_listtype(const struct mdoc_node *n)  arg_listtype(const struct mdoc_node *n)
 {  {
         int              i, len;          int              i, len;
Line 1126  termp_an_post(DECL_ARGS)
Line 1157  termp_an_post(DECL_ARGS)
                 return;                  return;
         }          }
   
         if (arg_getattr(MDOC_Split, n) > -1) {          if (arg_hasattr(MDOC_Split, n)) {
                 p->flags &= ~TERMP_NOSPLIT;                  p->flags &= ~TERMP_NOSPLIT;
                 p->flags |= TERMP_SPLIT;                  p->flags |= TERMP_SPLIT;
         } else {          } else {
Line 1598  static int
Line 1629  static int
 termp_bd_pre(DECL_ARGS)  termp_bd_pre(DECL_ARGS)
 {  {
         int                      i, type;          int                      i, type;
           size_t                   sv;
         const struct mdoc_node  *nn;          const struct mdoc_node  *nn;
   
         if (MDOC_BLOCK == n->type) {          if (MDOC_BLOCK == n->type) {
Line 1608  termp_bd_pre(DECL_ARGS)
Line 1640  termp_bd_pre(DECL_ARGS)
   
         nn = n->parent;          nn = n->parent;
   
         for (type = -1, i = 0; i < (int)nn->args->argc; i++) {          type = arg_disptype(nn);
                 switch (nn->args->argv[i].arg) {          assert(-1 != type);
                 case (MDOC_Centred):  
                         /* FALLTHROUGH */  
                 case (MDOC_Ragged):  
                         /* FALLTHROUGH */  
                 case (MDOC_Filled):  
                         /* FALLTHROUGH */  
                 case (MDOC_Unfilled):  
                         /* FALLTHROUGH */  
                 case (MDOC_Literal):  
                         type = nn->args->argv[i].arg;  
                         break;  
                 case (MDOC_Offset):  
                         p->offset += a2offs(&nn->args->argv[i]);  
                         break;  
                 default:  
                         break;  
                 }  
         }  
   
           if (-1 != (i = arg_getattr(MDOC_Offset, nn)))
                   p->offset += a2offs(&nn->args->argv[i]);
   
         /*          /*
          * If -ragged or -filled are specified, the block does nothing           * If -ragged or -filled are specified, the block does nothing
          * but change the indentation.  If -unfilled or -literal are           * but change the indentation.  If -unfilled or -literal are
Line 1637  termp_bd_pre(DECL_ARGS)
Line 1654  termp_bd_pre(DECL_ARGS)
          * lines are allowed.           * lines are allowed.
          */           */
   
         assert(type > -1);  
         if (MDOC_Literal != type && MDOC_Unfilled != type)          if (MDOC_Literal != type && MDOC_Unfilled != type)
                 return(1);                  return(1);
   
           sv = p->rmargin;
           p->rmargin = 100000; /* FIXME */
   
         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_mdoc_node(p, pair, m, nn);                  print_mdoc_node(p, pair, m, nn);
Line 1652  termp_bd_pre(DECL_ARGS)
Line 1671  termp_bd_pre(DECL_ARGS)
                         term_flushln(p);                          term_flushln(p);
         }          }
   
           p->rmargin = sv;
         return(0);          return(0);
 }  }
   
Line 1660  termp_bd_pre(DECL_ARGS)
Line 1680  termp_bd_pre(DECL_ARGS)
 static void  static void
 termp_bd_post(DECL_ARGS)  termp_bd_post(DECL_ARGS)
 {  {
           int              type;
           size_t           sv;
   
         if (MDOC_BODY != n->type)          if (MDOC_BODY != n->type)
                 return;                  return;
   
           type = arg_disptype(n->parent);
           assert(-1 != type);
   
           sv = p->rmargin;
   
           if (MDOC_Literal == type || MDOC_Unfilled == type)
                   p->rmargin = 100000; /* FIXME */
   
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         term_flushln(p);          term_flushln(p);
   
           p->rmargin = sv;
 }  }
   
   

Legend:
Removed from v.1.117  
changed lines
  Added in v.1.118

CVSweb