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

Diff for /mandoc/term.c between version 1.187 and 1.188

version 1.187, 2011/05/14 17:54:42 version 1.188, 2011/05/14 18:15:20
Line 36 
Line 36 
 static  void              spec(struct termp *, const char *, size_t);  static  void              spec(struct termp *, const char *, size_t);
 static  void              res(struct termp *, const char *, size_t);  static  void              res(struct termp *, const char *, size_t);
 static  void              bufferc(struct termp *, char);  static  void              bufferc(struct termp *, char);
 static  void              adjbuf(struct termp *p, size_t);  static  void              adjbuf(struct termp *p, int);
 static  void              encode(struct termp *, const char *, size_t);  static  void              encode(struct termp *, const char *, size_t);
   
   
Line 155  term_flushln(struct termp *p)
Line 155  term_flushln(struct termp *p)
         vis = vend = 0;          vis = vend = 0;
         i = 0;          i = 0;
   
         while (i < (int)p->col) {          while (i < p->col) {
                 /*                  /*
                  * Handle literal tab characters: collapse all                   * Handle literal tab characters: collapse all
                  * subsequent tabs into a single huge set of spaces.                   * subsequent tabs into a single huge set of spaces.
                  */                   */
                 while (i < (int)p->col && '\t' == p->buf[i]) {                  while (i < p->col && '\t' == p->buf[i]) {
                         vend = (vis / p->tabwidth + 1) * p->tabwidth;                          vend = (vis / p->tabwidth + 1) * p->tabwidth;
                         vbl += vend - vis;                          vbl += vend - vis;
                         vis = vend;                          vis = vend;
Line 174  term_flushln(struct termp *p)
Line 174  term_flushln(struct termp *p)
                  * space is printed according to regular spacing rules).                   * space is printed according to regular spacing rules).
                  */                   */
   
                 for (j = i, jhy = 0; j < (int)p->col; j++) {                  for (j = i, jhy = 0; j < p->col; j++) {
                         if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j])                          if ((j && ' ' == p->buf[j]) || '\t' == p->buf[j])
                                 break;                                  break;
   
Line 217  term_flushln(struct termp *p)
Line 217  term_flushln(struct termp *p)
                 }                  }
   
                 /* Write out the [remaining] word. */                  /* Write out the [remaining] word. */
                 for ( ; i < (int)p->col; i++) {                  for ( ; i < p->col; i++) {
                         if (vend > bp && jhy > 0 && i > jhy)                          if (vend > bp && jhy > 0 && i > jhy)
                                 break;                                  break;
                         if ('\t' == p->buf[i])                          if ('\t' == p->buf[i])
Line 524  term_word(struct termp *p, const char *word)
Line 524  term_word(struct termp *p, const char *word)
   
   
 static void  static void
 adjbuf(struct termp *p, size_t sz)  adjbuf(struct termp *p, int sz)
 {  {
   
         if (0 == p->maxcols)          if (0 == p->maxcols)
Line 532  adjbuf(struct termp *p, size_t sz)
Line 532  adjbuf(struct termp *p, size_t sz)
         while (sz >= p->maxcols)          while (sz >= p->maxcols)
                 p->maxcols <<= 2;                  p->maxcols <<= 2;
   
         p->buf = mandoc_realloc(p->buf, sizeof(int) * p->maxcols);          p->buf = mandoc_realloc
                   (p->buf, sizeof(int) * (size_t)p->maxcols);
 }  }
   
   
Line 543  bufferc(struct termp *p, char c)
Line 544  bufferc(struct termp *p, char c)
         if (p->col + 1 >= p->maxcols)          if (p->col + 1 >= p->maxcols)
                 adjbuf(p, p->col + 1);                  adjbuf(p, p->col + 1);
   
         p->buf[(int)p->col++] = c;          p->buf[p->col++] = c;
 }  }
   
   
Line 551  static void
Line 552  static void
 encode(struct termp *p, const char *word, size_t sz)  encode(struct termp *p, const char *word, size_t sz)
 {  {
         enum termfont     f;          enum termfont     f;
         int               i;          int               i, len;
   
           /* LINTED */
           len = sz;
   
         /*          /*
          * Encode and buffer a string of characters.  If the current           * Encode and buffer a string of characters.  If the current
          * font mode is unset, buffer directly, else encode then buffer           * font mode is unset, buffer directly, else encode then buffer
Line 560  encode(struct termp *p, const char *word, size_t sz)
Line 564  encode(struct termp *p, const char *word, size_t sz)
          */           */
   
         if (TERMFONT_NONE == (f = term_fonttop(p))) {          if (TERMFONT_NONE == (f = term_fonttop(p))) {
                 if (p->col + sz >= p->maxcols)                  if (p->col + len >= p->maxcols)
                         adjbuf(p, p->col + sz);                          adjbuf(p, p->col + len);
                 for (i = 0; i < (int)sz; i++)                  for (i = 0; i < len; i++)
                         p->buf[(int)p->col++] = word[i];                          p->buf[p->col++] = word[i];
                 return;                  return;
         }          }
   
         /* Pre-buffer, assuming worst-case. */          /* Pre-buffer, assuming worst-case. */
   
         if (p->col + 1 + (sz * 3) >= p->maxcols)          if (p->col + 1 + (len * 3) >= p->maxcols)
                 adjbuf(p, p->col + 1 + (sz * 3));                  adjbuf(p, p->col + 1 + (len * 3));
   
         for (i = 0; i < (int)sz; i++) {          for (i = 0; i < len; i++) {
                 if ( ! isgraph((u_char)word[i])) {                  if ( ! isgraph((unsigned char)word[i])) {
                         p->buf[(int)p->col++] = word[i];                          p->buf[p->col++] = word[i];
                         continue;                          continue;
                 }                  }
   
                 if (TERMFONT_UNDER == f)                  if (TERMFONT_UNDER == f)
                         p->buf[(int)p->col++] = '_';                          p->buf[p->col++] = '_';
                 else                  else
                         p->buf[(int)p->col++] = word[i];                          p->buf[p->col++] = word[i];
   
                 p->buf[(int)p->col++] = 8;                  p->buf[p->col++] = 8;
                 p->buf[(int)p->col++] = word[i];                  p->buf[p->col++] = word[i];
         }          }
 }  }
   

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

CVSweb