[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.175 and 1.187

version 1.175, 2015/04/04 17:47:18 version 1.187, 2016/01/08 17:48:09
Line 138  static const struct termact termacts[MAN_MAX] = {
Line 138  static const struct termact termacts[MAN_MAX] = {
   
   
 void  void
 terminal_man(void *arg, const struct man *man)  terminal_man(void *arg, const struct roff_man *man)
 {  {
         struct termp            *p;          struct termp            *p;
         const struct roff_meta  *meta;  
         struct roff_node        *n;          struct roff_node        *n;
         struct mtermp            mt;          struct mtermp            mt;
   
         p = (struct termp *)arg;          p = (struct termp *)arg;
   
         p->overstep = 0;          p->overstep = 0;
         p->rmargin = p->maxrmargin = p->defrmargin;          p->rmargin = p->maxrmargin = p->defrmargin;
         p->tabwidth = term_len(p, 5);          p->tabwidth = term_len(p, 5);
   
         n = man_node(man)->child;  
         meta = man_meta(man);  
   
         memset(&mt, 0, sizeof(struct mtermp));          memset(&mt, 0, sizeof(struct mtermp));
   
         mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);          mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
         mt.offset = term_len(p, p->defindent);          mt.offset = term_len(p, p->defindent);
         mt.pardist = 1;          mt.pardist = 1;
   
           n = man->first->child;
         if (p->synopsisonly) {          if (p->synopsisonly) {
                 while (n != NULL) {                  while (n != NULL) {
                         if (n->tok == MAN_SH &&                          if (n->tok == MAN_SH &&
Line 167  terminal_man(void *arg, const struct man *man)
Line 162  terminal_man(void *arg, const struct man *man)
                             !strcmp(n->child->child->string, "SYNOPSIS")) {                              !strcmp(n->child->child->string, "SYNOPSIS")) {
                                 if (n->child->next->child != NULL)                                  if (n->child->next->child != NULL)
                                         print_man_nodelist(p, &mt,                                          print_man_nodelist(p, &mt,
                                             n->child->next->child, meta);                                              n->child->next->child,
                                               &man->meta);
                                 term_newln(p);                                  term_newln(p);
                                 break;                                  break;
                         }                          }
Line 176  terminal_man(void *arg, const struct man *man)
Line 172  terminal_man(void *arg, const struct man *man)
         } else {          } else {
                 if (p->defindent == 0)                  if (p->defindent == 0)
                         p->defindent = 7;                          p->defindent = 7;
                 term_begin(p, print_man_head, print_man_foot, meta);                  term_begin(p, print_man_head, print_man_foot, &man->meta);
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
                 if (n != NULL)                  if (n != NULL)
                         print_man_nodelist(p, &mt, n, meta);                          print_man_nodelist(p, &mt, n, &man->meta);
                 term_end(p);                  term_end(p);
         }          }
 }  }
Line 216  static int
Line 212  static int
 pre_ign(DECL_ARGS)  pre_ign(DECL_ARGS)
 {  {
   
         return(0);          return 0;
 }  }
   
 static int  static int
 pre_ll(DECL_ARGS)  pre_ll(DECL_ARGS)
 {  {
   
         term_setwidth(p, n->nchild ? n->child->string : NULL);          term_setwidth(p, n->child != NULL ? n->child->string : NULL);
         return(0);          return 0;
 }  }
   
 static int  static int
Line 232  pre_I(DECL_ARGS)
Line 228  pre_I(DECL_ARGS)
 {  {
   
         term_fontrepl(p, TERMFONT_UNDER);          term_fontrepl(p, TERMFONT_UNDER);
         return(1);          return 1;
 }  }
   
 static int  static int
Line 259  pre_literal(DECL_ARGS)
Line 255  pre_literal(DECL_ARGS)
                 p->flags |= TERMP_NOSPACE;                  p->flags |= TERMP_NOSPACE;
         }          }
   
         return(0);          return 0;
 }  }
   
 static int  static int
Line 270  pre_PD(DECL_ARGS)
Line 266  pre_PD(DECL_ARGS)
         n = n->child;          n = n->child;
         if (n == NULL) {          if (n == NULL) {
                 mt->pardist = 1;                  mt->pardist = 1;
                 return(0);                  return 0;
         }          }
         assert(n->type == ROFFT_TEXT);          assert(n->type == ROFFT_TEXT);
         if (a2roffsu(n->string, &su, SCALE_VS))          if (a2roffsu(n->string, &su, SCALE_VS))
                 mt->pardist = term_vspan(p, &su);                  mt->pardist = term_vspan(p, &su);
         return(0);          return 0;
 }  }
   
 static int  static int
