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

Diff for /mandoc/term.c between version 1.251 and 1.258

version 1.251, 2015/09/26 00:54:04 version 1.258, 2016/08/10 11:03:43
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 160  term_flushln(struct termp *p)
Line 160  term_flushln(struct termp *p)
                         if (' ' == p->buf[j] || '\t' == p->buf[j])                          if (' ' == p->buf[j] || '\t' == p->buf[j])
                                 break;                                  break;
   
                         /* Back over the the last printed character. */                          /* Back over the last printed character. */
                         if (8 == p->buf[j]) {                          if (8 == p->buf[j]) {
                                 assert(j);                                  assert(j);
                                 vend -= (*p->width)(p, p->buf[j - 1]);                                  vend -= (*p->width)(p, p->buf[j - 1]);
Line 365  term_fontpush(struct termp *p, enum termfont f)
Line 365  term_fontpush(struct termp *p, enum termfont f)
         if (++p->fonti == p->fontsz) {          if (++p->fonti == p->fontsz) {
                 p->fontsz += 8;                  p->fontsz += 8;
                 p->fontq = mandoc_reallocarray(p->fontq,                  p->fontq = mandoc_reallocarray(p->fontq,
                     p->fontsz, sizeof(enum termfont *));                      p->fontsz, sizeof(*p->fontq));
         }          }
         p->fontq[p->fonti] = f;          p->fontq[p->fonti] = f;
 }  }
Line 454  term_word(struct termp *p, const char *word)
Line 454  term_word(struct termp *p, const char *word)
                         break;                          break;
                 case ESCAPE_SPECIAL:                  case ESCAPE_SPECIAL:
                         if (p->enc == TERMENC_ASCII) {                          if (p->enc == TERMENC_ASCII) {
                                 cp = mchars_spec2str(p->symtab,                                  cp = mchars_spec2str(seq, sz, &ssz);
                                     seq, sz, &ssz);  
                                 if (cp != NULL)                                  if (cp != NULL)
                                         encode(p, cp, ssz);                                          encode(p, cp, ssz);
                         } else {                          } else {
                                 uc = mchars_spec2cp(p->symtab, seq, sz);                                  uc = mchars_spec2cp(seq, sz);
                                 if (uc > 0)                                  if (uc > 0)
                                         encode1(p, uc);                                          encode1(p, uc);
                         }                          }
Line 474  term_word(struct termp *p, const char *word)
Line 473  term_word(struct termp *p, const char *word)
                         term_fontrepl(p, TERMFONT_BI);                          term_fontrepl(p, TERMFONT_BI);
                         continue;                          continue;
                 case ESCAPE_FONT:                  case ESCAPE_FONT:
                         /* FALLTHROUGH */  
                 case ESCAPE_FONTROMAN:                  case ESCAPE_FONTROMAN:
                         term_fontrepl(p, TERMFONT_NONE);                          term_fontrepl(p, TERMFONT_NONE);
                         continue;                          continue;
Line 506  term_word(struct termp *p, const char *word)
Line 504  term_word(struct termp *p, const char *word)
                                 }                                  }
                         }                          }
                         /* Trim trailing backspace/blank pair. */                          /* Trim trailing backspace/blank pair. */
                         if (p->col > 2 && p->buf[p->col - 1] == ' ')                          if (p->col > 2 &&
                               (p->buf[p->col - 1] == ' ' ||
                                p->buf[p->col - 1] == '\t'))
                                 p->col -= 2;                                  p->col -= 2;
                         continue;                          continue;
                 default:                  default:
