summaryrefslogtreecommitdiffstats
path: root/html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-05-17 11:34:31 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-05-17 11:34:31 +0000
commit76be1e51fc96ec5836c6a7b70dbb91beed5c8635 (patch)
tree2fa3de7c4fe0874950404ef2adc07eef2cc943e5 /html.c
parentf9e49942b1aa36eb1b9fca3803993ef3224d5f5b (diff)
downloadmandoc-76be1e51fc96ec5836c6a7b70dbb91beed5c8635.tar.gz
Cleanups in -T[x]html: make html_idcat() use the buffer and be called
bufcat_id(), then collapse it into a little function without so much crap. Next, make bufinit() only be called when we really need to do so, and not simply before pre/post calls.
Diffstat (limited to 'html.c')
-rw-r--r--html.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/html.c b/html.c
index 5508f0d4..e8801610 100644
--- a/html.c
+++ b/html.c
@@ -713,32 +713,13 @@ bufcat_su(struct html *h, const char *p, const struct roffsu *su)
}
void
-html_idcat(char *dst, const char *src, int sz)
+bufcat_id(struct html *h, const char *src)
{
- int ssz;
-
- assert(sz > 2);
/* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */
- /* We can't start with a number (bah). */
-
- if ('#' == *dst) {
- dst++;
- sz--;
- }
- if ('\0' == *dst) {
- *dst++ = 'x';
- *dst = '\0';
- sz--;
- }
-
- for ( ; *dst != '\0' && sz; dst++, sz--)
- /* Jump to end. */ ;
-
- for ( ; *src != '\0' && sz > 1; src++) {
- ssz = snprintf(dst, (size_t)sz, "%.2x", *src);
- sz -= ssz;
- dst += ssz;
- }
+ if (0 == h->buflen)
+ bufcat(h, "#x");
+ while ('\0' != *src)
+ bufcat_fmt(h, "%.2x", *src++);
}