Line 321  pre_alternate(DECL_ARGS)
Line 317  pre_alternate(DECL_ARGS)
                 term_fontrepl(p, font[i]);                  term_fontrepl(p, font[i]);
                 if (savelit && NULL == nn->next)                  if (savelit && NULL == nn->next)
                         mt->fl |= MANT_LITERAL;                          mt->fl |= MANT_LITERAL;
                 print_man_node(p, mt, nn, meta);                  assert(nn->type == ROFFT_TEXT);
                   term_word(p, nn->string);
                   if (nn->flags & MAN_EOS)
                           p->flags |= TERMP_SENTENCE;
                 if (nn->next)                  if (nn->next)
                         p->flags |= TERMP_NOSPACE;                          p->flags |= TERMP_NOSPACE;
         }          }
   
         return(0);          return 0;
 }  }
   
 static int  static int
Line 334  pre_B(DECL_ARGS)
Line 333  pre_B(DECL_ARGS)
 {  {
   
         term_fontrepl(p, TERMFONT_BOLD);          term_fontrepl(p, TERMFONT_BOLD);
         return(1);          return 1;
 }  }
   
 static int  static int
Line 356  pre_OP(DECL_ARGS)
Line 355  pre_OP(DECL_ARGS)
         term_fontrepl(p, TERMFONT_NONE);          term_fontrepl(p, TERMFONT_NONE);
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
         term_word(p, "]");          term_word(p, "]");
         return(0);          return 0;
 }  }
   
 static int  static int
Line 366  pre_ft(DECL_ARGS)
Line 365  pre_ft(DECL_ARGS)
   
         if (NULL == n->child) {          if (NULL == n->child) {
                 term_fontlast(p);                  term_fontlast(p);
                 return(0);                  return 0;
         }          }
   
         cp = n->child->string;          cp = n->child->string;
         switch (*cp) {          switch (*cp) {
         case '4':          case '4':
                 /* FALLTHROUGH */  
         case '3':          case '3':
                 /* FALLTHROUGH */  
         case 'B':          case 'B':
                 term_fontrepl(p, TERMFONT_BOLD);                  term_fontrepl(p, TERMFONT_BOLD);
                 break;                  break;
         case '2':          case '2':
                 /* FALLTHROUGH */  
         case 'I':          case 'I':
                 term_fontrepl(p, TERMFONT_UNDER);                  term_fontrepl(p, TERMFONT_UNDER);
                 break;                  break;
Line 387  pre_ft(DECL_ARGS)
Line 383  pre_ft(DECL_ARGS)
                 term_fontlast(p);                  term_fontlast(p);
                 break;                  break;
         case '1':          case '1':
                 /* FALLTHROUGH */  
         case 'C':          case 'C':
                 /* FALLTHROUGH */  
         case 'R':          case 'R':
                 term_fontrepl(p, TERMFONT_NONE);                  term_fontrepl(p, TERMFONT_NONE);
                 break;                  break;
         default:          default:
                 break;                  break;
         }          }
         return(0);          return 0;
 }  }
   
 static int  static int
Line 411  pre_in(DECL_ARGS)
Line 405  pre_in(DECL_ARGS)
   
         if (NULL == n->child) {          if (NULL == n->child) {
                 p->offset = mt->offset;                  p->offset = mt->offset;
                 return(0);                  return 0;
         }          }
   
         cp = n->child->string;          cp = n->child->string;
Line 425  pre_in(DECL_ARGS)
Line 419  pre_in(DECL_ARGS)
                 cp--;                  cp--;
   
         if ( ! a2roffsu(++cp, &su, SCALE_EN))          if ( ! a2roffsu(++cp, &su, SCALE_EN))
                 return(0);                  return 0;
   
         v = (term_hspan(p, &su) + 11) / 24;          v = (term_hspan(p, &su) + 11) / 24;
   
Line 438  pre_in(DECL_ARGS)
Line 432  pre_in(DECL_ARGS)
         if (p->offset > SHRT_MAX)          if (p->offset > SHRT_MAX)
                 p->offset = term_len(p, p->defindent);                  p->offset = term_len(p, p->defindent);
   
         return(0);          return 0;
 }  }
   
 static int  static int
