summaryrefslogtreecommitdiffstats
path: root/html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-03-03 13:02:11 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-03-03 13:02:11 +0000
commit8816b91eee3bcfacd831e3cefe5da84702ba2b03 (patch)
tree7e81ded606c17f5f321eabff09e1a6d1e495f582 /html.c
parentb4303641a5d76b39d16c4c9d86f415dff39f8c68 (diff)
downloadmandoc-8816b91eee3bcfacd831e3cefe5da84702ba2b03.tar.gz
Reset HTML formatter state, in particular the id_unique hash,
after processing each manual page, such that the next page starts from a clean state and doesn't continue suffix numbering. Issue found while looking at https://github.com/Debian/debiman/issues/48 which was brought up by Orestis Ioannou <oorestisime at github>.
Diffstat (limited to 'html.c')
-rw-r--r--html.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/html.c b/html.c
index 3a0c22ce..ea05c953 100644
--- a/html.c
+++ b/html.c
@@ -110,6 +110,7 @@ static const struct htmldata htmltags[TAG_MAX] = {
/* Avoid duplicate HTML id= attributes. */
static struct ohash id_unique;
+static void html_reset_internal(struct html *);
static void print_byte(struct html *, char);
static void print_endword(struct html *);
static void print_indent(struct html *);
@@ -145,21 +146,17 @@ html_alloc(const struct manoutput *outopts)
return h;
}
-void
-html_free(void *p)
+static void
+html_reset_internal(struct html *h)
{
struct tag *tag;
- struct html *h;
char *cp;
unsigned int slot;
- h = (struct html *)p;
while ((tag = h->tag) != NULL) {
h->tag = tag->next;
free(tag);
}
- free(h);
-
cp = ohash_first(&id_unique, &slot);
while (cp != NULL) {
free(cp);
@@ -169,6 +166,20 @@ html_free(void *p)
}
void
+html_reset(void *p)
+{
+ html_reset_internal(p);
+ mandoc_ohash_init(&id_unique, 4, 0);
+}
+
+void
+html_free(void *p)
+{
+ html_reset_internal(p);
+ free(p);
+}
+
+void
print_gen_head(struct html *h)
{
struct tag *t;