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

Diff for /mandoc/man_term.c between version 1.163 and 1.167

version 1.163, 2014/12/23 13:48:57 version 1.167, 2015/01/30 17:32:16
Line 21 
Line 21 
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
   #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
Line 46  struct mtermp {
Line 47  struct mtermp {
   
 #define DECL_ARGS         struct termp *p, \  #define DECL_ARGS         struct termp *p, \
                           struct mtermp *mt, \                            struct mtermp *mt, \
                           const struct man_node *n, \                            struct man_node *n, \
                           const struct man_meta *meta                            const struct man_meta *meta
   
 struct  termact {  struct  termact {
Line 113  static const struct termact termacts[MAN_MAX] = {
Line 114  static const struct termact termacts[MAN_MAX] = {
         { pre_I, NULL, 0 }, /* I */          { pre_I, NULL, 0 }, /* I */
         { pre_alternate, NULL, 0 }, /* IR */          { pre_alternate, NULL, 0 }, /* IR */
         { pre_alternate, NULL, 0 }, /* RI */          { pre_alternate, NULL, 0 }, /* RI */
         { pre_ign, NULL, MAN_NOTEXT }, /* na */  
         { pre_sp, NULL, MAN_NOTEXT }, /* sp */          { pre_sp, NULL, MAN_NOTEXT }, /* sp */
         { pre_literal, NULL, 0 }, /* nf */          { pre_literal, NULL, 0 }, /* nf */
         { pre_literal, NULL, 0 }, /* fi */          { pre_literal, NULL, 0 }, /* fi */
Line 279  static int
Line 279  static int
 pre_alternate(DECL_ARGS)  pre_alternate(DECL_ARGS)
 {  {
         enum termfont            font[2];          enum termfont            font[2];
         const struct man_node   *nn;          struct man_node         *nn;
         int                      savelit, i;          int                      savelit, i;
   
         switch (n->tok) {          switch (n->tok) {
Line 432  pre_in(DECL_ARGS)
Line 432  pre_in(DECL_ARGS)
                 p->offset += v;                  p->offset += v;
         else          else
                 p->offset = v;                  p->offset = v;
           if (p->offset > SHRT_MAX)
                   p->offset = term_len(p, p->defindent);
   
         return(0);          return(0);
 }  }
Line 508  pre_HP(DECL_ARGS)
Line 510  pre_HP(DECL_ARGS)
         if ((nn = n->parent->head->child) != NULL &&          if ((nn = n->parent->head->child) != NULL &&
             a2roffsu(nn->string, &su, SCALE_EN)) {              a2roffsu(nn->string, &su, SCALE_EN)) {
                 len = term_hspan(p, &su);                  len = term_hspan(p, &su);
                   if (len < 0 && (size_t)(-len) > mt->offset)
                           len = -mt->offset;
                   else if (len > SHRT_MAX)
                           len = term_len(p, p->defindent);
                 mt->lmargin[mt->lmargincur] = len;                  mt->lmargin[mt->lmargincur] = len;
         } else          } else
                 len = mt->lmargin[mt->lmargincur];                  len = mt->lmargin[mt->lmargincur];
   
         p->offset = mt->offset;          p->offset = mt->offset;
         if (len > 0 || (size_t)(-len) < mt->offset)          p->rmargin = mt->offset + len;
                 p->rmargin = mt->offset + len;  
         else  
                 p->rmargin = 0;  
   
         return(1);          return(1);
 }  }
   
Line 582  pre_IP(DECL_ARGS)
Line 584  pre_IP(DECL_ARGS)
             (nn = nn->next) != NULL &&              (nn = nn->next) != NULL &&
             a2roffsu(nn->string, &su, SCALE_EN)) {              a2roffsu(nn->string, &su, SCALE_EN)) {
                 len = term_hspan(p, &su);                  len = term_hspan(p, &su);
                 mt->lmargin[mt->lmargincur] = len;  
                 if (len < 0 && (size_t)(-len) > mt->offset)                  if (len < 0 && (size_t)(-len) > mt->offset)
                         len = -mt->offset;                          len = -mt->offset;
                   else if (len > SHRT_MAX)
                           len = term_len(p, p->defindent);
                   mt->lmargin[mt->lmargincur] = len;
         } else          } else
                 len = mt->lmargin[mt->lmargincur];                  len = mt->lmargin[mt->lmargincur];
   
Line 638  static int
Line 642  static int
 pre_TP(DECL_ARGS)  pre_TP(DECL_ARGS)
 {  {
         struct roffsu            su;          struct roffsu            su;
         const struct man_node   *nn;          struct man_node         *nn;
         int                      len, savelit;          int                      len, savelit;
   
         switch (n->type) {          switch (n->type) {
Line 662  pre_TP(DECL_ARGS)
Line 666  pre_TP(DECL_ARGS)
             nn->string != NULL && ! (MAN_LINE & nn->flags) &&              nn->string != NULL && ! (MAN_LINE & nn->flags) &&
             a2roffsu(nn->string, &su, SCALE_EN)) {              a2roffsu(nn->string, &su, SCALE_EN)) {
                 len = term_hspan(p, &su);                  len = term_hspan(p, &su);
                 mt->lmargin[mt->lmargincur] = len;  
                 if (len < 0 && (size_t)(-len) > mt->offset)                  if (len < 0 && (size_t)(-len) > mt->offset)
                         len = -mt->offset;                          len = -mt->offset;
                   else if (len > SHRT_MAX)
                           len = term_len(p, p->defindent);
                   mt->lmargin[mt->lmargincur] = len;
         } else          } else
                 len = mt->lmargin[mt->lmargincur];                  len = mt->lmargin[mt->lmargincur];
   
Line 833  static int
Line 839  static int
 pre_RS(DECL_ARGS)  pre_RS(DECL_ARGS)
 {  {
         struct roffsu    su;          struct roffsu    su;
         int              len;  
   
         switch (n->type) {          switch (n->type) {
         case MAN_BLOCK:          case MAN_BLOCK:
Line 845  pre_RS(DECL_ARGS)
Line 850  pre_RS(DECL_ARGS)
                 break;                  break;
         }          }
   
         if ((n = n->parent->head->child) != NULL &&          n = n->parent->head;
             a2roffsu(n->string, &su, SCALE_EN))          n->aux = SHRT_MAX + 1;
                 len = term_hspan(p, &su);          if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EN))
         else                  n->aux = term_hspan(p, &su);
                 len = term_len(p, p->defindent);          if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
                   n->aux = -mt->offset;
           else if (n->aux > SHRT_MAX)
                   n->aux = term_len(p, p->defindent);
   
         if (len > 0 || (size_t)(-len) < mt->offset)          mt->offset += n->aux;
                 mt->offset += len;  
         else  
                 mt->offset = 0;  
         p->offset = mt->offset;          p->offset = mt->offset;
         p->rmargin = p->maxrmargin;          p->rmargin = p->maxrmargin;
   
Line 868  pre_RS(DECL_ARGS)
Line 873  pre_RS(DECL_ARGS)
 static void  static void
 post_RS(DECL_ARGS)  post_RS(DECL_ARGS)
 {  {
         struct roffsu    su;  
         int              len;  
   
         switch (n->type) {          switch (n->type) {
         case MAN_BLOCK:          case MAN_BLOCK:
Line 881  post_RS(DECL_ARGS)
Line 884  post_RS(DECL_ARGS)
                 break;                  break;
         }          }
   
         if ((n = n->parent->head->child) != NULL &&          mt->offset -= n->parent->head->aux;
             a2roffsu(n->string, &su, SCALE_EN))  
                 len = term_hspan(p, &su);  
         else  
                 len = term_len(p, p->defindent);  
   
         if (len < 0 || (size_t)len < mt->offset)  
                 mt->offset -= len;  
         else  
                 mt->offset = 0;  
         p->offset = mt->offset;          p->offset = mt->offset;
   
         if (--mt->lmarginsz < MAXMARGINS)          if (--mt->lmarginsz < MAXMARGINS)
Line 955  print_man_node(DECL_ARGS)
Line 949  print_man_node(DECL_ARGS)
                  * Tables are preceded by a newline.  Then process a                   * Tables are preceded by a newline.  Then process a
                  * table line, which will cause line termination,                   * table line, which will cause line termination,
                  */                   */
                 if (TBL_SPAN_FIRST & n->span->flags)                  if (n->span->prev == NULL)
                         term_newln(p);                          term_newln(p);
                 term_tbl(p, n->span);                  term_tbl(p, n->span);
                 return;                  return;

Legend:
Removed from v.1.163  
changed lines
  Added in v.1.167

CVSweb