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

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

version 1.184, 2011/04/09 15:29:40 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 47  term_free(struct termp *p)
Line 47  term_free(struct termp *p)
         if (p->buf)          if (p->buf)
                 free(p->buf);                  free(p->buf);
         if (p->symtab)          if (p->symtab)
                 chars_free(p->symtab);                  mchars_free(p->symtab);
   
         free(p);          free(p);
 }  }
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 348  term_vspace(struct termp *p)
Line 348  term_vspace(struct termp *p)
 static void  static void
 numbered(struct termp *p, const char *word, size_t len)  numbered(struct termp *p, const char *word, size_t len)
 {  {
         const char      *rhs;          char             c;
   
         rhs = chars_num2char(word, len);          if ('\0' != (c = mchars_num2char(word, len)))
         if (rhs)                  encode(p, &c, 1);
                 encode(p, rhs, 1);  
 }  }
   
   
Line 362  spec(struct termp *p, const char *word, size_t len)
Line 361  spec(struct termp *p, const char *word, size_t len)
         const char      *rhs;          const char      *rhs;
         size_t           sz;          size_t           sz;
   
         rhs = chars_spec2str(p->symtab, word, len, &sz);          rhs = mchars_spec2str(p->symtab, word, len, &sz);
         if (rhs)          if (rhs)
                 encode(p, rhs, sz);                  encode(p, rhs, sz);
         else if (1 == len)          else if (1 == len)
Line 376  res(struct termp *p, const char *word, size_t len)
Line 375  res(struct termp *p, const char *word, size_t len)
         const char      *rhs;          const char      *rhs;
         size_t           sz;          size_t           sz;
   
         rhs = chars_res2str(p->symtab, word, len, &sz);          rhs = mchars_res2str(p->symtab, word, len, &sz);
         if (rhs)          if (rhs)
                 encode(p, rhs, sz);                  encode(p, rhs, sz);
 }  }
Line 525  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 533  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, p->maxcols);          p->buf = mandoc_realloc
                   (p->buf, sizeof(int) * (size_t)p->maxcols);
 }  }
   
   
Line 544  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 552  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 561  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);
                 memcpy(&p->buf[(int)p->col], word, sz);                  for (i = 0; i < len; i++)
                 p->col += sz;                          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];
         }          }
 }  }
   
Line 623  term_strlen(const struct termp *p, const char *cp)
Line 626  term_strlen(const struct termp *p, const char *cp)
   
                         switch (esc) {                          switch (esc) {
                         case (ESCAPE_PREDEF):                          case (ESCAPE_PREDEF):
                                 rhs = chars_res2str                                  rhs = mchars_res2str
                                         (p->symtab, seq, ssz, &rsz);                                          (p->symtab, seq, ssz, &rsz);
                                 break;                                  break;
                         case (ESCAPE_SPECIAL):                          case (ESCAPE_SPECIAL):
                                 rhs = chars_spec2str                                  rhs = mchars_spec2str
                                         (p->symtab, seq, ssz, &rsz);                                          (p->symtab, seq, ssz, &rsz);
   
                                 if (ssz != 1 || rhs)                                  if (ssz != 1 || rhs)

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

CVSweb