diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-05-17 11:34:31 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-05-17 11:34:31 +0000 |
commit | ed7b34daec8f64113849ed8b3d816f617cdf3983 (patch) | |
tree | 3b378d6fd5062d61cf9ce4e13cd7d6fc4b4eada1 /html.c | |
parent | 200e43749bd89f28c28647ce1c2736de721d6de8 (diff) | |
download | mandoc-ed7b34daec8f64113849ed8b3d816f617cdf3983.tar.gz mandoc-ed7b34daec8f64113849ed8b3d816f617cdf3983.tar.zst mandoc-ed7b34daec8f64113849ed8b3d816f617cdf3983.zip |
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.c | 31 |
1 files changed, 6 insertions, 25 deletions
@@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.141 2011/05/17 11:19:45 kristaps Exp $ */ +/* $Id: html.c,v 1.142 2011/05/17 11:34:31 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -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++); } |