summaryrefslogtreecommitdiffstats
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c44
1 files changed, 13 insertions, 31 deletions
diff --git a/html.c b/html.c
index 041e1061..ce623c8a 100644
--- a/html.c
+++ b/html.c
@@ -651,46 +651,28 @@ bufcat_su(struct html *h, const char *p, const struct roffsu *su)
void
-html_idcpy(char *dst, const char *src, int sz)
+html_idcat(char *dst, const char *src, int sz)
{
+ int ssz;
assert(sz);
- dst[0] = '\0';
- html_idcat(dst, src, sz);
-}
-
-
-void
-html_idcat(char *dst, const char *src, int sz)
-{
- int i;
/* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */
- for (i = 0; *dst != '\0' && i < sz - 1; dst++, i++)
+ for ( ; *dst != '\0' && sz; dst++, sz--)
/* Jump to end. */ ;
- for ( ; *src != '\0' && i < sz - 1; src++, i++, dst++) {
- if (isalnum((u_char)*src)) {
- *dst = *src;
- continue;
- }
+ assert(sz > 2);
- switch (*src) {
- case (';'):
- *dst = ';';
- break;
- case ('-'):
- *dst = '-';
- break;
- case (':'):
- *dst = ':';
- break;
- default:
- *dst = '_';
- break;
- }
- }
+ /* We can't start with a number (bah). */
+ *dst++ = 'x';
*dst = '\0';
+ sz--;
+
+ for ( ; *src != '\0' && sz > 1; src++) {
+ ssz = snprintf(dst, sz, "%.2x", *src);
+ sz -= ssz;
+ dst += ssz;
+ }
}