Line 450  pre_sp(DECL_ARGS)
Line 444  pre_sp(DECL_ARGS)
         if ((NULL == n->prev && n->parent)) {          if ((NULL == n->prev && n->parent)) {
                 switch (n->parent->tok) {                  switch (n->parent->tok) {
                 case MAN_SH:                  case MAN_SH:
                         /* FALLTHROUGH */  
                 case MAN_SS:                  case MAN_SS:
                         /* FALLTHROUGH */  
                 case MAN_PP:                  case MAN_PP:
                         /* FALLTHROUGH */  
                 case MAN_LP:                  case MAN_LP:
                         /* FALLTHROUGH */  
                 case MAN_P:                  case MAN_P:
                         /* FALLTHROUGH */                          return 0;
                         return(0);  
                 default:                  default:
                         break;                          break;
                 }                  }
Line 483  pre_sp(DECL_ARGS)
Line 472  pre_sp(DECL_ARGS)
                 for (i = 0; i < len; i++)                  for (i = 0; i < len; i++)
                         term_vspace(p);                          term_vspace(p);
   
         return(0);          /*
            * Handle an explicit break request in the same way
            * as an overflowing line.
            */
   
           if (p->flags & TERMP_BRIND) {
                   p->offset = p->rmargin;
                   p->rmargin = p->maxrmargin;
                   p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
           }
   
           return 0;
 }  }
   
 static int  static int
Line 496  pre_HP(DECL_ARGS)
Line 496  pre_HP(DECL_ARGS)
         switch (n->type) {          switch (n->type) {
         case ROFFT_BLOCK:          case ROFFT_BLOCK:
                 print_bvspace(p, n, mt->pardist);                  print_bvspace(p, n, mt->pardist);
                 return(1);                  return 1;
         case ROFFT_BODY:          case ROFFT_BODY:
                 break;                  break;
         default:          default:
                 return(0);                  return 0;
         }          }
   
         if ( ! (MANT_LITERAL & mt->fl)) {          if ( ! (MANT_LITERAL & mt->fl)) {
Line 523  pre_HP(DECL_ARGS)
Line 523  pre_HP(DECL_ARGS)
   
         p->offset = mt->offset;          p->offset = mt->offset;
         p->rmargin = mt->offset + len;          p->rmargin = mt->offset + len;
         return(1);          return 1;
 }  }
   
 static void  static void
Line 568  pre_PP(DECL_ARGS)
Line 568  pre_PP(DECL_ARGS)
                 break;                  break;
         }          }
   
         return(n->type != ROFFT_HEAD);          return n->type != ROFFT_HEAD;
 }  }
   
 static int  static int
Line 590  pre_IP(DECL_ARGS)
Line 590  pre_IP(DECL_ARGS)
                 print_bvspace(p, n, mt->pardist);                  print_bvspace(p, n, mt->pardist);
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         default:          default:
                 return(1);                  return 1;
         }          }
   
         /* Calculate the offset from the optional second argument. */          /* Calculate the offset from the optional second argument. */
Line 620  pre_IP(DECL_ARGS)
Line 620  pre_IP(DECL_ARGS)
                 if (savelit)                  if (savelit)
                         mt->fl |= MANT_LITERAL;                          mt->fl |= MANT_LITERAL;
   
                 return(0);                  return 0;
         case ROFFT_BODY:          case ROFFT_BODY:
                 p->offset = mt->offset + len;                  p->offset = mt->offset + len;
                 p->rmargin = p->maxrmargin;                  p->rmargin = p->maxrmargin;
Line 629  pre_IP(DECL_ARGS)
Line 629  pre_IP(DECL_ARGS)
                 break;                  break;
         }          }
   
         return(1);          return 1;
 }  }
   
 static void  static void
Line 661  pre_TP(DECL_ARGS)
Line 661  pre_TP(DECL_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case ROFFT_HEAD:          case ROFFT_HEAD:
                 p->flags |= TERMP_NOBREAK;                  p->flags |= TERMP_NOBREAK | TERMP_BRTRSP;
                 p->trailspace = 1;                  p->trailspace = 1;
                 break;                  break;
         case ROFFT_BODY:          case ROFFT_BODY:
Line 671  pre_TP(DECL_ARGS)
Line 671  pre_TP(DECL_ARGS)
                 print_bvspace(p, n, mt->pardist);                  print_bvspace(p, n, mt->pardist);
                 /* FALLTHROUGH */                  /* FALLTHROUGH */
         default:          default:
                 return(1);                  return 1;
         }          }
   
         /* Calculate offset. */          /* Calculate offset. */
Line 708  pre_TP(DECL_ARGS)
Line 708  pre_TP(DECL_ARGS)
   
                 if (savelit)                  if (savelit)
                         mt->fl |= MANT_LITERAL;                          mt->fl |= MANT_LITERAL;
                 return(0);                  return 0;
         case ROFFT_BODY:          case ROFFT_BODY:
                 p->offset = mt->offset + len;                  p->offset = mt->offset + len;
                 p->rmargin = p->maxrmargin;                  p->rmargin = p->maxrmargin;
                 p->trailspace = 0;                  p->trailspace = 0;
                 p->flags &= ~TERMP_NOBREAK;                  p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP);
                 break;                  break;
         default:          default:
                 break;                  break;
         }          }
   
         return(1);          return 1;
 }  }
   
 static void  static void
