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

Diff for /mandoc/html.c between version 1.150 and 1.151

version 1.150, 2011/10/05 21:35:17 version 1.151, 2012/05/31 22:29:13
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) 2011 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2011, 2012 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 262  print_metaf(struct html *h, enum mandoc_esc deco)
Line 262  print_metaf(struct html *h, enum mandoc_esc deco)
 int  int
 html_strlen(const char *cp)  html_strlen(const char *cp)
 {  {
         int              ssz, sz;          size_t           rsz;
         const char      *seq, *p;          int              skip, sz;
   
         /*          /*
          * Account for escaped sequences within string length           * Account for escaped sequences within string length
Line 274  html_strlen(const char *cp)
Line 274  html_strlen(const char *cp)
          */           */
   
         sz = 0;          sz = 0;
         while (NULL != (p = strchr(cp, '\\'))) {          skip = 0;
                 sz += (int)(p - cp);          while (1) {
                 ++cp;                  rsz = strcspn(cp, "\\");
                 switch (mandoc_escape(&cp, &seq, &ssz)) {                  if (rsz) {
                           cp += rsz;
                           if (skip) {
                                   skip = 0;
                                   rsz--;
                           }
                           sz += rsz;
                   }
                   if ('\0' == *cp)
                           break;
                   cp++;
                   switch (mandoc_escape(&cp, NULL, NULL)) {
                 case (ESCAPE_ERROR):                  case (ESCAPE_ERROR):
                         return(sz);                          return(sz);
                 case (ESCAPE_UNICODE):                  case (ESCAPE_UNICODE):
Line 285  html_strlen(const char *cp)
Line 296  html_strlen(const char *cp)
                 case (ESCAPE_NUMBERED):                  case (ESCAPE_NUMBERED):
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case (ESCAPE_SPECIAL):                  case (ESCAPE_SPECIAL):
                         sz++;                          if (skip)
                                   skip = 0;
                           else
                                   sz++;
                         break;                          break;
                   case (ESCAPE_SKIPCHAR):
                           skip = 1;
                           break;
                 default:                  default:
                         break;                          break;
                 }                  }
         }          }
           return(sz);
         assert(sz >= 0);  
         return(sz + strlen(cp));  
 }  }
   
 static int  static int
Line 308  print_encode(struct html *h, const char *p, int norecu
Line 323  print_encode(struct html *h, const char *p, int norecu
         nospace = 0;          nospace = 0;
   
         while ('\0' != *p) {          while ('\0' != *p) {
                   if (HTML_SKIPCHAR & h->flags && '\\' != *p) {
                           h->flags &= ~HTML_SKIPCHAR;
                           p++;
                           continue;
                   }
   
                 sz = strcspn(p, rejs);                  sz = strcspn(p, rejs);
   
                 fwrite(p, 1, sz, stdout);                  fwrite(p, 1, sz, stdout);
Line 338  print_encode(struct html *h, const char *p, int norecu
Line 359  print_encode(struct html *h, const char *p, int norecu
                         break;                          break;
   
                 switch (esc) {                  switch (esc) {
                   case (ESCAPE_FONT):
                           /* FALLTHROUGH */
                   case (ESCAPE_FONTPREV):
                           /* FALLTHROUGH */
                   case (ESCAPE_FONTBOLD):
                           /* FALLTHROUGH */
                   case (ESCAPE_FONTITALIC):
                           /* FALLTHROUGH */
                   case (ESCAPE_FONTROMAN):
                           if (0 == norecurse)
                                   print_metaf(h, esc);
                           continue;
                   case (ESCAPE_SKIPCHAR):
                           h->flags |= HTML_SKIPCHAR;
                           continue;
                   default:
                           break;
                   }
   
                   if (h->flags & HTML_SKIPCHAR) {
                           h->flags &= ~HTML_SKIPCHAR;
                           continue;
                   }
   
                   switch (esc) {
                 case (ESCAPE_UNICODE):                  case (ESCAPE_UNICODE):
                         /* Skip passed "u" header. */                          /* Skip passed "u" header. */
                         c = mchars_num2uc(seq + 1, len - 1);                          c = mchars_num2uc(seq + 1, len - 1);
Line 355  print_encode(struct html *h, const char *p, int norecu
Line 401  print_encode(struct html *h, const char *p, int norecu
                                 printf("&#%d;", c);                                  printf("&#%d;", c);
                         else if (-1 == c && 1 == len)                          else if (-1 == c && 1 == len)
                                 putchar((int)*seq);                                  putchar((int)*seq);
                         break;  
                 case (ESCAPE_FONT):  
                         /* FALLTHROUGH */  
                 case (ESCAPE_FONTPREV):  
                         /* FALLTHROUGH */  
                 case (ESCAPE_FONTBOLD):  
                         /* FALLTHROUGH */  
                 case (ESCAPE_FONTITALIC):  
                         /* FALLTHROUGH */  
                 case (ESCAPE_FONTROMAN):  
                         if (norecurse)  
                                 break;  
                         print_metaf(h, esc);  
                         break;                          break;
                 case (ESCAPE_NOSPACE):                  case (ESCAPE_NOSPACE):
                         if ('\0' == *p)                          if ('\0' == *p)

Legend:
Removed from v.1.150  
changed lines
  Added in v.1.151

CVSweb