=================================================================== RCS file: /cvs/mandoc/html.c,v retrieving revision 1.124 retrieving revision 1.128 diff -u -p -r1.124 -r1.128 --- mandoc/html.c 2010/12/27 21:41:05 1.124 +++ mandoc/html.c 2011/03/17 08:49:34 1.128 @@ -1,6 +1,7 @@ -/* $Id: html.c,v 1.124 2010/12/27 21:41:05 schwarze Exp $ */ +/* $Id: html.c,v 1.128 2011/03/17 08:49:34 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons + * Copyright (c) 2011 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -90,8 +91,10 @@ static const char *const htmlattrs[ATTR_MAX] = { "id", /* ATTR_ID */ "summary", /* ATTR_SUMMARY */ "align", /* ATTR_ALIGN */ + "colspan", /* ATTR_COLSPAN */ }; +static void print_num(struct html *, const char *, size_t); static void print_spec(struct html *, enum roffdeco, const char *, size_t); static void print_res(struct html *, const char *, size_t); @@ -117,11 +120,7 @@ ml_alloc(char *outopts, enum htmltype type) toks[2] = "includes"; toks[3] = NULL; - h = calloc(1, sizeof(struct html)); - if (NULL == h) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } + h = mandoc_calloc(1, sizeof(struct html)); h->type = type; h->tags.head = NULL; @@ -211,7 +210,17 @@ print_gen_head(struct html *h) } } +/* ARGSUSED */ +static void +print_num(struct html *h, const char *p, size_t len) +{ + const char *rhs; + rhs = chars_num2char(p, len); + if (rhs) + putchar((int)*rhs); +} + static void print_spec(struct html *h, enum roffdeco d, const char *p, size_t len) { @@ -332,6 +341,9 @@ print_encode(struct html *h, const char *p, int norecu len = a2roffdeco(&deco, &seq, &sz); switch (deco) { + case (DECO_NUMBERED): + print_num(h, seq, sz); + break; case (DECO_RESERVED): print_res(h, seq, sz); break; @@ -384,11 +396,7 @@ print_otag(struct html *h, enum htmltag tag, /* Push this tags onto the stack of open scopes. */ if ( ! (HTML_NOSTACK & htmltags[tag].flags)) { - t = malloc(sizeof(struct tag)); - if (NULL == t) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } + t = mandoc_malloc(sizeof(struct tag)); t->tag = tag; t->next = h->tags.head; h->tags.head = t; @@ -581,8 +589,14 @@ print_tagq(struct html *h, const struct tag *until) struct tag *tag; while ((tag = h->tags.head) != NULL) { + /* + * Remember to close out and nullify the current + * meta-font and table, if applicable. + */ if (tag == h->metaf) h->metaf = NULL; + if (tag == h->tblt) + h->tblt = NULL; print_ctag(h, tag->tag); h->tags.head = tag->next; free(tag); @@ -600,8 +614,14 @@ print_stagq(struct html *h, const struct tag *suntil) while ((tag = h->tags.head) != NULL) { if (suntil && tag == suntil) return; + /* + * Remember to close out and nullify the current + * meta-font and table, if applicable. + */ if (tag == h->metaf) h->metaf = NULL; + if (tag == h->tblt) + h->tblt = NULL; print_ctag(h, tag->tag); h->tags.head = tag->next; free(tag);