Line 566  encode1(struct termp *p, int c)
Line 566  encode1(struct termp *p, int c)
         if (p->col + 7 >= p->maxcols)          if (p->col + 7 >= p->maxcols)
                 adjbuf(p, p->col + 7);                  adjbuf(p, p->col + 7);
   
         f = (c == ASCII_HYPH || isgraph(c)) ?          f = (c == ASCII_HYPH || c > 127 || isgraph(c)) ?
             p->fontq[p->fonti] : TERMFONT_NONE;              p->fontq[p->fonti] : TERMFONT_NONE;
   
         if (p->flags & TERMP_BACKBEFORE) {          if (p->flags & TERMP_BACKBEFORE) {
                 if (p->buf[p->col - 1] == ' ')                  if (p->buf[p->col - 1] == ' ' || p->buf[p->col - 1] == '\t')
                         p->col--;                          p->col--;
                 else                  else
                         p->buf[p->col++] = 8;                          p->buf[p->col++] = 8;
Line 644  size_t
Line 644  size_t
 term_len(const struct termp *p, size_t sz)  term_len(const struct termp *p, size_t sz)
 {  {
   
         return((*p->width)(p, ' ') * sz);          return (*p->width)(p, ' ') * sz;
 }  }
   
 static size_t  static size_t
Line 653  cond_width(const struct termp *p, int c, int *skip)
Line 653  cond_width(const struct termp *p, int c, int *skip)
   
         if (*skip) {          if (*skip) {
                 (*skip) = 0;                  (*skip) = 0;
                 return(0);                  return 0;
         } else          } else
                 return((*p->width)(p, c));                  return (*p->width)(p, c);
 }  }
   
 size_t  size_t
Line 701  term_strlen(const struct termp *p, const char *cp)
Line 701  term_strlen(const struct termp *p, const char *cp)
                                 break;                                  break;
                         case ESCAPE_SPECIAL:                          case ESCAPE_SPECIAL:
                                 if (p->enc == TERMENC_ASCII) {                                  if (p->enc == TERMENC_ASCII) {
                                         rhs = mchars_spec2str(p->symtab,                                          rhs = mchars_spec2str(seq, ssz, &rsz);
                                             seq, ssz, &rsz);  
                                         if (rhs != NULL)                                          if (rhs != NULL)
                                                 break;                                                  break;
                                 } else {                                  } else {
                                         uc = mchars_spec2cp(p->symtab,                                          uc = mchars_spec2cp(seq, ssz);
                                             seq, ssz);  
                                         if (uc > 0)                                          if (uc > 0)
                                                 sz += cond_width(p, uc, &skip);                                                  sz += cond_width(p, uc, &skip);
                                 }                                  }
Line 771  term_strlen(const struct termp *p, const char *cp)
Line 769  term_strlen(const struct termp *p, const char *cp)
                 case ASCII_HYPH:                  case ASCII_HYPH:
                         sz += cond_width(p, '-', &skip);                          sz += cond_width(p, '-', &skip);
                         cp++;                          cp++;
                         /* FALLTHROUGH */  
                 case ASCII_BREAK:  
                         break;                          break;
                 default:                  default:
                         break;                          break;
                 }                  }
         }          }
   
         return(sz);          return sz;
 }  }
   
 int  int
Line 811  term_vspan(const struct termp *p, const struct roffsu 
Line 807  term_vspan(const struct termp *p, const struct roffsu 
                 r = su->scale / 12.0;                  r = su->scale / 12.0;
                 break;                  break;
         case SCALE_EN:          case SCALE_EN:
                 /* FALLTHROUGH */  
         case SCALE_EM:          case SCALE_EM:
                 r = su->scale * 0.6;                  r = su->scale * 0.6;
                 break;                  break;
Line 822  term_vspan(const struct termp *p, const struct roffsu 
Line 817  term_vspan(const struct termp *p, const struct roffsu 
                 abort();                  abort();
         }          }
         ri = r > 0.0 ? r + 0.4995 : r - 0.4995;          ri = r > 0.0 ? r + 0.4995 : r - 0.4995;
         return(ri < 66 ? ri : 1);          return ri < 66 ? ri : 1;
 }  }
   
 /*  /*
Line 832  int
Line 827  int
 term_hspan(const struct termp *p, const struct roffsu *su)  term_hspan(const struct termp *p, const struct roffsu *su)
 {  {
   
         return((*p->hspan)(p, su));          return (*p->hspan)(p, su);
 }  }

Legend:
Removed from v.1.251  
changed lines
  Added in v.1.258

CVSweb