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

Diff for /mandoc/term.c between version 1.164 and 1.167

version 1.164, 2010/07/25 22:56:47 version 1.167, 2010/08/20 01:02:07
Line 37 
Line 37 
 static  void              spec(struct termp *, enum roffdeco,  static  void              spec(struct termp *, enum roffdeco,
                                 const char *, size_t);                                  const char *, size_t);
 static  void              res(struct termp *, const char *, size_t);  static  void              res(struct termp *, const char *, size_t);
 static  void              buffera(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, size_t);
 static  void              encode(struct termp *, const char *, size_t);  static  void              encode(struct termp *, const char *, size_t);
Line 84  term_alloc(enum termenc enc)
Line 83  term_alloc(enum termenc enc)
         p = calloc(1, sizeof(struct termp));          p = calloc(1, sizeof(struct termp));
         if (NULL == p) {          if (NULL == p) {
                 perror(NULL);                  perror(NULL);
                 exit(EXIT_FAILURE);                  exit(MANDOCLEVEL_SYSERR);
         }          }
   
         p->enc = enc;          p->enc = enc;
Line 503  term_word(struct termp *p, const char *word)
Line 502  term_word(struct termp *p, const char *word)
   
         if ( ! (p->flags & TERMP_NONOSPACE))          if ( ! (p->flags & TERMP_NONOSPACE))
                 p->flags &= ~TERMP_NOSPACE;                  p->flags &= ~TERMP_NOSPACE;
           else
                   p->flags |= TERMP_NOSPACE;
   
         p->flags &= ~TERMP_SENTENCE;          p->flags &= ~TERMP_SENTENCE;
   
Line 576  adjbuf(struct termp *p, size_t sz)
Line 577  adjbuf(struct termp *p, size_t sz)
         p->buf = realloc(p->buf, p->maxcols);          p->buf = realloc(p->buf, p->maxcols);
         if (NULL == p->buf) {          if (NULL == p->buf) {
                 perror(NULL);                  perror(NULL);
                 exit(EXIT_FAILURE);                  exit(MANDOCLEVEL_SYSERR);
         }          }
 }  }
   
   
 static void  static void
 buffera(struct termp *p, const char *word, size_t sz)  
 {  
   
         if (p->col + sz >= p->maxcols)  
                 adjbuf(p, p->col + sz);  
   
         memcpy(&p->buf[(int)p->col], word, sz);  
         p->col += sz;  
 }  
   
   
 static void  
 bufferc(struct termp *p, char c)  bufferc(struct termp *p, char c)
 {  {
   
Line 617  encode(struct termp *p, const char *word, size_t sz)
Line 606  encode(struct termp *p, const char *word, size_t sz)
          */           */
   
         if (TERMFONT_NONE == (f = term_fonttop(p))) {          if (TERMFONT_NONE == (f = term_fonttop(p))) {
                 buffera(p, word, sz);                  if (p->col + sz >= p->maxcols)
                           adjbuf(p, p->col + sz);
                   memcpy(&p->buf[(int)p->col], word, sz);
                   p->col += sz;
                 return;                  return;
         }          }
   
           /* Pre-buffer, assuming worst-case. */
   
           if (p->col + 1 + (sz * 3) >= p->maxcols)
                   adjbuf(p, p->col + 1 + (sz * 3));
   
         for (i = 0; i < (int)sz; i++) {          for (i = 0; i < (int)sz; i++) {
                 if ( ! isgraph((u_char)word[i])) {                  if ( ! isgraph((u_char)word[i])) {
                         bufferc(p, word[i]);                          p->buf[(int)p->col++] = word[i];
                         continue;                          continue;
                 }                  }
   
                 if (TERMFONT_UNDER == f)                  if (TERMFONT_UNDER == f)
                         bufferc(p, '_');                          p->buf[(int)p->col++] = '_';
                 else                  else
                         bufferc(p, word[i]);                          p->buf[(int)p->col++] = word[i];
   
                 bufferc(p, 8);                  p->buf[(int)p->col++] = 8;
                 bufferc(p, word[i]);                  p->buf[(int)p->col++] = word[i];
         }          }
 }  }
   

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

CVSweb