Line 757  pre_SS(DECL_ARGS)
Line 757  pre_SS(DECL_ARGS)
   
                 do {                  do {
                         n = n->prev;                          n = n->prev;
                 } while (n != NULL && n->tok != MAN_MAX &&                  } while (n != NULL && n->tok != TOKEN_NONE &&
                     termacts[n->tok].flags & MAN_NOTEXT);                      termacts[n->tok].flags & MAN_NOTEXT);
                 if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL))                  if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL))
                         break;                          break;
Line 768  pre_SS(DECL_ARGS)
Line 768  pre_SS(DECL_ARGS)
         case ROFFT_HEAD:          case ROFFT_HEAD:
                 term_fontrepl(p, TERMFONT_BOLD);                  term_fontrepl(p, TERMFONT_BOLD);
                 p->offset = term_len(p, 3);                  p->offset = term_len(p, 3);
                   p->rmargin = mt->offset;
                   p->trailspace = mt->offset;
                   p->flags |= TERMP_NOBREAK | TERMP_BRIND;
                 break;                  break;
         case ROFFT_BODY:          case ROFFT_BODY:
                 p->offset = mt->offset;                  p->offset = mt->offset;
                   p->rmargin = p->maxrmargin;
                   p->trailspace = 0;
                   p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
                 break;                  break;
         default:          default:
                 break;                  break;
         }          }
   
         return(1);          return 1;
 }  }
   
 static void  static void
Line 823  pre_SH(DECL_ARGS)
Line 829  pre_SH(DECL_ARGS)
         case ROFFT_HEAD:          case ROFFT_HEAD:
                 term_fontrepl(p, TERMFONT_BOLD);                  term_fontrepl(p, TERMFONT_BOLD);
                 p->offset = 0;                  p->offset = 0;
                   p->rmargin = mt->offset;
                   p->trailspace = mt->offset;
                   p->flags |= TERMP_NOBREAK | TERMP_BRIND;
                 break;                  break;
         case ROFFT_BODY:          case ROFFT_BODY:
                 p->offset = mt->offset;                  p->offset = mt->offset;
                   p->rmargin = p->maxrmargin;
                   p->trailspace = 0;
                   p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
                 break;                  break;
         default:          default:
                 break;                  break;
         }          }
   
         return(1);          return 1;
 }  }
   
 static void  static void
Line 858  pre_RS(DECL_ARGS)
Line 870  pre_RS(DECL_ARGS)
         switch (n->type) {          switch (n->type) {
         case ROFFT_BLOCK:          case ROFFT_BLOCK:
                 term_newln(p);                  term_newln(p);
                 return(1);                  return 1;
         case ROFFT_HEAD:          case ROFFT_HEAD:
                 return(0);                  return 0;
         default:          default:
                 break;                  break;
         }          }
   
         n = n->parent->head;          n = n->parent->head;
         n->aux = SHRT_MAX + 1;          n->aux = SHRT_MAX + 1;
         if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EN))          if (n->child == NULL)
                   n->aux = mt->lmargin[mt->lmargincur];
           else if (a2roffsu(n->child->string, &su, SCALE_EN))
                 n->aux = term_hspan(p, &su) / 24;                  n->aux = term_hspan(p, &su) / 24;
         if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)          if (n->aux < 0 && (size_t)(-n->aux) > mt->offset)
                 n->aux = -mt->offset;                  n->aux = -mt->offset;
Line 881  pre_RS(DECL_ARGS)
Line 895  pre_RS(DECL_ARGS)
         if (++mt->lmarginsz < MAXMARGINS)          if (++mt->lmarginsz < MAXMARGINS)
                 mt->lmargincur = mt->lmarginsz;                  mt->lmargincur = mt->lmarginsz;
   
         mt->lmargin[mt->lmargincur] = mt->lmargin[mt->lmargincur - 1];          mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
         return(1);          return 1;
 }  }
   
 static void  static void
Line 910  static int
Line 924  static int
 pre_UR(DECL_ARGS)  pre_UR(DECL_ARGS)
 {  {
   
         return (n->type != ROFFT_HEAD);          return n->type != ROFFT_HEAD;
 }  }
   
 static void  static void

Legend:
Removed from v.1.175  
changed lines
  Added in v.1.187

CVSweb