From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Reset HTML formatter state, in particular the id_unique hash,
Date: Sun, 3 Mar 2019 08:02:41 -0500 (EST) [thread overview]
Message-ID: <e3f12e2265e939ed@fantadrom.bsd.lv> (raw)
Log Message:
-----------
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>.
Modified Files:
--------------
mandoc:
html.c
main.c
main.h
mandocd.c
Revision Data
-------------
Index: html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/html.c,v
retrieving revision 1.253
retrieving revision 1.254
diff -Lhtml.c -Lhtml.c -u -p -r1.253 -r1.254
--- html.c
+++ html.c
@@ -110,6 +110,7 @@ static const struct htmldata htmltags[TA
/* 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,27 +146,37 @@ html_alloc(const struct manoutput *outop
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);
cp = ohash_next(&id_unique, &slot);
}
ohash_delete(&id_unique);
+}
+
+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
Index: mandocd.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandocd.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lmandocd.c -Lmandocd.c -u -p -r1.10 -r1.11
--- mandocd.c
+++ mandocd.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org>
- * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2017, 2019 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -213,6 +213,8 @@ main(int argc, char *argv[])
process(parser, outtype, formatter);
mparse_reset(parser);
+ if (outtype == OUTT_HTML)
+ html_reset(formatter);
fflush(stdout);
fflush(stderr);
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.318
retrieving revision 1.319
diff -Lmain.c -Lmain.c -u -p -r1.318 -r1.319
--- main.c
+++ main.c
@@ -835,6 +835,8 @@ parse(struct curparse *curp, int fd, con
if (curp->outdata == NULL)
outdata_alloc(curp);
+ else if (curp->outtype == OUTT_HTML)
+ html_reset(curp);
mandoc_xr_reset();
meta = mparse_result(curp->mp);
Index: main.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lmain.h -Lmain.h -u -p -r1.29 -r1.30
--- main.h
+++ main.h
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014, 2015, 2019 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -29,6 +29,7 @@ struct manoutput;
void *html_alloc(const struct manoutput *);
void html_mdoc(void *, const struct roff_meta *);
void html_man(void *, const struct roff_meta *);
+void html_reset(void *);
void html_free(void *);
void tree_mdoc(void *, const struct roff_meta *);
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2019-03-03 13:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e3f12e2265e939ed@fantadrom.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).