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

Diff for /mandoc/html.c between version 1.65 and 1.68

version 1.65, 2009/10/20 05:45:21 version 1.68, 2009/10/28 05:08:17
Line 15 
Line 15 
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/queue.h>  
   
 #include <assert.h>  #include <assert.h>
   #include <ctype.h>
 #include <err.h>  #include <err.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdarg.h>  #include <stdarg.h>
Line 81  static const char  *const htmlattrs[ATTR_MAX] = {
Line 81  static const char  *const htmlattrs[ATTR_MAX] = {
         "valign",          "valign",
         "target",          "target",
         "id",          "id",
           "summary",
 };  };
   
 #ifdef __linux__  #ifdef __linux__
Line 102  html_alloc(char *outopts)
Line 103  html_alloc(char *outopts)
         if (NULL == (h = calloc(1, sizeof(struct html))))          if (NULL == (h = calloc(1, sizeof(struct html))))
                 return(NULL);                  return(NULL);
   
         SLIST_INIT(&h->tags);          h->tags.head = NULL;
         SLIST_INIT(&h->ords);          h->ords.head = NULL;
   
         if (NULL == (h->symtab = chars_init(CHARS_HTML))) {          if (NULL == (h->symtab = chars_init(CHARS_HTML))) {
                 free(h);                  free(h);
Line 138  html_free(void *p)
Line 139  html_free(void *p)
   
         h = (struct html *)p;          h = (struct html *)p;
   
         while ( ! SLIST_EMPTY(&h->ords)) {          while ((ord = h->ords.head) != NULL) {
                 ord = SLIST_FIRST(&h->ords);                  h->ords.head = ord->next;
                 SLIST_REMOVE_HEAD(&h->ords, entry);  
                 free(ord);                  free(ord);
         }          }
   
         while ( ! SLIST_EMPTY(&h->tags)) {          while ((tag = h->tags.head) != NULL) {
                 tag = SLIST_FIRST(&h->tags);                  h->tags.head = tag->next;
                 SLIST_REMOVE_HEAD(&h->tags, entry);  
                 free(tag);                  free(tag);
         }          }
   
Line 358  print_otag(struct html *h, enum htmltag tag, 
Line 357  print_otag(struct html *h, enum htmltag tag, 
                 if (NULL == (t = malloc(sizeof(struct tag))))                  if (NULL == (t = malloc(sizeof(struct tag))))
                         err(EXIT_FAILURE, "malloc");                          err(EXIT_FAILURE, "malloc");
                 t->tag = tag;                  t->tag = tag;
                 SLIST_INSERT_HEAD(&h->tags, t, entry);                  t->next = h->tags.head;
                   h->tags.head = t;
         } else          } else
                 t = NULL;                  t = NULL;
   
Line 468  print_tagq(struct html *h, const struct tag *until)
Line 468  print_tagq(struct html *h, const struct tag *until)
 {  {
         struct tag      *tag;          struct tag      *tag;
   
         while ( ! SLIST_EMPTY(&h->tags)) {          while ((tag = h->tags.head) != NULL) {
                 tag = SLIST_FIRST(&h->tags);  
                 print_ctag(h, tag->tag);                  print_ctag(h, tag->tag);
                 SLIST_REMOVE_HEAD(&h->tags, entry);                  h->tags.head = tag->next;
                 free(tag);                  free(tag);
                 if (until && tag == until)                  if (until && tag == until)
                         return;                          return;
Line 484  print_stagq(struct html *h, const struct tag *suntil)
Line 483  print_stagq(struct html *h, const struct tag *suntil)
 {  {
         struct tag      *tag;          struct tag      *tag;
   
         while ( ! SLIST_EMPTY(&h->tags)) {          while ((tag = h->tags.head) != NULL) {
                 tag = SLIST_FIRST(&h->tags);  
                 if (suntil && tag == suntil)                  if (suntil && tag == suntil)
                         return;                          return;
                 print_ctag(h, tag->tag);                  print_ctag(h, tag->tag);
                 SLIST_REMOVE_HEAD(&h->tags, entry);                  h->tags.head = tag->next;
                 free(tag);                  free(tag);
         }          }
 }  }
Line 651  bufcat_su(struct html *h, const char *p, const struct 
Line 649  bufcat_su(struct html *h, const char *p, const struct 
                 buffmt(h, "%s: %d%s;", p, (int)v, u);                  buffmt(h, "%s: %d%s;", p, (int)v, u);
 }  }
   
   
   void
   html_idcpy(char *dst, const char *src, int sz)
   {
   
           assert(sz);
           dst[0] = '\0';
           html_idcat(dst, src, sz);
   }
   
   
   void
   html_idcat(char *dst, const char *src, int sz)
   {
           int              i;
   
           /* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */
   
           for (i = 0; *dst != '\0' && i < sz - 1; dst++, i++)
                   /* Jump to end. */ ;
   
           for ( ; *src != '\0' && i < sz - 1; src++, i++) {
                   if (isalnum((u_char)*src)) {
                           *dst++ = *src;
                           continue;
                   }
   
                   switch (*src) {
                   case (';'):
                           *dst++ = ';';
                           break;
                   case ('-'):
                           *dst++ = '-';
                           break;
                   case (':'):
                           *dst++ = ':';
                           break;
                   case ('_'):
                           /* FALLTHROUGH */
                   default:
                           *dst++ = '_';
                           break;
                   }
           }
   
           *dst = '\0';
   }

Legend:
Removed from v.1.65  
changed lines
  Added in v.1.68

CVSweb