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

Diff for /mandoc/term.c between version 1.170 and 1.171

version 1.170, 2010/09/04 20:18:53 version 1.171, 2010/09/15 14:36:16
Line 458  void
Line 458  void
 term_word(struct termp *p, const char *word)  term_word(struct termp *p, const char *word)
 {  {
         const char      *sv, *seq;          const char      *sv, *seq;
         int              sz;  
         size_t           ssz;          size_t           ssz;
         enum roffdeco    deco;          enum roffdeco    deco;
   
Line 515  term_word(struct termp *p, const char *word)
Line 514  term_word(struct termp *p, const char *word)
                         continue;                          continue;
   
                 seq = ++word;                  seq = ++word;
                 sz = a2roffdeco(&deco, &seq, &ssz);                  word += a2roffdeco(&deco, &seq, &ssz);
   
                 switch (deco) {                  switch (deco) {
                 case (DECO_RESERVED):                  case (DECO_RESERVED):
Line 542  term_word(struct termp *p, const char *word)
Line 541  term_word(struct termp *p, const char *word)
                         break;                          break;
                 }                  }
   
                 word += sz;  
                 if (DECO_NOSPACE == deco && '\0' == *word)                  if (DECO_NOSPACE == deco && '\0' == *word)
                         p->flags |= TERMP_NOSPACE;                          p->flags |= TERMP_NOSPACE;
         }          }
Line 645  term_len(const struct termp *p, size_t sz)
Line 643  term_len(const struct termp *p, size_t sz)
 size_t  size_t
 term_strlen(const struct termp *p, const char *cp)  term_strlen(const struct termp *p, const char *cp)
 {  {
         size_t           sz;          size_t           sz, ssz, rsz, i;
           enum roffdeco    d;
           const char      *seq, *rhs;
   
         for (sz = 0; *cp; cp++)          for (sz = 0; '\0' != *cp; )
                 sz += (*p->width)(p, *cp);                  /*
                    * Account for escaped sequences within string length
                    * calculations.  This follows the logic in term_word()
                    * as we must calculate the width of produced strings.
                    */
                   if ('\\' == *cp) {
                           seq = ++cp;
                           cp += a2roffdeco(&d, &seq, &ssz);
   
                           switch (d) {
                           case (DECO_RESERVED):
                                   rhs = chars_res2str
                                           (p->symtab, seq, ssz, &rsz);
                                   break;
                           case (DECO_SPECIAL):
                                   /* FALLTHROUGH */
                           case (DECO_SSPECIAL):
                                   rhs = chars_spec2str
                                           (p->symtab, seq, ssz, &rsz);
   
                                   /* Allow for one-char escapes. */
                                   if (DECO_SSPECIAL != d || rhs)
                                           break;
   
                                   rhs = seq;
                                   rsz = ssz;
                                   break;
                           default:
                                   rhs = NULL;
                                   break;
                           }
   
                           if (rhs)
                                   for (i = 0; i < rsz; i++)
                                           sz += (*p->width)(p, *rhs++);
                   } else
                           sz += (*p->width)(p, *cp++);
   
         return(sz);          return(sz);
 }  }

Legend:
Removed from v.1.170  
changed lines
  Added in v.1.171

CVSweb